Unable to Place Blade in Industrial Mixer in Certain Condition
stop-x13 opened this issue ยท 1 comments
Step to reproduce:
- build a 3*3 vat
- place industrial mixer
- place blade inside mixer
- break the mixer
- place the mixer again
- then you CANNOT place blade anymore unless you close and relaunch the game
I think it is related to mixer block entity class: src/main/java/com/drmangotea/tfmg/content/machinery/vat/industrial_mixer/IndustrialMixerBlockEntity.java
enum MixerMode { NONE("none", ItemStack.EMPTY), MIXING("mixing", TFMGItems.MIXER_BLADE.asStack()), CENTRIFUGE("centrifuge", TFMGItems.CENTRIFUGE.asStack()); public final String name; public final ItemStack item; MixerMode(String name, ItemStack stack) { this.name = name; this.item = stack; } }
stores an ItemStack in enum MixerMode, then in the destroy method
public void destroy() { ItemStack mixerItem = mixerMode.item; Containers.dropItemStack(getLevel(), getBlockPos().getX(), getBlockPos().getY(), getBlockPos().getZ(), mixerItem); }
it drops the same reference item stack on the floor. that very item stack somehow gets modified, thus the enum's ItemStack item field for MIXING's may become empty.
and in
public boolean setMixerMode(ItemStack modeItem, boolean simulate) { for (MixerMode mode : MixerMode.values()) { if (mode.item.is(modeItem.getItem())) { if (!simulate) { mixerMode = mode; } else return true; } } if (!simulate && hasLevel()) VatBlock.updateVatState(getBlockState(), getLevel(), getBlockPos().relative(Direction.DOWN)); sendData(); return false; }
if (mode.item.is(modeItem.getItem())) will always return false because mode.item is an empty stack.