Started by
Dimensional_Hole
on
Topic category: Help with Minecraft modding (Java Edition)
So i made a mod with a duplication device but it seems to be broken in some way.
since i don't know how to share that broken mod here, i can't do that.
As you didn't add a screenshot, this may not be good advice
Maybe you could make it so you put an item into the block or item and then every so often it spawns a gem of the item on the ground, Idk how you'd add nbt data to the gem
I made a great bedrock texture for a ore duplicator!
Could this be what your looking for:
The 200 is how many ticks it takes to run
The 100 is how much power it needs
The 2 is how many per input it makes
The first 1 is the output slot
The other 1 is the amount of items required to duplicate
The 0s are the item to duplicate slot
Code generated:
package net.mcreator.ender.procedures;
/* imports omitted */
public class TESTProcedure {
public static void execute(LevelAccessor world, double x, double y, double z) {
new Object() {
private int ticks = 0;
private float waitTicks;
private LevelAccessor world;
public void start(LevelAccessor world, int waitTicks) {
this.waitTicks = waitTicks;
MinecraftForge.EVENT_BUS.register(this);
this.world = world;
}
@SubscribeEvent
public void tick(TickEvent.ServerTickEvent event) {
if (event.phase == TickEvent.Phase.END) {
this.ticks += 1;
if (this.ticks >= this.waitTicks)
run();
}
}
private void run() {
if (new Object() {
public int extractEnergySimulate(LevelAccessor level, BlockPos pos, int _amount) {
AtomicInteger _retval = new AtomicInteger(0);
BlockEntity _ent = level.getBlockEntity(pos);
if (_ent != null)
_ent.getCapability(CapabilityEnergy.ENERGY, null)
.ifPresent(capability -> _retval.set(capability.extractEnergy(_amount, true)));
return _retval.get();
}
}.extractEnergySimulate(world, new BlockPos((int) x, (int) y, (int) z), 100) == 100) {
{
BlockEntity _ent = world.getBlockEntity(new BlockPos((int) x, (int) y, (int) z));
int _amount = 100;
if (_ent != null)
_ent.getCapability(CapabilityEnergy.ENERGY, null).ifPresent(capability -> capability.extractEnergy(_amount, false));
}
{
BlockEntity _ent = world.getBlockEntity(new BlockPos((int) x, (int) y, (int) z));
if (_ent != null) {
final int _sltid = 1;
final ItemStack _setstack = (new Object() {
public ItemStack getItemStack(LevelAccessor world, BlockPos pos, int sltid) {
AtomicReference<ItemStack> _retval = new AtomicReference<>(ItemStack.EMPTY);
BlockEntity _ent = world.getBlockEntity(pos);
if (_ent != null) {
_ent.getCapability(CapabilityItemHandler.ITEM_HANDLER_CAPABILITY, null).ifPresent(capability -> {
_retval.set(capability.getStackInSlot(sltid).copy());
});
}
return _retval.get();
}
}.getItemStack(world, new BlockPos((int) x, (int) y, (int) z), 0));
_setstack.setCount(2);
_ent.getCapability(CapabilityItemHandler.ITEM_HANDLER_CAPABILITY, null).ifPresent(capability -> {
if (capability instanceof IItemHandlerModifiable) {
((IItemHandlerModifiable) capability).setStackInSlot(_sltid, _setstack);
}
});
}
}
{
BlockEntity _ent = world.getBlockEntity(new BlockPos((int) x, (int) y, (int) z));
if (_ent != null) {
final int _sltid = 0;
final int _amount = 1;
_ent.getCapability(CapabilityItemHandler.ITEM_HANDLER_CAPABILITY, null).ifPresent(capability -> {
if (capability instanceof IItemHandlerModifiable) {
ItemStack _stk = capability.getStackInSlot(_sltid).copy();
_stk.shrink(_amount);
((IItemHandlerModifiable) capability).setStackInSlot(_sltid, _stk);
}
});
}
}
} else {
EnderMod.LOGGER.info(("Not enough power at " + x + ", " + y + ", " + z));
}
MinecraftForge.EVENT_BUS.unregister(this);
}
}.start(world, 200);
}
}
??????????????????????????
Share-x Screen shot failed to send
What about this: