Jump to content

Jershy

Members
  • Posts

    45
  • Joined

  • Last visited

Everything posted by Jershy

  1. where is it implemented? I've been through the code the villager class and IMerchant, and haven't found any reference to it.
  2. Here is the Entity Class; ackage com.ageofempires.enitity.living; import java.util.ArrayList; import java.util.List; import java.util.Random; import javax.annotation.Nullable; import com.ageofempires.mod.AOE; import com.ageofempires.mod.event.gui.GuiHandler; import com.ageofempires.mod.gui.entity.IWorker; import net.minecraft.client.main.Main; import net.minecraft.entity.IMerchant; import net.minecraft.entity.INpc; import net.minecraft.entity.passive.EntityVillager; import net.minecraft.entity.passive.EntityVillager.ITradeList; import net.minecraft.entity.player.EntityPlayer; import net.minecraft.init.Blocks; import net.minecraft.init.Items; import net.minecraft.init.MobEffects; import net.minecraft.inventory.InventoryBasic; import net.minecraft.item.Item; import net.minecraft.item.ItemStack; import net.minecraft.network.datasync.DataParameter; import net.minecraft.network.datasync.DataSerializers; import net.minecraft.network.datasync.EntityDataManager; import net.minecraft.pathfinding.PathNavigateGround; import net.minecraft.potion.PotionEffect; import net.minecraft.stats.StatList; import net.minecraft.util.EnumHand; import net.minecraft.util.math.BlockPos; import net.minecraft.village.MerchantRecipe; import net.minecraft.village.MerchantRecipeList; import net.minecraft.village.Village; import net.minecraft.world.World; public class EntityUsefulVillager extends EntityVillager implements IMerchant, IWorker, INpc{ private int randomTickDivider; private boolean isMating; private boolean isPlaying; Village villageObj; private EntityPlayer buyingPlayer; private MerchantRecipeList buyingList; private int timeUntilReset; private boolean needsInitilization; private boolean isWillingToMate; private int wealth; private String lastBuyingPlayer; private int careerId; private int careerLevel; private boolean isLookingForHome; private boolean areAdditionalTasksSet; private final InventoryBasic villagerInventory; private final boolean isMerchant; private int profession; private boolean isJob; private int jobID; private boolean isSoldier; private int[] jobExp; private boolean isJobInit; public EntityUsefulVillager(World world) { this(world, 0, 2); } public EntityUsefulVillager(World world, int profession, int defaultLevel) { super(world); this.careerLevel = defaultLevel; this.villagerInventory = new InventoryBasic("Items", false, ; setProfession(profession); this.profession = profession; setSize(0.6F, 1.95F); ((PathNavigateGround) getNavigator()).setBreakDoors(true); setCanPickUpLoot(true); this.isMerchant = world.rand.nextInt(11) <= 2 ? true : false; this.isJob = false; } public boolean processInteract(EntityPlayer player, EnumHand p_processInteract_2_, @Nullable ItemStack p_processInteract_3_) { boolean flag = (p_processInteract_3_ != null) && (p_processInteract_3_.getItem() == Items.SPAWN_EGG); if ((!(this.worldObj.isRemote))) { if ((!(flag)) && (isEntityAlive()) && (!(isTrading())) && (!(isChild()))) { if (!player.isSneaking()) { if (((this.buyingList == null) || (!(this.buyingList .isEmpty())))) { setCustomer(player); player.displayVillagerTradeGui(this); } }else if(this.isJob){ //TODO add CONTAINER gui for job. }else{ this.setCustomer(player); player.openGui(AOE.instance, GuiHandler.USEFUL_VILLAGER_GUI_INIT_REQ, player.worldObj, (int)player.posX, (int)player.posY, (int)player.posZ); } player.addStat(StatList.TALKED_TO_VILLAGER); } } return super.processInteract(player, p_processInteract_2_, p_processInteract_3_); } @Override protected void updateAITasks() { BlockPos blockpos; if (--this.randomTickDivider <= 0) { blockpos = new BlockPos(this); this.worldObj.getVillageCollection().addToVillagerPositionList( blockpos); this.randomTickDivider = (70 + this.rand.nextInt(50)); this.villageObj = this.worldObj.getVillageCollection() .getNearestVillage(blockpos, 32); if (this.villageObj == null) { detachHome(); } else { BlockPos blockpos1 = this.villageObj.getCenter(); setHomePosAndDistance(blockpos1, this.villageObj.getVillageRadius()); if (this.isLookingForHome) { this.isLookingForHome = false; this.villageObj.setDefaultPlayerReputation(5); } } } if ((!(isTrading())) && (this.timeUntilReset > 0)) { this.timeUntilReset -= 1; if (this.timeUntilReset <= 0) { if (this.needsInitilization) { for (MerchantRecipe merchantrecipe : this.buyingList) { if (merchantrecipe.isRecipeDisabled()) { merchantrecipe.increaseMaxTradeUses(this.rand .nextInt(6) + this.rand.nextInt(6) + 2); } } populateBuyingList(); this.needsInitilization = false; if ((this.villageObj != null) && (this.lastBuyingPlayer != null)) { this.worldObj.setEntityState(this, (byte) 14); this.villageObj.modifyPlayerReputation( this.lastBuyingPlayer, 1); } } addPotionEffect(new PotionEffect(MobEffects.REGENERATION, 200, 0)); } } super.updateAITasks(); } private boolean canVillagerPickupItem(Item p_canVillagerPickupItem_1_) { if(this.checkJob()) { List<Item> list = this.isItemRelatedToJob(jobID); if(list == null) { return false; } for(int i = 0; i < list.size(); i++) { if(p_canVillagerPickupItem_1_ == list.get(i)) { return true; } } } if(isSoldier) { return true; } return ((p_canVillagerPickupItem_1_ == Items.BREAD) || (p_canVillagerPickupItem_1_ == Items.POTATO) || (p_canVillagerPickupItem_1_ == Items.CARROT) || (p_canVillagerPickupItem_1_ == Items.WHEAT) || (p_canVillagerPickupItem_1_ == Items.WHEAT_SEEDS) || (p_canVillagerPickupItem_1_ == Items.BEETROOT) || (p_canVillagerPickupItem_1_ == Items.BEETROOT_SEEDS)); } public boolean checkJob() { return this.isJob; } public static List<Item> isItemRelatedToJob(int job) { List<Item> list = new ArrayList(); switch(job) { case 1: list.add(Items.WHEAT); list.add(Items.WHEAT_SEEDS); list.add(Items.BEETROOT); list.add(Items.BEETROOT_SEEDS); list.add(Items.CARROT); list.add(Items.POTATO); return list; case 2: list.add(Item.getItemFromBlock(Blocks.IRON_ORE)); list.add(Item.getItemFromBlock(Blocks.GOLD_ORE)); list.add(Items.COAL); list.add(Items.DIAMOND); case 3: list.add(Item.getItemFromBlock(Blocks.LOG)); list.add(Item.getItemFromBlock(Blocks.SAPLING)); default: return null; } } private void populateBuyingList() { if ((this.careerId != 0) && (this.careerLevel != 0)) { this.careerLevel += 1; } else { this.careerId = (getProfessionForge().getRandomCareer(this.rand) + 1); this.careerLevel = 1; } if (this.buyingList == null) { this.buyingList = new MerchantRecipeList(); } if(this.isMerchant) { this.buyingList.add(new MerchantRecipe(new ItemStack(getCareerTradesMerchant(this.profession)), null, new ItemStack(Items.EMERALD), 0, 10)); }else{ this.buyingList.add(new MerchantRecipe(new ItemStack(randomFoodSource(this.worldObj.rand)), null, new ItemStack(Items.EMERALD), 0, 3)); } int i = this.careerId - 1; int j = this.careerLevel - 1; List<ITradeList> trades = (List<ITradeList>) getProfessionForge().getCareer(i).getTrades(j); if (trades == null) return; for (ITradeList entityvillager$itradelist : trades) { entityvillager$itradelist.modifyMerchantRecipeList(this.buyingList, this.rand); } } protected static Item getCareerTradesMerchant(int i) { switch(i) { case 0: return Items.WHEAT; case 1: return Items.PAPER; case 2: return Items.GOLD_INGOT; case 3: return Items.IRON_INGOT; case 4: return Items.COOKED_BEEF; case 5: return null; default: return Items.DIAMOND; } } protected Item randomFoodSource(Random rand) { int i = rand.nextInt(4); switch(i) { case 0: return Items.BREAD; case 1: return Items.BAKED_POTATO; case 2: return Items.CARROT; default: return Items.BEETROOT; } } @Override public int getJobID() { return this.jobID; } @Override public int getJobExp() { return jobExp[this.jobID]; } @Override public boolean isJobIntialized() { return this.isJobInit; } @Override public void setJobInitialized(boolean i) { this.isJobInit = i; } @Override public void setJobID(int i) { this.jobID = i; } } here is the Interface; package com.ageofempires.mod.gui.entity; import java.util.ArrayList; import net.minecraft.entity.IMerchant; import net.minecraft.entity.player.EntityPlayer; import net.minecraft.item.Item; import net.minecraft.item.ItemStack; import net.minecraft.util.text.ITextComponent; import net.minecraft.village.MerchantRecipe; import net.minecraft.village.MerchantRecipeList; import net.minecraftforge.fml.relauncher.Side; import net.minecraftforge.fml.relauncher.SideOnly; public interface IWorker extends IMerchant{ public abstract void setCustomer(EntityPlayer paramEntityPlayer); public abstract EntityPlayer getCustomer(); public abstract void setJobInitialized(boolean i); public abstract int getJobID(); public abstract void setJobID(int i); public abstract int getJobExp(); public abstract boolean isJobIntialized(); } Here is the GUI class; package com.ageofempires.mod.gui.entity; import java.io.IOException; import net.minecraft.client.gui.GuiButton; import net.minecraft.client.gui.GuiScreen; import net.minecraft.client.gui.inventory.GuiContainer; import net.minecraft.entity.player.InventoryPlayer; import net.minecraft.inventory.ContainerMerchant; import net.minecraft.util.ResourceLocation; import net.minecraft.util.text.ITextComponent; import net.minecraft.util.text.TextComponentString; import net.minecraft.world.World; public class GuiVillagerInitRequest extends GuiScreen { private static final ResourceLocation MERCHANT_INIT_REQ_GUI_TEXTURE = new ResourceLocation( "textures/gui/entity/villagerInitReq.png"); private IWorker worker; public final ITextComponent text; public ITextComponent status; private GuiButton Wood, Mine, Farm, Build; public GuiVillagerInitRequest(IWorker worker, World world) { super(); this.worker = worker; this.text = worker.getDisplayName(); this.status = new TextComponentString("please slect a job you want me to preform."); } @Override public void initGui() { this.Wood = new GuiButton(2, (3/4) * this.width, (3/4) * this.height, "Collect Wood"); this.Mine = new GuiButton(1, (1/4) * this.width, (3/4) * this.height, "Mine Ore"); this.Farm = new GuiButton(0, (3/4) * this.width, (1/4) * this.height, "Farm Crops"); this.Build = new GuiButton(3, (1/4) * this.width, (1/4) * this.height, "Build"); } @Override public void actionPerformed(GuiButton button) throws IOException{ int i = button.id; this.worker.setJobInitialized(false); switch(i) { case 0: this.worker.setJobID(i + 1); this.mc.displayGuiScreen(null); if (this.mc.currentScreen == null) this.mc.setIngameFocus(); case 1: this.worker.setJobID(i + 1); this.mc.displayGuiScreen(null); if (this.mc.currentScreen == null) this.mc.setIngameFocus(); case 2: this.worker.setJobID(i + 1); this.mc.displayGuiScreen(null); if (this.mc.currentScreen == null) this.mc.setIngameFocus(); case 3: this.worker.setJobID(i + 1); this.mc.displayGuiScreen(null); if (this.mc.currentScreen == null) this.mc.setIngameFocus(); default: status.appendText("an error occured, please try again."); return; } } @Override public void drawScreen(int mouseX, int mouseY, float partialTicks) { this.drawDefaultBackground(); super.drawScreen(mouseX, mouseY, partialTicks); } @Override public boolean doesGuiPauseGame() { return false; } }
  3. The interface works similar to IMerchant which helps communicate between an entity and the Gui.
  4. The normal way to call on a GUI seem to be by referring to an ID, which opens an instance of that Gui that has already been declared in the handler. However, my Gui needs an Interface to be passed through the constructor of that Gui. Is there any alternate method to call the Gui so that I can get a chance to pass in my variables?
  5. Ok, thanks. The problem was when I ran the game and looked at the console when I place the block the "Level" follows the value set in the "setDefaultState" method but my other values dont.
  6. I'm working on a water block that acts sort of like flood water so I decided to use BlockFluidFinite for the parent class because it has just what I want. The problem is that I want to add custom properties such as "FLOWSPEED" and "FLOWDIRECTION" along with "LEVEL" in the Parent class. However, the "setDefaultBlockState" method is final. the only thing that I thought I could do at this point was to copy all the code and paste it into my class. That just seemed much to silly and fraut with problems. Any suggestions? Class; package src.IVWeather.block; import java.util.ArrayList; import java.util.Iterator; import java.util.List; import java.util.Random; import com.google.common.base.Predicate; import com.google.common.collect.Iterators; import com.google.common.collect.Maps; import java.util.Map; import java.util.Random; import net.minecraft.block.Block; import net.minecraft.block.material.Material; import net.minecraft.block.properties.IProperty; import net.minecraft.block.properties.PropertyInteger; import net.minecraft.block.state.BlockState; import net.minecraft.block.state.IBlockState; import net.minecraft.entity.Entity; import net.minecraft.init.Blocks; import net.minecraft.item.Item; import net.minecraft.util.AxisAlignedBB; import net.minecraft.util.BlockPos; import net.minecraft.util.EnumFacing; import net.minecraft.util.EnumWorldBlockLayer; import net.minecraft.util.Vec3; import net.minecraft.world.IBlockAccess; import net.minecraft.world.World; import net.minecraftforge.fluids.Fluid; import net.minecraftforge.fluids.FluidRegistry; import net.minecraftforge.fluids.IFluidBlock; import net.minecraftforge.fml.relauncher.Side; import net.minecraftforge.fml.relauncher.SideOnly; import src.IVWeather.*; import src.IVWeather.block.properties.PropertyFloodWater; import src.IVWeather.fluid.IVBlockFluidFinite; import net.minecraft.block.Block; import net.minecraft.block.BlockAir; import net.minecraft.block.BlockLiquid; import net.minecraft.block.BlockStaticLiquid; import net.minecraft.block.material.Material; import net.minecraft.block.properties.IProperty; import net.minecraft.block.properties.PropertyInteger; import net.minecraft.block.state.BlockState; import net.minecraft.block.state.IBlockState; import net.minecraft.client.renderer.EnumFaceDirection; import net.minecraft.creativetab.CreativeTabs; import net.minecraft.init.Blocks; import net.minecraft.item.Item; import net.minecraft.item.ItemStack; import net.minecraft.util.BlockPos; import net.minecraft.util.EnumFacing; import net.minecraft.util.ResourceLocation; import net.minecraft.util.EnumFacing.Plane; import net.minecraft.world.IBlockAccess; import net.minecraft.world.World; import net.minecraftforge.fluids.BlockFluidFinite; import net.minecraftforge.fluids.Fluid; import net.minecraftforge.fluids.IFluidBlock; import net.minecraftforge.fml.common.registry.GameRegistry; import net.minecraft.entity.item.EntityItem; import net.minecraft.block.properties.PropertyEnum; public class BlockRushingWater extends BlockFluidFinite implements IFluidBlock{ public int tick_counter; public static final String name = "IVWFloodWaters"; public static final PropertyEnum FLOWDIRECTION = PropertyEnum.create("flow_dir", EnumFacing.class, EnumFacing.HORIZONTALS); public static final PropertyInteger FLOWSPEED = PropertyInteger.create("flow_speed", 0, 10); public BlockRushingWater(Fluid fluid) { super(fluid, Material.water); this.tickRate = 5; GameRegistry.registerBlock(this, name); setUnlocalizedName(name); setCreativeTab(CreativeTabs.tabBlock); this.setDefaultState(this.blockState.getBaseState().withProperty(LEVEL, Integer.valueOf(0)).withProperty(FLOWDIRECTION, EnumFacing.NORTH).withProperty(FLOWSPEED, Integer.valueOf(0))); } @Override protected BlockState createBlockState() { return new BlockState(this, new IProperty[]{LEVEL, FLOWSPEED, FLOWDIRECTION});// 121 } public boolean canDrain(World world, BlockPos pos) { return true; } public void updateTick(World world, BlockPos pos, IBlockState state, Random rand) { boolean changed = false;// 60 int quantaRemaining = ((Integer)state.getValue(LEVEL)).intValue() + 1;// 61 int prevRemaining = quantaRemaining;// 64 EnumFacing flowDirection = ((EnumFacing) state.getValue(FLOWDIRECTION)); int flowSpeed = ((Integer) state.getValue(FLOWSPEED)).intValue(); System.out.println("Quanta; "+quantaRemaining); System.out.println("flow_Speed; "+flowSpeed); System.out.println(flowDirection); quantaRemaining = this.tryToFlowVerticallyInto(world, pos, quantaRemaining, flowDirection, flowSpeed); if(flowSpeed < 1) { flowDirection = null; } if(quantaRemaining >= 1) {// 67 if(quantaRemaining != prevRemaining) {// 71 changed = true;// 73 if(quantaRemaining == 1) {// 74 world.setBlockState(pos, state.withProperty(LEVEL, Integer.valueOf(quantaRemaining - 1)), 2);// 76 return;// 77 } } else if(quantaRemaining == 1) {// 80 return;// 82 } int lowerthan = quantaRemaining - 1;// 86 int total = quantaRemaining;// 87 int count = 1;// 88 Iterator each = Plane.HORIZONTAL.iterator();// 90 List<BlockPos> open = new ArrayList(); List<BlockPos> water = new ArrayList(); int newQua = quantaRemaining > 1? (quantaRemaining / 2) - (quantaRemaining % 2): quantaRemaining; float size = quantaRemaining / this.quantaPerBlockFloat; if(flowSpeed > 0) { BlockPos flowOff = pos.offset(flowDirection); IBlockState block = world.getBlockState(flowOff); if(world.getBlockState(flowOff).getBlock() == Blocks.air) { quantaRemaining -= newQua; world.setBlockState(pos, this.getDefaultState().withProperty(LEVEL, Integer.valueOf(quantaRemaining)), 2); world.setBlockState(flowOff, this.getDefaultState().withProperty(LEVEL, Integer.valueOf(newQua)).withProperty(FLOWDIRECTION, flowDirection), 2); flowSpeed--; }else if(block.getBlock() == this){ int addTo = (Integer) block.getValue(LEVEL); int all = newQua+ addTo; if(all < this.quantaPerBlock) { world.setBlockState(pos, this.getDefaultState().withProperty(LEVEL, Integer.valueOf(quantaRemaining) - 1), 2); world.setBlockState(flowOff, this.getDefaultState().withProperty(LEVEL, Integer.valueOf(newQua + addTo)).withProperty(FLOWDIRECTION, flowDirection), 2); }else{ int additional = all - this.quantaPerBlock; world.setBlockState(pos, this.getDefaultState().withProperty(LEVEL, Integer.valueOf(quantaRemaining) - 1), 2); world.setBlockState(flowOff, this.getDefaultState().withProperty(LEVEL, Integer.valueOf(this.quantaPerBlock)).withProperty(FLOWDIRECTION, flowDirection), 2); world.setBlockState(flowOff.offset(flowDirection), this.getDefaultState().withProperty(LEVEL, Integer.valueOf(additional)).withProperty(FLOWDIRECTION, flowDirection), 2); } }else{ float totalHard = this.getBlockHardness(world, flowOff) + block.getBlock().getBlockHardness(world, flowOff.offset(flowDirection)); if(size * (flowSpeed / 10) >= totalHard) {//TODO these numbers for how much speed it takes to move a block were kinda arbitrary. make 'em better world.setBlockToAir(flowOff); world.setBlockToAir(flowOff.offset(flowDirection)); } } } while(each.hasNext()) { EnumFacing rem = (EnumFacing)each.next(); BlockPos i$ = pos.offset(rem);// 92 IBlockState state2 = world.getBlockState(i$); if(this.displaceIfPossible(world, i$)) {// 93 world.setBlockToAir(i$);// 94 } int side = this.getQuantaValueBelow(world, i$, lowerthan);// 96 if(side >= 0) {// 97 ++count;// 99 total += side;// 100 } } if(count == 1) {// 104 if(changed) {// 106 world.setBlockState(pos, state.withProperty(LEVEL, Integer.valueOf(quantaRemaining - 1)), 2);// 108 } } else { int div = total / count;// 113 int rem = total % count;// 114 Iterator horPlane = Plane.HORIZONTAL.iterator();// 116 while(true) { BlockPos off; EnumFacing dir; int quanta; int newFlowSpeed; do { if(!horPlane.hasNext()) { if(rem > 0) {// 145 ++div;// 147 } world.setBlockState(pos, state.withProperty(LEVEL, Integer.valueOf(div - 1)), 2);// 149 return;// 150 } dir = (EnumFacing)horPlane.next(); off = pos.offset(dir);// 118 quanta = this.getQuantaValueBelow(world, off, lowerthan);// 119 PropertyFloodWater floodwater = this.getProperty(world, off); } while(quanta < 0);// 120 int newquanta = div;// 122 if(rem == count || rem > 1 && rand.nextInt(count - rem) != 0) {// 123 newquanta = div + 1;// 125 --rem;// 126 } if(newquanta != quanta) {// 129 if(newquanta == 0) {// 131 world.setBlockToAir(off);// 133 } else if(quanta >= 0){ if(flowSpeed < 10) { if(quanta != 0) { world.setBlockState(off, this.getDefaultState().withProperty(LEVEL, Integer.valueOf(newquanta - 1)).withProperty(FLOWSPEED, flowSpeed + (int) quanta != 0 ? newquanta-quanta / quanta: 1).withProperty(FLOWDIRECTION, dir), 2);// 137 }else{ world.setBlockState(off, this.getDefaultState().withProperty(LEVEL, Integer.valueOf(newquanta - 1)).withProperty(FLOWSPEED, flowSpeed + 1).withProperty(FLOWDIRECTION, dir), 2);// 137 } }else{ world.setBlockState(off, this.getDefaultState().withProperty(LEVEL, Integer.valueOf(newquanta - 1))); } } else{ world.setBlockState(off, this.getDefaultState().withProperty(LEVEL, Integer.valueOf(newquanta - 1))); } //TODO i dont like how all this looks in regards to efficiency CLEAN IT UP! world.scheduleUpdate(off, this, this.tickRate);// 139 } --count;// 141 } } } } private PropertyFloodWater getProperty(World world, BlockPos off) { IBlockState state = world.getBlockState(off); if(state.getBlock() == this) { return new PropertyFloodWater((Integer) state.getValue(FLOWSPEED), (EnumFacing) state.getValue(FLOWDIRECTION)); }else { return null; } } public int tryToFlowVerticallyInto(World world, BlockPos pos, int amtToInput, EnumFacing flowDirection2, int flowspeed) { IBlockState myState = world.getBlockState(pos);// 154 BlockPos other = pos.add(0, this.densityDir, 0);// 155 if(other.getY() >= 0 && other.getY() < world.getHeight()) {// 156 int amt = this.getQuantaValueBelow(world, other, this.quantaPerBlock);// 162 if(flowDirection2 != EnumFacing.DOWN && flowspeed < 10) { world.setBlockState(pos, this.getDefaultState().withProperty(FLOWSPEED, Integer.valueOf(flowspeed + 1)), 3);//TODO you really need to figure out what these flags do } if(amt >= 0) {// 163 amt += amtToInput;// 165 if(amt > this.quantaPerBlock) {// 166 world.setBlockState(other, myState.withProperty(LEVEL, Integer.valueOf(this.quantaPerBlock - 1)), 3);// 168 world.scheduleUpdate(other, this, this.tickRate);// 169 return amt - this.quantaPerBlock;// 170 } else if(amt > 0) {// 172 world.setBlockState(other, myState.withProperty(LEVEL, Integer.valueOf(amt - 1)), 3);// 174 world.scheduleUpdate(other, this, this.tickRate);// 175 world.setBlockToAir(pos);// 176 return 0;// 177 } else { return amtToInput;// 179 } } else { int density_other = getDensity(world, other);// 183 if(density_other == Integer.MAX_VALUE) {// 184 if(this.displaceIfPossible(world, other)) {// 186 world.setBlockState(other, myState.withProperty(LEVEL, Integer.valueOf(amtToInput - 1)), 3);// 188 world.scheduleUpdate(other, this, this.tickRate);// 189 world.setBlockToAir(pos);// 190 return 0;// 191 } else { return amtToInput;// 195 } } else { IBlockState state; if(this.densityDir < 0) {// 199 if(density_other < this.density) {// 201 state = world.getBlockState(other);// 203 world.setBlockState(other, myState.withProperty(LEVEL, Integer.valueOf(amtToInput - 1)), 3);// 204 world.setBlockState(pos, state, 3);// 205 world.scheduleUpdate(other, this, this.tickRate);// 206 world.scheduleUpdate(pos, state.getBlock(), state.getBlock().tickRate(world));// 207 return 0;// 208 } } else if(density_other > this.density) {// 213 state = world.getBlockState(other);// 215 world.setBlockState(other, myState.withProperty(LEVEL, Integer.valueOf(amtToInput - 1)), 3);// 216 world.setBlockState(other, state, 3);// 217 world.scheduleUpdate(other, this, this.tickRate);// 218 world.scheduleUpdate(other, state.getBlock(), state.getBlock().tickRate(world));// 219 return 0;// 220 } return amtToInput;// 223 } } } else { world.setBlockToAir(pos);// 158 return 0;// 159 } } public String getName() { return name; } }
  7. it seems that a lot has changed since 1.8.0, before updating my mod had no error however, now many registries, some variables and other things are missing such as textureName, and even "world" object does not seem to work. Am I doing anything wrong with my environment or is my mod outdated?
  8. In my mod i need to be able to load an unload these Chunks of Chunks essentially. The 'chunk-chunks' contain 4096 objects that hold the variables that represent different surface temperatures and such for each minecraft chunk. So that when a function need say the percentage of the surface of a certain chunk covered in water block, surface temperature (which is defined by time of year and light level) it will be able to call on one of the "chunks". The problem is i don't know how to load and unload each of the chunk-chunks at any given time. Holding them all in the computers memory is completely absurd. How will i be able to call the nbt that I need if one of these chunk-chunks come into render distance.
  9. Microsoft may have some pressure to not demolish the modding community, most people who play minecraft have used mods and like them. Without mods mc would have lost its momentum much faster and died out already. They may do away with java mine-craft witch would suck. (although there might be a way to update through java independent of the original updates maybe?)
  10. What I want to know is why Mojang/Microsoft bothered to make a completely new branch of Minecraft for just one of a long string of windows versions. Although Microsoft probably did this for win10 promo, how will this affect modding, and vanilla?
  11. I have a mod where for each chunk there are a set of variables that go with it, i.e surfaceTemp, absolute humidity, water exposed to sun ect. It would be silly and inefficient to add these to the chunk class itself through a core-mod so i made my own class that is very small and just hold those vars for a particular coordinates. package src.IVWeather.util; import java.util.ArrayList; import java.util.List; import net.minecraft.block.Block; import net.minecraft.entity.Entity; import net.minecraft.init.Blocks; import net.minecraft.util.MathHelper; import net.minecraft.world.World; import net.minecraft.world.biome.*; import net.minecraft.world.chunk.Chunk; import src.IVWeather.entity.*; public class IVChunkDefinition{ public int positionX; public int positionZ; public float surfaceTemp; public float absoluteHumidity; public float relativeHumidity; public int exposedWSurface; public double exposedDirectSunlight; public double evaporationRate; public Chunk chunk; private boolean[] canSeeArray = new boolean[4096]; public float kilogramsOfWater; public boolean needUpdate; private int ID; public IVChunkDefinition() { } public IVChunkDefinition(int x, int z) { positionX = x; positionZ = z; } BiomeGenBase bgb; private double evaporationTick; public boolean[] getCanSeeArray() { return canSeeArray; } private float biomeDefaultRHumidity(BiomeGenBase biome) { if(biome instanceof BiomeGenDesert | biome instanceof BiomeGenSnow | biome instanceof BiomeGenMesa) { return 25f; }else if(biome instanceof BiomeGenForest){ return 75; }else if(biome instanceof BiomeGenPlains){ return 75; }else if(biome instanceof BiomeGenJungle){ return 90; }else if(biome instanceof BiomeGenTaiga){ return 50; }else if(biome instanceof BiomeGenHills){ return 70; }else if(biome instanceof BiomeGenRiver | biome instanceof BiomeGenOcean | biome instanceof BiomeGenBeach){ return 90; }else if(biome instanceof BiomeGenSavanna){ return 50; }else{ return 75; } } public boolean check(World world, Chunk chunk) { this.chunk = chunk; int y = chunk.getTopFilledSegment(); for(int f = 1; f < 16; f++) { for(int z = 1; z < 16; z++) { for(int y2 = 1; y2 < y; y2++) { if(chunk.canBlockSeeTheSky(f, y2, z)) { if(chunk.getBlock(f, y2, z) == Blocks.water) { this.exposedWSurface++; }else{ this.canSeeArray[f * y2 * z] = true; } if(chunk.getBlock(f, y2, z) == null) { return false; } } } } } return true; } public double updateWaterValue(BiomeGenBase bgb, int timeSinceRain, boolean isDayTime, Block topblock, float airTemp) { if(bgb == BiomeGenBase.ocean) { return 100; }else if(timeSinceRain <= 0){ return 100; }else if(isDayTime == true){ double pws = BiomeTemperature.maxSaturationPressureWV(this.surfaceTemp); double Xs = BiomeTemperature.ratioOfTheComplexHumidityThing((5f/9f) * (this.surfaceTemp - 32f) + 273f); double X = kilogramsOfWater / (1.293 - kilogramsOfWater); double O; List listlist = new ArrayList(); if(isEntityPresent(listlist)) { for(int u = 0; u < listlist.size(); u++) { EntityWeatherParcel ewp = (EntityWeatherParcel) listlist.get(u); O = ewp.getVelocity() * 20; this.evaporationRate = (O * this.exposedWSurface) * (Xs - X); } }else{ this.evaporationRate = this.exposedWSurface * (Xs - X); } this.evaporationTick = (this.evaporationRate / Math.pow(60, 2)) / 20; return this.evaporationTick; } return 0; } public boolean isEntityPresent(List par3list) { boolean istrue = false; for (int k = 0; k <= 16; k++) { List list1 = this.chunk.entityLists[k]; for (int l = 0; l < list1.size(); l++) { Entity entity1 = (Entity)list1.get(l); if(entity1 instanceof EntityWeatherParcel) { par3list.add(entity1); istrue = true; } } } return istrue; } } How would i go about getting the chunks from their coordinates? I tried to look in vanilla decompilations for answers but it just had some interface and a blank method for creating one and i looked in many other related classes with no avail. I you know how to do this, I would appreciate your help, Thanks.
  12. I want to keep track of the days-for the purpose of weather cycles and such. I cant do a tickHandler because that would be loop-holey and going to bed at night would make the mod think it's night and Minecraft know it's day. Thank you in advance
  13. i looked in the tutorials and tried to find how to save Lists and Objects to NBTs but i could not find how to do that.
  14. What i'm trying to do is create a List of the loaded biomes in that world as well as a list of all the loaded biomes inside the player(s) render distance. So what did was create an event class that uses the Chunk.Load event and find new biomes. CLASS; package src.IVWeather.sideWorldHandlers; import java.util.ArrayList; import java.util.List; import src.IVWeather.biome.BiomeTemperatureIndex; import src.IVWeather.entity.EntityWeatherAirmass; import cpw.mods.fml.common.eventhandler.SubscribeEvent; import net.minecraft.entity.passive.EntityChicken; import net.minecraft.entity.player.EntityPlayer; import net.minecraft.util.ChatComponentText; import net.minecraft.util.IChatComponent; import net.minecraft.world.World; import net.minecraft.world.biome.BiomeCache; import net.minecraft.world.biome.BiomeGenBase; import net.minecraft.world.chunk.Chunk; import net.minecraftforge.client.event.RenderGameOverlayEvent.Chat; import net.minecraftforge.event.terraingen.BiomeEvent; import net.minecraftforge.event.world.ChunkEvent; import net.minecraftforge.event.world.ChunkEvent.Load; public class ChunkLoadHandler { public List LoadedBiomes = new ArrayList(); public ChunkLoadHandler() { super(); } Chunk chunk; World worldObj; @SubscribeEvent public void eventSpawnAirmassOnLoad(ChunkEvent.Load event) { int blockX = event.getChunk().xPosition << 4; int blockZ = event.getChunk().zPosition << 4; BiomeGenBase bgb = event.world.getBiomeGenForCoords(blockX, blockZ); BiomeGenBase bgb1; System.out.println(bgb.getClass().getName()); if(LoadedBiomes.size() == 0) { this.LoadedBiomes.add(bgb); System.out.println("ADDED BIOME TO LOAD LIST"); }else{ for(int w = 0; w < this.LoadedBiomes.size(); w++) { BiomeGenBase iLikeFire = (BiomeGenBase) LoadedBiomes.get(w); if(iLikeFire != bgb) { this.LoadedBiomes.add(bgb); System.out.println("ADDED BIOME TO LOAD LIST"); } } } } } This causes noticeable lag in the world and I would like to do something to reduce the lag. Thank You for reading
  15. I'm having trouble with the method that i was using getEntitiesWithinAABBExludingEntity. What I want is to get really not if the posX posY posZ location of an entity that is in my bounding box but when the two are colliding. AND the target entity is of the same class as my entity. Thank you for reading.
  16. when i print out the Bounding Box's minX or maxX ect. it prints out something like 1 or -1 it it supposed to do that or printig out the world coords of the owners location. Because i have been having problems of late with the world method getEntitiesWithinAABBExcludingEntity(this, this.boundingBox); I want to receive a list of entities within my entities BoundingBox and compare the variables. Should I modify the boundingbox, if not what should I do. Thank You,
  17. I am trying to get the entities within the target entity of the same type to compare variables to affect gameplay I know for a fact there are other entities within it bounding box yet not printing the message n the ide console. this is my code package src.IVWeather.entity; import java.util.List; import src.IVWeather.biome.BiomeTemperature; import src.IVWeather.block.BlockFlyingBlock; import net.minecraft.block.Block; import net.minecraft.block.material.Material; import net.minecraft.entity.Entity; import net.minecraft.entity.effect.EntityWeatherEffect; import net.minecraft.entity.player.EntityPlayer; import net.minecraft.init.Blocks; import net.minecraft.nbt.NBTTagCompound; import net.minecraft.util.AxisAlignedBB; import net.minecraft.util.MathHelper; import net.minecraft.world.World; import net.minecraft.world.biome.BiomeDecorator; import net.minecraft.world.biome.BiomeGenBase; import net.minecraft.world.chunk.Chunk; import src.IVWeather.*; public class EntityWeatherAirmass extends WeatherEntity{ public Vaccume vaccum; public float temperature; public float maxGramsOfWaterHoldable; public float currentGramsOfWaterInAir; BiomeTemperature BiomeTemp; public float evaporationrate; public float dewpoint; int time; double droplesize; boolean rainProcess; double yboundingBoxERatePerTick; public boolean eventFlag; List precipitationCunkList; public BiomeTemperature bt; protected double GreaterTemp; protected TempCategory tc; public EntityWeatherAirmass(World thisworld) { super(thisworld); } public TempCategory getTempCategory() { return tc; } public EntityWeatherAirmass(World arg0, float par1, double x, double z, double ddY, float setx, float setz) { super(arg0); this.setSize(setx, setz); this.temperature = par1; this.currentGramsOfWaterInAir = evaporationrate; this.maxGramsOfWaterHoldable = .1580888888888888f * (temperature * 50); this.humidity = (this.currentGramsOfWaterInAir * 100) / this.maxGramsOfWaterHoldable; int time = 0; droplesize = 0; this.posX = x; this.posZ = z; this.posY = ddY; this.CyclePeriod = IVWeather.startCycle; } public float gethumidity() { return humidity; } public boolean canBeCollidedWith() { return true; } boolean flerg; private List collidingBoundingWeather; public float AverageHighLow; public float CycleExtremeityMaxT; public int CyclePeriod; private boolean Active; private boolean Declining; public boolean cycloneFlag; public void onUpdate() { System.out.println("UPDATING AIRMASS;"); AxisAlignedBB boundingBox = this.boundingBox; BiomeGenBase Biom = worldObj.getBiomeGenForCoords((int)Math.floor(this.posX), (int)Math.floor(this.posZ)); if (IVWeather.Seasonalchanges) { System.out.println("SesonalChanges Accepted"); this.AverageHighLow = (Biom.temperature + 0.4F); if (this.AverageHighLow > 2.0F) { this.AverageHighLow = 2.0F; System.out.println("Too high Average High-Low Temp, Reseting to 2.0"); } this.CycleExtremeityMaxT = (Biom.temperature + 0.6F); if (this.CycleExtremeityMaxT > 2.1F) { this.CycleExtremeityMaxT = 2.1F; System.out.println("Maximum Temps too High, Reseting to 2.1"); } float par1; if (IVWeather.Fluc) { System.out.println("Fluc Accepted"); par1 = (this.CycleExtremeityMaxT - Biom.temperature) / IVWeather.WeatherPatternMaxD; } else { par1 = this.AverageHighLow; if (this.CyclePeriod == 1) { par1 = this.AverageHighLow; } else { par1 = -this.AverageHighLow; } } if ((this.CyclePeriod == 1) && (this.Active == true)) { Biom.temperature += par1; System.out.println("Cycle Active; Warm Cycle"); } if ((this.CyclePeriod == 2) && (!this.Declining) && (this.Active == true)) { Biom.temperature += par1; System.out.println("Cycle Active; Cold Cycle"); } if ((Biom.temperature == this.CycleExtremeityMaxT) || (Biom.temperature == -this.CycleExtremeityMaxT)) { this.Declining = true; System.out.println("Now Declining"); } else { this.Declining = false; } if ((this.Declining == true) && (this.Active == true)) { this.CycleExtremeityMaxT -= par1; } }else{ System.out.println("SeasonalChanges Declined"); } double prevPosY = this.posY; double cbiomeTemp = Biom.temperature; List BlockList = this.collidingBoundingWeather; List iiiiiii = this.collidingBoundingWeather; if(BlockList != null) { BlockList.clear(); } if(iiiiiii != null) { iiiiiii.clear(); } double d0 = .25; List list = worldObj.getEntitiesWithinAABBExcludingEntity(this, this.boundingBox.expand(d0, d0, d0)); if(list !=null) { System.out.println("list is not null"); } for (int j2 = 0; j2 < list.size(); j2++) { Entity entity = ((Entity)list.get(j2)); if(entity instanceof EntityWeatherAirmass){ System.out.println("Adding entity to list"); iiiiiii.add(entity); } double prevY = this.posY; double prevMY= this.boundingBox.maxY; if(iiiiiii != null) { System.out.println("List located Other Airmasses"); for(int u =0; u < iiiiiii.size(); u++) { EntityWeatherAirmass e = (EntityWeatherAirmass) iiiiiii.get(u); this.GreaterTemp = this.temperature - e.temperature; if(!cycloneFlag) { if(e.temperature < this.temperature){ tc = TempCategory.WARM; System.out.println("now WARM"); }else if(e.temperature > this.temperature){ tc = TempCategory.COLD; System.out.println("now COLD"); }else if(this.temperature > e.temperature && this.humidity < e.humidity) { tc = TempCategory.HOT; System.out.println("now HOT"); } } boolean eAirMassTSupport = false; boolean thisAirMassTSupport = false; double distance = 0; double distance2 = 0; distance = Math.abs(this.temperature - cbiomeTemp); distance2 = Math.abs(e.temperature - cbiomeTemp); if(distance > distance2) { thisAirMassTSupport = true; System.out.println("recievving t-support"); } if(tc == TempCategory.WARM) { if(thisAirMassTSupport){ this.boundingBox.expand(0, this.temperature - cbiomeTemp + 4, 0); System.out.println("Expanding"); } else { this.motionY = ((this.temperature - e.temperature) / 4); } } if(tc == TempCategory.COLD) { if(this.getCollidingBlockWithWE(this, this.boundingBox).size() < 150 && this.boundingBox.minX <= 55) { this.motionY = ((this.temperature - e.temperature) / 4); } } if(tc == TempCategory.HOT) { this.motionY = ((this.temperature - e.temperature) / 3); if(e.humidity - this.humidity > this.humidity + (this.humidity / 6)) { flerg = true; } } if(flerg == true) { this.humidity = this.humidity + (float) .001; } if(list.size() == 0) { if(this.temperature > cbiomeTemp) { tc = TempCategory.WARM; }else{ tc = TempCategory.COLD; } this.boundingBox.expand(15, 0, 15); if(this.boundingBox.maxY < 3000) { this.boundingBox.expand(0, 15, 0); if(tc == TempCategory.WARM && this.boundingBox.maxY > (Biom.temperature - (this.boundingBox.maxY / 700))) { } } } this.evaporationrate = (float) (Biom.temperature); this.currentGramsOfWaterInAir = maxGramsOfWaterHoldable / evaporationrate; this.maxGramsOfWaterHoldable = .1580888888888888f * (temperature * 50); this.humidity = (this.currentGramsOfWaterInAir * 100) / this.maxGramsOfWaterHoldable; dewpoint = bt.getDewPoint(humidity, this.temperature); yboundingBoxERatePerTick = prevMY - prevY; if(this.temperature <= dewpoint) { this.rainProcess = true; if(droplesize <= 0) { droplesize = .0000000001; } droplesize = droplesize * time; int gravity = 18000; if(droplesize > (gravity + (this.yboundingBoxERatePerTick ) * 2.) { double maxx = this.boundingBox.maxX; double minx = this.boundingBox.minX; double maxz = this.boundingBox.maxZ; double minz = this.boundingBox.minZ; for(int o = (int) minx; o < maxx; o++) { for(int p = (int) minz; p < maxz; p++) { Chunk C = worldObj.getChunkFromBlockCoords(o, p); this.precipitationCunkList.clear(); this.precipitationCunkList.add(C); if(this.precipitationCunkList != null) { System.out.println("Precipitation"); }else{ System.out.println("No Rain List"); } } } } } double velocity = (this.motionX + this.motionY + this.motionZ )/3; if(this.humidity < e.humidity) { this.humidity = this.humidity + ((e.humidity - this.humidity)/50); }else if(this.humidity < bt.getBiomeTemp(Biom)) { this.humidity = this.humidity + ((e.humidity - bt.getBiomeTemp(Biom))/50); } } }else{ System.err.println("No Airmasses found"); this.motionY = Biom.temperature - this.temperature; } } } protected void entityInit() { } public List collidingAirmasses(EntityWeatherAirmass ewa) { List list = this.collidingBoundingWeather; list.clear(); int i = MathHelper.floor_double(ewa.posX + this.boundingBox.minX); int j = MathHelper.floor_double(ewa.posX + this.boundingBox.maxX + 1.0D); int k = MathHelper.floor_double(ewa.posY + this.boundingBox.minY); int l = MathHelper.floor_double(ewa.posY + this.boundingBox.maxY + 1.0D); int i1 = MathHelper.floor_double(ewa.posZ + this.boundingBox.minZ); int j1 = MathHelper.floor_double(ewa.posX + this.boundingBox.maxZ + 1.0D); double d0 = 0.25D; System.out.println(i); System.out.println(j); System.out.println(k); System.out.println(l); System.out.println(i1); System.out.println(j1); for(int q = i; q < j; q++) { for(int w = k; k < l; k++) { for(int f = i1; f < j1; f++) { Block block = worldObj.getBlock(q, w, f); List list2 = worldObj.getEntitiesWithinAABBExcludingEntity(this, this.boundingBox.expand(d0, d0, d0)); for (int j2 = 0; j2 < list2.size(); j2++) { Entity entity = ((Entity)list2.get(j2)); if(entity instanceof EntityWeatherAirmass){ list.add(entity); } } } } } return list; } @Override protected void readEntityFromNBT(NBTTagCompound arg0) { } @Override protected void writeEntityToNBT(NBTTagCompound arg0) { // TODO Auto-generated method stub } public enum TempCategory { WARM, COLD, HOT, COOL; } } thank you for reading.
  18. I there a tutorial or anything like that because i am having difficulties trying to do this.
  19. I've never worked with this event before, sorry. I dont like random stuff that much. But that i do not know but i do know that you can but some registery is involved hence; public static enum EventType { BIG_SHROOM, CACTUS, CLAY, DEAD_BUSH, LILYPAD, FLOWERS, GRASS, LAKE, PUMPKIN, REED, SAND, SAND_PASS2, SHROOM, TREE, CUSTOM // < that; private EventType() {} }
  20. What i want to due it very simple, or at least i think. I want to save a series of ints in a file and save it to a world so that when that world loads it loads the file and reads the integers inscribes on it. How would I do that. Thank you,
  21. I realize you must be frustrated, but do you have anything to show us there is nothing i know that this would happen except for messing with forge base files. Otherwise, i'm very afraid we cannot help you
  22. I now have no clue as to the nature of this crash
×
×
  • Create New...

Important Information

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