Skip to content

Commit

Permalink
Merge branch '1.20.x' of https://github.com/Uraneptus/Sullys-Mod into…
Browse files Browse the repository at this point in the history
… 1.20.x
  • Loading branch information
Uraneptus committed Nov 8, 2023
2 parents 78928c4 + 9ccf4bb commit 5e899e5
Show file tree
Hide file tree
Showing 6 changed files with 25 additions and 13 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
"damage": {
"type": {
"direct_entity": {
"type": "#sullysmod:cannot_bounce"
"type": "sullysmod:tortoise_shell"
}
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
import com.uraneptus.sullysmod.client.renderer.entities.layer.LanternfishGlowLayer;
import com.uraneptus.sullysmod.common.entities.Lanternfish;
import net.minecraft.MethodsReturnNonnullByDefault;
import net.minecraft.client.renderer.MultiBufferSource;
import net.minecraft.client.renderer.entity.EntityRendererProvider;
import net.minecraft.client.renderer.entity.MobRenderer;
import net.minecraft.resources.ResourceLocation;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,10 +26,10 @@ public LanternfishGlowLayer(RenderLayerParent<E, LanternfishModel<E>> entityRend

@Override
public void render(PoseStack pMatrixStack, MultiBufferSource pBuffer, int pPackedLight, E pLivingEntity, float pLimbSwing, float pLimbSwingAmount, float pPartialTicks, float pAgeInTicks, float pNetHeadYaw, float pHeadPitch) {
int i = (int) Mth.clampedLerp(0.0F, 15.0F, 1.0F - (float) pLivingEntity.getDarkTicksRemaining() / 10.0F);
int packedLight = i == 15 ? 240 : pPackedLight;
RenderType renderType = i == 15 ? BlueprintRenderTypes.getUnshadedCutoutEntity(GLOW_LAYER, true) : RenderType.entityCutoutNoCull(GLOW_LAYER);
VertexConsumer vertexconsumer = pBuffer.getBuffer(renderType);
this.getParentModel().renderToBuffer(pMatrixStack, vertexconsumer, packedLight, OverlayTexture.NO_OVERLAY, 1.0F, 1.0F, 1.0F, 1.0F);
if (pLivingEntity.renderGlow()) {
RenderType renderType = RenderType.eyes(GLOW_LAYER);
VertexConsumer vertexconsumer = pBuffer.getBuffer(renderType);
this.getParentModel().renderToBuffer(pMatrixStack, vertexconsumer, pPackedLight, OverlayTexture.NO_OVERLAY, 1.0F, 1.0F, 1.0F, 1.0F);
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,6 @@ private static boolean releaseOccupant(Level pLevel, BlockPos pPos, BlockState p

public static void serverTick(Level pLevel, BlockPos pPos, BlockState pState, FlingerTotemBlockEntity pBlockEntity) {
boolean flag = false;
System.out.println(pBlockEntity.stored.size());
FlingerTotemBlockEntity.ProjectileData projectileData;
for(Iterator<FlingerTotemBlockEntity.ProjectileData> iterator = pBlockEntity.stored.iterator(); iterator.hasNext(); projectileData.delayTicks--) {
projectileData = iterator.next();
Expand Down Expand Up @@ -126,7 +125,6 @@ public BlockEntityType<?> getType() {
@Override
public void load(CompoundTag pTag) {
super.load(pTag);
//this.stored.clear(); Mojang does this, but why?
ListTag listtag = pTag.getList("Projectiles", 10);

for(int i = 0; i < listtag.size(); ++i) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
import net.minecraft.network.syncher.SynchedEntityData;
import net.minecraft.sounds.SoundEvent;
import net.minecraft.tags.FluidTags;
import net.minecraft.util.Mth;
import net.minecraft.util.RandomSource;
import net.minecraft.world.damagesource.DamageSource;
import net.minecraft.world.entity.EntityType;
Expand Down Expand Up @@ -84,6 +85,11 @@ public int getDarkTicksRemaining() {
return this.entityData.get(DATA_DARK_TICKS_REMAINING);
}

public boolean renderGlow() {
int i = (int) Mth.clampedLerp(0.0F, 15.0F, 1.0F - (float) this.getDarkTicksRemaining() / 10.0F);
return i == 15;
}

@Override
protected SoundEvent getFlopSound() {
return SMSounds.LANTERNFISH_FLOP.get();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -35,12 +35,12 @@
import java.util.List;
import java.util.UUID;

public class TortoiseShell extends Entity {
public class TortoiseShell extends Entity implements OwnableEntity {
private static final EntityDataAccessor<Integer> DATA_ID_HURT = SynchedEntityData.defineId(TortoiseShell.class, EntityDataSerializers.INT);
private static final EntityDataAccessor<Integer> DATA_ID_HURTDIR = SynchedEntityData.defineId(TortoiseShell.class, EntityDataSerializers.INT);
private static final EntityDataAccessor<Float> DATA_ID_DAMAGE = SynchedEntityData.defineId(TortoiseShell.class, EntityDataSerializers.FLOAT);
public int spinTicks = 0;
private Entity cachedOwner;
private LivingEntity cachedOwner;
private UUID ownerUUID;

public TortoiseShell(EntityType<? extends TortoiseShell> pEntityType, Level pLevel) {
Expand All @@ -51,18 +51,25 @@ public TortoiseShell(EntityType<? extends TortoiseShell> pEntityType, Level pLev
public TortoiseShell(PlayMessages.SpawnEntity spawnEntity, Level level) {
this(SMEntityTypes.TORTOISE_SHELL.get(), level);
}
public void setOwner(@Nullable Entity pOwner) {
public void setOwner(@Nullable LivingEntity pOwner) {
if (pOwner != null) {
this.ownerUUID = pOwner.getUUID();
this.cachedOwner = pOwner;
}
}

@org.jetbrains.annotations.Nullable
@Override
public UUID getOwnerUUID() {
return this.cachedOwner.getUUID();
}

@Nullable
public Entity getOwner() {
public LivingEntity getOwner() {
if (this.cachedOwner != null && !this.cachedOwner.isRemoved()) {
return this.cachedOwner;
} else if (this.ownerUUID != null && this.level() instanceof ServerLevel) {
this.cachedOwner = ((ServerLevel)this.level()).getEntity(this.ownerUUID);
this.cachedOwner = (LivingEntity) ((ServerLevel)this.level()).getEntity(this.ownerUUID);
return this.cachedOwner;
} else {
return null;
Expand Down

0 comments on commit 5e899e5

Please sign in to comment.