Create: The Factory Must Grow

Create: The Factory Must Grow

4M Downloads

Unable to Place Blade in Industrial Mixer in Certain Condition

stop-x13 opened this issue ยท 1 comments

commented

Step to reproduce:

  1. build a 3*3 vat
  2. place industrial mixer
  3. place blade inside mixer
  4. break the mixer
  5. place the mixer again
  6. 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.

commented

Same problem observed for electrode holder. If electrode holder is destroyed when there is any electrode inside, the vat can no longer recognise having electrode.