
EmperorZelos
Members-
Posts
148 -
Joined
-
Last visited
Everything posted by EmperorZelos
-
All entities have a coordinate that they are on, my question is when it comes to mobs. Where is their X, Y, Z position located relative to the model? Is it squirely in the center, at the center horisontally but at the bottom? or maybe top?
-
Shall be provided! Container package aerosteam.container; import cpw.mods.fml.relauncher.Side; import cpw.mods.fml.relauncher.SideOnly; import aerosteam.crafting.AnvilSmithManager; import aerosteam.items.ItemsAS; import aerosteam.tileentity.TileEntityAnvil; import aerosteam.tileentity.TileEntitySmelter; import net.minecraft.entity.player.EntityPlayer; import net.minecraft.entity.player.InventoryPlayer; import net.minecraft.inventory.Container; import net.minecraft.inventory.ICrafting; import net.minecraft.inventory.IInventory; import net.minecraft.inventory.InventoryCraftResult; import net.minecraft.inventory.InventoryCrafting; import net.minecraft.inventory.Slot; import net.minecraft.inventory.SlotCrafting; import net.minecraft.inventory.SlotFurnace; import net.minecraft.item.Item; import net.minecraft.item.ItemStack; import net.minecraft.item.crafting.FurnaceRecipes; import net.minecraft.tileentity.TileEntityFurnace; import net.minecraft.world.World; public class ContainerAnvil extends Container { private TileEntityAnvil anvil; private World worldObj; private int posX; private int posY; private int posZ; public InventoryCrafting craftMatrix; public IInventory craftResult; public ContainerAnvil(InventoryPlayer inventory,TileEntityAnvil tileentity, World world, int x, int y, int z){ this.anvil=tileentity; craftMatrix = new InventoryCrafting(this, 2,3); craftResult = new InventoryCraftResult(); worldObj=world; this.posX=x; this.posY=y; this.posZ=z; //Hammer slot this.addSlotToContainer(new Slot(tileentity,0,116,13)); for (int i = 0; i<2;i++){ for (int j = 0; j<3;j++){ this.addSlotToContainer(new Slot(craftMatrix,(i*3+j),21+18*j,33+18*i)); } } this.addSlotToContainer(new AnvilSlots(inventory.player, craftMatrix,craftResult, 1,136,42)); for(int i=0; i<3;i++){ for(int j=0; j<9;j++){ this.addSlotToContainer(new Slot(inventory,j+i*9+9,7+18*j+1,83+18*i+1 )); } } for(int i=0;i<9;i++){ this.addSlotToContainer(new Slot(inventory,i,8+18*i,142)); } onCraftMatrixChanged(craftMatrix); } public void onCraftMatrixChanged(IInventory inventory){ //System.out.println("Craft Change"); Slot slot = (Slot)this.inventorySlots.get(0); if (slot != null && slot.getHasStack()){ Item item = slot.getStack().getItem(); if (slot.getStack().getItem() != null){ if (slot.getStack().getItem() == ItemsAS.hammerBronze){ //System.out.println("has hammer"); craftResult.setInventorySlotContents(7, AnvilSmithManager.getInstance().findMatchingRecipe(craftMatrix,worldObj)); } } } //System.out.println("Done matching"); } @Override public boolean canInteractWith(EntityPlayer player) { return player.getDistanceSq((double)posX +0.5D, (double)posY+0.5D, (double)posZ+0.5D)<64.0D; } public void addCraftingToCrafter (ICrafting icraft){ super.addCraftingToCrafters(icraft); //icraft.sendProgressBarUpdate(this, 0, this.anvil.cookTime); } public void detectAndSendChanges (){ super.detectAndSendChanges(); for (int i=0; i<this.crafters.size();i++){ ICrafting icraft = (ICrafting) this.crafters.get(i); //if(this.lastCookTime != this.anvil.cookTime){ //icraft.sendProgressBarUpdate(this, 0, this.anvil.burnTime); //} } //this.lastCookTime = this.smelter.cookTime; } @SideOnly(Side.CLIENT) public void updateProgressBar (int slot, int newValue) { //if (slot==0) this.anvil.burnTime=newValue; } public ItemStack transferStackInSlot(EntityPlayer player, int i) { ItemStack itemstack = null; Slot slot = (Slot)this.inventorySlots.get(i); if (slot != null && slot.getHasStack()) { ItemStack itemstack1 = slot.getStack(); itemstack = itemstack1.copy(); if (i == 3) { if (!this.mergeItemStack(itemstack1, 4, 39, true)) { return null; } slot.onSlotChange(itemstack1, itemstack); } else if (i != 1 && i != 0 && i != 2) { if (FurnaceRecipes.smelting().getSmeltingResult(itemstack1) != null) { if (!this.mergeItemStack(itemstack1, 1, 2, false)) { return null; } } else if (TileEntityFurnace.isItemFuel(itemstack1)) { if (!this.mergeItemStack(itemstack1, 0, 3, false)) { return null; } } else if (i >= 3 && i < 30) { if (!this.mergeItemStack(itemstack1, 30, 39, false)) { return null; } } else if (i >= 30 && i < 39 && !this.mergeItemStack(itemstack1, 4, 30, false)) { return null; } } else if (!this.mergeItemStack(itemstack1, 4, 39, false)) { return null; } if (itemstack1.stackSize == 0) { slot.putStack((ItemStack)null); } else { slot.onSlotChanged(); } if (itemstack1.stackSize == itemstack.stackSize) { return null; } slot.onPickupFromSlot(player, itemstack1); } return itemstack; } public void onContainerClosed(EntityPlayer p_75134_1_) { super.onContainerClosed(p_75134_1_); if (!this.worldObj.isRemote) { for (int i = 0; i < 6; ++i) { ItemStack itemstack = this.craftMatrix.getStackInSlotOnClosing(i); if (itemstack != null) { p_75134_1_.dropPlayerItemWithRandomChoice(itemstack, false); } } } } } Gui: package aerosteam.gui; import org.lwjgl.opengl.GL11; import aerosteam.AeroSteam; import aerosteam.tileentity.TileEntityAnvil; import aerosteam.tileentity.TileEntitySmelter; import aerosteam.container.ContainerAnvil; import aerosteam.container.ContainerSmelter; import net.minecraft.client.Minecraft; import net.minecraft.client.gui.inventory.GuiContainer; import net.minecraft.client.resources.I18n; import net.minecraft.entity.player.InventoryPlayer; import net.minecraft.inventory.Container; import net.minecraft.util.ResourceLocation; public class GuiAnvil extends GuiContainer{ public static final ResourceLocation bground=new ResourceLocation(AeroSteam.MODID + ":" + "textures/gui/Anvil.png"); public TileEntityAnvil anvil; public GuiAnvil(InventoryPlayer inventoryPlayer,TileEntityAnvil entity, int x, int y, int z) { super(new ContainerAnvil(inventoryPlayer,entity,entity.getWorldObj(), x,y,z)); this.anvil=entity; this.xSize=176; this.ySize=166; } private static Container ContainerAbil(InventoryPlayer inventoryPlayer, TileEntityAnvil entity) { // TODO Auto-generated method stub return null; } public void drawGuiContainerForegroundLayer(int x, int y){ String name="Anvil"; //String name=this.smelter.hasCustomInventoryName() ? this.smelter.getInventoryName():I18n.format(this.smelter.getInventoryName(),new Object[0]); this.fontRendererObj.drawString(name, this.xSize/2-this.fontRendererObj.getStringWidth(name)/2, 4, 4210752); this.fontRendererObj.drawString(I18n.format("container.inventory",new Object[0]),120,this.ySize-96+2,4210752); } @Override protected void drawGuiContainerBackgroundLayer(float var1,int var2, int var3) { GL11.glColor4f(1F,1F,1F,1F); Minecraft.getMinecraft().getTextureManager().bindTexture(bground); drawTexturedModalRect(guiLeft,guiTop,0,0,this.xSize,this.ySize); /*if(this.smelter.isBurning()){ this.fontRendererObj.drawString("true", this.xSize/2+40, this.ySize-96+2, 4210752); }else{ int shit = this.smelter.burnTime; this.fontRendererObj.drawString("false:" + String.valueOf(shit) , this.xSize/2+40, this.ySize-96+2, 4210752); }*/ /*if(this.anvil.isBurning()){ int k=this.smelter.getBurnTimeRemainingScaled(14); drawTexturedModalRect(guiLeft+35, guiTop+40+14-k, 176, 28+14-k, 14 , k); } int i=this.smelter.getCookProgressScaled(26); drawTexturedModalRect(guiLeft+81, guiTop+19, 177, 42, 18 , i);*/ } } Gui Handler: package aerosteam.handler; import aerosteam.AeroSteam; import aerosteam.container.ContainerAnvil; import aerosteam.container.ContainerBarrel; import aerosteam.container.ContainerBoiler; import aerosteam.container.ContainerGrinder; import aerosteam.container.ContainerMelter; import aerosteam.container.ContainerSmelter; import aerosteam.container.ContainerWoodenFurnace; import aerosteam.gui.GuiAnvil; import aerosteam.gui.GuiBarrel; import aerosteam.gui.GuiBoiler; import aerosteam.gui.GuiGrinder; import aerosteam.gui.GuiMelter; import aerosteam.gui.GuiSmelter; import aerosteam.gui.GuiWoodenFurnace; import aerosteam.tileentity.TileEntityAnvil; import aerosteam.tileentity.TileEntityBarrel; import aerosteam.tileentity.TileEntityBoiler; import aerosteam.tileentity.TileEntityGrinder; import aerosteam.tileentity.TileEntityMelter; import aerosteam.tileentity.TileEntitySmelter; import aerosteam.tileentity.TileEntityWoodenFurnace; import net.minecraft.entity.player.EntityPlayer; import net.minecraft.tileentity.TileEntity; import net.minecraft.world.World; import cpw.mods.fml.common.network.IGuiHandler; public class GuiHandler implements IGuiHandler { @Override public Object getServerGuiElement(int ID, EntityPlayer player, World world, int x, int y, int z) { TileEntity entity=world.getTileEntity(x, y, z); if (entity != null){ switch (ID){ case AeroSteam.guiIDSmelter: if(entity instanceof TileEntitySmelter){ return new ContainerSmelter(player.inventory,(TileEntitySmelter) entity); } case AeroSteam.guiIDMelter: if(entity instanceof TileEntityMelter){ return new ContainerMelter(player.inventory,(TileEntityMelter) entity); } case AeroSteam.guiIDBoiler: if(entity instanceof TileEntityBoiler){ return new ContainerBoiler(player.inventory,(TileEntityBoiler) entity); } case AeroSteam.guiIDBarrel: if(entity instanceof TileEntityBarrel){ return new ContainerBarrel(player.inventory,(TileEntityBarrel) entity); } case AeroSteam.guiIDAnvilBronze: if(entity instanceof TileEntityAnvil){ return new ContainerAnvil(player.inventory,(TileEntityAnvil) entity, world, x, y, z); } case AeroSteam.guiIDGrinder: if(entity instanceof TileEntityGrinder){ return new ContainerGrinder(player.inventory,(TileEntityGrinder) entity); } case AeroSteam.guiIDWoodenFurnace: if(entity instanceof TileEntityWoodenFurnace){ return new ContainerWoodenFurnace(player.inventory,(TileEntityWoodenFurnace) entity); } } } return null; } @Override public Object getClientGuiElement(int ID, EntityPlayer player, World world, int x, int y, int z) { TileEntity entity=world.getTileEntity(x, y, z); if (entity != null){ switch (ID){ case AeroSteam.guiIDSmelter: if(entity instanceof TileEntitySmelter){ return new GuiSmelter(player.inventory,(TileEntitySmelter) entity); } case AeroSteam.guiIDMelter: if(entity instanceof TileEntityMelter){ return new GuiMelter(player.inventory,(TileEntityMelter) entity); } case AeroSteam.guiIDBoiler: if(entity instanceof TileEntityBoiler){ return new GuiBoiler(player.inventory,(TileEntityBoiler) entity); } case AeroSteam.guiIDBarrel: if(entity instanceof TileEntityBarrel){ return new GuiBarrel(player.inventory,(TileEntityBarrel) entity); } case AeroSteam.guiIDAnvilBronze: if(entity instanceof TileEntityAnvil){ return new GuiAnvil(player.inventory,(TileEntityAnvil) entity, x, y, z); } case AeroSteam.guiIDGrinder: if(entity instanceof TileEntityGrinder){ return new GuiGrinder(player.inventory,(TileEntityGrinder) entity); } case AeroSteam.guiIDWoodenFurnace: if(entity instanceof TileEntityWoodenFurnace){ return new GuiWoodenFurnace(player.inventory,(TileEntityWoodenFurnace) entity); } } } return null; } }
-
I work on my crafting table and I get it to produce anything I so want but none of the resources are being removed, I am a bit stumped and don't even know where to look in the code. Got any hints what part could be the culprit? I got a container for it, dedicated manager for the custom recipies for it and such, I am not sure which code would give you the correct information so do tell what would help you get an idea and I'll gladly post it, as it is a bit much of code I don't post it all right now.
-
[1.7.10] Compiling the mod but not all textures
EmperorZelos replied to EmperorZelos's topic in Modder Support
I did, it seems to be correlated to what DB07 said which I find odd that Eclipse can run it but the builder fails then, peculiar -
[1.7.10] Compiling the mod but not all textures
EmperorZelos replied to EmperorZelos's topic in Modder Support
Yes good sir -
I try to compile the mod for some to test but some of the art does not appear. when I play it in my modding it all appears perfectly fine but when I compile it and run it in normal minecraft it does not, what could cause this? I have it all in \forge\src\main\resources\assets\modID when i do compile it and I can see that the stuff is in there.
-
I am working on making a lamp running on gas, I got 1 for it being inactive that has no light level, and I got 1 for when it is on with light level. But when it renders I get no light spreading, I have checked it so it says "Light level 15" package aerosteam.blocks; import aerosteam.AeroSteam; import aerosteam.items.ItemsAS; import aerosteam.tileentity.TileEntityFirePlace; import aerosteam.tileentity.TileEntityGasLamp; import cpw.mods.fml.relauncher.Side; import cpw.mods.fml.relauncher.SideOnly; import java.util.Random; import net.minecraft.block.Block; import net.minecraft.block.ITileEntityProvider; import net.minecraft.block.material.Material; import net.minecraft.client.renderer.texture.IIconRegister; import net.minecraft.creativetab.CreativeTabs; import net.minecraft.entity.player.EntityPlayer; import net.minecraft.init.Blocks; import net.minecraft.tileentity.TileEntity; import net.minecraft.util.AxisAlignedBB; import net.minecraft.util.MovingObjectPosition; import net.minecraft.util.Vec3; import net.minecraft.world.World; import static net.minecraftforge.common.util.ForgeDirection.*; public class DeviceGasLamp extends Block implements ITileEntityProvider { private static final String __OBFID = "CL_00000325"; public boolean isActive; private static boolean keepInventory; public DeviceGasLamp(boolean active) { super(Material.circuits); this.setTickRandomly(true); System.out.println("state is: " + active); if (active){ this.setLightLevel(1F); System.out.println("light1"); } if (!active){ this.setCreativeTab(AeroSteam.aeroTab); }else{ this.setLightLevel(1F); this.setCreativeTab(AeroSteam.aeroTab); System.out.println("light2"); } this.isActive=active; System.out.println("light at: " + this.getLightValue()); } public boolean isOpaqueCube() { return false; } /** * If this block doesn't render as an ordinary block it will return False (examples: signs, buttons, stairs, etc) */ public boolean renderAsNormalBlock() { return false; } public void ChangeState(World world, int x, int y, int z, boolean state){ int i=world.getBlockMetadata(x, y, z); if (!world.isRemote) System.out.println("Gas lamp changed state to " + state); TileEntity entity = world.getTileEntity(x, y, z); keepInventory=true; if(state){ world.setBlock(x,y,z,BlocksAS.deviceGasLampactive); }else{ world.setBlock(x,y,z,BlocksAS.deviceGasLampidle); } keepInventory=false; world.setBlockMetadataWithNotify(x, y, z, i, 3); if(entity != null){ entity.validate(); world.setTileEntity(x, y, z, entity); } } /** * The type of render function that is called for this block */ public int getRenderType() { return -2; } public boolean onBlockActivated(World world, int x, int y, int z, EntityPlayer player, int side, float hitX, float hitY, float hitZ){ if (player.getHeldItem() != null){ if (player.getHeldItem().getItem() == ItemsAS.toolWrench){ if (!world.isRemote) System.out.println("light measurement: " + this.getLightValue()); } } return true; } @Override public TileEntity createNewTileEntity(World p_149915_1_, int p_149915_2_) { return new TileEntityGasLamp(); } @SideOnly(Side.CLIENT) public void registerBlockIcons(IIconRegister iconregister){ this.blockIcon = iconregister.registerIcon(AeroSteam.MODID + ":" + "GasLamp"); } @SideOnly(Side.CLIENT) public void randomDisplayTick(World p_149734_1_, int p_149734_2_, int p_149734_3_, int p_149734_4_, Random p_149734_5_) { if (this.isActive){ double d0 = (double)((float)p_149734_2_ + 0.5F); double d1 = (double)((float)p_149734_3_ + 0.7F); double d2 = (double)((float)p_149734_4_ + 0.5F); double d3 = 0.2199999988079071D; double d4 = 0.27000001072883606D; p_149734_1_.spawnParticle("smoke", d0, d1, d2+0.1F, 0.0D, 0.0D, 0.0D); p_149734_1_.spawnParticle("smoke", d0, d1, d2, 0.0D, 0.0D, 0.0D); p_149734_1_.spawnParticle("flame", d0, d1, d2, 0.0D, 0.0D, 0.0D); p_149734_1_.spawnParticle("flame", d0, d1-0.15F, d2, 0.0D, 0.0D, 0.0D); } } }
-
To show pictures of what happens, mere movement of my view causes this http://i1310.photobucket.com/albums/s644/EmperorZelos/2014-10-05_142738_zpsb5dcb888.png http://i1310.photobucket.com/albums/s644/EmperorZelos/2014-10-05_142718_zps7101804c.png http://i1310.photobucket.com/albums/s644/EmperorZelos/2014-10-05_142725_zps9ab3185d.png http://i1310.photobucket.com/albums/s644/EmperorZelos/2014-10-05_142722_zps14a56f61.png http://i1310.photobucket.com/albums/s644/EmperorZelos/2014-10-05_142721_zps2ba6f3a2.png http://i1310.photobucket.com/albums/s644/EmperorZelos/2014-10-05_142719_zps18913f25.png
-
I am working on my gun still and the bullet, which moves REALLY slow for exploration purposes, is having dead angles where it is not being rendered, if I move about or change my looking angle ever so slightly it will reappear where it would be after having moved and all, what could cause this? package aerosteam.renderer.mob; import org.lwjgl.opengl.GL11; import aerosteam.AeroSteam; import aerosteam.mobs.MobThief; import aerosteam.model.mobs.ModelBullet; import aerosteam.model.mobs.ModelThief; import aerosteam.projectiles.ProjectileBullet; import net.minecraft.client.model.ModelBase; import net.minecraft.client.renderer.entity.Render; import net.minecraft.client.renderer.entity.RenderLiving; import net.minecraft.entity.Entity; import net.minecraft.entity.EntityLiving; import net.minecraft.util.ResourceLocation; public class RenderBullet extends Render { private static final ResourceLocation texture = new ResourceLocation(AeroSteam.MODID + ":" + "textures/model/Bullet.png"); protected ModelBullet modelEntity; public RenderBullet(ModelBase model, float f) { modelEntity=((ModelBullet) model); } public void doRender(Entity entity, double x, double y, double z, float u, float v){ GL11.glPushMatrix(); GL11.glTranslatef((float)x,(float)y,(float)z); GL11.glRotatef(180, 0F, 0F, 1F); this.bindTexture(texture); GL11.glPushMatrix(); this.modelEntity.renderModel(0.0625F); GL11.glPopMatrix(); GL11.glPopMatrix(); } @Override protected ResourceLocation getEntityTexture(Entity p_110775_1_) { return texture; } } this is the code I have PS: I am noticing that the server position of the object and client positoin differ by the eyeheight of the player, could that affect it?
-
Client side was the issue, thanks. I really gotta learn how those things work.
-
Hiya, I am trying to make a gun, or a musket more. I am currently messign around and I have encountered a strange problem. The bullet does not appear, I have other items that spawns it and even detects it where I shot the gun (as I haven't added movement yet) but it is not visible this is the spawning code I have in the musket, where it does not appear, I DO get the message that a bullet has been fired (and hear the sound) public void onPlayerStoppedUsing(ItemStack stack, World world, EntityPlayer player, int i) { if (!world.isRemote){ if (needReload){ this.reloading=false; int j = this.getMaxItemUseDuration(stack) - i; }else{ double x = player.posX; double y = player.posY+player.eyeHeight; double z = player.posZ; world.playSoundEffect(x, y, z, "random.explode", 3.0F, 1.0F / (0.7F)); ProjectileBullet bullet = new ProjectileBullet(world); bullet.setPosition(player.posX, player.posY, player.posZ); world.spawnEntityInWorld(bullet); System.out.println("bullet at-" + bullet.posX + "," + bullet.posY + "," + bullet.posZ); } System.out.println("stopped-" + this.needReload); this.needReload=!this.needReload; } } This is my "wrench" which I use for various tasks as I need it, it locates the bullet that was recently spawned AND spawns another one, when THIS item spawns a bullet it appears visible. public ItemStack onItemRightClick(ItemStack stack, World world, EntityPlayer player) { System.out.println("Item Right Click"); List near = world.getLoadedEntityList(); for (int i = 0; i < near.size(); ++i) { Entity entity = (Entity)near.get(i); if (entity instanceof ProjectileBullet){ System.out.println("There's a bullet!: " + entity.posX + ":"+ entity.posY + ":" + entity.posZ); } } /*if (world.getBlock(x, y, z) instanceof Gases){ System.out.println("Gas Meta: " + world.getBlockMetadata(x, y, z)); System.out.println("X Y Z: " + x + ";" + y + ";" + z); }*/ ProjectileBullet bullet = new ProjectileBullet(world); bullet.setPosition( player.posX, player.posY, player.posZ); world.spawnEntityInWorld(bullet); return stack; } What could be the culprit?
-
I am interested in, in my rendering, to store some additional data in a chunk, like "Does it have X?" which would be a boolean for the entire chunk, this is so I can make occurences not happen all too close to one another as I want some distance between them, how would I go about it exacly? I don't want the code for me, just either a tutorial (as I don't know what to search for) or hints on what kind of structures would allow it, if I get something simple that gives me a signal of some sort I love to explore the rest myself!
-
any good tutorial or explonation of it?
-
IN this mod you see the tornado pick up blocks and move them about, I am curious what is the function that renders some entity you can control from a block?
-
I may add that when I tyr putting some code in the MobThief class which si the entitymob extended one Vec3 targetVec = Vec3.createVectorHelper(this.posX - this.lastTarget.posX, this.boundingBox.minY + (double)(this.height / 2.0F) - (this.lastTarget.posY + (double)this.lastTarget.getEyeHeight()), this.posZ - this.lastTarget.posZ); double xPosition = this.posX+20*Math.signum(targetVec.xCoord); double yPosition = this.posY+20*Math.signum(targetVec.yCoord); double zPosition = this.posZ+20*Math.signum(targetVec.zCoord); System.out.println("New X: " + xPosition); System.out.println("New Y: " + yPosition); System.out.println("New Z: " + zPosition); System.out.println("Move: " + this.getNavigator().tryMoveToXYZ(xPosition, yPosition, zPosition, 5)); this.getNavigator().tryMoveToXYZ(xPosition, yPosition, zPosition, 50); this code, it seems to get the target but the mob never runs toward it, how come?
-
so.....priorty isn't first second third order but rather higher number = greater priority....dagnamnit I am extending entitymob What I am trying to create is a mob that spawns randomly throughout the day, runs up to a player if they are not seen and then away if they are seen, once they hit the player they grab one of the players tiems and runs off with it
-
I am trying to work out some AIs but I am having toruble, it doesn't execute anything. This is my code, I have put system output markers all over to see where it goes and all I get is "supered" which is the initialization part, all the others do not occure so it doesn't even TRY to execute anything, why? Mob: public MobThief(World world) { super(world); System.out.println("Thief is mobbing"); this.targetTasks.addTask(1, new EntityAIRunIfSeenByTarget(this, EntityPlayer.class, false, false)); } AI: package aerosteam.mobs.ai; import java.util.Comparator; import net.minecraft.command.IEntitySelector; import net.minecraft.entity.Entity; import net.minecraft.entity.EntityCreature; import net.minecraft.entity.EntityLiving; import net.minecraft.entity.EntityLivingBase; import net.minecraft.entity.ai.EntityAINearestAttackableTarget; import net.minecraft.entity.ai.EntityAITarget; import net.minecraft.entity.player.EntityPlayer; import net.minecraft.util.Vec3; public class EntityAIRunIfSeenByTarget extends EntityAITarget{ private final EntityCreature creature; private EntityLivingBase target; private EntityPlayer player; private final Class targetClass; private double xPosition; private double yPosition; private double zPosition; /** * This filter is applied to the Entity search. Only matching entities will be targetted. (null -> no * restrictions) */ public EntityAIRunIfSeenByTarget(EntityCreature creature, Class target, boolean b1, boolean b2) { super(creature, b1, b2); // TODO Auto-generated constructor stub System.out.println("supered"); this.creature = creature; this.targetClass = target; this.setMutexBits(1); } public boolean shouldExecute() { System.out.println("trying to execute"); this.target = this.creature.getAttackTarget(); if (this.target instanceof EntityPlayer){ this.player = (EntityPlayer) this.target; if (isLookedAt(player)){ return true; } } return false; } public void startExecuting() { System.out.println("start exxecuting"); Vec3 targetVec = Vec3.createVectorHelper(this.creature.posX - this.player.posX, this.creature.boundingBox.minY + (double)(this.creature.height / 2.0F) - (this.player.posY + (double)this.player.getEyeHeight()), this.creature.posZ - this.player.posZ); this.xPosition = this.creature.posX+targetVec.xCoord; this.yPosition = this.creature.posY+targetVec.yCoord; this.zPosition = this.creature.posZ+targetVec.zCoord; this.creature.getNavigator().tryMoveToXYZ(this.xPosition, this.yPosition, this.zPosition, 5); } private boolean isLookedAt(EntityPlayer player) { Vec3 vec3 = player.getLook(1.0F).normalize(); System.out.println("look angle: " + vec3.xCoord + ":" + vec3.yCoord + ":" + vec3.zCoord); Vec3 vec31 = Vec3.createVectorHelper(this.creature.posX - player.posX, this.creature.boundingBox.minY + (double)(this.creature.height / 2.0F) - (player.posY + (double)player.getEyeHeight()), this.creature.posZ - player.posZ); double d0 = vec31.lengthVector(); vec31 = vec31.normalize(); System.out.println("monster angle: " + vec31.xCoord + ":" + vec31.yCoord + ":" + vec31.zCoord); double d1 = vec3.dotProduct(vec31)-0.75D; System.out.println("dot product: " + d1); System.out.println("right angle: " + (d1 < 0.0D)); return d1 > 0.0D && player.canEntityBeSeen(this.creature); } }
-
I get this message which I suspect is due to my additional biome package aerosteam.biomes; import net.minecraft.world.biome.BiomeGenBase; import net.minecraftforge.common.BiomeDictionary; import net.minecraftforge.common.BiomeDictionary.Type; import net.minecraftforge.common.BiomeManager; import net.minecraftforge.common.BiomeManager.BiomeEntry; public class BiomesAS { public static BiomeGenBase biomeTwilightForest; public static void init(){ registerBiomes(); } private static void registerBiomes() { biomeTwilightForest = new BiomeTwilightForest(50).setBiomeName("Twilight Forest"); BiomeDictionary.registerBiomeType(biomeTwilightForest, Type.FOREST); BiomeManager.coolBiomes.add(new BiomeEntry(biomeTwilightForest,10)); } } package aerosteam.biomes; import net.minecraft.world.biome.BiomeGenBase; public class BiomeTwilightForest extends BiomeGenBase{ private static final Height biomeHeight = new Height(0.1F,0.3F); public BiomeTwilightForest(int id) { super(id); this.setHeight(biomeHeight); this.setColor(8782003); this.setTemperatureRainfall(0.4F, 1.0F); this.waterColorMultiplier=2127872; } @Override public int getBiomeGrassColor(int x, int y,int z){ return 5767288; } @Override public int getBiomeFoliageColor(int x, int y,int z){ return 5767288; } @Override public int getSkyColorByTemp(float par1){ return 0; } } if not I am at a loss =O As a matter of fact, I am at a loss, what does invalid biome ID even refer to and how is it resolved?
-
This is the code I use to check it public boolean onBlockActivated(World world, int x, int y, int z, EntityPlayer player, int side, float hitX, float hitY, float hitZ){ if (!world.isRemote){ System.out.println("Light value: " + world.getBlockLightValue(x, y, z)); System.out.println("Light_do true value: " + world.getBlockLightValue_do(x, y, z, true)); System.out.println("Light_do false value: " + world.getBlockLightValue_do(x, y, z, false)); System.out.println("saved light block: " + world.getSavedLightValue(EnumSkyBlock.Block, x, y, z)); System.out.println("saved light sky: " + world.getSavedLightValue(EnumSkyBlock.Sky, x, y, z)); } return true; } This is what I get
-
Both of them give me value 0 in broad daylight
-
I am interested in doing a gas for my mod (among other things) that is light sensitive and reaction depends on the light level itself, is there a means to which I can detect how much light it recieves? or any proximal block suffices
-
[Solved][1.7.10] Strange phenomena, video
EmperorZelos replied to EmperorZelos's topic in Modder Support
My explosive one doesn't have it but that seems to have solved the problem Thanks again! -
I have encountered a strange phenomena, I have included a video of it. I have an explosive block I can use that detonates when destroyed, no issue there. But I have also created coal dust that explodes upon ignition but it seems that afterward sometimes it is having a block there but it isn't visible and it is fighting with itself as I lag and when I place ANY block there it turns into a stone/ore block, what could cause it? package aerosteam.gases; import java.util.Random; import cpw.mods.fml.relauncher.Side; import cpw.mods.fml.relauncher.SideOnly; import aerosteam.AeroSteam; import aerosteam.blocks.BlocksAS; import aerosteam.blocks.BlocksGases; import aerosteam.gas.Pipes; import aerosteam.items.ItemsAS; import aerosteam.proxy.ClientProxy; import net.minecraft.block.Block; import net.minecraft.block.BlockFire; import net.minecraft.block.material.Material; import net.minecraft.client.renderer.texture.IIconRegister; import net.minecraft.entity.Entity; import net.minecraft.entity.EntityLiving; import net.minecraft.entity.EntityLivingBase; import net.minecraft.entity.item.EntityItem; import net.minecraft.entity.player.EntityPlayer; import net.minecraft.init.Blocks; import net.minecraft.item.Item; import net.minecraft.item.ItemStack; import net.minecraft.potion.Potion; import net.minecraft.potion.PotionEffect; import net.minecraft.util.AxisAlignedBB; import net.minecraft.util.DamageSource; import net.minecraft.util.IIcon; import net.minecraft.util.Vec3; import net.minecraft.world.Explosion; import net.minecraft.world.IBlockAccess; import net.minecraft.world.World; import net.minecraftforge.common.util.ForgeDirection; import net.minecraftforge.fluids.BlockFluidClassic; import net.minecraftforge.fluids.FluidStack; public class Gases extends Block { protected float density=100; protected float viscosity=1000; protected int tickRate=10; protected boolean toxic = false; protected int toxLevel = 100; protected boolean lethal = false; protected boolean harm = false; protected boolean flammable = false; protected boolean burning = false; protected boolean source = false; protected Block sourceTo = null; protected boolean corrosive = false; protected boolean explosive = false; protected float explosion = 4; protected boolean breathable = true; protected int corrosion = 0; protected String texture = "Gas"; protected int harmLevel = 1; protected int decayRate = 1; protected int decayDistance = 700; public float red=0; public float green=0; public float blue=0; public float fogdensity=0; private EntityPlayer[] corrodingPlayers = new EntityPlayer[15]; private EntityLivingBase[] suffocatingEntity = new EntityLivingBase[15]; public Gases() { super(Material.iron); this.setTickRandomly(true); this.setResistance(0F); BlocksGases.nrGases++; this.setBlockBounds(0.0F, 0.0F, 0.0F, 1.0F, 1.0F, 1.0F); } public Gases setDensity(float density) { this.density = density; if (this.density<0) this.density = 0; if (this.density>200) this.density = 200; return this; } public float getDensity() { return this.density; } public Gases setViscosity(float viscosity) { this.viscosity = viscosity; if (this.viscosity<100) this.viscosity = 100; if (this.viscosity>10000) this.viscosity = 10000; return this; } public Gases setTexture(String text) { this.texture = text; return this; } public float getViscosity() { return this.viscosity; } public Gases setToxicityLevel(int level) { this.toxLevel = level; if (this.toxLevel<1) this.toxLevel = 1; if (this.toxLevel>20) this.toxLevel = 20; return this; } public int getToxicLevel() { return this.toxLevel; } public Gases setHarmLevel(int level) { this.harmLevel = level; if (this.harmLevel<1) this.harmLevel = 1; if (this.harmLevel>20) this.harmLevel = 20; return this; } public int getHarmLevel() { return this.harmLevel; } public Gases setToxic(boolean bool) { this.toxic = bool; return this; } public boolean getToxicity() { return this.toxic; } public Gases setExplosive(boolean bool) { this.explosive = bool; return this; } public boolean getExplosive() { return this.explosive; }public Gases setExplosion(float power) { this.explosion = power; return this; } public float getExplosion() { return this.explosion; } public Gases setBreathable(boolean bool) { this.breathable = bool; return this; } public boolean getBreathable() { return this.breathable; } public Gases setDecay(int distance) { this.decayDistance = distance; double calcProb = 1000*(1-Math.exp(Math.log(0.5D)/distance)); if (calcProb <1) calcProb = 1; this.decayRate = (int) Math.round(calcProb); System.out.println("Decay:" + this.decayRate); return this; } public int getDecay() { return this.decayDistance; } public Gases setFlammable(boolean bool) { this.flammable = bool; return this; } public boolean getFlammable() { return this.flammable; } public Gases setSource(boolean bool) { this.setCreativeTab(AeroSteam.gasTab); this.source = bool; if(bool) BlocksGases.nrGases--; return this; } public boolean getSource() { return this.source; } public Gases setSourceBlock(Block gas) { Gases gasen = (Gases) gas; this.setViscosity(gasen.getViscosity()); this.setLethal(gasen.getLethality()); this.setHarm(gasen.getHarmfull()); this.setHarmLevel(gasen.getHarmLevel()); this.setToxic(gasen.getToxicity()); this.setToxicityLevel(gasen.getToxicLevel()); this.setCorrosive(gasen.getCorrosive()); this.setCorrosion(gasen.getCorrosion()); this.setBreathable(gasen.getBreathable()); this.setFlammable(gasen.getFlammable()); this.setExplosive(gasen.getExplosive()); this.setExplosion(gasen.getExplosion()); this.sourceTo = gas; return this; } public Block getSourceBlock() { return this.sourceTo; } public Gases setCorrosive(boolean bool) { this.corrosive = bool; return this; } public boolean getCorrosive() { return this.corrosive; } public Gases setCorrosion(int corrosion) { this.corrosion = corrosion; if (this.corrosion<0) this.corrosion = 0; if (this.corrosion>100) this.corrosion = 100; return this; } public int getCorrosion() { return this.corrosion; } public Gases setLethal(boolean bool) { this.lethal = bool; return this; } public boolean getLethality() { return this.lethal; } public Gases setHarm(boolean bool) { this.harm = bool; return this; } public boolean getHarmfull() { return this.harm; } public Gases setBurn(boolean bool) { this.burning = bool; return this; } //Fix public Gases setFogColour(float red, float green, float blue) { this.red=red; this.green=green; this.blue=blue; return this; } public Gases setFogDensity(float density) { //this.burning = bool; this.fogdensity=density; return this; } public boolean getBurn() { return this.burning; } @Override public boolean isFlammable(IBlockAccess world, int x, int y, int z, ForgeDirection face) { return true; } @Override public void onBlockAdded(World world, int x, int y, int z) { //world.setBlockMetadataWithNotify(x, y, z, RndInt(0,15), 2); world.scheduleBlockUpdate(x, y, z, this, (int) (this.viscosity/10)); } @Override public void onBlockPlacedBy(World world, int x, int y, int z, EntityLivingBase entityplayer,ItemStack itemstack){ //world.setBlockMetadataWithNotify(x, y, z, 15, 2); world.scheduleBlockUpdate(x, y, z, this, (int) (this.viscosity/10)); } public int RndInt(int min, int max){ Random generator = new Random(); int rnd = generator.nextInt(max-min+1) + min; return rnd; } public float RndFloat(float min, float max){ Random generator = new Random(); float rnd = generator.nextFloat()*(max-min+1.0F) + min; return rnd; } private boolean itemCanIgnite(Item item){ if (item == Item.getItemFromBlock(BlocksAS.deviceTorch)) return true; return false; } //will react hwen player is in the block public void onEntityCollidedWithBlock(World world, int x, int y, int z, Entity entity) { //System.out.println("collide"); if(this.harm){ entity.attackEntityFrom(DamageSource.generic, this.harmLevel); } if(this.burning){ entity.setFire(10); //player.addPotionEffect(new PotionEffect(Potion.wither.getId(),this.getToxicLevel())); } if (entity instanceof EntityPlayer){ EntityPlayer player = (EntityPlayer) entity; ItemStack held = player.getCurrentEquippedItem(); if (held != null){ if (itemCanIgnite(held.getItem())){ if (this.flammable){ world.setBlock(x, y, z, BlocksGases.burningGas); } if (this.explosive){ explodeBlock(world,x,y,z); } } } if (this.toxic){ if (this.lethal){ player.addPotionEffect(new PotionEffect(Potion.wither.getId(),this.getToxicLevel())); }else{ player.addPotionEffect(new PotionEffect(Potion.poison.getId(),this.getToxicLevel())); } } if(this.corrosive){ boolean found=false; int insert=0; for (int i=0; i<corrodingPlayers.length;i++){ if (corrodingPlayers[i]==player){ found=true; break; } if (corrodingPlayers[i] == null){ insert=i; break; } } if (!found){ corrodingPlayers[insert] = player; } } }else if (this.toxic){ entity.attackEntityFrom(DamageSource.wither, 1); } if(!this.breathable){ if (entity instanceof EntityLivingBase){ EntityLivingBase living = (EntityLivingBase) entity; boolean found=false; int insert=0; for (int i=0; i<suffocatingEntity.length;i++){ if (suffocatingEntity[i]==living){ found=true; break; } if (suffocatingEntity[i] == null){ insert=i; break; } } if (!found){ //System.out.println("added"); suffocatingEntity[insert] = living; } //player.inventory.mainInventory } } } //Makes block pass through public AxisAlignedBB getCollisionBoundingBoxFromPool(World world, int i, int j, int k) { return null; } //makes block impossible to hit public boolean canCollideCheck(int meta, boolean fullHit) { return fullHit && meta == 0; } @Override public void onNeighborBlockChange(World world, int x, int y, int z, Block block) { //System.out.println("neighbour changed" + block.tickRate(world)); world.scheduleBlockUpdate(x, y, z, this, (int) (this.viscosity/10)); //this.stuck=world.getBlock(x, y+1, z) != Blocks.air; //block.updateTick(world, x, y, z, world.rand); } public void igniteGas(World world, int x, int y, int z){ for (gasDirection check: gasDirection.VALID_DIRECTIONS){ int deltaXpos=x+check.offsetX; int deltaYpos=y+check.offsetY; int deltaZpos=z+check.offsetZ; Block block = world.getBlock(deltaXpos, deltaYpos, deltaZpos); if (canIgnite(block)){ if(this.flammable){ world.setBlock(x, y, z, BlocksGases.burningGas); }else if(this.explosive){ explodeBlock(world,x,y,z); } } } } public void explodeBlock(World world, int x, int y, int z){ float power = RndFloat(1,this.explosion); EntityItem splosion = new EntityItem(world,(double)x,(double)y,(double)z, new ItemStack(Blocks.dirt,1,0)); world.setBlockToAir(x, y, z); world.spawnEntityInWorld(splosion); world.createExplosion(splosion, (double)x, (double)y, (double)z, power, true); world.removeEntity(splosion); } public boolean canIgnite(Block block){ if (block==BlocksAS.deviceTorch) return true; if (block==BlocksAS.firePlace) return true; if (block==BlocksGases.burningGas) return true; if (block==Blocks.fire) return true; if (block==Blocks.lava) return true; return false; } @Override public void onBlockDestroyedByExplosion(World world, int x, int y, int z, Explosion boom) { if(this.explosive){ explodeBlock(world,x,y,z); } } public void corrodeItem(){ if(corrodingPlayers[0]!= null){ for (int i=0;i<corrodingPlayers.length;i++){ if (corrodingPlayers[i] == null) break; int start = RndInt(0,35); ItemStack itemstack = null; for (int j=0;j<36;j++){ itemstack=corrodingPlayers[i].inventory.mainInventory[(j+start)%36]; if (itemstack != null) break; } if (itemstack!=null){ int pow=3; int propPow=(int) Math.pow(this.corrosion, pow); int tenPow=(int) Math.pow(10, pow); if (RndInt(0,tenPow)<propPow){ corrodingPlayers[i].inventory.consumeInventoryItem(itemstack.getItem()); } } corrodingPlayers[i]=null; } } } public void suffocate(){ //System.out.println("start suffocation"); if(suffocatingEntity[0]!= null){ //System.out.println("isn't empty"); for (int i=0;i<suffocatingEntity.length;i++){ if (suffocatingEntity[i] == null) break; EntityLivingBase entity = suffocatingEntity[i]; entity.setAir(entity.getAir()-5); //System.out.println("less air"); suffocatingEntity[i]=null; } } } private int metaAdd(int meta1, int meta2){ return 1+meta1+meta2; } private int metaSub(int meta1, int meta2){ return (meta1+meta2-1)%16; } @Override public void updateTick(World world, int x, int y, int z, Random random) { //world.setBlock(x, y, z, Blocks.air); //System.out.println("update tick"); if (this.flammable||this.explosive)igniteGas(world,x,y,z); if (this.corrosive)corrodeItem(); if (this.corrosive && !this.source && this.decayDistance >= 12) System.out.println("It is unwise to have corrosive gases with such low decay rate! SHORTEN THE DISTANCE!"); if (!this.breathable)suffocate(); if (!this.source){ if (RndInt(1,1000)>this.decayRate){ if (canMove(world,x,y,z)){ ForgeDirection dir = rndMove(); if (dirFree(world,x,y,z,dir)){ //this.stuck=true; if(y < 250){ Block source = world.getBlock(x, y, z); world.setBlock(x+dir.offsetX, y+dir.offsetY, z+dir.offsetZ, source); world.setBlock(x, y, z, Blocks.air); }else{ world.setBlock(x, y, z, Blocks.air); } }else if (dirDoor(world,x,y,z,dir)){ Block source = world.getBlock(x, y, z); world.setBlock(x+2*dir.offsetX, y+2*dir.offsetY, z+2*dir.offsetZ, source); world.setBlock(x, y, z, Blocks.air); } world.scheduleBlockUpdate(x, y, z, this, (int) (this.viscosity/10)); }else world.scheduleBlockUpdate(x, y, z, this, (int) (this.viscosity)); }else{ world.setBlock(x, y, z, Blocks.air); } }else{ //System.out.println("Is Source"); for (ForgeDirection dir: ForgeDirection.VALID_DIRECTIONS){ if (dirFree(world,x,y,z,dir)){ world.setBlock(x+dir.offsetX, y+dir.offsetY, z+dir.offsetZ, this.sourceTo); } } world.scheduleBlockUpdate(x, y, z, this, (int) (this.viscosity/10)); } if (this.burning) startFire(world,x,y,z); } private void startFire(World world,int x,int y,int z){ for (ForgeDirection dir: ForgeDirection.VALID_DIRECTIONS){ Block check = world.getBlock(x+dir.offsetX, y+dir.offsetY, z+dir.offsetZ); if (check != BlocksGases.burningGas){ if (check.isFlammable(world, x+dir.offsetX, y+dir.offsetY, z+dir.offsetZ, dir.getOpposite())){ world.setBlock(x+dir.offsetX, y+dir.offsetY, z+dir.offsetZ, Blocks.fire); } } } } //Can the block move in any direction? private boolean canMove(World world, int x, int y, int z){ if (this.corrosive){ return true; } for (ForgeDirection dir: ForgeDirection.VALID_DIRECTIONS){ Block check = world.getBlock(x+dir.offsetX, y+dir.offsetY, z+dir.offsetZ); if (check == Blocks.air||check==Blocks.fire){ return true; } } return false; } //Is the direction free to move into somehow? private boolean dirFree(World world, int x, int y, int z, ForgeDirection dir){ Block block = world.getBlock(x+dir.offsetX, y+dir.offsetY, z+dir.offsetZ); if (block==Blocks.air){ return true; }else if (RndInt(0,100)<this.corrosion && block != Blocks.bedrock){ if (block instanceof Gases){ Gases gas = (Gases) block; if(!gas.getSource()){ return true; } }else return true; } return false; } private boolean dirDoor(World world, int x, int y, int z, ForgeDirection dir){ Block block = world.getBlock(x+dir.offsetX, y+dir.offsetY, z+dir.offsetZ); if(block==Blocks.wooden_door || block==Blocks.iron_door||block==Blocks.trapdoor){ Block second = world.getBlock(x+2*dir.offsetX, y+2*dir.offsetY, z+2*dir.offsetZ); if (second==Blocks.air){ return true; }else{ return false; } }else{ return false; } } private int boolToInt(boolean bool){ return bool?1:0; } //generate random direction based on density private ForgeDirection rndMove(){ int rnd = RndInt(0,100); int relDens = (int) (this.density-100); int rndUp = 84+relDens*16/100; int rndDown = 16+relDens*83/100; if (rnd>rndUp){ return ForgeDirection.UP; }else if (rnd < rndDown){ return ForgeDirection.DOWN; }else{ return ForgeDirection.getOrientation(RndInt(2,5)); } } //Rendering stuff @Override public boolean renderAsNormalBlock() { return false; } @Override public boolean isOpaqueCube() { return false; } @Override public int getRenderType() { return ClientProxy.gasRenderType; } @Override public boolean canRenderInPass(int pass) { //Set the static var in the client proxy //ClientProxy.renderPass = pass; //the block can render in both passes, so return true always return pass==1; } @Override public boolean shouldSideBeRendered(IBlockAccess world, int x, int y, int z, int side) { Block block = world.getBlock(x, y, z); return blockRenderAgainst(block); } public static boolean blockRenderAgainst(Block block){ if (block==Blocks.air|| block==BlocksAS.deviceTorch|| block==BlocksAS.firePlace|| block==Blocks.tallgrass|| block==Blocks.fire|| block==Blocks.redstone_wire|| block==Blocks.redstone_torch|| block==Blocks.snow_layer|| block==Blocks.water|| block==Blocks.lava|| block==Blocks.wooden_door|| block==Blocks.iron_door|| block==BlocksAS.deviceGasLamp|| block instanceof Pipes){ return true; } return false; } @Override public int getRenderBlockPass() { return 1; } @SideOnly(Side.CLIENT) public IIcon getIcon(int side, int metadata) { return this.blockIcon; } @SideOnly(Side.CLIENT) public void registerBlockIcons(IIconRegister icon) { this.blockIcon = icon.registerIcon(AeroSteam.MODID + ":" + this.texture); } @Override public Item getItemDropped(int p_149650_1_, Random p_149650_2_, int p_149650_3_) { return null; } /* @Override public void velocityToAddToEntity(World world, int x, int y, int z, Entity entity, Vec3 vec) { if (densityDir > 0) return; Vec3 vec_flow = this.getFlowVector(world, x, y, z); vec.xCoord += vec_flow.xCoord * (quantaPerBlock * 4); vec.yCoord += vec_flow.yCoord * (quantaPerBlock * 4); vec.zCoord += vec_flow.zCoord * (quantaPerBlock * 4); }*/ //update tick with meta value is for concentration /*public void updateTick(World world, int x, int y, int z, Random random) { //world.setBlock(x, y, z, Blocks.air); //System.out.println("update tick"); if (this.flammable||this.explosive)igniteGas(world,x,y,z); if (this.corrosive)corrodeItem(); if (!this.breathable)suffocate(); if (!this.source){ if (canMove(world,x,y,z)){ ForgeDirection dir = rndMove(); if (dirFree(world,x,y,z,dir)){ int meta = world.getBlockMetadata(x, y, z); //this.stuck=true; if(y < 250){ Block target = world.getBlock(x+dir.offsetX, y+dir.offsetY, z+dir.offsetZ); if (target == this){ int tmeta = world.getBlockMetadata(x+dir.offsetX, y+dir.offsetY, z+dir.offsetZ); int smeta = world.getBlockMetadata(x, y, z); int maxMeta = smeta; if (smeta>(15-tmeta)) maxMeta=15-tmeta; int addmeta=RndInt(0,maxMeta); int newTmeta = metaAdd(tmeta,addmeta); int newSmeta = metaSub(smeta,addmeta); System.out.println("tmeta: " + tmeta); System.out.println("smeta: " + smeta); System.out.println("MaxMeta: " + maxMeta); System.out.println("new-tmeta: " + newTmeta); System.out.println("new-smeta: " + newSmeta); if (addmeta!=smeta){ world.setBlockMetadataWithNotify(x+dir.offsetX, y+dir.offsetY, z+dir.offsetZ, newTmeta, 2); world.setBlockMetadataWithNotify(x, y, z, newSmeta, 2); world.scheduleBlockUpdate(x, y, z, this, (int) (this.viscosity/10)); world.scheduleBlockUpdate(x+dir.offsetX, y+dir.offsetY, z+dir.offsetZ, this, (int) (this.viscosity/10)); }else{ world.setBlockMetadataWithNotify(x+dir.offsetX, y+dir.offsetY, z+dir.offsetZ, metaAdd(tmeta,smeta), 2); world.setBlock(x, y, z, Blocks.air); world.scheduleBlockUpdate(x+dir.offsetX, y+dir.offsetY, z+dir.offsetZ, this, (int) (this.viscosity/10)); } world.setBlock(x, y, z, Blocks.air); }else{ //world.setBlock(x, y, z, Blocks.air); Block source = world.getBlock(x, y, z); if (meta>1){ int realMeta = meta+1; int deltaMeta=RndInt(0,meta); int newTmeta = deltaMeta; int newSmeta = metaSub(,deltaMeta); System.out.println("meta: " + meta); System.out.println("deltaMeta: " + deltaMeta); System.out.println("new-tmeta: " + newTmeta); System.out.println("new-smeta: " + newSmeta); world.setBlock(x+dir.offsetX, y+dir.offsetY, z+dir.offsetZ, source, newTmeta, 2); world.setBlockMetadataWithNotify(x, y, z, newSmeta, 2); world.scheduleBlockUpdate(x, y, z, this, (int) (this.viscosity/10)); }else{ if (meta==1){ world.setBlock(x+dir.offsetX, y+dir.offsetY, z+dir.offsetZ, source, 0, 2); world.setBlock(x, y, z, Blocks.air); }else{ if (RndInt(1,10)<=this.decayRate){ world.setBlock(x, y, z, Blocks.air); }else{ world.setBlock(x+dir.offsetX, y+dir.offsetY, z+dir.offsetZ, source, 0, 2); world.setBlock(x, y, z, Blocks.air); } } } } world.scheduleBlockUpdate(x, y, z, this, (int) (this.viscosity/10)); }else{ world.setBlock(x, y, z, Blocks.air); } }else if(!this.flammable){ world.scheduleBlockUpdate(x, y, z, this, (int) (this.viscosity/10)); }else if (this.burning){ System.out.println("Meta Decrease 1"); int meta=world.getBlockMetadata(x, y, z); if (meta>0){ world.setBlockMetadataWithNotify(x, y, z, meta-1, 2); world.scheduleBlockUpdate(x, y, z, this, (int) (this.viscosity/10)); }else{ world.setBlock(x, y, z, Blocks.air); } } }else if (this.burning){ System.out.println("Meta Decrease 2"); int meta=world.getBlockMetadata(x, y, z); if (meta>0){ world.setBlockMetadataWithNotify(x, y, z, meta-1, 2); world.scheduleBlockUpdate(x, y, z, this, (int) (this.viscosity/10)); }else{ world.setBlock(x, y, z, Blocks.air); } } }else{ //System.out.println("Is Source"); for (ForgeDirection dir: ForgeDirection.VALID_DIRECTIONS){ if (dirFree(world,x,y,z,dir)){ world.setBlock(x+dir.offsetX, y+dir.offsetY, z+dir.offsetZ, this.sourceTo, 15, 2); } } world.scheduleBlockUpdate(x, y, z, this, (int) (this.viscosity/10)); } if (this.burning) startFire(world,x,y,z); world.scheduleBlockUpdate(x, y, z, this, (int) (this.viscosity/10)); }*/ } gas block code
-
Hello! I am working on my little gases and stuff and I wish to add a function to vanilla blocks. Namely that something is produced when they break. Is there a way to do that or is the easiest way to simply replace them? This is somethign that occures naturally (mainly coal block for now)