Skip to content

Commit

Permalink
add the world on the client side too
Browse files Browse the repository at this point in the history
  • Loading branch information
BlueWeabo committed Aug 4, 2024
1 parent 6eda367 commit 1bb7a80
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 2 deletions.
2 changes: 2 additions & 0 deletions src/main/java/com/gtnewhorizons/mutecore/MuTENetwork.java
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@
import com.cleanroommc.modularui.network.IPacket;
import com.gtnewhorizons.mutecore.api.block.MultiTileEntityBlock;
import com.gtnewhorizons.mutecore.api.data.Coordinates;
import com.gtnewhorizons.mutecore.api.data.WorldContainer;
import com.gtnewhorizons.mutecore.api.data.WorldStateValidator;
import com.gtnewhorizons.mutecore.api.registry.MultiTileContainer;
import com.gtnewhorizons.mutecore.api.registry.MultiTileEntityRegistry;
Expand Down Expand Up @@ -120,6 +121,7 @@ public void read(PacketBuffer buf) throws IOException {
.getInteger("i"));
Entity entity = container.createNewEntity();
entity.add(coords);
entity.add(new WorldContainer(Minecraft.getMinecraft().theWorld));
Object[] components = ((IntEntity) entity).getComponentArray();
for (int i = 0; i < components.length; i++) {
if (!(components[i] instanceof WorldStateValidator validator)) continue;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -150,16 +150,16 @@ public void setRegId(int regId) {
@Override
public void save(NBTTagCompound nbt) {
NBTTagCompound idNBT = new NBTTagCompound();
idNBT.setInteger("i", id);
idNBT.setInteger("r", regId);
idNBT.setInteger("i", id);
nbt.setTag("idData", idNBT);
}

@Override
public void load(NBTTagCompound nbt) {
NBTTagCompound idNBT = nbt.getCompoundTag("idData");
id = idNBT.getInteger("i");
regId = idNBT.getInteger("r");
id = idNBT.getInteger("i");
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,9 @@ public ModularPanel buildUI(ComponentData data, GuiSyncManager syncManager) {
if (entity == null) {
entity = container.createNewEntity();
}
if (!entity.has(WorldContainer.class)) {
entity.add(new WorldContainer(syncManager.getPlayer().worldObj));
}
Object[] components = ((IntEntity) entity).getComponentArray();
for (Object component : components) {
if (component instanceof WorldStateValidator validator) {
Expand Down

0 comments on commit 1bb7a80

Please sign in to comment.