• Recently Browsing

    No registered users viewing this page.

  • Posts

    • Container: package com.budrunbun.lavalamp.containers; import net.minecraft.entity.player.PlayerEntity; import net.minecraft.entity.player.PlayerInventory; import net.minecraft.inventory.container.Container; import net.minecraft.inventory.container.Slot; import net.minecraft.tileentity.TileEntity; import net.minecraft.util.math.BlockPos; import net.minecraft.world.World; import net.minecraftforge.items.IItemHandler; import net.minecraftforge.items.ItemStackHandler; import net.minecraftforge.items.SlotItemHandler; import net.minecraftforge.items.wrapper.InvWrapper; public class CheeseGeneratorContainer extends Container { private final IItemHandler generatorInventory, playerInventory; public CheeseGeneratorContainer(int windowId, PlayerInventory playerInventory, IItemHandler generatorInventory) { super(ModContainers.CHEESE_GENERATOR_CONTAINER, windowId); this.generatorInventory = generatorInventory; this.playerInventory = new InvWrapper(playerInventory); this.addSlot(new SlotItemHandler(generatorInventory, 0, 12 + 4 * 18, 8 + 2 * 18)); int leftCol = (184 - 162) / 2 + 1; for (int playerInvRow = 0; playerInvRow < 3; playerInvRow++) { for (int playerInvCol = 0; playerInvCol < 9; playerInvCol++) { this.addSlot(new SlotItemHandler(generatorInventory, playerInvCol + playerInvRow * 9 + 9, leftCol + playerInvCol * 18, 184 - (4 - playerInvRow) * 18 - 10)); } } for (int hotbarSlot = 0; hotbarSlot < 9; hotbarSlot++) { this.addSlot(new SlotItemHandler(this.playerInventory, hotbarSlot, leftCol + hotbarSlot * 18, 184 - 24)); } } @Override public boolean canInteractWith(PlayerEntity playerIn) { return true; } } TE: package com.budrunbun.lavalamp.tileEntities; import com.budrunbun.lavalamp.containers.CheeseGeneratorContainer; import com.budrunbun.lavalamp.proxy.ClientProxy; import net.minecraft.client.world.ClientWorld; import net.minecraft.entity.player.PlayerEntity; import net.minecraft.entity.player.PlayerInventory; import net.minecraft.inventory.container.Container; import net.minecraft.inventory.container.INamedContainerProvider; import net.minecraft.nbt.CompoundNBT; import net.minecraft.tileentity.TileEntity; import net.minecraft.util.Direction; import net.minecraft.util.text.ITextComponent; import net.minecraft.util.text.TranslationTextComponent; import net.minecraftforge.common.capabilities.Capability; import net.minecraftforge.common.util.LazyOptional; import net.minecraftforge.items.CapabilityItemHandler; import net.minecraftforge.items.ItemStackHandler; import javax.annotation.Nonnull; import javax.annotation.Nullable; public class CheeseGeneratorTE extends TileEntity implements INamedContainerProvider { private final ItemStackHandler handler = new ItemStackHandler(1) { @Override protected void onContentsChanged(int slot) { super.onContentsChanged(slot); markDirty(); } }; public CheeseGeneratorTE() { super(ModTileEntities.CHEESE_GENERATOR_TE); } @Override public void read(CompoundNBT compound) { handler.deserializeNBT(compound.getCompound("inv")); super.read(compound); } @Override public CompoundNBT write(CompoundNBT compound) { compound.put("inv",handler.serializeNBT()); return super.write(compound); } @Override public ITextComponent getDisplayName() { return new TranslationTextComponent("cheese_generator"); } @Nullable @Override public Container createMenu(int windowId, PlayerInventory playerInventory, PlayerEntity playerEntity) { return new CheeseGeneratorContainer(windowId, playerInventory, handler); } }  
    • LivingSpawnEvent does not do what you think it does. In fact subscribing to LivingSpawnEvent alone does not make any sense, you'd have to choose one of it's subclasses. You are looking for EntityJoinWorldEvent.
    • Looking at the Forge code (specifically, fmllauncher), it seems that although the config option exists, it isn't retrieved and used for anything other than logging the value to the log file. It might've been added in some update but its functionality was removed. In any case, it does not work currently.
    • I am trying to make an event that will spawn armor stands with arms whenever an armor stand is spawned but I cannot get it to work. I included a logger to see if it gets past the if statement that checks if the entity spawned was an armor stand and it does not log anything so I am assuming that is the problem(I put one outside of the if statement and it does log when things spawn). Any ideas?   package com.chaoticsoul.evolate.events; import com.chaoticsoul.evolate.Evolate; import net.minecraft.entity.item.ArmorStandEntity; import net.minecraft.nbt.CompoundNBT; import net.minecraftforge.event.entity.living.LivingSpawnEvent; import net.minecraftforge.eventbus.api.SubscribeEvent; import net.minecraftforge.fml.common.Mod; import net.minecraftforge.fml.common.Mod.EventBusSubscriber.Bus; @Mod.EventBusSubscriber(modid = Evolate.MOD_ID, bus = Bus.FORGE) public class SpawnArmorStandEvent { @SubscribeEvent public static void spawnArmorStandEvent(LivingSpawnEvent event) { if (event.getEntityLiving() instanceof ArmorStandEntity) { Evolate.LOGGER.info("test"); ArmorStandEntity stand = (ArmorStandEntity) event.getEntityLiving(); CompoundNBT compound = new CompoundNBT(); compound.putBoolean("ShowArms", true); stand.writeAdditional(compound); } } } Also, I am new to nbt data so that part may be wrong as well.
    • You can use PlayerInteractEvent.RightClickBlock for this purpose.
  • Topics

  • Who's Online (See full list)