From 08176d1dfc822057384df94dff80fd9a1c3b7b11 Mon Sep 17 00:00:00 2001 From: Justin Aquadro Date: Sat, 8 Jul 2017 13:24:52 -0400 Subject: [PATCH] Fixed stackoverflow crash placing drawers; fixed controller not building network --- gradle.properties | 2 +- resources/pack.mcmeta | 6 ------ .../block/tile/TileEntityController.java | 2 +- .../block/tile/TileEntityDrawers.java | 17 +++++++---------- .../block/tile/TileEntityDrawersComp.java | 15 +++++++++++++-- .../block/tile/TileEntityDrawersStandard.java | 15 +++++++++++++-- 6 files changed, 35 insertions(+), 22 deletions(-) delete mode 100644 resources/pack.mcmeta diff --git a/gradle.properties b/gradle.properties index 13f95944a..ae28472da 100644 --- a/gradle.properties +++ b/gradle.properties @@ -2,7 +2,7 @@ org.gradle.jvmargs=-Xmx3G minecraft_base_version=1.12 minecraft_version=1.12 -mod_version=5.2.2 +mod_version=5.2.3 chameleon_version=4.1.0 chameleon_max_version=5.0.0 diff --git a/resources/pack.mcmeta b/resources/pack.mcmeta deleted file mode 100644 index 10df4b91b..000000000 --- a/resources/pack.mcmeta +++ /dev/null @@ -1,6 +0,0 @@ -{ - "pack": { - "description": "Storage Drawers resources", - "pack_format": 3 - } -} \ No newline at end of file diff --git a/src/com/jaquadro/minecraft/storagedrawers/block/tile/TileEntityController.java b/src/com/jaquadro/minecraft/storagedrawers/block/tile/TileEntityController.java index 72109ed79..8e88b0876 100644 --- a/src/com/jaquadro/minecraft/storagedrawers/block/tile/TileEntityController.java +++ b/src/com/jaquadro/minecraft/storagedrawers/block/tile/TileEntityController.java @@ -173,7 +173,7 @@ public void validate () { super.validate(); if (!getWorld().isUpdateScheduled(getPos(), ModBlocks.controller)) - getWorld().scheduleUpdate(getPos(), ModBlocks.controller, 1); + getWorld().scheduleBlockUpdate(getPos(), ModBlocks.controller, 1, 0); } @Override diff --git a/src/com/jaquadro/minecraft/storagedrawers/block/tile/TileEntityDrawers.java b/src/com/jaquadro/minecraft/storagedrawers/block/tile/TileEntityDrawers.java index f36aa3b6c..71ed3361f 100644 --- a/src/com/jaquadro/minecraft/storagedrawers/block/tile/TileEntityDrawers.java +++ b/src/com/jaquadro/minecraft/storagedrawers/block/tile/TileEntityDrawers.java @@ -616,32 +616,29 @@ public int[] getAccessibleDrawerSlots () { @CapabilityInject(IDrawerGroup.class) public static Capability DRAWER_GROUP_CAPABILITY = null; - @CapabilityInject(IItemRepository.class) - static Capability DRAWER_ATTRIBUTES_CAPABILITY = null; @SuppressWarnings("unchecked") @Override public T getCapability(@Nonnull Capability capability, @Nullable EnumFacing facing) { - if (getGroup().hasCapability(capability, facing)) - return getGroup().getCapability(capability, facing); - - if (capability == DRAWER_ATTRIBUTES_CAPABILITY) - return (T) drawerAttributes; if (capability == DRAWER_GROUP_CAPABILITY) return (T) getGroup(); + if (getGroup().hasCapability(capability, facing)) + return getGroup().getCapability(capability, facing); + return super.getCapability(capability, facing); } @Override public boolean hasCapability(@Nonnull Capability capability, @Nullable EnumFacing facing) { + if (capability == DRAWER_GROUP_CAPABILITY) + return true; + if (getGroup().hasCapability(capability, facing)) return true; - return capability == DRAWER_ATTRIBUTES_CAPABILITY - || capability == DRAWER_GROUP_CAPABILITY - || super.hasCapability(capability, facing); + return super.hasCapability(capability, facing); } } diff --git a/src/com/jaquadro/minecraft/storagedrawers/block/tile/TileEntityDrawersComp.java b/src/com/jaquadro/minecraft/storagedrawers/block/tile/TileEntityDrawersComp.java index 3811ef5ae..296d742b6 100644 --- a/src/com/jaquadro/minecraft/storagedrawers/block/tile/TileEntityDrawersComp.java +++ b/src/com/jaquadro/minecraft/storagedrawers/block/tile/TileEntityDrawersComp.java @@ -1,6 +1,8 @@ package com.jaquadro.minecraft.storagedrawers.block.tile; import com.jaquadro.minecraft.storagedrawers.StorageDrawers; +import com.jaquadro.minecraft.storagedrawers.api.capabilities.IItemRepository; +import com.jaquadro.minecraft.storagedrawers.api.storage.IDrawerAttributes; import com.jaquadro.minecraft.storagedrawers.api.storage.IDrawerGroup; import com.jaquadro.minecraft.storagedrawers.block.tile.tiledata.FractionalDrawerGroup; import com.jaquadro.minecraft.storagedrawers.config.ConfigManager; @@ -13,6 +15,7 @@ import net.minecraft.util.EnumFacing; import net.minecraft.world.World; import net.minecraftforge.common.capabilities.Capability; +import net.minecraftforge.common.capabilities.CapabilityInject; import net.minecraftforge.fml.common.network.NetworkRegistry; import net.minecraftforge.fml.common.network.simpleimpl.IMessage; import net.minecraftforge.fml.relauncher.Side; @@ -23,6 +26,9 @@ public class TileEntityDrawersComp extends TileEntityDrawers { + @CapabilityInject(IDrawerAttributes.class) + static Capability DRAWER_ATTRIBUTES_CAPABILITY = null; + private GroupData groupData; private int capacity = 0; @@ -88,13 +94,18 @@ protected void onAmountChanged () { @Override public boolean hasCapability (@Nonnull Capability capability, @Nullable EnumFacing facing) { - return TileEntityDrawersComp.this.hasCapability(capability, facing); + return capability == TileEntityDrawersComp.DRAWER_ATTRIBUTES_CAPABILITY + || super.hasCapability(capability, facing); + } @Nullable @Override public T getCapability (@Nonnull Capability capability, @Nullable EnumFacing facing) { - return TileEntityDrawersComp.this.getCapability(capability, facing); + if (capability == TileEntityDrawersComp.DRAWER_ATTRIBUTES_CAPABILITY) + return (T) TileEntityDrawersComp.this.getDrawerAttributes(); + + return super.getCapability(capability, facing); } } diff --git a/src/com/jaquadro/minecraft/storagedrawers/block/tile/TileEntityDrawersStandard.java b/src/com/jaquadro/minecraft/storagedrawers/block/tile/TileEntityDrawersStandard.java index 834b2ca65..3124629b6 100644 --- a/src/com/jaquadro/minecraft/storagedrawers/block/tile/TileEntityDrawersStandard.java +++ b/src/com/jaquadro/minecraft/storagedrawers/block/tile/TileEntityDrawersStandard.java @@ -1,8 +1,10 @@ package com.jaquadro.minecraft.storagedrawers.block.tile; import com.jaquadro.minecraft.storagedrawers.StorageDrawers; +import com.jaquadro.minecraft.storagedrawers.api.capabilities.IItemRepository; import com.jaquadro.minecraft.storagedrawers.api.event.DrawerPopulatedEvent; import com.jaquadro.minecraft.storagedrawers.api.storage.EnumBasicDrawer; +import com.jaquadro.minecraft.storagedrawers.api.storage.IDrawerAttributes; import com.jaquadro.minecraft.storagedrawers.api.storage.IDrawerGroup; import com.jaquadro.minecraft.storagedrawers.block.BlockStandardDrawers; import com.jaquadro.minecraft.storagedrawers.block.tile.tiledata.StandardDrawerGroup; @@ -19,12 +21,16 @@ import net.minecraft.util.EnumFacing; import net.minecraftforge.common.MinecraftForge; import net.minecraftforge.common.capabilities.Capability; +import net.minecraftforge.common.capabilities.CapabilityInject; import javax.annotation.Nonnull; import javax.annotation.Nullable; public class TileEntityDrawersStandard extends TileEntityDrawers { + @CapabilityInject(IDrawerAttributes.class) + static Capability DRAWER_ATTRIBUTES_CAPABILITY = null; + private static final String[] GUI_IDS = new String[] { null, StorageDrawers.MOD_ID + ":basicDrawers1", StorageDrawers.MOD_ID + ":basicDrawers2", null, StorageDrawers.MOD_ID + ":basicDrawers4" }; @@ -222,13 +228,18 @@ protected DrawerData createDrawer (int slot) { @Override public boolean hasCapability (@Nonnull Capability capability, @Nullable EnumFacing facing) { - return TileEntityDrawersStandard.this.hasCapability(capability, facing); + return capability == TileEntityDrawersStandard.DRAWER_ATTRIBUTES_CAPABILITY + || super.hasCapability(capability, facing); + } @Nullable @Override public T getCapability (@Nonnull Capability capability, @Nullable EnumFacing facing) { - return TileEntityDrawersStandard.this.getCapability(capability, facing); + if (capability == TileEntityDrawersStandard.DRAWER_ATTRIBUTES_CAPABILITY) + return (T) TileEntityDrawersStandard.this.getDrawerAttributes(); + + return super.getCapability(capability, facing); } }