Jump to content

Big_Bad_E

Members
  • Posts

    312
  • Joined

  • Last visited

Everything posted by Big_Bad_E

  1. I just gave up, I've spent way too long working on this.
  2. How would I wait a tick? Would I add it into the command's code, and just delay the entire thing a tick? I don't think I could do that because I think the mod is on the same thread as Minecraft. Idk I just need you to be a little less vague maybe on I should go about this. Nevermind I figured it out myself. I just added a event every tick to check a boolean to see if the command was run, if so set another boolean to true and set boolean 1 to false, then if boolean 1 is false and boolean 2 is true I run the cmd.
  3. I am trying to make a command open a GuiScreen, but when I send the command it doesn't open. I've heard it's because when the chat closes it closes all open GUIs, so I tried listeneing to GuiOpen event and if it's my GUI set a boolean to true, and if the GUI is null and the boolean is true set it to false and open my GUI. But still nothing happens. No errors or anything. Code: GuiScreen: private List<GuiButton> overlayConfig = new ArrayList<GuiButton>(); @Override public void initGui() { super.initGui(); overlayConfig.add(new GuiButton(0, 50, 50, "True")); } @Override public void drawScreen(int mouseX, int mouseY, float partialTicks) { drawDefaultBackground(); overlayConfig.get(0).drawButton(Minecraft.getMinecraft(), mouseX, mouseY); overlayConfig.get(0).displayString = ""; super.drawScreen(mouseX, mouseY, partialTicks); } @Override protected void mouseClicked(int x, int y, int button) { for (GuiButton config : overlayConfig) { if (config.mousePressed(Minecraft.getMinecraft(), x, y)) { config.enabled = !config.enabled; } } } Command execute code: if (sender.getEntityWorld().isRemote) Minecraft.getMinecraft().displayGuiScreen(new ConfigMenu()); Event listener to try and fix my problems: @SubscribeEvent public void onGuiClose(GuiOpenEvent event) { if(event.gui == null && justOpened) { Minecraft.getMinecraft().displayGuiScreen(new ConfigMenu()); justOpened = false; } if(event.gui != null && event.gui.getClass().equals(ConfigMenu.class)) { justOpened = true; } } The event is registered in my ClientProxy's postInit.
  4. Will look into it. I am now using SlotItemHandler, good idea with that one.
  5. 1.7.10 Isn't supported, please update. Also the best way would be a custom furnace. I don't think any other way would really work at all.
  6. Oh, didn't know, sorry about ur airplane problems. How come we can mass produce nuclear weapons but we cant move from point A to point B in an airplane easily. Input and output is a good idea i'm going to try it. Still being weird, see updated code/errors above.
  7. Are you asking how to register the model to your block? If so, here's some registry code that should be in your registry class @SubscribeEvent public static void registerModels(ModelRegistryEvent event) { for (Block block : blocks) { ModelLoader.setCustomModelResourceLocation(Item.getItemFromBlock(block), 0, new ModelResourceLocation(block.getRegistryName(), "inventory")); } } Where the block variable is the instance of your chest block
  8. The entire log, not just a clip of it. It should be in Documents/Curse/Minecraft/Instances/All The Mods/
  9. How would I use IItemHandler? I can't set slot's inventory to it because it doesn't implement IInventory. It looks nice but I can't use it. Also back to the original question what's wrong with my code?
  10. Download forge on your computer, click install server, then drag all the files into your server directory. Run the forge JAR file to start the server.
  11. I'm just gonna bump this because Draco is online
  12. Just use a JSON modeler program to make a model with the textures. Here is the ChestModel class: @SideOnly(Side.CLIENT) public class ModelChest extends ModelBase { /** The chest lid in the chest's model. */ public ModelRenderer chestLid = (new ModelRenderer(this, 0, 0)).setTextureSize(64, 64); /** The model of the bottom of the chest. */ public ModelRenderer chestBelow; /** The chest's knob in the chest model. */ public ModelRenderer chestKnob; public ModelChest() { this.chestLid.addBox(0.0F, -5.0F, -14.0F, 14, 5, 14, 0.0F); this.chestLid.rotationPointX = 1.0F; this.chestLid.rotationPointY = 7.0F; this.chestLid.rotationPointZ = 15.0F; this.chestKnob = (new ModelRenderer(this, 0, 0)).setTextureSize(64, 64); this.chestKnob.addBox(-1.0F, -2.0F, -15.0F, 2, 4, 1, 0.0F); this.chestKnob.rotationPointX = 8.0F; this.chestKnob.rotationPointY = 7.0F; this.chestKnob.rotationPointZ = 15.0F; this.chestBelow = (new ModelRenderer(this, 0, 19)).setTextureSize(64, 64); this.chestBelow.addBox(0.0F, 0.0F, 0.0F, 14, 10, 14, 0.0F); this.chestBelow.rotationPointX = 1.0F; this.chestBelow.rotationPointY = 6.0F; this.chestBelow.rotationPointZ = 1.0F; } /** * This method renders out all parts of the chest model. */ public void renderAll() { this.chestKnob.rotateAngleX = this.chestLid.rotateAngleX; this.chestLid.render(0.0625F); this.chestKnob.render(0.0625F); this.chestBelow.render(0.0625F); } } Chest textures are stored at textures/entity/chest. You gotta do most things yourself though. Good luck!
  13. You want a chest that doesn't have an opening animation that still connects with other chests?
  14. No, I am not trying to have a super large item stack, I am trying to store it as a number in the tile entity's NBT data along with the item. Then I can use that to let the player get the item. It's literally the Deep Storage Unit.
  15. I am trying to make a Tile Entity that stores one item and its amount. I have a Container which has one slot, that is where you should put the item. The item goes up to the 32 bit integer limit. My problems are: Shift clicking is weird, slots 9-10 just go to each other 2-8 goes to 19-26, slot 27-35 and 1 crashes game with this error: Caused by: java.lang.NullPointerException at net.minecraft.inventory.Container.slotClick(Container.java:271) ~[Container.class:?] at net.minecraft.client.multiplayer.PlayerControllerMP.windowClick(PlayerControllerMP.java:610) ~[PlayerControllerMP.class:?] at net.minecraft.client.gui.inventory.GuiContainer.handleMouseClick(GuiContainer.java:693) ~[GuiContainer.class:?] at net.minecraft.client.gui.inventory.GuiContainer.mouseClicked(GuiContainer.java:430) ~[GuiContainer.class:?] at net.minecraft.client.gui.GuiScreen.handleMouseInput(GuiScreen.java:611) ~[GuiScreen.class:?] at net.minecraft.client.gui.GuiScreen.handleInput(GuiScreen.java:576) ~[GuiScreen.class:?] at net.minecraft.client.Minecraft.runTick(Minecraft.java:1884) ~[Minecraft.class:?] ... 15 more I'm just gonna post a video cause it's easier to explain. (Ima add textures/models later ofc) Container: public class QuantumContainer extends Container { QuantumContainer(InventoryPlayer inventory, TEQuantumStorage tile) { SlotItemHandler slot = new SlotQuantum(new QuantumHandler(tile), 36, 80, 40); addSlotToContainer(slot); slot.putStack(new ItemStack(tile.getItem(), tile.getAmount())); int i; for (i = 0; i < 3; ++i) { for (int j = 0; j < 9; ++j) { addSlotToContainer(new Slot(inventory, j + i * 9 + 9, 8 + j * 18, 84 + i * 18)); } } // add hotbar slots for (i = 0; i < 9; ++i) { addSlotToContainer(new Slot(inventory, i, 8 + i * 18, 142)); } } @Override @ParametersAreNonnullByDefault public boolean canInteractWith(EntityPlayer playerIn) { return true; } @Override @MethodsReturnNonnullByDefault public ItemStack transferStackInSlot(EntityPlayer playerIn, int slotIndex) { ItemStack itemStack1 = null; Slot slot = inventorySlots.get(slotIndex); if (slot != null && slot.getHasStack()) { ItemStack itemStack2 = slot.getStack(); itemStack1 = itemStack2.copy(); // player inventory slots if (slotIndex >= 9 && slotIndex < 36) { if (!mergeItemStack(itemStack2, 9, 35, false)) return null; // hotbar slots } else if (slotIndex < 9 && !mergeItemStack(itemStack2, 2, 28, false)) { if (!mergeItemStack(itemStack2, 0, 8, false)) return null; } else if (!mergeItemStack(itemStack2, 0, 37, false)) { return null; } if (itemStack2.getCount() == 0) { slot.putStack(ItemStack.EMPTY); } else { slot.onSlotChanged(); } if (itemStack2.getCount() == itemStack1.getCount()) { return null; } } return itemStack1; } } QuantumHandler: private ItemStack stack; private TEQuantumStorage tile; public QuantumHandler(TEQuantumStorage tile) { this.tile = tile; } @Override public int getSlots() { return 1; } @Nonnull @Override public ItemStack getStackInSlot(int slot) { return stack; } @Nonnull @Override public ItemStack insertItem(int slot, @Nonnull ItemStack stack, boolean simulate) { tile.setItem(stack.getItem()); tile.addAmount(stack.getCount()); this.stack = stack; this.stack.setCount(tile.getAmount()); tile.markDirty(); ItemStack stack1 = stack.copy(); if(stack.getCount() == 1) { stack1.setCount(stack1.getCount() - 1); return stack1; } else return ItemStack.EMPTY; } @Nonnull @Override public ItemStack extractItem(int slot, int amount, boolean simulate) { ItemStack stack = this.stack.copy(); if (stack.getCount() > 64) { stack.setCount(64); } if(amount == 1 && tile.getAmount() > 0) stack.setCount(1); else if(tile.getAmount() < 64) stack.setCount(tile.getAmount()); tile.addAmount(-amount); this.stack.setCount(this.stack.getCount() - amount); tile.markDirty(); return stack; } @Override public int getSlotLimit(int slot) { return 2147483647; } @Override public void setStackInSlot(int slot, @Nonnull ItemStack stack) { this.stack = stack; tile.markDirty(); } SlotQantum: public class SlotQuantum extends SlotItemHandler { public SlotQuantum(IItemHandler handler, int index, int xPosition, int yPosition) { super(handler, index, xPosition, yPosition); } @Override public int getSlotStackLimit() { return 2147483647; } } Tile Entity: public class TEQuantumStorage extends TileEntity { private Item item; private int amount; @Override public void readFromNBT(NBTTagCompound nbt) { super.readFromNBT(nbt); this.item = Item.getItemById(nbt.getInteger("item")); this.amount = nbt.getInteger("amount"); } @Override public NBTTagCompound writeToNBT(NBTTagCompound nbt) { super.writeToNBT(nbt); nbt.setInteger("item", Item.getIdFromItem(item)); nbt.setInteger("amount", amount); return nbt; } public int getAmount() { return amount; } public void setAmount(int amount) { this.amount = amount; } public Item getItem() { return item; } public void setItem(Item item) { this.item = item; } } Sorry for code dump, but I've been at this for hours and have no idea what I'm doing wrong.
  16. Oh, good job getting it working. I was talking about in the Edit Configurations menu, sorry I wasn't being clear.
  17. The main class should be GradleStart, Working Directory is (mod folder)\run Use classpath of modules should be (modname)_main (There is only one _main module)
  18. Oh, did not know that. I had assumed forge was completely different. Good to know I guess.
  19. There are a ton of guides, and I felt like I just needed to make one of how I mod using 1.12.2. Table of Contents: 1. Getting Started 2. Registries 3. Proxies 3. Basic Block/Item 4. GUIs (There will be more coming, I am writing this as I learn.) Getting Started: Download Forge mdk Unzip it Run gradlew setupDecompWorkspace for Eclipse: Run gradlew eclipse in cmd.exe for Intellij: Run gradlew setupDevWorkspace ideaModule Import build.gradle as a project Go to File -> Project Structure -> Modules Click '+' and click import, choose (folder name).iml. (There is only one in the folder) Close intellij run gradlew genIntellijruns Open Intellij Run -> Profile -> Edit Configurations Choose server/client Set "Use classpath of module" to (folder name)_main Apply Registries: Registries are Forge's way of injecting instances of your classes into the game. Basic setup: You need a class annotated with EventBusSubscriber From there you add methods annotated with EventHandler to register blocks. Example: @EventHandler public static void registerBlocks(RegistryEvent.Register<Block> event) { event.getRegistry().registerAll(blocks); } blocks is a List of all blocks in the mod. Note: When registering blocks, you also have to register an ItemBlock. To do this use the Item registry event, and register a new instance of ItemBlock(you have to set its registry name). Registering models: (This may need to be client side only, if it is please tell me) @SubscribeEvent public static void registerModels(ModelRegistryEvent event) { for (Block block : blocks) { if (block.getRegistryName() != null) ModelLoader.setCustomModelResourceLocation(Item.getItemFromBlock(block), 0, new ModelResourceLocation(block.getRegistryName(),"inventory")); } } Pretty simple, nothing too hard. ObjectHolder: What is ObjectHolder? ObjectHolder is used to get instances of your block. Use: @ObjectHolder("modid") public class ModBlocks { @ObjectHolder("mod_block") public static final Block MOD_BLOCK = null; After the block is registered, an instance of it will be injected into MOD_BLOCK. Proxies: Minecraft runs on 2 sides. Client and server. Certain things are only client side, some are only server side. Setting up proxies: Proxies require 2 classes, Client and Server. The SidedProxy annotation requires 2 arguments, the path to your client and server proxy (ex. "com.author.mod.proxies.ClientProxy") Then you can use the SidedProxy annotation with the argument saying what side it is to tell Forge to run that code on a certain side. If you want to check what side a method is, use world.isRemote(), true means client side, false means server side. Blocks/Items: This is pretty simple, just make a class extend Block/Item, put in the necessary methods and constructors (setRegistryName() is a big one). Then register an instance of that block/item in the appropriate registry. When making a texture/model, you need to have the appropriate files. (BlockState for a block, block model for blocks, item model for blocks and items, and textures) I suggest looking at the default MC asset files when making textures. I won't get too much into detail here because it's not that hard to do. GUIs: GUIs are a bit harder. A GUI can either be a container, or a screen. A GUI requires 2-3 classes bare minimum, depending on what type it is. Simple screen: Create a class that implements IGuiHandler. That class needs 2 overrided methods. Example: @Override public Object getServerGuiElement(int ID, EntityPlayer player, World world, int x, int y, int z) { return new Container(player.inventory, world); } @Override public Object getClientGuiElement(int id, EntityPlayer player, World world, int x, int y, int z) { return new Gui(new Container(player.inventory, world)); } Now you gotta register it in your main class's init method: NetworkRegistry.INSTANCE.registerGuiHandler(instance, new WorkbenchGuiHandler()); (instance is the instance of your main class) Note: the instance should be obtained by making a variable and annotating it with the Instance annotation, and your modid as an argument. Now, we have to make the actual GUI. For my example I am going to be making a custom crafting table. Here is the GUI screen with the crafting table background: GuiScreen(Container inventorySlotsIn) { super(inventorySlotsIn); } //This is for everything behind the items @Override protected void drawGuiContainerBackgroundLayer(float partialTicks, int mouseX, int mouseY) { GlStateManager.color(1.0F, 1.0F, 1.0F, 1.0F); //Makes the background darker like in a normal craftring table this.drawDefaultBackground(); //Size of the GUI image int i = (this.width - this.xSize) / 2; int j = (this.height - this.ySize) / 2; //Load the default crafting GUI texture this.mc.getTextureManager().bindTexture(new ResourceLocation("textures/gui/container/crafting_table.png")); //Draw it this.drawTexturedModalRect(i, j, 0, 0, this.xSize, this.ySize); } //Now for on top of the items @Override protected void drawGuiContainerForegroundLayer(int mouseX, int mouseY) { //Draw the name at the top, getting the name from the lang file. this.fontRenderer.drawString(I18n.format("gui.custom_workbench.name"), 28, 6, 4210752); } Now we need a container to contain all of the items. the container has to draw the player's inventory, the inventory, listen for click events, etc... just saying, this one's a big class. Commented code is code for making the inventory a crafting table public class GUIContainer extends Container { private World world; private InventoryCrafting matrix; private InventoryCraftResult result; private EntityPlayer player; GUIContainer(InventoryPlayer playerInventory, World world) { //matrix = new InventoryCrafting(this, 3, 3); player = playerInventory.player; this.world = world; //result = new InventoryCraftResult(); /* int index = 1; Output slot, code down below. addSlotToContainer(new CraftResultSlot(matrix, 0, 124, 35)); Crafting matrix for (int i = 0; i < 3; i++) { for (int j = 0; j < 3; j++) { addSlotToContainer(new Slot(matrix, index, 30 + j * 18, 17 + i * 18)); index += 1; } } */ //Player's inventory for (int k = 0; k < 3; k++) { for (int i = 0; i < 9; i++) { addSlotToContainer(new Slot(playerInventory, index, 8 + i * 18, 84 + k * 18)); index += 1; } } //Player's hotbar for (int i = 0; i < 9; i++) { addSlotToContainer(new Slot(playerInventory, i, 8 + i * 18, 142)); } } //Checking if player can open the inventory @Override @ParametersAreNonnullByDefault public boolean canInteractWith(EntityPlayer playerIn) { /* Code to check if it is a custom crafting table Getting the block the player is looking at, with a max distance of 6 RayTraceResult ray = playerIn.rayTrace(6, 1.0f); if (ray == null) return false; //Get the position of the block BlockPos pos = ray.getBlockPos(); //Get the world World world = playerIn.getEntityWorld(); //And the block Block block = world.getBlockState(pos).getBlock(); //Check if it is our block return block.equals(ModBlocks.CUSTOM_WORKBENCH); */ return true; } @Override public void onContainerClosed(EntityPlayer playerIn) { super.onContainerClosed(playerIn); /* drop the items in the crafting grid if (!world.isRemote) { for (int i = 0; i < 9; ++i) { ItemStack itemstack = matrix.removeStackFromSlot(i); if (!itemstack.isEmpty()) { playerIn.dropItem(itemstack, false); } } } */ } //Code when item is shift clicked @Override @Nonnull public ItemStack transferStackInSlot(EntityPlayer playerIn, int index) { ItemStack itemstack = ItemStack.EMPTY; Slot slot = inventorySlots.get(index); if (slot != null && slot.getHasStack()) { ItemStack currentItem = slot.getStack(); itemstack = currentItem.copy(); /* if (index == 0) { currentItem.getItem().onCreated(currentItem, world, playerIn); if (!mergeItemStack(currentItem, 37, 46, false)) { return ItemStack.EMPTY; } onPickupFromSlot(recipe); slot.onSlotChange(currentItem, itemstack); } */ if (index >= 11 && index < 38) { //if (!mergeItemStack(currentItem, 37, 46, false)) { //if (recipe != null) //Put correct output in output slot //putStackInSlot(0, recipe.output); //return ItemStack.EMPTY; //} //This might not work! if(!mergeItemStack(currentItem, 0, 8, false)) { return ItemStack.EMPTY; } } //else if (index >= 38 && index < 46) { //if (!mergeItemStack(currentItem, 10, 37, false)) { //return ItemStack.EMPTY; //} //} else if (!mergeItemStack(currentItem, 10, 46, false)) { //return ItemStack.EMPTY; //} if (currentItem.isEmpty()) { slot.putStack(ItemStack.EMPTY); } else { slot.onSlotChanged(); } if (currentItem.getCount() == itemstack.getCount()) { return ItemStack.EMPTY; } slot.onTake(playerIn, currentItem); } return itemstack; } @Override public boolean canMergeSlot(ItemStack stack, Slot slotIn) { return /*slotIn.inventory != result && */super.canMergeSlot(stack, slotIn); } /* @Override public void onCraftMatrixChanged(IInventory in) { IRecipe recipe = CraftingManager.findMatchingRecipe(matrix, world); if (recipe != null) putStackInSlot(0, recipe.getRecipeOutput()); } */ } If you want the CraftResultSlot code, here it is: public class CraftResultSlot extends Slot { public CraftResultSlot(InventoryCrafting matrix, int index, int x, int y) { super(matrix, index, x, y); } //Disable items getting put in the slot @Override public boolean isItemValid(ItemStack stack) { return false; } } Please comment anything i missed, things I should add, errors, etc... I will expand this soon!
  20. Try setting BlockRenderLayer to CUTOUT.
  21. What I mean by it's forge code is that the class was edited by forge, not the class is completely made by forge. I'm assuming Minecraft BlockGlass code isn't a copy of the Forge BlockGlass code.
  22. Sure. Forge's code in the git with patches is in the package org.minecraft, and I think the Block class is forge code, and BlockGlass extends Block, so unless Block is not modified by forge, then BLockGlass has to be forge code.
  23. Well, you've shown you can't infact make blocks without knowing how to code in Java. Making a thread every hour is not a good thing, you need to learn how to read errors, basic Java, how to research into problems. Hell, you can't even understand the straightforward error your JDK was probably yelling at you. I think there's a point where you can use it even if you are inexperienced, and I think you could use other APIs or use Spigot if you like MInecraft coding, but Forge is not good at all for newcomers. I tried when I first started Java, didn't understand it at all, went and learned Java, now I don't need to follow step by step tutorials. I'd suggest you do the same.
×
×
  • Create New...

Important Information

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