Jump to content

ghostwolf_

Members
  • Posts

    17
  • Joined

  • Last visited

Recent Profile Visitors

The recent visitors block is disabled and is not being shown to other users.

ghostwolf_'s Achievements

Tree Puncher

Tree Puncher (2/8)

0

Reputation

  1. Hey guys im trying to add a bunch of cosmetic armor slots to the player, where if there is an armor present it will override your actual armor texture. so you can wear the fancy armor for show and wear your normal armor for its effectiveness. i found the cosmetic armor reworked mod, and looked at its source code to get an idea of how they did it link to its source. but it feels very hacky to me and not a good way to go about it. so im hoping anyone here knows a better way. ItemStackHandler localInv = new ItemStackHandler (4); private void SwapInv (EntityPlayer p) { if (p.hasCapability(CapabilityCosmeticArmor.Cosmetic_Armor_Capability, null) && p.inventory.armorInventory.size() <= 4 ) { IItemHandler cosInv = p.getCapability(CapabilityCosmeticArmor.Cosmetic_Armor_Capability, null); for (int i = 0; i < cosInv.getSlots(); i++) { localInv.insertItem(i, cosInv.extractItem(i, 1, false), false); } NonNullList<ItemStack> armor = p.inventory.armorInventory; for (int i = 0; i < armor.size(); i++) { cosInv.insertItem(cosInv.getSlots() - 1 - i, armor.get(i), false); } for (int i = 0; i < localInv.getSlots(); i++) { armor.set(localInv.getSlots() - i - 1, localInv.extractItem(i, 1, false)); } } } @SubscribeEvent public void handleCanceledEvent(RenderPlayerEvent.Pre event) { } @SubscribeEvent public void handleEvent(RenderPlayerEvent.Post event) { SwapInv(event.getEntityPlayer()); } @SubscribeEvent public void handleEvent(RenderPlayerEvent.Pre event) { SwapInv(event.getEntityPlayer()); } this is my current code, and it kinda works. it has some sync issues but thats because i havent added the packet handling yet for the Capability i added. to sync it between clients. this is what it looks like in game, i render the armor on the right and i have the armor on the left equipped.but right now every time the render player event gets called the items in those slots get swapped and then swapped back after. is there a smoother way of doing this?
  2. sounds like a better solution then i what i currently have which is this: BiomeDictionary.Type[] types = { BiomeDictionary.Type.BEACH, BiomeDictionary.Type.COLD, BiomeDictionary.Type.CONIFEROUS, BiomeDictionary.Type.DEAD, BiomeDictionary.Type.DENSE, BiomeDictionary.Type.DRY, BiomeDictionary.Type.FOREST, BiomeDictionary.Type.HILLS, BiomeDictionary.Type.HOT, BiomeDictionary.Type.JUNGLE, BiomeDictionary.Type.LUSH, BiomeDictionary.Type.MAGICAL, BiomeDictionary.Type.MESA, BiomeDictionary.Type.MOUNTAIN, BiomeDictionary.Type.OCEAN, BiomeDictionary.Type.PLAINS, BiomeDictionary.Type.RARE, BiomeDictionary.Type.RIVER, BiomeDictionary.Type.SANDY, BiomeDictionary.Type.SAVANNA, BiomeDictionary.Type.SNOWY, BiomeDictionary.Type.SPARSE, BiomeDictionary.Type.SPOOKY, BiomeDictionary.Type.SWAMP, BiomeDictionary.Type.VOID, BiomeDictionary.Type.WASTELAND, BiomeDictionary.Type.WATER, BiomeDictionary.Type.WET }; SpawnListEntry spawnKabaneri = new SpawnListEntry(EntityKabaneri.class, Config.KabaneriSpawnChance, 1, 2); for (BiomeDictionary.Type t : types) { Set<Biome> biomes = BiomeDictionary.getBiomes(t); Iterator biomeIterator = biomes.iterator(); while(biomeIterator.hasNext()) { Biome currentBiome = (Biome) biomeIterator.next(); if (BiomeDictionary.hasType(currentBiome, BiomeDictionary.Type.END) || BiomeDictionary.hasType(currentBiome, BiomeDictionary.Type.NETHER)) { } else { currentBiome.getSpawnableList(EnumCreatureType.MONSTER).add(spawnKabaneri); } } } altough this would also mean that if people add new dimensions they should also spawn there, so ill leave it like this for now. but ill probably switch to your suggestion at some point. thanks for the tip.
  3. reasonably, yes. public static void initSpawns () { BiomeDictionary.Type[] types = { BiomeDictionary.Type.BEACH, BiomeDictionary.Type.COLD, BiomeDictionary.Type.CONIFEROUS, BiomeDictionary.Type.DEAD, BiomeDictionary.Type.DENSE, BiomeDictionary.Type.DRY, BiomeDictionary.Type.FOREST, BiomeDictionary.Type.HILLS, BiomeDictionary.Type.HOT, BiomeDictionary.Type.JUNGLE, BiomeDictionary.Type.LUSH, BiomeDictionary.Type.MAGICAL, BiomeDictionary.Type.MESA, BiomeDictionary.Type.MOUNTAIN, BiomeDictionary.Type.OCEAN, BiomeDictionary.Type.PLAINS, BiomeDictionary.Type.RARE, BiomeDictionary.Type.RIVER, BiomeDictionary.Type.SANDY, BiomeDictionary.Type.SAVANNA, BiomeDictionary.Type.SNOWY, BiomeDictionary.Type.SPARSE, BiomeDictionary.Type.SPOOKY, BiomeDictionary.Type.SWAMP, BiomeDictionary.Type.VOID, BiomeDictionary.Type.WASTELAND, BiomeDictionary.Type.WATER, BiomeDictionary.Type.WET }; SpawnListEntry spawnKabaneri = new SpawnListEntry(EntityKabaneri.class, Config.KabaneriSpawnChance, 1, 2); for (BiomeDictionary.Type t : types) { Set<Biome> biomes = BiomeDictionary.getBiomes(t); Iterator biomeIterator = biomes.iterator(); while(biomeIterator.hasNext()) { Biome currentBiome = (Biome) biomeIterator.next(); currentBiome.getSpawnableList(EnumCreatureType.MONSTER).add(spawnKabaneri); } } } this is how i currently solved it, but i was wondering if there was a better way to do it, i couldnt really find a tag in the biomedictionary for overworld. also i called this function in the post-init within my common-proxy is that the right place to call it? it seems to work and i figured i should call it after all mods have registed their biomes but since this is my first time modding these kind of things i figured id ask just to be sure.
  4. Hey guys, i was wondering about how to go about this. i tried adding them via the entityregistry.addspawn() but i dont quite understand how to use the biomedictionary. i also tried this: https://www.minecraftforum.net/forums/mapping-and-modding-java-edition/mapping-and-modding-tutorials/1571414-how-to-use-the-forge-biomedictionary but since its outdated i got stuck again. so what should i use to register a mob spawn in all overworld biomes, i made an entity that extends the zombie class and i added some loot and a different texture (altough somewhat hacky) and i would like it to have the same spawn conditions as a zombie.
  5. hey guys im trying to dynamically paint my blocks and items so i dont have to draw them for each type of metal i want to add to the game. this is the result i have so far, no issues on any of the items or itemblocks. but i have issues with the ore block. it has this wierd black layer over it at a certain distance and angle. but the color also applies to the whole block instead of only the ore vein like it does on the itemblock that im holding in my hand. Client proxy @Override public void init(FMLInitializationEvent e) { ModEntities.initModels(); Minecraft.getMinecraft().getItemColors().registerItemColorHandler(new IMaterialColor(), ModItems.material); Minecraft.getMinecraft().getItemColors().registerItemColorHandler(new IMetalColor(), ModItems.metal); Minecraft.getMinecraft().getItemColors().registerItemColorHandler(new IItemBlockMetalColor(), ItemBlock.getItemFromBlock(ModBlocks.metalBlock)); Minecraft.getMinecraft().getItemColors().registerItemColorHandler(new IItemBlockMetalColor(), ItemBlock.getItemFromBlock(ModBlocks.ore)); Minecraft.getMinecraft().getBlockColors().registerBlockColorHandler(new IBlockMetalColor(), ModBlocks.metalBlock); Minecraft.getMinecraft().getBlockColors().registerBlockColorHandler(new IBlockMetalColor(), ModBlocks.ore); super.init(e); } IBlockMetalColor public class IBlockMetalColor implements IBlockColor { @Override public int colorMultiplier(IBlockState state, IBlockAccess worldIn, BlockPos pos, int tintIndex) { if (tintIndex == 0) { EnumMetals m = (EnumMetals) state.getValue(BlockMetal.type); return m.getColor(); } else { return 0xffffff; } } } IItemMetalBlockColor public class IItemBlockMetalColor implements IItemColor { @Override public int colorMultiplier(ItemStack stack, int tintIndex) { return EnumMetals.values()[stack.getItemDamage()].getColor(); } } BlockOre public class BlockOre extends Block implements IMetaBlockName { public static final PropertyEnum type = PropertyEnum.create("type", EnumMetals.class); public BlockOre() { super(Material.ROCK); setUnlocalizedName(Reference.MOD_ID + ":" + "ore"); setRegistryName("ore"); setCreativeTab(ModItems.SteampunkItemsTab); setHardness(1.5F); setResistance(5F); setHarvestLevel("pickaxe", 1); setDefaultState(blockState.getBaseState().withProperty(type, EnumMetals.Copper)); } @Override public int getHarvestLevel(IBlockState state) { return ((EnumMetals) state.getValue(type)).getHarvestLevel(); } @Override public float getBlockHardness(IBlockState blockState, World worldIn, BlockPos pos) { return ((EnumMetals) blockState.getValue(type)).getHardness(); } @SideOnly(Side.CLIENT) public void initModel() { for (EnumMetals o : EnumMetals.values()) { ModelLoader.setCustomModelResourceLocation(Item.getItemFromBlock(this), o.getId() , new ModelResourceLocation(getRegistryName(), "type=" + o.getName())); } } @Override public int getMetaFromState(IBlockState state) { return ((EnumMetals) state.getValue(type)).getId(); } @Override public IBlockState getStateFromMeta(int meta) { return getDefaultState().withProperty(type, EnumMetals.values()[meta]); } @Override protected BlockStateContainer createBlockState() { return new BlockStateContainer(this, type); } @Override public String getSpecialName(ItemStack stack) { return EnumMetals.values()[stack.getItemDamage()].getName(); } @Override public ItemStack getPickBlock(IBlockState state, RayTraceResult target, World world, BlockPos pos, EntityPlayer player) { return new ItemStack(Item.getItemFromBlock(this),1,getMetaFromState(world.getBlockState(pos))); } @Override public int damageDropped(IBlockState state) { return getMetaFromState(state); } public void initOreDict () { for (EnumMetals o : EnumMetals.values()) { OreDictionary.registerOre("ore" + o.name(), new ItemStack(Item.getItemFromBlock(this),1,o.getId())); } } @Override public void getSubBlocks(CreativeTabs itemIn, NonNullList<ItemStack> tab) { for (EnumMetals o : EnumMetals.values()) { if (o.hasOre()) { tab.add(new ItemStack(Item.getItemFromBlock(this),1, o.getId())); } } } EnumMetals public enum EnumMetals implements IStringSerializable{ Copper(0,0xe56b51,1,1.5F), Tin(1,0xcdcbc9,1,1.5F), Lead(2,0xa3a6c3,1,1.5F), Zinc(3,0xb8b3ad,1,1.5F), Silver(4,0xe8e8e8,2,1.5F), Titanium(5,0xb1c5c4,3,2F), Tungsten(6,0x07005d,3,2F), Brass(7,0xf9d352), Bronze(8,0xecb977), Steel(9,0x64635f), Electrum(10,0xfff182), Blacksteel(11,0x555970); int color = 0xffffff; boolean hasOre = false; float hardness = 1; int harvestLevel = 1; int id = 0; EnumMetals (int id) { this.id = id; }; EnumMetals (int id, int color) { this.color = color; this.id = id; } EnumMetals (int id, int color, int harvestLevel, float hardness) { this.color = color; this.harvestLevel = harvestLevel; this.hardness = hardness; this.hasOre = true; this.id = id; } @Override public String getName() { return this.toString().toLowerCase(Locale.ENGLISH); } public boolean hasOre () { return this.hasOre; } public float getHardness () { return this.hardness; } public int getHarvestLevel () { return this.harvestLevel; } public int getColor () { return this.color; } public int getId () { return this.id; } blockstate json for the ore block { "forge_marker": 1, "defaults": { "model": "steampunkrevolution:ore", "textures": { "all": "minecraft:blocks/stone", "colored": "steampunkrevolution:blocks/basevein" } }, "variants": { "normal": [{}], "inventory": [{}], "type": { "copper": { }, "tin": { }, "lead": { }, "silver": { }, "tungsten": { }, "titanium": { }, "zinc": { } } } } ore model json { "parent": "block/cube_all", "textures": { "all": "minecraft:blocks/stone", "colored": "steampunkrevolution:blocks/basevein" }, "elements": [ { "from": [ 0, 0, 0 ], "to": [ 16, 16, 16 ], "faces": { "down": { "texture": "#all", "cullface": "down" }, "up": { "texture": "#all", "cullface": "up" }, "north": { "texture": "#all", "cullface": "north" }, "south": { "texture": "#all", "cullface": "south" }, "west": { "texture": "#all", "cullface": "west" }, "east": { "texture": "#all", "cullface": "east" } } }, { "from": [ 0, 0, 0 ], "to": [ 16, 16, 16 ], "faces": { "down": { "tintindex": 0, "texture": "#colored", "cullface": "down" }, "up": { "tintindex": 0, "texture": "#colored", "cullface": "up" }, "north": { "tintindex": 0, "texture": "#colored", "cullface": "north" }, "south": { "tintindex": 0, "texture": "#colored", "cullface": "south" }, "west": { "tintindex": 0, "texture": "#colored", "cullface": "west" }, "east": { "tintindex": 0, "texture": "#colored", "cullface": "east" } } } ] }
  6. i looked at the home position from the creature file that how i knew it even existed and i wanted to use the functionality listed there. i tend to look at a similar vanilla code or someone else their github to get an idea of how to approach things, or find a tutorial. but i couldnt really find anything on this but since those fields are private i couldnt blindly set them. setHomePosAndDistance that function should do the trick, but i wanted the home pos to be set upon spawning, but since the getPosition() returns 0,0,0 that wasnt really do able so i made a second constructor which accepted a Blockpos and passed it to that function. but i was hoping there was an easier way of doing it, since so far i use the summon command to spawn the entity. meaning that it wont set the home pos. i plan on adding a function simelar to setting the insert and extract points for the home position, so i suppose that will have to do, just hoped that there was a way to set it upon being spawned, maybe via an Eventhandler or something might have to try that. thanks for the advice.
  7. that clears up alot, i blindly assumed that the priority was the only thing. i added the interruptible and set it to false, which makes it alot smoother and only 1 returns true at the time, but i still messed up somewhere as somehow the insert still has the priority, meaning it will only transfer a few items at the item instead of the 4 stacks it is capable of. so ill have to do some debugging on that, i did glance over your tutorial earlier a bit but after reading the first bit i went on to try and get it to work rather then reading the later parts that included the info on this. quick side question how do you properly set a home point for an entity, mainly upon being spawned because while testing they tend to wander off.
  8. Hey guys im trying to create a custom entity with some custom AI attached, where the player can set a bunch of inventories as "extract" or "insert" and the entity will then move an air block next to the inventory and once within ~3 blocks range it will start transferring items. most things work fine, but the 2 AI's ive added both return true leaving the entity to juggle between extracting and inserting items. while extracting should have the priority over inserting, while registering the tasks ive set the extract priority to 1 and the insert priority to 2 (swimming is at 0). extract should return false once the entities inventory is full or there are no items in the connected inventories. insert should return true while the entity has items in its inventory and there is a slot available in one of the connected insert inventories. full project here: https://github.com/theredghostwolf/SteampunkRevolution ive attached an image with what it looks like in game (red box is extract blue box is insert), what happens is it takes ~5 to 10 items then inserts those and grabs another 5 to 10 items and keeps stuttering between the 2 and i feel like i just messed up somewhere big time but im having a hard time pin pointing where it is. this is the AI for extracting items public class EntityAIRobotExtractItem extends EntityAIRobotBase { public EntityAIRobotExtractItem (EntityRobot robot, World world) { super(robot, world); } @Override public boolean shouldExecute() { getExtractInventories(); for (int i = 0; i < this.targetList.size(); i++) { IItemHandler inv = this.targetList.get(i).inv; for (int j = 0; j < inv.getSlots(); j++) { ItemStack item = inv.getStackInSlot(j); if (invHelper.InventoryHasRoomForItem(this.robot.getItemStackHandler(), item)) { return true; } } } return false; } @Override public void updateTask () { if (this.target != null) { if (this.robot.getDistance(this.target.pos.getX(), this.target.pos.getY(), this.target.pos.getZ()) <= this.robot.interactRange) { for (int i = 0; i < this.target.inv.getSlots(); i++) { boolean transferedItem = false; ItemStack stack = this.target.inv.getStackInSlot(i); if (! stack.isEmpty()) { ItemStack extracted = this.target.inv.extractItem(i, this.robot.getItemTransferSpeed(), true); for (int j = 0; j < this.robot.getInventory().getSlots(); j++) { ItemStack remainder = this.robot.getInventory().insertItem(j, extracted, true); if (remainder.isEmpty()) { ItemStack extracted1 = this.target.inv.extractItem(i, this.robot.getItemTransferSpeed(), false); ItemStack remainder1 = this.robot.getInventory().insertItem(j, extracted1,false ); transferedItem = true; break; } else if (remainder.getCount() < extracted.getCount()) { ItemStack extracted1 = this.target.inv.extractItem(i, remainder.getCount(), false); ItemStack remainder1 = this.robot.getInventory().insertItem(j, extracted1,false ); transferedItem = true; break; } } if (transferedItem) { break; } } } } else { BlockPos p = findAirBlockNearTarget(); this.robot.getNavigator().tryMoveToXYZ(p.getX(),p.getY(),p.getZ(), 1F); } } } @Override public void startExecuting() { findExtractTarget(); } @Override public void resetTask() { this.target = null; this.targetList = new ArrayList<Target>(); } @Override public boolean shouldContinueExecuting() { getExtractInventories(); findExtractTarget(); if (this.target != null) { TileEntity e = world.getTileEntity(target.pos); if (e != null) { if (e.hasCapability(CapabilityItemHandler.ITEM_HANDLER_CAPABILITY, this.target.facing)) { SteampunkRevolutionMod.logger.log(Level.INFO, "extract = true"); return true; } else { return false; } } else { return false; } } else { return false; } } } insert AI public class EntityAIRobotInsertItem extends EntityAIRobotBase { public EntityAIRobotInsertItem (EntityRobot robot, World world) { super(robot, world); } @Override public boolean shouldExecute() { getInsertInventories(); IItemHandler robotInv = this.robot.getInventory(); if (invHelper.inventoryHasItem(robotInv)) { for (int i = 0; i < this.targetList.size(); i++) { IItemHandler inv = this.targetList.get(i).inv; for (int j = 0; j < robotInv.getSlots(); j++) { if (! robotInv.getStackInSlot(i).isEmpty()) { if (invHelper.InventoryHasRoomForItem(inv,robotInv.getStackInSlot(i) )) { return true; } } } } } return false; } public void updateTask () { if (this.target != null) { if (this.robot.getDistance(this.target.pos.getX(), this.target.pos.getY(), this.target.pos.getZ()) <= this.robot.interactRange) { IItemHandler robotInv = this.robot.getInventory(); boolean transferedItem = false; for (int i = 0; i < robotInv.getSlots(); i++) { if (! robotInv.getStackInSlot(i).isEmpty()) { ItemStack extracted = robotInv.extractItem(i, this.robot.getItemTransferSpeed(), true); for (int j = 0; j < this.target.inv.getSlots(); j++) { ItemStack remainder = this.target.inv.insertItem(j, extracted, true); if (remainder.isEmpty()) { ItemStack extracted1 = robotInv.extractItem(i, this.robot.getItemTransferSpeed(), false); ItemStack remainder1 = this.target.inv.insertItem(j, extracted1, false); transferedItem = true; break; } else if (remainder.getCount() < extracted.getCount()) { ItemStack extracted1 =robotInv.extractItem(i, remainder.getCount(), false); ItemStack remainder1 = this.target.inv.insertItem(j, extracted1,false ); transferedItem = true; break; } } if (transferedItem) { break; } } } } else { BlockPos p = findAirBlockNearTarget(); this.robot.getNavigator().tryMoveToXYZ(p.getX(),p.getY(),p.getZ(), 1F); } } } @Override public void startExecuting() { findInsertTarget(); } @Override public void resetTask() { this.target = null; this.targetList = new ArrayList<Target>(); } @Override public boolean shouldContinueExecuting() { getInsertInventories(); findInsertTarget(); if (this.target != null) { TileEntity e = world.getTileEntity(target.pos); if (e != null) { if (e.hasCapability(CapabilityItemHandler.ITEM_HANDLER_CAPABILITY, this.target.facing)) { SteampunkRevolutionMod.logger.log(Level.INFO, "insert = true"); return true; } else { return false; } } else { return false; } } else { return false; } } } AI base public class EntityAIRobotBase extends EntityAIBase { public InventoryHelper invHelper = new InventoryHelper(); public EntityRobot robot; public World world; public List<Target> targetList; public Target target; public EntityAIRobotBase (EntityRobot robot, World world) { this.robot = robot; this.world = world; } @Override public boolean shouldExecute() { return false; } public void getExtractInventories () { this.targetList = new ArrayList<Target>(); for (int i = 0; i < this.robot.ExtractPoints.size(); i++) { AccessPoint p = this.robot.ExtractPoints.get(i); TileEntity te = this.world.getTileEntity(p.pos); if (te != null && te.hasCapability(CapabilityItemHandler.ITEM_HANDLER_CAPABILITY, p.facing)) { IItemHandler inv = te.getCapability(CapabilityItemHandler.ITEM_HANDLER_CAPABILITY, p.facing); this.targetList.add(new Target(p.pos, te, inv, p.facing, this.robot.getDistance(p.pos.getX(), p.pos.getY(), p.pos.getZ()))); } } Collections.sort(this.targetList, new Comparator<Target>() { @Override public int compare(Target lhs, Target rhs) { // -1 - less than, 1 - greater than, 0 - equal, all inversed for descending return lhs.distance < rhs.distance ? -1 : (lhs.distance > rhs.distance) ? 1 : 0; } }); } public void getInsertInventories () { this.targetList = new ArrayList<Target>(); for (int i = 0; i < this.robot.InsertPoints.size(); i++) { AccessPoint p = this.robot.InsertPoints.get(i); TileEntity te = this.world.getTileEntity(p.pos); if (te != null && te.hasCapability(CapabilityItemHandler.ITEM_HANDLER_CAPABILITY, p.facing)) { IItemHandler inv = te.getCapability(CapabilityItemHandler.ITEM_HANDLER_CAPABILITY, p.facing); this.targetList.add(new Target(p.pos, te, inv, p.facing, this.robot.getDistance(p.pos.getX(), p.pos.getY(), p.pos.getZ()))); } } Collections.sort(this.targetList, new Comparator<Target>() { @Override public int compare(Target lhs, Target rhs) { // -1 - less than, 1 - greater than, 0 - equal, all inversed for descending return lhs.distance < rhs.distance ? -1 : (lhs.distance > rhs.distance) ? 1 : 0; } }); } public class Target { BlockPos pos; TileEntity te; IItemHandler inv; EnumFacing facing; double distance; public Target (BlockPos pos, TileEntity te, IItemHandler inv, EnumFacing facing, double distance) { this.pos = pos; this.te = te; this.inv = inv; this.facing = facing; this.distance = distance; } } public void findExtractTarget () { this.target = null; boolean foundTarget = false; for (int i = 0; i < this.targetList.size(); i++) { IItemHandler inv = this.targetList.get(i).inv; for (int j = 0; j < inv.getSlots(); j++) { ItemStack item = inv.getStackInSlot(j); if (invHelper.InventoryHasRoomForItem(this.robot.getItemStackHandler(), item)) { this.target = this.targetList.get(i); foundTarget = true; break; } } if (foundTarget) { break; } } } public void findInsertTarget () { this.target = null; boolean foundTarget = false; IItemHandler robotInv = this.robot.getInventory(); if (invHelper.inventoryHasItem(robotInv)) { for (int i = 0; i < this.targetList.size(); i++) { IItemHandler inv = this.targetList.get(i).inv; for (int j = 0; j < robotInv.getSlots(); j++) { if (! robotInv.getStackInSlot(i).isEmpty()) { if (invHelper.InventoryHasRoomForItem(inv,robotInv.getStackInSlot(i) )) { this.target = this.targetList.get(i); foundTarget = true; break; } } } if (foundTarget) { break; } } } } public BlockPos findAirBlockNearTarget () { if (this.target != null) { List<BlockPos> airblocks = new ArrayList<BlockPos>(); if (this.world.isAirBlock(this.target.pos.north())) { airblocks.add(this.target.pos.north()); } if (this.world.isAirBlock(this.target.pos.south())) { airblocks.add(this.target.pos.south()); } if (this.world.isAirBlock(this.target.pos.west())) { airblocks.add(this.target.pos.west()); } if (this.world.isAirBlock(this.target.pos.east())) { airblocks.add(this.target.pos.east()); } if (airblocks.isEmpty()) { return this.target.pos; } else { Random rand = new Random(); return airblocks.get(rand.nextInt(airblocks.size())); } } return null; }
  9. yes sir. also i fixed the name swapped names, and the path "steampunkrevolution:items/material/copperingot "
  10. when i had it in the other folder originally i ended up with invisible items, so that didnt work either. but ill try again. any idea what might have caused items being invisible? Edit: back to invisible items again, added image
  11. Hey guy im working on adding items to my mod and i while doing so i had difficulty get a few things right and maybe you can point me in the right direction. first off i couldnt find a clear guide on how to save data to an item, right now it changes the global value for the item rather then just the stack used, below is the code for the wrench im making and i want the user to be able to switch modes but switching the mode changes it for all wrenches rather then just the one used how so i make it so that it only affects the one wrench? public class ItemRobotWrench extends Item { EntityRobot selectedBot; private String[] modes = new String[]{"insert", "extract", "fuel"}; private int mode = 0; public ItemRobotWrench() { setRegistryName("robotwrench"); setUnlocalizedName(Reference.MOD_ID + ":robotwrench"); setCreativeTab(ModItems.SteampunkItemsTab); this.selectedBot = null; } @Override public ActionResult<ItemStack> onItemRightClick(World worldIn, EntityPlayer playerIn, EnumHand handIn) { Entity target= Minecraft.getMinecraft().objectMouseOver.entityHit; if (target != null && target instanceof EntityRobot) { if (this.selectedBot != null) { this.selectedBot.setGlowing(false); } this.selectedBot = (EntityRobot) target; } else { if (! playerIn.isSneaking()) { nextMode(); } } return super.onItemRightClick(worldIn, playerIn, handIn); } @Override public EnumActionResult onItemUse(EntityPlayer player, World worldIn, BlockPos pos, EnumHand hand, EnumFacing facing, float hitX, float hitY, float hitZ) { if (worldIn.isRemote) { if (worldIn.isAirBlock(pos)) { nextMode(); } else { if (player.isSneaking()) { if (this.selectedBot != null) { PacketHandler.INSTANCE.sendToServer(new PacketSetAccessPoint(pos,facing.ordinal(),this.selectedBot.getEntityId(),this.mode)); } } } } return super.onItemUse(player, worldIn, pos, hand, facing, hitX, hitY, hitZ); } private void nextMode () { this.mode++; if (this.mode >= this.modes.length) { this.mode = 0; } } @Override public String getItemStackDisplayName(ItemStack stack) { if (this.selectedBot != null) { return super.getItemStackDisplayName(stack) + ":" + this.modes[this.mode] + ":" + this.selectedBot.getName(); } return super.getItemStackDisplayName(stack) + ":" + this.modes[this.mode]; } @Override public void onUpdate(ItemStack stack, World worldIn, Entity entityIn, int itemSlot, boolean isSelected) { if (this.selectedBot != null) { if (isSelected) { this.selectedBot.setGlowing(true); } else { this.selectedBot.setGlowing(false); } } super.onUpdate(stack, worldIn, entityIn, itemSlot, isSelected); } } in another item i have trouble getting the texture loaded, i found a post that said i had to insert the .json for the item in the blockstates, which i think should be the right way since thermal foundation does it the same way, but i cant get it to load the file i have attached an image with what it looks like in game the place where it most likely goes wrong is in the .json file because thats what im most unfamiliar with { "forge_marker": 1, "defaults": { "model": "item/generated", "textures": { "layer0": "blocks/dirt" }, }, "variants": { "inventory": [{}], "normal": [{}], "type": { "ingotcopper": { "textures": { "layer0": "steampunkrevolution:items/material/ingotcopper" } }, "ingottin": { "textures": { "layer0": "steampunkrevolution:items/material/ingotcopper" } } } } } tin and copper currently use the same texture but neither of them load i get an java.io.FileNotFoundException: steampunkrevolution:models/item/material.json error because the file is under models/block/material.json
  12. well thanks its working fine now, but i ran into another issue. i cant get my block model to rotate on the x-axis, { "forge_marker": 1, "defaults": { "model": "steampunkrevolution:unloader", "textures": { "front": "minecraft:blocks/coal_block" } }, "variants": { "normal": [{}], "inventory": [{}], "facing": { "north": {"y": 270}, "south": {"y": 90}, "west": {"y": 180}, "east": {}, "up": { "x": -90}, "down": {"x": 90} }, "enabled": { "true": {}, "false": {} } } } this is the blockstate file, the facing is set correct (checked via the F3 menu and it moves items from the cart above it when set to up). but the model doesnt rotate towards up { "source": "[120, -38, 99, 98, 17, -56, -51, -52, 75, 77, 46, 74, 76, 43, 81, 53, 118, 76, -52, 44, -78, 103, -112, 71, 22, 41, 46, -55, -49, 75, -75, 47, 75, 44, -54, 76, -52, 43, -79, 5, -13, 24, -60, -111, 21, 100, 22, -27, -25, -59, 39, -27, -28, 39, 103, -37, -93, 74, 36, -25, 39, -26, -64, 36, 24, 26, 56, 66, -127, 32, 107, -43, -86, -107, 40, 120, 106, -40, -54, -84, 9, 108, -88, 24, 36, -122, -90, 14, -90, 119, 106, 104, 104, 24, 6, -114, -1, -118, -118, -79, -88, -127, -103, 3, 98, -101, -110, -120, 7, -115, 126, 96, -72, 96, -47, 31, -118, 3, -93, -22, -121, -122, 51, 40, 124, -80, -24, -113, 65, -61, -88, -6, -127, 122, 96, 113, 51, -92, -11, 83, 26, 126, 67, 61, -3, 80, -104, 127, 40, -51, -65, 0, 46, -94, -85, -38]", "textures": {"1398723388": "minecraft:blocks/hopper_outside", "1695556649": "#front", "761770141": "minecraft:blocks/nether_brick", "particle": "minecraft:blocks/nether_brick"}, "elements": [ { "from": [1,0,1], "to": [15,0,5], "faces": { "down": { "uv": [1,11,15,15], "texture": "#1398723388", "cullface": "down" } } }, { "from": [1,0,5], "to": [5,0,11], "faces": { "down": { "uv": [1,5,5,11], "texture": "#1398723388", "cullface": "down" } } }, { "from": [1,0,11], "to": [15,0,15], "faces": { "down": { "uv": [1,1,15,5], "texture": "#1398723388", "cullface": "down" } } }, { "from": [11,0,5], "to": [15,0,11], "faces": { "down": { "uv": [11,5,15,11], "texture": "#1398723388", "cullface": "down" } } }, { "from": [1,16,1], "to": [15,16,5], "faces": { "up": { "uv": [1,1,15,5], "texture": "#1398723388", "cullface": "up" } } }, { "from": [1,16,5], "to": [5,16,11], "faces": { "up": { "uv": [1,5,5,11], "texture": "#1398723388", "cullface": "up" } } }, { "from": [1,16,11], "to": [15,16,15], "faces": { "up": { "uv": [1,11,15,15], "texture": "#1398723388", "cullface": "up" } } }, { "from": [11,16,5], "to": [15,16,11], "faces": { "up": { "uv": [11,5,15,11], "texture": "#1398723388", "cullface": "up" } } }, { "from": [1,1,0], "to": [15,5,0], "faces": { "north": { "uv": [1,11,15,15], "texture": "#1398723388", "cullface": "north" } } }, { "from": [1,5,0], "to": [5,11,0], "faces": { "north": { "uv": [11,5,15,11], "texture": "#1398723388", "cullface": "north" } } }, { "from": [1,11,0], "to": [15,15,0], "faces": { "north": { "uv": [1,1,15,5], "texture": "#1398723388", "cullface": "north" } } }, { "from": [11,5,0], "to": [15,11,0], "faces": { "north": { "uv": [1,5,5,11], "texture": "#1398723388", "cullface": "north" } } }, { "from": [1,1,16], "to": [15,5,16], "faces": { "south": { "uv": [1,11,15,15], "texture": "#1398723388", "cullface": "south" } } }, { "from": [1,5,16], "to": [5,11,16], "faces": { "south": { "uv": [1,5,5,11], "texture": "#1398723388", "cullface": "south" } } }, { "from": [1,11,16], "to": [15,15,16], "faces": { "south": { "uv": [1,1,15,5], "texture": "#1398723388", "cullface": "south" } } }, { "from": [11,5,16], "to": [15,11,16], "faces": { "south": { "uv": [11,5,15,11], "texture": "#1398723388", "cullface": "south" } } }, { "from": [0,1,1], "to": [0,15,5], "faces": { "west": { "uv": [1,1,5,15], "texture": "#1398723388", "cullface": "west" } } }, { "from": [0,1,5], "to": [0,5,11], "faces": { "west": { "uv": [5,11,11,15], "texture": "#1398723388", "cullface": "west" } } }, { "from": [0,1,11], "to": [0,15,15], "faces": { "west": { "uv": [11,1,15,15], "texture": "#1398723388", "cullface": "west" } } }, { "from": [0,11,5], "to": [0,15,11], "faces": { "west": { "uv": [5,1,11,5], "texture": "#1398723388", "cullface": "west" } } }, { "from": [16,1,1], "to": [16,15,2], "faces": { "east": { "uv": [14,1,15,15], "texture": "#1398723388", "cullface": "east" } } }, { "from": [16,1,2], "to": [16,2,14], "faces": { "east": { "uv": [2,14,14,15], "texture": "#1398723388", "cullface": "east" } } }, { "from": [16,14,2], "to": [16,15,14], "faces": { "east": { "uv": [2,1,14,2], "texture": "#1398723388", "cullface": "east" } } }, { "from": [16,1,14], "to": [16,15,15], "faces": { "east": { "uv": [1,1,2,15], "texture": "#1398723388", "cullface": "east" } } }, { "from": [15,2,2], "to": [16,2,14], "faces": { "up": { "uv": [15,2,16,14], "texture": "#1398723388" } } }, { "from": [15,14,2], "to": [16,14,14], "faces": { "down": { "uv": [15,2,16,14], "texture": "#1398723388" } } }, { "from": [15,2,2], "to": [16,14,2], "faces": { "south": { "uv": [15,2,16,14], "texture": "#1398723388" } } }, { "from": [15,2,14], "to": [16,14,14], "faces": { "north": { "uv": [0,2,1,14], "texture": "#1398723388" } } }, { "from": [15,2,2], "to": [15,14,14], "faces": { "east": { "uv": [2,2,14,14], "texture": "#1695556649" } } }, { "from": [1,6,6], "to": [1,10,10], "faces": { "west": { "uv": [6,6,10,10], "texture": "#1695556649" } } }, { "from": [6,15,6], "to": [10,15,10], "faces": { "up": { "uv": [6,6,10,10], "texture": "#1695556649" } } }, { "from": [6,1,6], "to": [10,1,10], "faces": { "down": { "uv": [6,6,10,10], "texture": "#1695556649" } } }, { "from": [6,6,15], "to": [10,10,15], "faces": { "south": { "uv": [6,6,10,10], "texture": "#1695556649" } } }, { "from": [6,6,1], "to": [10,10,1], "faces": { "north": { "uv": [6,6,10,10], "texture": "#1695556649" } } }, { "from": [0,0,0], "to": [16,0,1], "faces": { "down": { "uv": [0,15,16,16], "texture": "#761770141", "cullface": "down" } } }, { "from": [0,0,1], "to": [1,0,15], "faces": { "down": { "uv": [0,1,1,15], "texture": "#761770141", "cullface": "down" } } }, { "from": [15,0,1], "to": [16,0,15], "faces": { "down": { "uv": [15,1,16,15], "texture": "#761770141", "cullface": "down" } } }, { "from": [0,0,15], "to": [16,0,16], "faces": { "down": { "uv": [0,0,16,1], "texture": "#761770141", "cullface": "down" } } }, { "from": [5,0,6], "to": [6,0,10], "faces": { "down": { "uv": [5,6,6,10], "texture": "#761770141", "cullface": "down" } } }, { "from": [10,0,6], "to": [11,0,10], "faces": { "down": { "uv": [10,6,11,10], "texture": "#761770141", "cullface": "down" } } }, { "from": [5,0,5], "to": [11,0,6], "faces": { "down": { "uv": [5,10,11,11], "texture": "#761770141", "cullface": "down" } } }, { "from": [5,0,10], "to": [11,0,11], "faces": { "down": { "uv": [5,5,11,6], "texture": "#761770141", "cullface": "down" } } }, { "from": [0,16,0], "to": [16,16,1], "faces": { "up": { "uv": [0,0,16,1], "texture": "#761770141", "cullface": "up" } } }, { "from": [0,16,1], "to": [1,16,15], "faces": { "up": { "uv": [0,1,1,15], "texture": "#761770141", "cullface": "up" } } }, { "from": [15,16,1], "to": [16,16,15], "faces": { "up": { "uv": [15,1,16,15], "texture": "#761770141", "cullface": "up" } } }, { "from": [0,16,15], "to": [16,16,16], "faces": { "up": { "uv": [0,15,16,16], "texture": "#761770141", "cullface": "up" } } }, { "from": [5,16,6], "to": [6,16,10], "faces": { "up": { "uv": [5,6,6,10], "texture": "#761770141", "cullface": "up" } } }, { "from": [10,16,6], "to": [11,16,10], "faces": { "up": { "uv": [10,6,11,10], "texture": "#761770141", "cullface": "up" } } }, { "from": [5,16,5], "to": [11,16,6], "faces": { "up": { "uv": [5,5,11,6], "texture": "#761770141", "cullface": "up" } } }, { "from": [5,16,10], "to": [11,16,11], "faces": { "up": { "uv": [5,10,11,11], "texture": "#761770141", "cullface": "up" } } }, { "from": [0,0,0], "to": [16,1,0], "faces": { "north": { "uv": [0,15,16,16], "texture": "#761770141", "cullface": "north" } } }, { "from": [0,1,0], "to": [1,15,0], "faces": { "north": { "uv": [15,1,16,15], "texture": "#761770141", "cullface": "north" } } }, { "from": [15,1,0], "to": [16,15,0], "faces": { "north": { "uv": [0,1,1,15], "texture": "#761770141", "cullface": "north" } } }, { "from": [0,15,0], "to": [16,16,0], "faces": { "north": { "uv": [0,0,16,1], "texture": "#761770141", "cullface": "north" } } }, { "from": [5,6,0], "to": [6,10,0], "faces": { "north": { "uv": [10,6,11,10], "texture": "#761770141", "cullface": "north" } } }, { "from": [10,6,0], "to": [11,10,0], "faces": { "north": { "uv": [5,6,6,10], "texture": "#761770141", "cullface": "north" } } }, { "from": [5,5,0], "to": [11,6,0], "faces": { "north": { "uv": [5,10,11,11], "texture": "#761770141", "cullface": "north" } } }, { "from": [5,10,0], "to": [11,11,0], "faces": { "north": { "uv": [5,5,11,6], "texture": "#761770141", "cullface": "north" } } }, { "from": [0,0,16], "to": [16,1,16], "faces": { "south": { "uv": [0,15,16,16], "texture": "#761770141", "cullface": "south" } } }, { "from": [0,1,16], "to": [1,15,16], "faces": { "south": { "uv": [0,1,1,15], "texture": "#761770141", "cullface": "south" } } }, { "from": [15,1,16], "to": [16,15,16], "faces": { "south": { "uv": [15,1,16,15], "texture": "#761770141", "cullface": "south" } } }, { "from": [0,15,16], "to": [16,16,16], "faces": { "south": { "uv": [0,0,16,1], "texture": "#761770141", "cullface": "south" } } }, { "from": [5,6,16], "to": [6,10,16], "faces": { "south": { "uv": [5,6,6,10], "texture": "#761770141", "cullface": "south" } } }, { "from": [10,6,16], "to": [11,10,16], "faces": { "south": { "uv": [10,6,11,10], "texture": "#761770141", "cullface": "south" } } }, { "from": [5,5,16], "to": [11,6,16], "faces": { "south": { "uv": [5,10,11,11], "texture": "#761770141", "cullface": "south" } } }, { "from": [5,10,16], "to": [11,11,16], "faces": { "south": { "uv": [5,5,11,6], "texture": "#761770141", "cullface": "south" } } }, { "from": [0,0,0], "to": [0,16,1], "faces": { "west": { "uv": [0,0,1,16], "texture": "#761770141", "cullface": "west" } } }, { "from": [0,0,1], "to": [0,1,15], "faces": { "west": { "uv": [1,15,15,16], "texture": "#761770141", "cullface": "west" } } }, { "from": [0,15,1], "to": [0,16,15], "faces": { "west": { "uv": [1,0,15,1], "texture": "#761770141", "cullface": "west" } } }, { "from": [0,0,15], "to": [0,16,16], "faces": { "west": { "uv": [15,0,16,16], "texture": "#761770141", "cullface": "west" } } }, { "from": [0,5,6], "to": [0,6,10], "faces": { "west": { "uv": [6,10,10,11], "texture": "#761770141", "cullface": "west" } } }, { "from": [0,10,6], "to": [0,11,10], "faces": { "west": { "uv": [6,5,10,6], "texture": "#761770141", "cullface": "west" } } }, { "from": [0,5,5], "to": [0,11,6], "faces": { "west": { "uv": [5,5,6,11], "texture": "#761770141", "cullface": "west" } } }, { "from": [0,5,10], "to": [0,11,11], "faces": { "west": { "uv": [10,5,11,11], "texture": "#761770141", "cullface": "west" } } }, { "from": [16,0,0], "to": [16,16,1], "faces": { "east": { "uv": [15,0,16,16], "texture": "#761770141", "cullface": "east" } } }, { "from": [16,0,1], "to": [16,1,15], "faces": { "east": { "uv": [1,15,15,16], "texture": "#761770141", "cullface": "east" } } }, { "from": [16,15,1], "to": [16,16,15], "faces": { "east": { "uv": [1,0,15,1], "texture": "#761770141", "cullface": "east" } } }, { "from": [16,0,15], "to": [16,16,16], "faces": { "east": { "uv": [0,0,1,16], "texture": "#761770141", "cullface": "east" } } }, { "from": [6,6,0], "to": [6,10,1], "faces": { "east": { "uv": [15,6,16,10], "texture": "#761770141" } } }, { "from": [6,0,6], "to": [6,1,10], "faces": { "east": { "uv": [6,15,10,16], "texture": "#761770141" } } }, { "from": [6,15,6], "to": [6,16,10], "faces": { "east": { "uv": [6,0,10,1], "texture": "#761770141" } } }, { "from": [6,6,15], "to": [6,10,16], "faces": { "east": { "uv": [0,6,1,10], "texture": "#761770141" } } }, { "from": [10,6,0], "to": [10,10,1], "faces": { "west": { "uv": [0,6,1,10], "texture": "#761770141" } } }, { "from": [10,0,6], "to": [10,1,10], "faces": { "west": { "uv": [6,15,10,16], "texture": "#761770141" } } }, { "from": [10,15,6], "to": [10,16,10], "faces": { "west": { "uv": [6,0,10,1], "texture": "#761770141" } } }, { "from": [10,6,15], "to": [10,10,16], "faces": { "west": { "uv": [15,6,16,10], "texture": "#761770141" } } }, { "from": [6,6,0], "to": [10,6,1], "faces": { "up": { "uv": [6,0,10,1], "texture": "#761770141" } } }, { "from": [0,6,6], "to": [1,6,10], "faces": { "up": { "uv": [0,6,1,10], "texture": "#761770141" } } }, { "from": [6,6,15], "to": [10,6,16], "faces": { "up": { "uv": [6,15,10,16], "texture": "#761770141" } } }, { "from": [6,10,0], "to": [10,10,1], "faces": { "down": { "uv": [6,15,10,16], "texture": "#761770141" } } }, { "from": [0,10,6], "to": [1,10,10], "faces": { "down": { "uv": [0,6,1,10], "texture": "#761770141" } } }, { "from": [6,10,15], "to": [10,10,16], "faces": { "down": { "uv": [6,0,10,1], "texture": "#761770141" } } }, { "from": [6,0,6], "to": [10,1,6], "faces": { "south": { "uv": [6,15,10,16], "texture": "#761770141" } } }, { "from": [0,6,6], "to": [1,10,6], "faces": { "south": { "uv": [0,6,1,10], "texture": "#761770141" } } }, { "from": [6,15,6], "to": [10,16,6], "faces": { "south": { "uv": [6,0,10,1], "texture": "#761770141" } } }, { "from": [6,0,10], "to": [10,1,10], "faces": { "north": { "uv": [6,15,10,16], "texture": "#761770141" } } }, { "from": [0,6,10], "to": [1,10,10], "faces": { "north": { "uv": [15,6,16,10], "texture": "#761770141" } } }, { "from": [6,15,10], "to": [10,16,10], "faces": { "north": { "uv": [6,0,10,1], "texture": "#761770141" } } } ], "display": { "thirdperson": { "rotation": [ 10, -45, 170 ], "translation": [ 0, 1.5, -2.75 ], "scale": [ 0.375, 0.375, 0.375 ] } }, "parent": "block/cube_all" } this is the model im using. im fairly new to modding so im not too familiar with the model and block states files, but setting the facing to n,s,w,e works fine and rotates like its supposed to, but rotating up and down doesnt work.
  13. sigh.. im a retard. i missed the ! that i use on every other update function. no wonder shit didnt work.
×
×
  • Create New...

Important Information

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