Jump to content

KmKadze

Members
  • Posts

    7
  • Joined

  • Last visited

Converted

  • Gender
    Male
  • Location
    Kazakhstan

KmKadze's Achievements

Tree Puncher

Tree Puncher (2/8)

0

Reputation

  1. No, it didnt work
  2. Hi everyone!(sorry for my english) I created new item, registered it and add an icon to it Mod main class: ItemsList.java: Also I added textures to assets/littlefeatures/textures/items/autoArmorStand.png and JSON file to assets/littlefeatures/models/item/autoArmorStand.json : Icon works, however, it's too big. I tried to change "scale" value in the json file but it didnt work. Screenshot:
  3. Ok, I removed the position and spectator cheking, now it works perfectly but in the one block radius from the "auto armor stand". Timer resets in onLivingUpdate method.
  4. Ok so maybe it'll be helpful. This is in mod main class: @Mod(modid=modInfo.MODID, name=modInfo.MODNAME, version=modInfo.VERSION) public class LittleFeatures { @Instance(modInfo.MODID) public static LittleFeatures instance; @EventHandler public void init(FMLInitializationEvent event) { EntitiesList.entities(); } public static void registerEntity(Class entityClass, String name, int id) { EntityRegistry.registerModEntity(entityClass, name, id, instance, 64, 1, true); } } EntitiesList.java: public class EntitiesList { public static void entities() { LittleFeatures.registerEntity(EntityAutoArmorStand.class, "autoArmorStand", 364545); } } EntityAutoArmorStand.java (i copied all of the EntityArmorStand(minecraft's armor stand), changed variables' names and added this code): public class EntityAutoArmorStand extends EntityLivingBase { private int timer = 0; //for timer private boolean isActive = true; public void onLivingUpdate() //cooldown timer, based on ticks { if(isActive == false && timer < 60) { timer++; } else if(timer >= 60 && isActive == false) { isActive = true; timer = 0; } } public void onCollideWithPlayer(EntityPlayer player) { if(isActive == true) { int playerX = player.getPosition().getX(); int playerY = player.getPosition().getY(); int playerZ = player.getPosition().getZ(); int thisX = this.getPosition().getX(); int thisY = this.getPosition().getY(); int thisZ = this.getPosition().getZ(); if(playerX == thisX && playerY == thisY && playerZ == thisZ && !player.isSpectator() && !player.isInvisible()) { swapItemsWithPlayer(player, EntityEquipmentSlot.MAINHAND); swapItemsWithPlayer(player, EntityEquipmentSlot.OFFHAND); swapItemsWithPlayer(player, EntityEquipmentSlot.HEAD); swapItemsWithPlayer(player, EntityEquipmentSlot.CHEST); swapItemsWithPlayer(player, EntityEquipmentSlot.LEGS); swapItemsWithPlayer(player, EntityEquipmentSlot.FEET); isActive = false; } } } private void swapItemsWithPlayer(EntityPlayer player, EntityEquipmentSlot slot) { if(player.getItemStackFromSlot(slot) != null && this.getItemStackFromSlot(slot) == null) { this.setItemStackToSlot(slot, player.getItemStackFromSlot(slot)); player.setItemStackToSlot(slot, null); } else if(player.getItemStackFromSlot(slot) == null && this.getItemStackFromSlot(slot) != null) { player.setItemStackToSlot(slot, this.getItemStackFromSlot(slot)); this.setItemStackToSlot(slot, null); this.playEquipSound(player.getItemStackFromSlot(slot)); } else if(player.getItemStackFromSlot(slot) != null && this.getItemStackFromSlot(slot) != null) { ItemStack playerStack = player.getItemStackFromSlot(slot); ItemStack thisStack = this.getItemStackFromSlot(slot); this.setItemStackToSlot(slot, playerStack); player.setItemStackToSlot(slot, thisStack); } }
  5. Hi everyone! (sorry for my english) I want to create my own Armor Stand(call it "auto armor stand") which is activated when player "step on" it. I used onCollideWithPlayer method, in which I wrote verifying of that the player is in the same block as the "auto armor stand". If it's true, another method swaps armor: public void onCollideWithPlayer(EntityPlayer player) { if(isActive) { int playerX = player.getPosition().getX(); int playerY = player.getPosition().getY(); int playerZ = player.getPosition().getZ(); int thisX = this.getPosition().getX(); int thisY = this.getPosition().getY(); int thisZ = this.getPosition().getZ(); if(playerX == thisX && playerY == thisY && playerZ == thisZ && !player.isSpectator() && !player.isInvisible()) { swapItemsWithPlayer(player, EntityEquipmentSlot.MAINHAND); swapItemsWithPlayer(player, EntityEquipmentSlot.OFFHAND); swapItemsWithPlayer(player, EntityEquipmentSlot.HEAD); swapItemsWithPlayer(player, EntityEquipmentSlot.CHEST); swapItemsWithPlayer(player, EntityEquipmentSlot.LEGS); swapItemsWithPlayer(player, EntityEquipmentSlot.FEET); isActive = false; } } I used "isActive" variable to make swap worked once, then went to cooldown. The problem is that the method all the same have a time to work twice and in the and armor doesn't swap. What should I do to fix this? p.s. Armor stand and "auto armor stand" is an entity
×
×
  • Create New...

Important Information

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