Fix crashes when placing chests in the crafting table, closes #67, closes #68

This commit is contained in:
malte0811 2019-01-15 08:25:29 +01:00
parent e9a8225f77
commit 0f3794e645
2 changed files with 15 additions and 9 deletions

View file

@ -470,7 +470,8 @@ public class ClientProxy extends CommonProxy {
IBakedModel texModel = Minecraft.getMinecraft().getRenderItem().getItemModelWithOverrides(stack, IBakedModel texModel = Minecraft.getMinecraft().getRenderItem().getItemModelWithOverrides(stack,
null, null); null, null);
TextureAtlasSprite sprite = texModel.getParticleTexture(); TextureAtlasSprite sprite = texModel.getParticleTexture();
if (sprite.hasAnimationMetadata()) { //noinspection ConstantConditions
if (sprite == null || sprite.hasAnimationMetadata()) {
return false; return false;
} }
int[][] data = sprite.getFrameTextureData(0); int[][] data = sprite.getFrameTextureData(0);

View file

@ -34,7 +34,7 @@ import javax.annotation.Nonnull;
public class RecipePanelTexture extends IForgeRegistryEntry.Impl<IRecipe> implements IRecipe { public class RecipePanelTexture extends IForgeRegistryEntry.Impl<IRecipe> implements IRecipe {
@Override @Override
public boolean matches(@Nonnull InventoryCrafting inv, @Nonnull World worldIn) { public boolean matches(@Nonnull InventoryCrafting inv, @Nonnull World worldIn) {
boolean foundTexture = false; int texX = -1, texY = -1;
boolean foundPanel = false; boolean foundPanel = false;
for (int x = 0; x < inv.getWidth(); x++) { for (int x = 0; x < inv.getWidth(); x++) {
for (int y = 0; y < inv.getHeight(); y++) { for (int y = 0; y < inv.getHeight(); y++) {
@ -44,18 +44,23 @@ public class RecipePanelTexture extends IForgeRegistryEntry.Impl<IRecipe> implem
return false; return false;
} }
foundPanel = true; foundPanel = true;
} else if (IndustrialWires.proxy.isValidTextureSource(here)) { } else if (!here.isEmpty()) {
if (foundTexture || (here.getItem() == Item.getItemFromBlock(IndustrialWires.panel) if (texX == -1) {
&& here.getMetadata() != BlockTypes_Panel.DUMMY.ordinal())) { texX = x;
texY = y;
} else {
return false; return false;
} }
foundTexture = true;
} else if (!here.isEmpty()) {
return false;
} }
} }
} }
return foundPanel && foundTexture; if (!foundPanel || texX == -1) {
return false;
}
ItemStack texSource = inv.getStackInRowAndColumn(texX, texY);
return IndustrialWires.proxy.isValidTextureSource(texSource) &&
(texSource.getItem() != Item.getItemFromBlock(IndustrialWires.panel)
|| texSource.getMetadata() == BlockTypes_Panel.DUMMY.ordinal());
} }
private boolean isUnfinishedPanel(ItemStack stack) { private boolean isUnfinishedPanel(ItemStack stack) {