Jump to content

TesterTesting135

Members
  • Posts

    105
  • Joined

  • Last visited

Everything posted by TesterTesting135

  1. So i was following with MCJty's 1.12 Modding tutorial, episode 10, and i'm stuck on something. Here is the link: The time is about 12:10 on the video. I can't seem to find the method "split" in StringUtils. I'm wondering if this was removed or moved somewhere. Any help would be greatly appreciated! Ok, well it looks like i used the wrong StringUtils.
  2. I've been recently working on a custom crafting table that uses energy, and is a tile entity. I'm trying to add custom recipes, but i'm not sure how. I'm stuck on how to detect if there are the correct items in the correct slots. I was also following along with MCJTY's modding tutorial for 1.12.2. Link to the video: Here are my classes: Tile Entity class: public class TileTestCraftingBench extends TileEntity implements ITickable { private static final int INPUT_SLOTS = 9; private static final int OUTPUT_SLOTS = 1; static final int SIZE = INPUT_SLOTS + OUTPUT_SLOTS; public static final int MAX_PROGRESS = ConfigHandler.MAX_CUTTER_PROGRESS; private int progress = 0; @Override public void update() { if (!world.isRemote) { } } public int getProgress() { return progress; } public void setProgress(int progress) { this.progress = progress; } private ItemStackHandler inputHandler = new ItemStackHandler(INPUT_SLOTS) { @Override protected void onContentsChanged(int slot) { // We need to tell the tile entity that something has changed so // that the chest contents is persisted TileBlackHoleCompactor.this.markDirty(); } }; private ItemStackHandler outputHandler = new ItemStackHandler(OUTPUT_SLOTS) { @Override protected void onContentsChanged(int slot) { // We need to tell the tile entity that something has changed so // that the chest contents is persisted TileBlackHoleCompactor.this.markDirty(); } }; private CombinedInvWrapper combinedHandler = new CombinedInvWrapper(inputHandler, outputHandler); @Override public void readFromNBT(NBTTagCompound compound) { super.readFromNBT(compound); if (compound.hasKey("itemsIn")) { inputHandler.deserializeNBT((NBTTagCompound) compound.getTag("itemsIn")); } if (compound.hasKey("itemsOut")) { outputHandler.deserializeNBT((NBTTagCompound) compound.getTag("itemsOut")); } progress = compound.getInteger("progress"); } @Override public NBTTagCompound writeToNBT(NBTTagCompound compound) { super.writeToNBT(compound); compound.setTag("itemsIn", inputHandler.serializeNBT()); compound.setTag("itemsOut", outputHandler.serializeNBT()); compound.setInteger("progress", progress); return compound; } public boolean canInteractWith(EntityPlayer playerIn) { // If we are too far away from this tile entity you cannot use it return !isInvalid() && playerIn.getDistanceSq(pos.add(0.5D, 0.5D, 0.5D)) <= 64D; } @Override public boolean hasCapability(Capability<?> capability, EnumFacing facing) { if (capability == CapabilityItemHandler.ITEM_HANDLER_CAPABILITY) { return true; } return super.hasCapability(capability, facing); } @Override public <T> T getCapability(Capability<T> capability, EnumFacing facing) { if (capability == CapabilityItemHandler.ITEM_HANDLER_CAPABILITY) { if (facing == null) { return CapabilityItemHandler.ITEM_HANDLER_CAPABILITY.cast(combinedHandler); } else if (facing == EnumFacing.UP) { return CapabilityItemHandler.ITEM_HANDLER_CAPABILITY.cast(inputHandler); } else { return CapabilityItemHandler.ITEM_HANDLER_CAPABILITY.cast(outputHandler); } } return super.getCapability(capability, facing); } } Container Class: public class ContainerTestBench extends Container { private TileTestCraftingBench te; public ContainerTestBench(IInventory playerInventory, TileTestCraftingBench te) { this.te = te; addOwnSlots(); addPlayerSlots(playerInventory); } private void addPlayerSlots(IInventory playerInventory) { // Slots for the main inventory for (int row = 0; row < 3; ++row) { for (int col = 0; col < 9; ++col) { int x = 10 + col * 18; int y = row * 18 + 70; this.addSlotToContainer(new Slot(playerInventory, col + row * 9 + 10, x, y)); } } // Slots for the hotbar for (int row = 0; row < 9; ++row) { int x = 10 + row * 18; int y = 58 + 70; this.addSlotToContainer(new Slot(playerInventory, row, x, y)); } } private void addOwnSlots() { IItemHandler itemHandler = this.te.getCapability(CapabilityItemHandler.ITEM_HANDLER_CAPABILITY, null); int x = 64; int y = 9; int slotIndex = 0; addSlotToContainer(new SlotItemHandler(itemHandler, slotIndex++, x, y)); x +=18; addSlotToContainer(new SlotItemHandler(itemHandler, slotIndex++, x, y)); x +=18; addSlotToContainer(new SlotItemHandler(itemHandler, slotIndex++, x, y)); x = 64; y = 27; addSlotToContainer(new SlotItemHandler(itemHandler, slotIndex++, x, y)); x +=18; addSlotToContainer(new SlotItemHandler(itemHandler, slotIndex++, x, y)); x +=18; addSlotToContainer(new SlotItemHandler(itemHandler, slotIndex++, x, y)); x = 64; y = 45; addSlotToContainer(new SlotItemHandler(itemHandler, slotIndex++, x, y)); x +=18; addSlotToContainer(new SlotItemHandler(itemHandler, slotIndex++, x, y)); x +=18; addSlotToContainer(new SlotItemHandler(itemHandler, slotIndex++, x, y)); x = 136; y = 27; addSlotToContainer(new SlotItemHandler(itemHandler, slotIndex++, x, y)); } @Override public ItemStack transferStackInSlot(EntityPlayer playerIn, int index) { ItemStack itemstack = ItemStack.EMPTY; Slot slot = this.inventorySlots.get(index); if (slot != null && slot.getHasStack()) { ItemStack itemstack1 = slot.getStack(); itemstack = itemstack1.copy(); if (index < TileTestCraftingBench.SIZE) { if (!this.mergeItemStack(itemstack1, TileTestCraftingBench.SIZE, this.inventorySlots.size(), true)) { return ItemStack.EMPTY; } } else if (!this.mergeItemStack(itemstack1, 0, TileTestCraftingBench.SIZE, false)) { return ItemStack.EMPTY; } if (itemstack1.isEmpty()) { slot.putStack(ItemStack.EMPTY); } else { slot.onSlotChanged(); } } return itemstack; } @Override public boolean canInteractWith(EntityPlayer playerIn) { return te.canInteractWith(playerIn); } } Any help would be greatly appreciated!
  3. Ok, i think i've figured it out now. I just used different parameters and it seems to work now.l
  4. Hello, so i've been recently working on some special armor. If you press a keybind, your armor slots automatically fill up with the armor. I am using player.inventory.armorInventory.set to replace the slots. I am probably doing something really wrong, but whenever i press the keybind, everybody in the world gets the armor. Is there any way i can fix this? Any help would be greatly appreciated, thanks. Here is the code: @SubscribeEvent public void armorTick(LivingEvent.LivingUpdateEvent event) { if (event.getEntityLiving() instanceof EntityPlayer) { EntityPlayer player = (EntityPlayer) event.getEntityLiving(); if(permanentArmor) { if(player.inventory.armorItemInSlot(3).getItem() != ModItems.QUICK_HELMET) { player.inventory.armorInventory.set(3, new ItemStack(ModItems.QUICK_HELMET)); } if(player.inventory.armorItemInSlot(2).getItem() != ModItems.QUICK_CHESTPLATE) { player.inventory.armorInventory.set(2, new ItemStack(ModItems.QUICK_CHESTPLATE)); } if(player.inventory.armorItemInSlot(1).getItem() != ModItems.QUICK_LEGGINGS) { player.inventory.armorInventory.set(1, new ItemStack(ModItems.QUICK_LEGGINGS)); } if(player.inventory.armorItemInSlot(0).getItem() != ModItems.QUICK_BOOTS) { player.inventory.armorInventory.set(0, new ItemStack(ModItems.QUICK_BOOTS)); } } } } EDIT: Here is "permanentarmor": public static void togglePermanentArmor(EntityPlayer player) { if (MAP.containsKey(player) && MAP.get(player)) { MAP.remove(player); permanentArmor = false; player.sendStatusMessage(new TextComponentString("Permanent Armor: Off"), true); } else { MAP.put(player, true); permanentArmor = true; player.sendStatusMessage(new TextComponentString("Permanent Armor: On"), true); } } }
  5. Hello, so i have started java programming recently and i am making a mod that has armor that allows you to go into no-clip mode. (basically spectator mode) I want it so that when i press a key, it turns on no-clip, and sends a message to me. I think i can manage everything else but i'm having trouble registering the keybind. I have a KeybindHandler class which registers the keybind. I'm using MC 1.12.2. Code for my KeybindHandler: public class KeybindHandler { public static KeyBinding keybind; public static void init() { keybind = new KeyBinding("No-Clip", Keyboard.KEY_SEMICOLON, "TestKeybind"); ClientRegistry.registerKeyBinding(keybind); } } I'm not sure if i need to do anything else, other than this, but this by itself isn't working. Any help would be greatly appreciated. EDIT: The problem is the keybind doesn't show up in the controls section. EDIT # 2: It looks like i forgot to call it... woops
×
×
  • Create New...

Important Information

By using this site, you agree to our Terms of Use.