Jump to content

OrangeVillager61

Members
  • Posts

    339
  • Joined

  • Last visited

Everything posted by OrangeVillager61

  1. Alright, when I try to test the GUI I get errors that arrays cannot be cast to IvVillager on the line below. return new ContainerIvVillagerHauler((IvVillager) world.getEntitiesWithinAABB(IvVillager.class, vilSearch), player.inventory); Since I require an IvVillager as an argument, how can I get the IvVillager and select it?
  2. Okay, thanks, however, when I compare the slot.getStack and the new ItemStack I want with a standard >=, it is undefined and I cannot seem to find an alternative.
  3. Hello! I don't know how to access my mob's container with my gui. I want my button on this gui to fire a series of functions if there are enough emeralds in the gui slot. I do not know to access the slots to check this. Container: public class ContainerIvVillagerHireNitwit extends Container{ private IvVillager villager; private IItemHandler handler = villager.getCapability(CapabilityItemHandler.ITEM_HANDLER_CAPABILITY, null); public ContainerIvVillagerHireNitwit(IvVillager villager, IInventory playerInv){ IItemHandler handler = villager.getCapability(CapabilityItemHandler.ITEM_HANDLER_CAPABILITY, null); this.addSlotToContainer(new SlotItemHandler(handler, 3, 76, 47)); int xPos = 8; int yPos = 84; for (int y = 0; y < 3; ++y) { for (int x = 0; x < 9; ++x) { this.addSlotToContainer(new Slot(playerInv, x + y * 9 + 9, xPos + x * 18, yPos + y * 18)); } } for (int x = 0; x < 9; ++x) { this.addSlotToContainer(new Slot(playerInv, x, xPos + x * 18, yPos + 58)); } } @Override public boolean canInteractWith(EntityPlayer player) { // TODO Auto-generated method stub return false; } @Override public ItemStack transferStackInSlot(EntityPlayer playerIn, int fromSlot) { ItemStack previous = ItemStack.EMPTY; Slot slot = (Slot) this.inventorySlots.get(fromSlot); if (slot != null && slot.getHasStack()) { ItemStack current = slot.getStack(); previous = current.copy(); if (fromSlot < this.handler.getSlots()) { // From the block breaker inventory to player's inventory if (!this.mergeItemStack(current, handler.getSlots(), handler.getSlots() + 36, true)) return ItemStack.EMPTY; } else { // From the player's inventory to block breaker's inventory if (!this.mergeItemStack(current, 0, handler.getSlots(), false)) return ItemStack.EMPTY; } if (current.getCount() == 0) //Use func_190916_E() instead of stackSize 1.11 only 1.11.2 use getCount() slot.putStack(ItemStack.EMPTY); //Use ItemStack.field_190927_a instead of (ItemStack)null for a blank item stack. In 1.11.2 use ItemStack.EMPTY else slot.onSlotChanged(); if (current.getCount() == previous.getCount()) return null; slot.onTake(playerIn, current); } return previous; } } GUI public class GuiIvVillagerHireNitwit extends GuiContainer{ private IvVillager villager; private IInventory playerInv; public GuiIvVillagerHireNitwit(IvVillager villager, IInventory playerInv) { super(new ContainerIvVillagerHireNitwit(villager, playerInv)); this.xSize = 176; this.ySize = 166; this.villager = villager; this.playerInv = playerInv; } @Override protected void drawGuiContainerBackgroundLayer(float partialTicks, int mouseX, int mouseY) { GlStateManager.color(1.0F, 1.0F, 1.0F, 1.0F); this.mc.getTextureManager().bindTexture(new ResourceLocation(Reference.MOD_ID, "gui/hire_nitwit.png")); this.drawTexturedModalRect(this.getGuiLeft(), this.getGuiTop(), 0, 0, this.xSize, this.ySize); } @Override protected void drawGuiContainerForegroundLayer(int mouseX, int mouseY) { String s = this.villager.getName(); Boolean has_emeralds; this.mc.fontRenderer.drawString(s, this.xSize / 2 - this.mc.fontRenderer.getStringWidth(s) / 2, 6, 4210752); this.mc.fontRenderer.drawString(this.playerInv.getDisplayName().getFormattedText(), 8, 72, 4210752); if (){ //this is where the container needs to be accessed has_emeralds = true; } else { has_emeralds = false; } this.addButton(new Button_Hire(0, 115, 20, 40, 25, "Hire", this.villager, has_emeralds)); } } As well, does addSlotToContainer id need to be different across containers?
  4. Okay, then I would want in onLivingUpdate() then? Behavior I want is that the entity gets the different health and speed according to its life stage. I am getting the default code that I put in "else" at the end. I would use an enum but I don't know how to make them work as dataParameters.
  5. My Entity class: public class IvVillager extends EntityVillager{ protected Village villageObj; public String name; public int gender; protected boolean isWillingToMate; protected int wealth; //public String Adult_Age; //protected int int_Age; protected MerchantRecipeList buyingList; private static final DataParameter<String> Adult_Age = EntityDataManager.<String>createKey(IvVillager.class, DataSerializers.STRING); private static final DataParameter<Integer> int_Age = EntityDataManager.<Integer>createKey(IvVillager.class, DataSerializers.VARINT); private int careerId; private int careerLevel; private boolean isLookingForHome; private boolean areAdditionalTasksSet; protected final InventoryBasic villagerInventory; Random r = new Random(); /** A multi-dimensional array mapping the various professions, careers and career levels that a Villager may offer */ public String[] male_list = {"Bob", "Joseph", "Aaron", "Philp", "Adam", "Paul", "Donald", "Ryan", "Mark", "Brian", "Robert", "Willam", "Harold", "Anthony", "Julius", "Mathew", "Tyler", "Noah", "Patrick", "Caden", "Michael", "Jeffery", "James", "John", "Thomas", "Otto", "Bill", "Sheldon", "Leonard", "Howard", "Carter", "Theodore", "Herbert", "Paul", "Kurt", "Blaine", "Ronald", "Christian", "Frederick", "Justinian", "Justin"}; public String[] female_list = {"Karen", "Lessie", "Kayla", "Brianna", "Isabella", "Elizabeth", "Kira", "Jadzia", "Abigail", "Chloe", "Olivia", "Sophia", "Emily", "Charlotte", "Amelia", "Maria", "Daria", "Sarah", "Theodora", "Tia", "Jennifer", "Anglica", "Denna", "Tasha", "Catherine", "Lily", "Amy", "Penny", "Julina", "Audrey", "Avery", "Hoshi", "Leia", "Rachel", "Tina", "Lacy", "Quinn", "Alexandra"}; public IvVillager(World world) { super(world); this.villagerInventory = new InventoryBasic("Items", false, 20); this.setVillagerAge(); } public IvVillager(World world, int professionId, int gender, String name) { super(world, professionId); this.setProfession(professionId); this.villagerInventory = new InventoryBasic("Items", false, 20); this.gender = gender; this.name = name; this.setCustomNameTag(name); this.setVillagerAge(); } public InventoryBasic getVillagerInventory() { return this.villagerInventory; } @Override protected void applyEntityAttributes() { super.applyEntityAttributes(); if (this.getAdultAge().equals("Elder")) { this.getEntityAttribute(SharedMonsterAttributes.MAX_HEALTH).setBaseValue(16.0D); this.getEntityAttribute(SharedMonsterAttributes.MOVEMENT_SPEED).setBaseValue(0.45D); this.setSize(0.6F, 1.8F); } else if (this.getAdultAge().equals("Middle Aged")) { this.getEntityAttribute(SharedMonsterAttributes.MAX_HEALTH).setBaseValue(20.0D); this.getEntityAttribute(SharedMonsterAttributes.MOVEMENT_SPEED).setBaseValue(0.53D); } else if (this.getAdultAge().equals("Young Adult")) { this.getEntityAttribute(SharedMonsterAttributes.MAX_HEALTH).setBaseValue(22.0D); this.getEntityAttribute(SharedMonsterAttributes.MOVEMENT_SPEED).setBaseValue(0.6D); } else if (this.isChild()) { this.getEntityAttribute(SharedMonsterAttributes.MAX_HEALTH).setBaseValue(16.0D); this.getEntityAttribute(SharedMonsterAttributes.MOVEMENT_SPEED).setBaseValue(0.6D); } else { this.getEntityAttribute(SharedMonsterAttributes.MOVEMENT_SPEED).setBaseValue(0.55D); this.getEntityAttribute(SharedMonsterAttributes.MAX_HEALTH).setBaseValue(20.0D); this.setSize(0.6F, 1.95F); } } @Override protected void entityInit() { super.entityInit(); this.getDataManager().register(int_Age, Integer.valueOf(1)); this.getDataManager().register(Adult_Age, String.valueOf("")); } protected void setAdultAge(String name) { this.dataManager.set(Adult_Age, name); } protected void setIntAge(int num) { this.dataManager.set(int_Age, num); } public int getIntAge() { return (int)this.dataManager.get(int_Age); } public String getAdultAge() { return (String)this.dataManager.get(Adult_Age); } protected void setVillagerAge(){ if (this.isChild() == false) { this.setIntAge(1); if (r.nextInt(6) == 0){ this.setAdultAge("Elder"); } else if (r.nextInt(2) == 0){ this.setAdultAge("Young Adult"); } else{ this.setAdultAge("Middle Aged"); } } else{ this.setAdultAge("Child"); } } public void ivVillagerAdultAge(int lifeChangeNum){ if (world.isRemote == false){ if (this.isChild() == false){ if (this.getIntAge() >= lifeChangeNum){ if (this.getAdultAge().equals("Young Adult")){ this.setIntAge(1); this.setAdultAge("Middle Aged"); } else if (this.getAdultAge().equals("Middle Aged")){ this.setIntAge(1); this.setAdultAge("Elder"); } else if (this.getAdultAge().equals("Elder")){ this.setIntAge(this.getIntAge() - 500); } } else{ this.setIntAge(this.getIntAge() + 1); } } } } @Override public void onLivingUpdate() { super.onLivingUpdate(); this.ivVillagerAdultAge(360000); } @Override protected void onGrowingAdult() { super.onGrowingAdult(); this.setAdultAge("Young Adult"); this.setIntAge(1); } @Override protected void initEntityAI() { if (world.isRemote == false){ BlockPos blockpos = new BlockPos(this); this.villageObj = this.world.getVillageCollection().getNearestVillage(blockpos, 32); } this.tasks.addTask(0, new EntityAISwimming(this)); this.tasks.addTask(1, new EntityAIAvoidEntity(this, EntityZombie.class, 8.0F, 0.6D, 0.6D)); //this.tasks.addTask(1, new VillagerAvoidEvilPlayer(this, 8.0F, 0.6D, 0.6D, this.villageObj)); this.tasks.addTask(1, new EntityAIAvoidEntity(this, EntityEvoker.class, 12.0F, 0.8D, 0.8D)); this.tasks.addTask(1, new EntityAIAvoidEntity(this, EntityVindicator.class, 8.0F, 0.8D, 0.8D)); this.tasks.addTask(1, new EntityAIAvoidEntity(this, EntityVex.class, 8.0F, 0.6D, 0.6D)); this.tasks.addTask(1, new EntityAIPanic(this, 0.8D)); this.tasks.addTask(1, new EntityAITradePlayer(this)); this.tasks.addTask(2, new EntityAILookAtTradePlayer(this)); this.tasks.addTask(2, new EntityAIMoveIndoors(this)); this.tasks.addTask(3, new EntityAIRestrictOpenDoor(this)); this.tasks.addTask(3, new EntityAITempt(this, 0.9D, Items.EMERALD, false)); this.tasks.addTask(4, new EntityAIOpenDoor(this, true)); this.tasks.addTask(5, new EntityAIMoveTowardsRestriction(this, 0.6D)); this.tasks.addTask(5, new IvVilsPerDoor(this)); this.tasks.addTask(7, new EntityAIFollowGolem(this)); this.tasks.addTask(9, new EntityAIVillagerInteract(this)); this.tasks.addTask(9, new EntityAIWanderAvoidWater(this, 0.6D)); this.tasks.addTask(10, new EntityAIWatchClosest2(this, EntityPlayer.class, 3.0F, 1.0F)); this.tasks.addTask(10, new EntityAIWatchClosest(this, EntityLiving.class, 8.0F)); } private void setAdditionalAItasks() { if (!this.areAdditionalTasksSet) { this.areAdditionalTasksSet = true; if (this.isChild()) { this.tasks.addTask(8, new EntityAIPlay(this, 0.32D)); } else if (this.getProfession() == 0) { this.tasks.addTask(6, new EntityAIHarvestFarmland(this, 0.6D)); } } } @Override public void writeEntityToNBT(NBTTagCompound compound) { super.writeEntityToNBT(compound); if (world.isRemote == false){ compound.setInteger("Profession", this.getProfession()); compound.setString("ProfessionName", this.getProfessionForge().getRegistryName().toString()); compound.setInteger("Riches", this.wealth); compound.setInteger("Int_Age", this.getIntAge()); compound.setInteger("Career", this.careerId); compound.setInteger("CareerLevel", this.careerLevel); compound.setBoolean("Willing", this.isWillingToMate); if ((this.getAdultAge().equals("")) == false){ compound.setString("Adult_Age", this.getAdultAge()); } if (this.buyingList != null) { compound.setTag("Offers", this.buyingList.getRecipiesAsTags()); } } NBTTagList nbttaglist = new NBTTagList(); for (int i = 0; i < this.getVillagerInventory().getSizeInventory(); ++i) { ItemStack itemstack = this.villagerInventory.getStackInSlot(i); if (!itemstack.isEmpty()) { nbttaglist.appendTag(itemstack.writeToNBT(new NBTTagCompound())); } } compound.setTag("Inventory", nbttaglist); if (world.isRemote == false){ if (this.gender != 1 || this.gender != 2){ this.gender = r.nextInt(2) + 1; } compound.setInteger("Gender", this.gender); if (this.getCustomNameTag() == null || this.getCustomNameTag() == "None" || this.getCustomNameTag() == "none"){ if (this.gender == 1){ this.name = male_list[r.nextInt(male_list.length)]; } else if (this.gender == 2){ this.name = female_list[r.nextInt(female_list.length)]; } else{ this.name = "None"; System.out.println("Something went wrong with gender, please report."); System.out.println("No Name"); } compound.setString("Name", this.name); this.setCustomNameTag(this.name); } } } @Override public void readEntityFromNBT(NBTTagCompound compound){ super.readEntityFromNBT(compound); if (world.isRemote == false){ this.gender = compound.getInteger("Gender"); this.name = compound.getString("Name"); //this.setCustomNameTag(this.name); } if (compound.hasKey("Adult_Age")) { this.setAdultAge(compound.getString("Adult_Age")); } if (compound.hasKey("Int_Age")){ this.setIntAge(compound.getInteger("Int_Age")); } this.setProfession(compound.getInteger("Profession")); if (compound.hasKey("ProfessionName")) { net.minecraftforge.fml.common.registry.VillagerRegistry.VillagerProfession p = net.minecraftforge.fml.common.registry.VillagerRegistry.instance().getRegistry().getValue(new net.minecraft.util.ResourceLocation(compound.getString("ProfessionName"))); if (p == null) p = net.minecraftforge.fml.common.registry.VillagerRegistry.instance().getRegistry().getValue(new net.minecraft.util.ResourceLocation("minecraft:farmer")); this.setProfession(p); } this.wealth = compound.getInteger("Riches"); this.careerId = compound.getInteger("Career"); this.careerLevel = compound.getInteger("CareerLevel"); this.isWillingToMate = compound.getBoolean("Willing"); if (compound.hasKey("Offers", 10)) { NBTTagCompound nbttagcompound = compound.getCompoundTag("Offers"); this.buyingList = new MerchantRecipeList(nbttagcompound); } NBTTagList nbttaglist = compound.getTagList("Inventory", 10); for (int i = 0; i < nbttaglist.tagCount(); ++i) { ItemStack itemstack = new ItemStack(nbttaglist.getCompoundTagAt(i)); if (!itemstack.isEmpty()) { this.villagerInventory.addItem(itemstack); } } this.setCanPickUpLoot(true); this.setAdditionalAItasks(); } private void populateBuyingList() { if (this.careerId != 0 && this.careerLevel != 0) { ++this.careerLevel; } else { this.careerId = this.getProfessionForge().getRandomCareer(this.rand) + 1; this.careerLevel = 1; } if (this.buyingList == null) { this.buyingList = new MerchantRecipeList(); } int i = this.careerId - 1; int j = this.careerLevel - 1; java.util.List<EntityVillager.ITradeList> trades = this.getProfessionForge().getCareer(i).getTrades(j); if (trades != null) { for (EntityVillager.ITradeList entityvillager$itradelist : trades) { entityvillager$itradelist.addMerchantRecipe(this, this.buyingList, this.rand); } } } @Override public boolean processInteract(EntityPlayer player, EnumHand hand){ if (world.isRemote == false){ BlockPos blockpos = new BlockPos(this); this.villageObj = this.world.getVillageCollection().getNearestVillage(blockpos, 32); } ItemStack itemstack = player.getHeldItem(hand); if (itemstack.getItem() == IvItems.thieving_nose && !this.isChild()){ itemstack.damageItem(1, player); this.setHealth(this.getHealth() - 2); this.playHurtSound(getLastDamageSource()); if (rand.nextInt(10) + 1 < 6){ } if (rand.nextInt(10) + 1 < 9 && rand.nextInt(10) + 1 > 5){ this.entityDropItem(new ItemStack(Items.EMERALD, r.nextInt(2) + 1), 0); } if (rand.nextInt(10) + 1 < 10 && rand.nextInt(10) + 1 > 8){ this.entityDropItem(new ItemStack(Items.EMERALD, r.nextInt(2) + 1), 0); } if (world.isRemote == false){ if (this.villageObj != null) { this.villageObj.modifyPlayerReputation(player.getName(), -2); } } return true; } else if (!this.holdingSpawnEggOfClass(itemstack, this.getClass()) && this.isEntityAlive() && !this.isTrading() && !this.isChild()) { if (this.buyingList == null) { this.populateBuyingList(); } if (hand == EnumHand.MAIN_HAND) { player.addStat(StatList.TALKED_TO_VILLAGER); } if (!this.world.isRemote && !this.buyingList.isEmpty()) { this.setCustomer(player); player.displayVillagerTradeGui(this); } else if (this.buyingList.isEmpty()) { return super.processInteract(player, hand); } return true; } else { return super.processInteract(player, hand); } } } Common Proxy: public class CommonProxy { public static final ResourceLocation VILLAGE_BUTCHER_LT = LootTableList.register(new ResourceLocation("iv","village_butcher")); @EventHandler public void preInit(FMLPreInitializationEvent e) { ResourceLocation resourceLocation1 = new ResourceLocation("iv", "villager"); EntityRegistry.registerModEntity(resourceLocation1, IvVillager.class, "IvVillager", 0, Iv.instance, 32, 1, true); } @EventHandler public void init(FMLInitializationEvent e) { } @EventHandler public void postInit(FMLPostInitializationEvent e) { } }
  6. Lately, I've had issues changing mob attributes. I am trying to change the mob's height, health and speed. This though isn't called even when it is supposed to. The function is called. @Override protected void applyEntityAttributes() { super.applyEntityAttributes(); System.out.println("Entity Attributes Applied"); if (this.getAdultAge().equals("Elder")) { this.getEntityAttribute(SharedMonsterAttributes.MAX_HEALTH).setBaseValue(16.0D); this.getEntityAttribute(SharedMonsterAttributes.MOVEMENT_SPEED).setBaseValue(0.38D); this.setSize(0.6F, 1.8F); System.out.println("Elder Check Passed"); } else { this.getEntityAttribute(SharedMonsterAttributes.MOVEMENT_SPEED).setBaseValue(0.55D); this.getEntityAttribute(SharedMonsterAttributes.MAX_HEALTH).setBaseValue(20.0D); this.setSize(0.6F, 1.95F); } }
  7. Yep that fixed it thanks!
  8. I could have sworn I checked that twice, this is a reason why I hate working with json files . That probably fixed it, I am testing now.
  9. It is used in my custom village with addComponentParts, (I omitted most of this function): public boolean addComponentParts(World worldIn, Random randomIn, StructureBoundingBox structureBoundingBoxIn) { this.generateChest(worldIn, structureBoundingBoxIn, randomIn, 7, 1, 1, CommonProxy.VILLAGE_BUTCHER_LT); } Common Proxy is above.
  10. If you mean village_butcher.json then yes, I have it at src/main/resources/assets/iv/loot_tables/village_butcher.json
  11. After adding a comma after "village_butcher" it still doesn't do anything.
  12. Okay, but the chests spawn empty with no errors related to that in the console. this.generateChest(worldIn, structureBoundingBoxIn, randomIn, 7, 1, 1, CommonProxy.VILLAGE_BUTCHER_LT); public class CommonProxy { public static final ResourceLocation VILLAGE_BUTCHER_LT = LootTableList.register(new ResourceLocation("iv","villager_butcher")); @EventHandler public void preInit(FMLPreInitializationEvent e) { ResourceLocation resourceLocation1 = new ResourceLocation("iv", "villager"); MinecraftForge.EVENT_BUS.register(new ChangeVilMateAI()); MinecraftForge.EVENT_BUS.register(new OverrideVillagers()); EntityRegistry.registerModEntity(resourceLocation1, IvVillager.class, "IvVillager", 0, Iv.instance, 32, 1, true); //MinecraftForge.EVENT_BUS.register(new CapabilityHandler()); if (Config.enableVillages){ MinecraftForge.TERRAIN_GEN_BUS.register(new ChangeVillageGeneration()); } IvItems.Init(); IvBlocks.Init(); IvItems.createItems(); IvBlocks.createBlocks(); } @EventHandler public void init(FMLInitializationEvent e) { IvRecipes.addRecipes(); MinecraftForge.EVENT_BUS.register(new VillagerDrops()); } @EventHandler public void postInit(FMLPostInitializationEvent e) { } } { "pools": [ { "name": "village_butcher" "rolls": { "min": 1, "max": 11 }, "entries": [ { "type": "item", "name": "minecraft:cooked_beef", "functions": [ { "function": "set_count", "count": { "min": 4, "max": 12 } } ], "weight": 8 }, { "type": "item", "name": "minecraft:cooked_porkchop", "functions": [ { "function": "set_count", "count": { "min": 4, "max": 12 } } ], "weight": 8 }, { "type": "item", "name": "minecraft:cooked_chicken", "functions": [ { "function": "set_count", "count": { "min": 4, "max": 12 } } ], "weight": 8 }, { "type": "item", "name": "minecraft:leather", "functions": [ { "function": "set_count", "count": { "min": 2, "max": 20 } } ], "weight": 18 }, { "type": "item", "name": "minecraft:beef", "functions": [ { "function": "set_count", "count": { "min": 16, "max": 32 } } ], "weight": 30 }, { "type": "item", "name": "minecraft:chicken", "functions": [ { "function": "set_count", "count": { "min": 16, "max": 32 } } ], "weight": 30 }, { "type": "item", "name": "minecraft:porkchop", "functions": [ { "function": "set_count", "count": { "min": 16, "max": 32 } } ], "weight": 30 }, { "type": "item", "name": "minecraft:iron_sword", "weight": 5 }, { "type": "item", "name": "minecraft:saddle", "weight": 5 }, { "type": "item", "name": "minecraft:leather_leggings", "weight": 5 }, { "type": "item", "name": "minecraft:leather_chestplate", "weight": 5 } ] } ] }
  13. What I'm saying is that I can't find access to the ID. LootTableList.register(new ResourceLocation("iv", "village_butcher")); This is my register.
  14. So how to get said id out of LootTableList? I can only seem to get vanilia stuff such as LootTableList.CHESTS_ABANDONED_MINESHAFT.
  15. I have made a loot table for a custom chest I have world generated but I don't know how to have my code access said loot table. I am using StructureComponent.generateChest to accomplish this. this.generateChest(worldIn, structureBoundingBoxIn, randomIn, 7, 1, 1, ); //Here in the last parameter is where it should go
  16. Yes it should, thanks for catching that. The textures work now, thank you.
  17. Solution Found - I was loading my config file after my proxies causing the issues.
  18. Doing a println in my client and common proxy has shown that MC always does my ints as 0. [09:57:03] [Forge Version Check/INFO] [ForgeVersionCheck]: [forge] Starting version check at http://files.minecraftforge.net/maven/net/minecraftforge/forge/promotions_slim.json 0 0 [09:57:04] [Forge Version Check/INFO] [ForgeVersionCheck]: [forge] Found status: OUTDATED Target: 13.20.0.2296 System.out.println(Config.enableDrops); Even though my config file is set to 1. # If this is set to 1, villager drops will be enabled. [range: 0 ~ 1, default: 1] I:"Enable Villager Drops"=1 # If this is set to 1, this mod's villages will be enabled. Should fix village incompatibilities with other mods [range: 0 ~ 1, default: 1] I:"Enable Villages"=1 public class Config { public static double VilPerDoor; public static int MateAgain; public static int twins; public static int enableDrops; public static int enableVillages; public static int VillageDistance; public static int overwriteOriginalVillagers; public static int enableIvTexture; public final static Config instance = new Config(); public void load(FMLPreInitializationEvent event) { Configuration config = new Configuration(event.getSuggestedConfigurationFile()); config.load(); twins = config.getInt("Twin Chance", Configuration.CATEGORY_GENERAL, 3, 0, 100, "Set this to the chance for the villagers to have twins. Set to 0 if you want to disable this."); VilPerDoor = config.get(Configuration.CATEGORY_GENERAL, "Villagers per Door", 1.0, "Set this to the number of villagers per door. Unmodded: 0.35(almost 3 doors for one villager), Mod Default: 1.0 (one door per villager)").getDouble(1.0); enableIvTexture = config.getInt("Enable Iv Texture", Configuration.CATEGORY_GENERAL, 1, 0, 1, "Set this to 1 to enable this mod's villager texture, disable this if you don't like this mod's textures or you want resource packs to work with this mod's villagers."); MateAgain = config.getInt("Mate Again", Configuration.CATEGORY_GENERAL, 1, 0, 1, "Set this to 1 if you want a chance(1/3) that villagers to be willing to mate again after mating."); enableDrops = config.getInt("Enable Villager Drops", Configuration.CATEGORY_GENERAL, 1, 0, 1, "If this is set to 1, villager drops will be enabled."); overwriteOriginalVillagers = config.getInt("Override Original Villagers?", Configuration.CATEGORY_GENERAL, 1, 0, 1, "If this is set to 1, then villagers will be overridden by the mod."); enableVillages = config.getInt("Enable Villages", Configuration.CATEGORY_GENERAL, 1, 0, 1, "If this is set to 1, this mod's villages will be enabled. Should fix village incompatibilities with other mods"); VillageDistance = config.getInt("Village Distance", Configuration.CATEGORY_GENERAL, 24, 2, 1024, "For each of this number of blocks, a village will try to spawn, Unmodded:32. This is will not do anything if Enable Villages is set to 1"); if (config.hasChanged()) { config.save(); } } } And yet it is extremely random if something is enabled or not.
  19. I have put that code into the IvVillagerRender: protected void preRenderCallback(EntityVillager entitylivingbaseIn, float partialTickTime) { float f = 0.9375F; if (entitylivingbaseIn.getGrowingAge() < 0) { f = (float)((double)f * 0.5D); this.shadowSize = 0.25F; } else { this.shadowSize = 0.5F; } GlStateManager.scale(f, f, f); } Client Proxy: RenderingRegistry.registerEntityRenderingHandler(IvVillager.class, new RenderFactory()); RenderFactory: public class RenderFactory implements IRenderFactory{ @Override public Render createRenderFor(RenderManager manager) { return new IvVillagerRender(manager); } } Below is a child, while the name is in the right place, the textures aren't.
  20. I meant the boolean checks were part of the original config file before I changed it to an int based system. The current system is this: if (Config.enableVillages == 1) The boolean check in the first is an example of the former system that didn't save before I switched to an int based system that didn't save either. I edited the first post to clarify this.
  21. Okay, that fixed it, however, baby villagers are rendered at full size. Is a model file required to have baby villagers rendered at their supposed size?
  22. I've always had issues with Config files that don't give any value at all. When I formerly used a boolean system, all times I did config.variable == True or config.varaible == False it doesn't do anything. When I switched to ints also tend to fail if checks as well such as Config.variable == 1 even if it is set to 1 in the config system. I know my config file is supposed to be a boolean system and not 0 or 1 but the boolean system doesn't work at all with the problems mentioned above. public class Config { public static double VilPerDoor; public static int MateAgain; public static int twins; public static int enableDrops; public static int enableVillages; public static int VillageDistance; public static int overwriteOriginalVillagers; public static int enableIvTexture; public final static Config instance = new Config(); public void load(FMLPreInitializationEvent event) { Configuration config = new Configuration(event.getSuggestedConfigurationFile()); config.load(); twins = config.getInt("Twin Chance", Configuration.CATEGORY_GENERAL, 3, 0, 100, "Set this to the chance for the villagers to have twins. Set to 0 if you want to disable this."); VilPerDoor = config.get(Configuration.CATEGORY_GENERAL, "Villagers per Door", 1.0, "Set this to the number of villagers per door. Unmodded: 0.35(almost 3 doors for one villager), Mod Default: 1.0 (one door per villager)").getDouble(1.0); enableIvTexture = config.getInt("Enable Iv Texture", Configuration.CATEGORY_GENERAL, 1, 0, 1, "Set this to 1 to enable this mod's villager texture, disable this if you don't like this mod's textures or you want resource packs to work with this mod's villagers."); MateAgain = config.getInt("Mate Again", Configuration.CATEGORY_GENERAL, 1, 0, 1, "Set this to 1 if you want a chance(1/3) that villagers to be willing to mate again after mating."); enableDrops = config.getInt("Enable Villager Drops", Configuration.CATEGORY_GENERAL, 1, 0, 1, "If this is set to 1, villager drops will be enabled."); overwriteOriginalVillagers = config.getInt("Override Original Villagers?", Configuration.CATEGORY_GENERAL, 1, 0, 1, "If this is set to 1, then villagers will be overridden by the mod."); enableVillages = config.getInt("Enable Villages", Configuration.CATEGORY_GENERAL, 1, 0, 1, "If this is set to 1, this mod's villages will be enabled. Should fix village incompatibilities with other mods"); VillageDistance = config.getInt("Village Distance", Configuration.CATEGORY_GENERAL, 24, 2, 1024, "For each of this number of blocks, a village will try to spawn, Unmodded:32. This is will not do anything if Enable Villages is set to 1"); if (config.hasChanged()) { config.save(); } } } Where it is loaded by the main class. @EventHandler public void preInit(FMLPreInitializationEvent e) { proxy.preInit(e); Config.instance.load(e); } @EventHandler public void init(FMLInitializationEvent e) { proxy.init(e); } @EventHandler public void postInit(FMLPostInitializationEvent e) { proxy.postInit(e); }
  23. According to the console, MC is trying to use the original MC folder which is not where it should be using. [Client thread/WARN]: Failed to load texture: minecraft:iv/textures/entity/villager/villager.png
  24. Alright, so I've got the villagers looking like this below. Do I need a separate model file or will it still automatically use the entity villager one? @SideOnly(Side.CLIENT) public class IvVillagerRender extends RenderLiving<IvVillager> { private static final ResourceLocation VILLAGER_TEXTURES = new ResourceLocation("iv/textures/entity/villager/villager.png"); private static final ResourceLocation FARMER_VILLAGER_TEXTURES = new ResourceLocation("iv/textures/entity/villager/farmer.png"); private static final ResourceLocation LIBRARIAN_VILLAGER_TEXTURES = new ResourceLocation("iv/textures/entity/villager/librarian.png"); private static final ResourceLocation PRIEST_VILLAGER_TEXTURES = new ResourceLocation("iv/textures/entity/villager/priest.png"); private static final ResourceLocation SMITH_VILLAGER_TEXTURES = new ResourceLocation("iv/textures/entity/villager/smith.png"); private static final ResourceLocation BUTCHER_VILLAGER_TEXTURES = new ResourceLocation("iv/textures/entity/villager/butcher.png"); public IvVillagerRender(RenderManager renderManager) { super(renderManager, new ModelVillager(0.0F), 0.5F); this.addLayer(new LayerCustomHead(this.getMainModel().villagerHead)); } public ModelVillager getMainModel() { return (ModelVillager)super.getMainModel(); } /** * Returns the location of an entity's texture. Doesn't seem to be called unless you call Render.bindEntityTexture. */ protected ResourceLocation getEntityTexture(IvVillager entity) { if (entity.getProfession() == 0) { return FARMER_VILLAGER_TEXTURES; } else if (entity.getProfession() == 1) { return LIBRARIAN_VILLAGER_TEXTURES; } else if (entity.getProfession() == 2) { return PRIEST_VILLAGER_TEXTURES; } else if (entity.getProfession() == 3) { return SMITH_VILLAGER_TEXTURES; } else if (entity.getProfession() == 4) { return BUTCHER_VILLAGER_TEXTURES; } else if (entity.getProfession() == 5) { return VILLAGER_TEXTURES; } else { return VILLAGER_TEXTURES; } } /** * Allows the render to do state modifications necessary before the model is rendered. */ protected void preRenderCallback(EntityVillager entitylivingbaseIn, float partialTickTime) { float f = 0.9375F; if (entitylivingbaseIn.getGrowingAge() < 0) { f = (float)((double)f * 0.5D); this.shadowSize = 0.25F; } else { this.shadowSize = 0.5F; } GlStateManager.scale(f, f, f); } } public class ClientProxy extends CommonProxy{ @Override public void preInit(FMLPreInitializationEvent e) { super.preInit(e); BlockRender.preInit(); RenderingRegistry.registerEntityRenderingHandler(IvVillager.class, new RenderFactory()); } @Override public void init(FMLInitializationEvent e) { super.init(e); ItemRender.registerItemRenderer(); BlockRender.registerBlockRenderer(); } @Override public void postInit(FMLPostInitializationEvent e) { super.postInit(e); } } public class RenderFactory implements IRenderFactory{ @Override public Render createRenderFor(RenderManager manager) { return new IvVillagerRender(manager); } }
  25. That's why one shouldn't code at 10pm while sick with a fever.
×
×
  • Create New...

Important Information

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