Started by
BiggenB
on
Topic category: Help with Minecraft modding (Java Edition)
So i am trying to understand and get the hang of all this. I am creating a machine block that extracts power from a generator which is working now and then automatically grinds one specific ore into its ore dust. I can get the energy to work but when it tells me i am missing a block state?
* imports omitted */
public class TestProcedure {
public static void execute(LevelAccessor world, double x, double y, double z, Entity entity) {
if (entity == null)
return;
if (new Object() {
public int getEnergyStored(LevelAccessor level, BlockPos pos) {
AtomicInteger _retval = new AtomicInteger(0);
BlockEntity _ent = level.getBlockEntity(pos);
if (_ent != null)
_ent.getCapability(ForgeCapabilities.ENERGY, null).ifPresent(capability -> _retval.set(capability.getEnergyStored()));
return _retval.get();
}
}.getEnergyStored(world, new BlockPos(x, y, z)) >= 1) {
{
BlockEntity _ent = world.getBlockEntity(new BlockPos(x, y, z));
int _amount = 1;
if (_ent != null)
_ent.getCapability(ForgeCapabilities.ENERGY, null).ifPresent(capability -> capability.extractEnergy(_amount, false));
}
if (new Object() {
public int getAmount(int sltid) {
if (entity instanceof ServerPlayer _player && _player.containerMenu instanceof Supplier _current
&& _current.get() instanceof Map _slots) {
ItemStack stack = ((Slot) _slots.get(sltid)).getItem();
if (stack != null)
return stack.getCount();
}
return 0;
}
}.getAmount(1) != 64) {
if ((entity instanceof ServerPlayer _plrSlotItem && _plrSlotItem.containerMenu instanceof Supplier _splr
&& _splr.get() instanceof Map _slt ? ((Slot) _slt.get(0)).getItem() : ItemStack.EMPTY)
.getItem() == MeteoriteModItems.METEORITE_INGOT.get()) {
if (entity instanceof ServerPlayer _player && _player.containerMenu instanceof Supplier _current
&& _current.get() instanceof Map _slots) {
((Slot) _slots.get(0)).remove(1);
_player.containerMenu.broadcastChanges();
}
if (entity instanceof ServerPlayer _player && _player.containerMenu instanceof Supplier _current
&& _current.get() instanceof Map _slots) {
ItemStack _setstack = new ItemStack(MeteoriteModItems.METEORITEDUST.get());
_setstack.setCount((int) (new Object() {
public int getAmount(int sltid) {
if (entity instanceof ServerPlayer _player && _player.containerMenu instanceof Supplier _current
&& _current.get() instanceof Map _slots) {
ItemStack stack = ((Slot) _slots.get(sltid)).getItem();
if (stack != null)
return stack.getCount();
}
return 0;
}
}.getAmount(0) + 1));
((Slot) _slots.get(1)).set(_setstack);
_player.containerMenu.broadcastChanges();
}
}
}
}
}
}