well where do i start one there is no tutorial that is not some weird hacky stuff on the internet all i want to do i add a chest like block if anyone could help it would be appreciated
I would never recommend Java as your first language, coding is as much a mindset, as it a skill set. Unlike Spanish, as soon as I get some practice and learn the words I can be a fluent Spanish speaker. This isn't true for Coding, you can understand how it works but will give up in frustration because you can't think in a manner that helps you. Item creation is very basic yes, but more advanced things are not.
im doing fine most tutorial are really good but tile entitys and container tutorials and such are horrible or really hacky im new to this but even to me this rings alarm bells
actually, i'd reccomend java as a first language, it's simple and easy to understand compared to most and it's so high leveled that you don't deal with stuff like #define #ifdef #endif etc.
im doing good with it ive done "joke" drag and drop stuff before and that was really annoying plus i love a challange also anyone thats trying to learn this website is amazing Java For Beginners - Contents Page
As in get an EntityPlayer from a string? I think (EntityPlayer)"playername" should work, but I can't remember exactly.
I would wait a bit before trying to code containers. Try to get comfortable with coding before taking on containrs. I personally hate containers -.-' Containers & GUI's love to crash, especially with ArrayOutOfBoundsExceptions. Oh, and if you want to whitelist/blacklist/filter items, so that lets say you cannot insert other inventories, like bags, me-drives or whatever, you need to make your own custom slot-class, as the vanilla slot-class only filters exclusively for hoppers. Heres one of my own custom containers. Though switch out the New SlotRun.... for pure New Slot, if you do not have a custom slot-class. Spoiler: container Code: public class ContainerRunicScribe extends Container{ protected TileRunicScribe tileEntity; public ContainerRunicScribe (InventoryPlayer inventoryPlayer, TileRunicScribe te){ tileEntity = te; //the Slot constructor takes the IInventory and the slot number in that it binds to //and the x-y coordinates it resides on-screen addSlotToContainer(new SlotRunicScribe(tileEntity, 0, (8 + 4 * 18)-39, -9)); addSlotToContainer(new SlotRunicScribe(tileEntity, 1, (8 + 2 * 18)-39, 11)); addSlotToContainer(new SlotRunicScribe(tileEntity, 2, (8 + 4 * 18)-39, 21)); addSlotToContainer(new SlotRunicScribe(tileEntity, 3, (8 + 6 * 18)-39, 11)); //commonly used vanilla code that adds the player's inventory bindPlayerInventory(inventoryPlayer); } @Override public boolean canInteractWith(EntityPlayer player) { return tileEntity.isUseableByPlayer(player); } protected void bindPlayerInventory(InventoryPlayer inventoryPlayer) { for (int i = 0; i < 3; i++) { for (int j = 0; j < 9; j++) { addSlotToContainer(new Slot(inventoryPlayer, j + i * 9 + 9, (8 + j * 18)-39, (84 + i * 18)-1)); } } for (int i = 0; i < 9; i++) { addSlotToContainer(new Slot(inventoryPlayer, i, (8 + i * 18)-39, 141)); } } @Override public ItemStack transferStackInSlot(EntityPlayer player, int slot) { ItemStack stack = null; Slot slotObject = (Slot) inventorySlots.get(slot); //null checks and checks if the item can be stacked (maxStackSize > 1) if (slotObject != null && slotObject.getHasStack()) { ItemStack stackInSlot = slotObject.getStack(); stack = stackInSlot.copy(); //merges the item into player inventory since its in the tileEntity if (slot < tileEntity.getSizeInventory()) { if (!this.mergeItemStack(stackInSlot, tileEntity.getSizeInventory(), tileEntity.getSizeInventory(), true)) { return null; } } //places it into the tileEntity is possible since its in the player inventory else if (!this.mergeItemStack(stackInSlot, 0, tileEntity.getSizeInventory(), false)) { return null; } if (stackInSlot.stackSize == 0) { slotObject.putStack(null); } else { slotObject.onSlotChanged(); } if (stackInSlot.stackSize == stack.stackSize) { return null; } slotObject.onPickupFromSlot(player, stackInSlot); } return stack; } }
I commend you, Sir. Coding containers/GUI's is annoying in any language, the basics of what you want to accomplish are the same, Java GUI/containers are especially. Several other languages have the ability to create GUI's, but anything Minecraft in that regard, makes me shut down. So therefore I commend you, because things like that make me close the tab and turn on music while I try to re-organize my brain for overload.
Just "from a string" is quite insufficient. A player is an Entity, which means you need to get access to the Entity class to begin with. Oh, and I'd recommend using the UUID of that player instead of his/her name, as thats much more reliable. To say exactly how you would get the player, I'd need more information on what you are trying to do with the player. There are several ways, each with their own ways of getting a specific player, and with their own shortcomings.
trying to track a players location using a command /locate <playername> then works out the players position and prints to user
the EntityPlayer you get from the command thingy, use it, it's got it's coords stored SOMEWHERE in that object
not quite what i mean i mean lets say jimmy wants to know where bobby is he can do /locate bobby and it will print bobbys location in jimmys chat
That will require an eventhandler. Here's some code you should find useful. You need to edit the name-variable based on the command's issued string, but that should not be too hard. ( I've never messed with commands) Code: public String name; double playerX; double playerY; double playerZ; @SubscribeEvent public String locatePlayer(LivingUpdateEvent event){ if(event.entityLiving instanceof EntityPlayer){ EntityPlayer player = (EntityPlayer) event.entityLiving; if(name == player.getDisplayName()){ playerX = player.posX; playerY = player.posY; playerZ = player.posZ; } } return "Coords: X=" + playerX + ": Y=" + playerY + ": Z=" + playerZ; } You then use what is returned from this method, and issue it in a player.addChatMessage for who issued the command.
Do you have that inside an initialized eventhandler? Eg: public class EventHandler{ <above code> } and in your main class, have Code: @EventHandler public void Init(FMLInitializationEvent event){ MinecraftForge.EVENT_BUS.register(new EventHandler()); }