• Recently Browsing

    No registered users viewing this page.

  • Posts

    • Hi,   I would like to ask what is the best way to replace taken stack from container for a new one. I've tried to do it in 2 ways.   1. Implement it within removeStackFromSlot like this:   @Override public ItemStack removeStackFromSlot(int index) { int maxPossibleItemStackSize = contents.getSlotLimit(index); ItemStack newStack = new ItemStack(CommonEvents.keysItem); CompoundNBT nbt = newStack.getOrCreateTag(); if(!KeysItem.hasKeysGenerated(nbt)){ KeysItem.generateKeys(nbt); } ItemStack takenStack = contents.extractItem(index, maxPossibleItemStackSize, false); this.setInventorySlotContents(index, newStack); return takenStack; }   But this doesn't work at all.   2. Implement it within markDirty like this:   @Override public void markDirty() { markDirtyNotification.invoke(); if(this.getStackInSlot(0) == ItemStack.EMPTY) { ItemStack newStack = new ItemStack(CommonEvents.keysItem); CompoundNBT nbt = newStack.getOrCreateTag(); if (!KeysItem.hasKeysGenerated(nbt)) { KeysItem.generateKeys(nbt); } this.setInventorySlotContents(0, newStack); } }   This works, but somehow inconsistently, that even the taken stack with generated NBT properties gets replaced for a new one and that is not exactly what I want. I need to extract exactly the Item Stack that is currently in the container and after it was taken away generate a new one instead.    Thank you in advance
    • Hi I have moded server for while everything went almost smooth. Today morning I started game and server is stuck in loading because server have autorestart at morning every day. I put here lates log please help thanks! https://gist.github.com/perecnicek/c4d8f405070fe77f81162d3deebef305 latest.log
    • I'm having a hard time understanding capabilities as there seems to be a few ways of adding them making it really confusing to me. I also seem to be missing something when adding a capability to an ItemStack. Could someone nudge me in the right direction? I've tried looking at the Forge Docs and Github code and nothing seems to help.   package com.event_horizon.capabilities; public interface IFission { public float getDuration(); public float getTemperature(); public void addNeutrons(final long neutrons); public long getNeutrons(); } package com.event_horizon.capabilities; import net.minecraft.nbt.CompoundNBT; import net.minecraftforge.common.util.INBTSerializable; public class Fission implements IFission, INBTSerializable<CompoundNBT> { private static final float duration = 0.0001f; private float temperature = 293; private long neutrons = 0; @Override public float getDuration() { return duration; } @Override public float getTemperature() { return temperature; } @Override public void addNeutrons(long neutrons) { this.neutrons += neutrons; } @Override public long getNeutrons() { return neutrons; } @Override public CompoundNBT serializeNBT() { CompoundNBT nbt = new CompoundNBT(); nbt.putFloat("temperature", temperature); nbt.putLong("neutrons", neutrons); return nbt; } @Override public void deserializeNBT(CompoundNBT nbt) { temperature = nbt.getFloat("temperature"); neutrons = nbt.getLong("neutrons"); } } package com.event_horizon.events; import com.event_horizon.EventHorizon; import com.event_horizon.capabilities.FissionProvider; import com.event_horizon.items.FuelRod; import net.minecraft.item.Item; import net.minecraft.item.ItemStack; import net.minecraft.util.ResourceLocation; import net.minecraftforge.event.AttachCapabilitiesEvent; import net.minecraftforge.eventbus.api.SubscribeEvent; import net.minecraftforge.fml.common.Mod; import net.minecraftforge.fml.common.Mod.EventBusSubscriber.Bus; @Mod.EventBusSubscriber(modid = EventHorizon.MOD_ID, bus = Bus.FORGE) public class CapabilitiesEvent { public static final ResourceLocation FISSION = new ResourceLocation(EventHorizon.MOD_ID, "fission"); @SubscribeEvent public static void itemStackCapabilities(AttachCapabilitiesEvent<ItemStack> event) { Item item = event.getObject().getItem(); if (item instanceof FuelRod) { event.addCapability(FISSION, new Fission()); } } }  
  • Topics

  • Who's Online (See full list)