Posted June 24, 20169 yr I currently use the setSize method to resize the entity bounding box is there a way to change the size of the entity boudingbox manually and to make it float. package HxCKDMS.HxCLasers.Entity; import HxCKDMS.HxCLasers.Api.ILens; import HxCKDMS.HxCLasers.Api.LaserHandler; import HxCKDMS.HxCLasers.Api.LaserRegistry; import HxCKDMS.HxCLasers.Registry.Registry; import net.minecraft.entity.Entity; import net.minecraft.item.ItemStack; import net.minecraft.nbt.NBTTagCompound; import net.minecraft.world.World; import net.minecraftforge.common.util.ForgeDirection; import java.awt.*; import java.util.UUID; public class EntityLaserBeam extends Entity { public UUID uuid; public ForgeDirection direction; public int length; public boolean shouldDrawTop; public ItemStack lens; public int powerLevel; public boolean transparent; private LaserHandler laserHandler; private boolean first = true; public EntityLaserBeam(World world) { super(world); } public EntityLaserBeam(World world, double x, double y, double z, UUID uuid, ForgeDirection direction, int length, ItemStack lens) { super(world); setPosition(x, y, z); this.uuid = uuid; this.direction = direction; this.length = length; this.lens = lens; } @Override protected void entityInit() { dataWatcher.addObject(24, (byte) 0); //transparent dataWatcher.addObject(25, 1); //powerLevel dataWatcher.addObject(26, 0); //red dataWatcher.addObject(27, 0); //green dataWatcher.addObject(28, 0); //blue dataWatcher.addObject(29, (float) posY); dataWatcher.addObject(30, 1); //direction dataWatcher.addObject(31, 0); //length setSize(0.2F, 0.2F); } @Override protected void readEntityFromNBT(NBTTagCompound tagCompound) { } @Override protected void writeEntityToNBT(NBTTagCompound tagCompound) { } @Override public void onUpdate() { if(!worldObj.isRemote){ Color color = Color.white; if(lens != null && lens.hasTagCompound()) color = ((ILens) lens.getItem()).getColor(lens); if(first) { laserHandler = LaserRegistry.getLaserHandler(color); transparent = lens != null && Registry.itemLens.isTransparent(lens); powerLevel = lens != null ? Registry.itemLens.getPowerLevel(lens) : 1; laserHandler.laserBeam = this; first = false; } dataWatcher.updateObject(24, transparent ? (byte) 1 : (byte) 0); dataWatcher.updateObject(25, powerLevel); dataWatcher.updateObject(26, color.getRed()); dataWatcher.updateObject(27, color.getGreen()); dataWatcher.updateObject(28, color.getBlue()); dataWatcher.updateObject(30, direction.ordinal()); dataWatcher.updateObject(31, length); dataWatcher.updateObject(29, (float) posY); } else { direction = ForgeDirection.getOrientation(dataWatcher.getWatchableObjectInt(30)); //posY = dataWatcher.getWatchableObjectFloat(29); //lastTickPosY = dataWatcher.getWatchableObjectFloat(29); } } @Override public void moveEntity(double motionX, double motionY, double motionZ) { } @Override public boolean doesEntityNotTriggerPressurePlate() { return true; } @Override public void writeToNBT(NBTTagCompound tagCompound) { tagCompound.setString("UUID", uuid.toString()); tagCompound.setInteger("Direction", direction.ordinal()); tagCompound.setInteger("Length", length); if(lens != null) tagCompound.setTag("Lens", lens.writeToNBT(new NBTTagCompound())); super.writeToNBT(tagCompound); } @Override public void readFromNBT(NBTTagCompound tagCompound) { uuid = UUID.fromString(tagCompound.getString("UUID")); direction = ForgeDirection.getOrientation(tagCompound.getInteger("Direction")); length = tagCompound.getInteger("Length"); lens = ItemStack.loadItemStackFromNBT(tagCompound.getCompoundTag("Lens")); super.readFromNBT(tagCompound); } @Override public boolean shouldRenderInPass(int pass) { return pass == 1; } } what it looks like currently:
June 24, 20169 yr I am not sure what you want, please elaborate. My interpretation: you want you little box to be inside laser (not fall) or you want it to expand in length (the box) with the laser itself (so it covers whole beam). So which one is it, or other? 1.7.10 is no longer supported by forge, you are on your own.
June 24, 20169 yr Author I want the white box to be on the laser itself and expand it over the whole beam.
June 24, 20169 yr I can't say I see what you say you do: I currently use the setSize method to resize the entity bounding box Generally - Entity is on server and client so you have to resize it on both sides. And yeah - setSize should work (as long as you call it on both sides). You will want to do that from onUpdate() and make it so that Entity can't be moved and it "hovers" above ground. To do the hovering you won't be using bounding box (since you want box itself to hover) but you will be cancelling gravity. Since laser entity is bound to Block that emits it you can easily get Y of given block and in onUpdate() method cancel falling if (entity.posY <= block.posY + 0.5D) - well, something like this. But then I need to point out - if this is supposed to be an "entity laser" - you shouldn't be doing it like this. Unless you have some special reason for it, I'd do it more like: * Place TileEntity with all data (such as colors and direction) that uses custom renderer that basically renders given beam and all that. * Since it is TileEntity you can use onUpdate() to do ray-trace in direction the laser is going. Boom - you can limit range and you can gather all "hits" (entity or block) in given direction. 1.7.10 is no longer supported by forge, you are on your own.
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.