Fix crystal chests crashing the client upon opening and fix wood to iron upgrade not working. Closes #266, Closes #263 Closes #265
This commit is contained in:
parent
1d89a105d9
commit
295d887844
|
|
@ -12,10 +12,14 @@ import net.minecraft.client.gui.screens.MenuScreens;
|
||||||
import net.minecraft.client.renderer.blockentity.BlockEntityRenderers;
|
import net.minecraft.client.renderer.blockentity.BlockEntityRenderers;
|
||||||
import net.minecraft.data.DataGenerator;
|
import net.minecraft.data.DataGenerator;
|
||||||
import net.minecraft.world.item.CreativeModeTab;
|
import net.minecraft.world.item.CreativeModeTab;
|
||||||
|
import net.minecraft.world.item.Item;
|
||||||
import net.minecraft.world.item.ItemStack;
|
import net.minecraft.world.item.ItemStack;
|
||||||
|
import net.minecraft.world.level.block.Block;
|
||||||
import net.minecraftforge.api.distmarker.Dist;
|
import net.minecraftforge.api.distmarker.Dist;
|
||||||
import net.minecraftforge.api.distmarker.OnlyIn;
|
import net.minecraftforge.api.distmarker.OnlyIn;
|
||||||
|
import net.minecraftforge.event.RegistryEvent;
|
||||||
import net.minecraftforge.eventbus.api.IEventBus;
|
import net.minecraftforge.eventbus.api.IEventBus;
|
||||||
|
import net.minecraftforge.eventbus.api.SubscribeEvent;
|
||||||
import net.minecraftforge.fml.DistExecutor;
|
import net.minecraftforge.fml.DistExecutor;
|
||||||
import net.minecraftforge.fml.common.Mod;
|
import net.minecraftforge.fml.common.Mod;
|
||||||
import net.minecraftforge.fml.event.lifecycle.FMLClientSetupEvent;
|
import net.minecraftforge.fml.event.lifecycle.FMLClientSetupEvent;
|
||||||
|
|
@ -96,4 +100,14 @@ public class IronChests {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@SubscribeEvent
|
||||||
|
void missingBlocks(final RegistryEvent.MissingMappings<Block> event) {
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
@SubscribeEvent
|
||||||
|
void missingItems(final RegistryEvent.MissingMappings<Item> event) {
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -10,6 +10,8 @@ import net.minecraft.world.item.ItemStack;
|
||||||
import net.minecraft.world.level.Level;
|
import net.minecraft.world.level.Level;
|
||||||
import net.minecraft.world.level.block.state.BlockState;
|
import net.minecraft.world.level.block.state.BlockState;
|
||||||
|
|
||||||
|
import javax.annotation.Nullable;
|
||||||
|
|
||||||
public interface ICrystalChest {
|
public interface ICrystalChest {
|
||||||
|
|
||||||
default NonNullList<ItemStack> buildItemStackDataList() {
|
default NonNullList<ItemStack> buildItemStackDataList() {
|
||||||
|
|
@ -46,6 +48,7 @@ public interface ICrystalChest {
|
||||||
|
|
||||||
NonNullList<ItemStack> getTopItems();
|
NonNullList<ItemStack> getTopItems();
|
||||||
|
|
||||||
|
@Nullable
|
||||||
Level getChestLevel();
|
Level getChestLevel();
|
||||||
|
|
||||||
BlockPos getChestWorldPosition();
|
BlockPos getChestWorldPosition();
|
||||||
|
|
@ -57,15 +60,15 @@ public interface ICrystalChest {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
NonNullList<ItemStack> tempCopy = NonNullList.<ItemStack>withSize(this.getContainerSize(), ItemStack.EMPTY);
|
NonNullList<ItemStack> tempCopy = NonNullList.<ItemStack>withSize(IronChestsTypes.CRYSTAL.size, ItemStack.EMPTY);
|
||||||
|
|
||||||
boolean hasStuff = false;
|
boolean hasStuff = false;
|
||||||
|
|
||||||
int compressedIdx = 0;
|
int compressedIdx = 0;
|
||||||
|
|
||||||
mainLoop:
|
mainLoop:
|
||||||
for (int i = 0; i < this.getContainerSize(); i++) {
|
for (int i = 0; i < IronChestsTypes.CRYSTAL.size; i++) {
|
||||||
ItemStack itemStack = this.getItems().get(i);
|
ItemStack itemStack = this.getCurrentItems().get(i);
|
||||||
|
|
||||||
if (!itemStack.isEmpty()) {
|
if (!itemStack.isEmpty()) {
|
||||||
for (int j = 0; j < compressedIdx; j++) {
|
for (int j = 0; j < compressedIdx; j++) {
|
||||||
|
|
@ -143,11 +146,9 @@ public interface ICrystalChest {
|
||||||
this.sendTopStacksPacket();
|
this.sendTopStacksPacket();
|
||||||
}
|
}
|
||||||
|
|
||||||
NonNullList<ItemStack> getItems();
|
NonNullList<ItemStack> getCurrentItems();
|
||||||
|
|
||||||
void setHadStuff(boolean hadStuff);
|
void setHadStuff(boolean hadStuff);
|
||||||
|
|
||||||
boolean getHadStuff();
|
boolean getHadStuff();
|
||||||
|
|
||||||
int getContainerSize();
|
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -83,4 +83,9 @@ public class CrystalChestBlockEntity extends AbstractIronChestBlockEntity implem
|
||||||
public boolean getHadStuff() {
|
public boolean getHadStuff() {
|
||||||
return this.hadStuff;
|
return this.hadStuff;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public NonNullList<ItemStack> getCurrentItems() {
|
||||||
|
return this.getItems();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -75,6 +75,11 @@ public class TrappedCrystalChestBlockEntity extends AbstractTrappedIronChestBloc
|
||||||
this.topStacks = topStacks;
|
this.topStacks = topStacks;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public NonNullList<ItemStack> getCurrentItems() {
|
||||||
|
return this.getItems();
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void setHadStuff(boolean hadStuff) {
|
public void setHadStuff(boolean hadStuff) {
|
||||||
this.hadStuff = hadStuff;
|
this.hadStuff = hadStuff;
|
||||||
|
|
|
||||||
|
|
@ -48,8 +48,8 @@ public class ChestUpgradeItem extends Item {
|
||||||
}
|
}
|
||||||
|
|
||||||
if (this.type.canUpgrade(IronChestsTypes.WOOD)) {
|
if (this.type.canUpgrade(IronChestsTypes.WOOD)) {
|
||||||
if (!(world.getBlockState(blockPos).getBlock() instanceof ChestBlock)) {
|
if (world.getBlockState(blockPos).getBlock() instanceof ChestBlock) {
|
||||||
return InteractionResult.PASS;
|
passed = true;
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
for (Block block : IronChestsTypes.get(this.type.source)) {
|
for (Block block : IronChestsTypes.get(this.type.source)) {
|
||||||
|
|
@ -130,9 +130,9 @@ public class ChestUpgradeItem extends Item {
|
||||||
boolean trapped = tileEntity instanceof TrappedChestBlockEntity;
|
boolean trapped = tileEntity instanceof TrappedChestBlockEntity;
|
||||||
|
|
||||||
if(trapped) {
|
if(trapped) {
|
||||||
iBlockState = IronChestsTypes.get(this.type.source).get(1).defaultBlockState();
|
iBlockState = IronChestsTypes.get(this.type.target).get(1).defaultBlockState();
|
||||||
} else {
|
} else {
|
||||||
iBlockState = IronChestsTypes.get(this.type.source).get(0).defaultBlockState();
|
iBlockState = IronChestsTypes.get(this.type.target).get(0).defaultBlockState();
|
||||||
}
|
}
|
||||||
|
|
||||||
iBlockState = iBlockState.setValue(AbstractIronChestBlock.FACING, chestFacing);
|
iBlockState = iBlockState.setValue(AbstractIronChestBlock.FACING, chestFacing);
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue