modding

Dieses Thema im Forum "Offtopic" wurde erstellt von johnfg10, 9. April 2016.

  1. johnfg10

    johnfg10 Well-Known Member

    Beiträge:
    2.430
    Zustimmungen:
    200
    Ortszeit:
    10:35
    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
     
  2. Arcanuo

    Arcanuo Old School Poster

    Beiträge:
    424
    Zustimmungen:
    160
    Ortszeit:
    05:35
    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.
     
    The_Icy_One, profrags und LucidTheStick gefällt das.
  3. johnfg10

    johnfg10 Well-Known Member

    Beiträge:
    2.430
    Zustimmungen:
    200
    Ortszeit:
    10:35
    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
     
  4. chugga_fan

    chugga_fan ME 4M storage cell of knowledge, all the time

    Beiträge:
    5.861
    Zustimmungen:
    730
    Ortszeit:
    05:35
    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.
     
  5. johnfg10

    johnfg10 Well-Known Member

    Beiträge:
    2.430
    Zustimmungen:
    200
    Ortszeit:
    10:35
    im doing good with it ive done "joke" drag and drop stuff before and that was really annoying plus i love a challange :p

    also anyone thats trying to learn this website is amazing
    Java For Beginners - Contents Page
     
    Zuletzt bearbeitet: 10. April 2016
  6. johnfg10

    johnfg10 Well-Known Member

    Beiträge:
    2.430
    Zustimmungen:
    200
    Ortszeit:
    10:35
    would anyone be able to tell me how i would get a player from a string?
     
  7. The_Icy_One

    The_Icy_One Procrastinates by doing work

    Beiträge:
    1.044
    Zustimmungen:
    210
    Ortszeit:
    10:35
    As in get an EntityPlayer from a string? I think (EntityPlayer)"playername" should work, but I can't remember exactly.
     
  8. Matryoshika

    Matryoshika Well-Known Member

    Beiträge:
    1.193
    Zustimmungen:
    606
    Ortszeit:
    11:35
    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.
    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;
    	}
    }
     
    Arcanuo gefällt das.
  9. Arcanuo

    Arcanuo Old School Poster

    Beiträge:
    424
    Zustimmungen:
    160
    Ortszeit:
    05:35
    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.
     
  10. johnfg10

    johnfg10 Well-Known Member

    Beiträge:
    2.430
    Zustimmungen:
    200
    Ortszeit:
    10:35
    yup i dont need a container EVER
     
  11. Arcanuo

    Arcanuo Old School Poster

    Beiträge:
    424
    Zustimmungen:
    160
    Ortszeit:
    05:35
    We all said this at one point.
     
  12. johnfg10

    johnfg10 Well-Known Member

    Beiträge:
    2.430
    Zustimmungen:
    200
    Ortszeit:
    10:35
    nope not needed il just idk ummm use chests -.-
     
  13. Matryoshika

    Matryoshika Well-Known Member

    Beiträge:
    1.193
    Zustimmungen:
    606
    Ortszeit:
    11:35
    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.
     
  14. johnfg10

    johnfg10 Well-Known Member

    Beiträge:
    2.430
    Zustimmungen:
    200
    Ortszeit:
    10:35
    trying to track a players location
    using a command /locate <playername> then works out the players position and prints to user
     
  15. chugga_fan

    chugga_fan ME 4M storage cell of knowledge, all the time

    Beiträge:
    5.861
    Zustimmungen:
    730
    Ortszeit:
    05:35
    the EntityPlayer you get from the command thingy, use it, it's got it's coords stored SOMEWHERE in that object
     
  16. johnfg10

    johnfg10 Well-Known Member

    Beiträge:
    2.430
    Zustimmungen:
    200
    Ortszeit:
    10:35
    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
     
  17. Matryoshika

    Matryoshika Well-Known Member

    Beiträge:
    1.193
    Zustimmungen:
    606
    Ortszeit:
    11:35
    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.
     
  18. johnfg10

    johnfg10 Well-Known Member

    Beiträge:
    2.430
    Zustimmungen:
    200
    Ortszeit:
    10:35
    ignore that :p
     
  19. Matryoshika

    Matryoshika Well-Known Member

    Beiträge:
    1.193
    Zustimmungen:
    606
    Ortszeit:
    11:35
    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());
    	}
     
  20. Slind

    Slind Founder

    Beiträge:
    8.332
    Zustimmungen:
    3.018
    Ortszeit:
    11:35
    Is that event even fired client side?
     

Diese Seite empfehlen