Skip to content

Commit

Permalink
Fixed stackoverflow crash placing drawers; fixed controller not build…
Browse files Browse the repository at this point in the history
…ing network
  • Loading branch information
jaquadro committed Jul 8, 2017
1 parent 38f389d commit 08176d1
Show file tree
Hide file tree
Showing 6 changed files with 35 additions and 22 deletions.
2 changes: 1 addition & 1 deletion gradle.properties
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
6 changes: 0 additions & 6 deletions resources/pack.mcmeta

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -616,32 +616,29 @@ public int[] getAccessibleDrawerSlots () {

@CapabilityInject(IDrawerGroup.class)
public static Capability<IDrawerGroup> DRAWER_GROUP_CAPABILITY = null;
@CapabilityInject(IItemRepository.class)
static Capability<IDrawerAttributes> DRAWER_ATTRIBUTES_CAPABILITY = null;

@SuppressWarnings("unchecked")
@Override
public <T> T getCapability(@Nonnull Capability<T> 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);
}
}
Original file line number Diff line number Diff line change
@@ -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;
Expand All @@ -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;
Expand All @@ -23,6 +26,9 @@

public class TileEntityDrawersComp extends TileEntityDrawers
{
@CapabilityInject(IDrawerAttributes.class)
static Capability<IDrawerAttributes> DRAWER_ATTRIBUTES_CAPABILITY = null;

private GroupData groupData;

private int capacity = 0;
Expand Down Expand Up @@ -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> T getCapability (@Nonnull Capability<T> 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);
}
}

Expand Down
Original file line number Diff line number Diff line change
@@ -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;
Expand All @@ -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<IDrawerAttributes> 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"
};
Expand Down Expand Up @@ -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> T getCapability (@Nonnull Capability<T> 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);
}
}

Expand Down

0 comments on commit 08176d1

Please sign in to comment.