diff --git a/gradle.properties b/gradle.properties index 85868723..db29e6c3 100644 --- a/gradle.properties +++ b/gradle.properties @@ -24,7 +24,7 @@ parchment_version=2023.09.03-1.20.1 # Mod Properties mod_name=Lodestone mod_id=lodestone -mod_version=1.4.33 +mod_version=1.4.34 mod_license=GPLv3 mod_group_id=team.lodestar.lodestone # The authors of the mod. This is a simple text string that is used for display purposes in the mod list. diff --git a/src/main/java/team/lodestar/lodestone/systems/blockentity/LodestoneBlockEntity.java b/src/main/java/team/lodestar/lodestone/systems/blockentity/LodestoneBlockEntity.java index 76c4878a..83de2399 100644 --- a/src/main/java/team/lodestar/lodestone/systems/blockentity/LodestoneBlockEntity.java +++ b/src/main/java/team/lodestar/lodestone/systems/blockentity/LodestoneBlockEntity.java @@ -2,10 +2,15 @@ import io.github.fabricators_of_create.porting_lib.block.CustomDataPacketHandlingBlockEntity; import io.github.fabricators_of_create.porting_lib.block.CustomUpdateTagHandlingBlockEntity; +import io.github.fabricators_of_create.porting_lib.extensions.extensions.BlockEntityExtensions; +import net.fabricmc.fabric.api.transfer.v1.item.ItemVariant; +import net.fabricmc.fabric.api.transfer.v1.transaction.Transaction; +import net.fabricmc.fabric.api.transfer.v1.transaction.TransactionContext; import net.minecraft.core.BlockPos; import net.minecraft.nbt.CompoundTag; import net.minecraft.network.Connection; import net.minecraft.network.protocol.game.ClientboundBlockEntityDataPacket; +import net.minecraft.server.level.ServerLevel; import net.minecraft.world.InteractionHand; import net.minecraft.world.InteractionResult; import net.minecraft.world.entity.Entity; @@ -17,13 +22,14 @@ import net.minecraft.world.level.block.entity.BlockEntity; import net.minecraft.world.level.block.entity.BlockEntityType; import net.minecraft.world.level.block.state.BlockState; +import net.minecraft.world.level.chunk.LevelChunk; import org.jetbrains.annotations.Nullable; import team.lodestar.lodestone.systems.block.LodestoneEntityBlock; /** * A simple block entity with various frequently used methods called from {@link LodestoneEntityBlock} */ -public class LodestoneBlockEntity extends BlockEntity implements CustomUpdateTagHandlingBlockEntity, CustomDataPacketHandlingBlockEntity { +public class LodestoneBlockEntity extends BlockEntity implements BlockEntityExtensions, CustomUpdateTagHandlingBlockEntity, CustomDataPacketHandlingBlockEntity { public boolean needsSync; @@ -54,21 +60,26 @@ public void onEntityInside(BlockState state, Level level, BlockPos pos, Entity e } @Override - public CompoundTag getUpdateTag() { - return this.saveWithoutMetadata(); + public void load(CompoundTag pTag) { + needsSync = true; + super.load(pTag); } - @Override - public void handleUpdateTag(CompoundTag tag) { - if (tag != null) { - CustomUpdateTagHandlingBlockEntity.super.handleUpdateTag(tag); + public void tick() { + if (needsSync) { + init(); + needsSync = false; } } + public void init() { + + } + + //Sync @Override - public void load(CompoundTag pTag) { - needsSync = true; - super.load(pTag); + public CompoundTag getUpdateTag() { + return writeClient(new CompoundTag()); } @Override @@ -77,18 +88,43 @@ public ClientboundBlockEntityDataPacket getUpdatePacket() { } @Override - public void onDataPacket(Connection net, ClientboundBlockEntityDataPacket pkt) { - handleUpdateTag(getUpdatePacket().getTag()); + public void handleUpdateTag(CompoundTag tag) { + readClient(tag); } - public void tick() { - if (needsSync) { - init(); - needsSync = false; - } + @Override + public void onDataPacket(Connection connection, ClientboundBlockEntityDataPacket packet) { + CompoundTag tag = packet.getTag(); + readClient(tag == null ? new CompoundTag() : tag); } - public void init() { + // Special handling for client update packets + public void readClient(CompoundTag tag) { + load(tag); + } + // Special handling for client update packets + public CompoundTag writeClient(CompoundTag tag) { + saveAdditional(tag); + return tag; + } + + public void sendData() { + if (level instanceof ServerLevel serverLevel) + serverLevel.getChunkSource().blockChanged(getBlockPos()); + } + + public void notifyUpdate() { + setChanged(); + sendData(); + } + + public LevelChunk containedChunk() { + return level.getChunkAt(worldPosition); + } + + @Override + public void deserializeNBT(BlockState state, CompoundTag nbt) { + this.load(nbt); } } \ No newline at end of file diff --git a/src/main/java/team/lodestar/lodestone/systems/blockentity/LodestoneBlockEntityInventory.java b/src/main/java/team/lodestar/lodestone/systems/blockentity/LodestoneBlockEntityInventory.java index 71b803b5..e7c46203 100644 --- a/src/main/java/team/lodestar/lodestone/systems/blockentity/LodestoneBlockEntityInventory.java +++ b/src/main/java/team/lodestar/lodestone/systems/blockentity/LodestoneBlockEntityInventory.java @@ -31,6 +31,8 @@ public class LodestoneBlockEntityInventory extends ItemStackHandlerContainer { public int nonEmptyItemAmount; public int firstEmptyItemIndex; + private LodestoneBlockEntity blockEntity; + public LodestoneBlockEntityInventory(int slotCount, int allowedItemSize, Predicate inputPredicate, Predicate outputPredicate) { this(slotCount, allowedItemSize, inputPredicate); this.outputPredicate = outputPredicate; @@ -56,6 +58,11 @@ public boolean isEmpty() { return nonEmptyItemAmount == 0; } + @Override + public void setChanged() { + super.setChanged(); + } + public void clear() { for (int i = 0; i < slotCount; i++) { setStackInSlot(i, ItemStack.EMPTY); diff --git a/src/main/resources/assets/lodestone/shaders/core/particle/particle.fsh b/src/main/resources/assets/lodestone/shaders/core/particle/particle.fsh index f241d54a..da12e4e5 100644 --- a/src/main/resources/assets/lodestone/shaders/core/particle/particle.fsh +++ b/src/main/resources/assets/lodestone/shaders/core/particle/particle.fsh @@ -1,7 +1,7 @@ #version 150 #moj_import -#moj_import +#moj_import uniform sampler2D Sampler0; uniform sampler2D SceneDepthBuffer; diff --git a/src/main/resources/assets/lodestone/shaders/core/particle/particle.vsh b/src/main/resources/assets/lodestone/shaders/core/particle/particle.vsh index f1eace38..1ba5d036 100644 --- a/src/main/resources/assets/lodestone/shaders/core/particle/particle.vsh +++ b/src/main/resources/assets/lodestone/shaders/core/particle/particle.vsh @@ -2,7 +2,7 @@ #moj_import #moj_import -#moj_import +#moj_import in vec3 Position; in vec2 UV0; diff --git a/src/main/resources/assets/lodestone/shaders/include/commoner.glsl b/src/main/resources/assets/lodestone/shaders/include/common_math.glsl similarity index 100% rename from src/main/resources/assets/lodestone/shaders/include/commoner.glsl rename to src/main/resources/assets/lodestone/shaders/include/common_math.glsl