Skip to content

Commit

Permalink
rotation is no longer saved in crystallized amber's nbt tag
Browse files Browse the repository at this point in the history
  • Loading branch information
NewJumper committed May 20, 2024
1 parent 2d3fa11 commit 2122ba2
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 7 deletions.
1 change: 0 additions & 1 deletion src/main/java/com/kyanite/deeperdarker/DeeperDarker.java
Original file line number Diff line number Diff line change
Expand Up @@ -187,7 +187,6 @@ public static void breakEvent(final BlockEvent.BreakEvent event) {
CompoundTag tag = new CompoundTag();
tag.put("item", blockEntity.getLoot().save(new CompoundTag()));
tag.putBoolean("leech", blockEntity.fossilizedEntity);
tag.putFloat("rotation", blockEntity.rotation);

ItemStack stack = new ItemStack(DDBlocks.CRYSTALLIZED_AMBER.get());
BlockItem.setBlockEntityData(stack, DDBlockEntities.CRYSTALLIZED_AMBER.get(), tag);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
import net.minecraft.client.renderer.blockentity.BlockEntityRendererProvider;
import net.minecraft.client.renderer.entity.EntityRenderDispatcher;
import net.minecraft.client.renderer.entity.ItemRenderer;
import net.minecraft.util.RandomSource;
import net.minecraft.world.item.ItemDisplayContext;

public class CrystallizedAmberBlockRenderer implements BlockEntityRenderer<CrystallizedAmberBlockEntity> {
Expand All @@ -29,7 +30,8 @@ public void render(CrystallizedAmberBlockEntity pBlockEntity, float pPartialTick
pPoseStack.pushPose();
pPoseStack.translate(0.5f, 0.5f, 0.5f);
pPoseStack.mulPose(Axis.XP.rotationDegrees(-40f));
pPoseStack.mulPose(Axis.YP.rotationDegrees(pBlockEntity.rotation));
RandomSource random = RandomSource.create(pBlockEntity.getBlockPos().asLong() / (pBlockEntity.getBlockPos().getX() + pBlockEntity.getBlockPos().getZ()));
pPoseStack.mulPose(Axis.YP.rotationDegrees(random.nextFloat() * 180f));
if(pBlockEntity.fossilizedEntity) {
pPoseStack.scale(0.9f, 0.9f, 0.9f);
SculkLeech leech = new SculkLeech(DDEntities.SCULK_LEECH.get(), pBlockEntity.getLevel());
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,9 +34,11 @@ public void generateFossil(Level level, BlockPos pos) {
if(fossilizedEntity || loot != ItemStack.EMPTY) return;

RandomSource random = RandomSource.create(pos.asLong());
if(random.nextFloat() < 0.15f) fossilizedEntity = true;
rotation = random.nextFloat() * 180;
if(fossilizedEntity) return;
if(random.nextFloat() < 0.15f) {
fossilizedEntity = true;
return;
}

LootTable table = level.getServer().getLootData().getLootTable(DDChestLoot.CRYSTALLIZED_AMBER);
List<ItemStack> list = table.getRandomItems(new LootParams.Builder((ServerLevel) level).withParameter(LootContextParams.ORIGIN, this.getBlockPos().getCenter()).withParameter(LootContextParams.BLOCK_ENTITY, this).create(LootContextParamSets.CHEST));
Expand All @@ -58,21 +60,18 @@ public Packet<ClientGamePacketListener> getUpdatePacket() {
CompoundTag tag = new CompoundTag();
tag.put("item", this.loot.save(new CompoundTag()));
tag.putBoolean("leech", this.fossilizedEntity);
tag.putFloat("rotation", this.rotation);
return tag;
}

@Override
public void load(CompoundTag pTag) {
if(pTag.contains("item")) this.loot = ItemStack.of(pTag.getCompound("item"));
if(pTag.contains("leech")) this.fossilizedEntity = pTag.getBoolean("leech");
if(pTag.contains("rotation")) this.rotation = pTag.getFloat("rotation");
}

@Override
protected void saveAdditional(CompoundTag pTag) {
pTag.put("item", this.loot.save(new CompoundTag()));
pTag.putBoolean("leech", this.fossilizedEntity);
pTag.putFloat("rotation", this.rotation);
}
}

0 comments on commit 2122ba2

Please sign in to comment.