From 0a017e9672d52801918121f56d39f4be535cf02b Mon Sep 17 00:00:00 2001 From: Bob Date: Mon, 20 Jun 2022 22:34:47 +0200 Subject: [PATCH 1/4] torex tweaks --- .../hbm/entity/effect/EntityNukeTorex.java | 63 ++++++++++++++----- .../hbm/render/entity/effect/RenderTorex.java | 6 +- 2 files changed, 50 insertions(+), 19 deletions(-) diff --git a/src/main/java/com/hbm/entity/effect/EntityNukeTorex.java b/src/main/java/com/hbm/entity/effect/EntityNukeTorex.java index 4ea9d3c6d..3ad54fc6e 100644 --- a/src/main/java/com/hbm/entity/effect/EntityNukeTorex.java +++ b/src/main/java/com/hbm/entity/effect/EntityNukeTorex.java @@ -43,9 +43,13 @@ public class EntityNukeTorex extends Entity { double range = (torusWidth - rollerSize) * 0.25; if(this.ticksExisted + cloudletLife * 2 < maxAge) { - for(int i = 0; i < 20; i++) { + + int toSpawn = (int) Math.ceil(10 * getSimulationSpeed()); + + for(int i = 0; i < toSpawn; i++) { double y = posY + rand.nextGaussian() - 3; //this.ticksExisted < 60 ? this.posY + this.coreHeight : posY + rand.nextGaussian() - 3; Cloudlet cloud = new Cloudlet(posX + rand.nextGaussian() * range, y, posZ + rand.nextGaussian() * range, (float)(rand.nextDouble() * 2D * Math.PI), 0); + cloud.setScale(1F + this.ticksExisted * 0.001F, 5F); cloudlets.add(cloud); } } @@ -53,10 +57,12 @@ public class EntityNukeTorex extends Entity { int cloudCount = ticksExisted * 3; if(ticksExisted < 200) { for(int i = 0; i < cloudCount; i++) { - Vec3 vec = Vec3.createVectorHelper(ticksExisted + rand.nextDouble(), 0, 0); + Vec3 vec = Vec3.createVectorHelper((ticksExisted + rand.nextDouble()) * 2, 0, 0); float rot = (float) (Math.PI * 2 * rand.nextDouble()); vec.rotateAroundY(rot); - this.cloudlets.add(new Cloudlet(vec.xCoord + posX, worldObj.getHeightValue((int) (vec.xCoord + posX) + 2, (int) (vec.zCoord + posZ)), vec.zCoord + posZ, rot, 0)); + this.cloudlets.add(new Cloudlet(vec.xCoord + posX, worldObj.getHeightValue((int) (vec.xCoord + posX) + 1, (int) (vec.zCoord + posZ)), vec.zCoord + posZ, rot, 0) + .setScale(5F, 2F) + .setMotion(0)); } } @@ -79,6 +85,16 @@ public class EntityNukeTorex extends Entity { this.setDead(); } } + + public double getSimulationSpeed() { + + if(EntityNukeTorex.this.ticksExisted > 45 * 20) { + int timeLeft = 1600 - EntityNukeTorex.this.ticksExisted; + return MathHelper.clamp_double((double) timeLeft / 900D, 0, 1); + } + + return 1.0D; + } public class Cloudlet { @@ -135,17 +151,11 @@ public class EntityNukeTorex extends Entity { this.motionY = convection.yCoord * factor + lift.yCoord * (1D - factor); this.motionZ = convection.zCoord * factor + lift.zCoord * (1D - factor); - if(EntityNukeTorex.this.ticksExisted > 45 * 20) { - int timeLeft = 1600 - EntityNukeTorex.this.ticksExisted; - double scaled = Math.max((double) timeLeft / 900D, 0); - this.motionX *= scaled; - this.motionY *= scaled; - this.motionZ *= scaled; - } - - this.posX += this.motionX; - this.posY += this.motionY; - this.posZ += this.motionZ; + double mult = this.motionMult * getSimulationSpeed(); + + this.posX += this.motionX * mult; + this.posY += this.motionY * mult; + this.posZ += this.motionZ * mult; this.updateColor(); } @@ -223,7 +233,6 @@ public class EntityNukeTorex extends Entity { dist = Math.max(dist, 1); double col = 2D / dist; - //col *= col; this.color = Vec3.createVectorHelper( Math.max(col * 2, 0.25), @@ -245,6 +254,30 @@ public class EntityNukeTorex extends Entity { prevColor.yCoord + (color.yCoord - prevColor.yCoord) * interp, prevColor.zCoord + (color.zCoord - prevColor.zCoord) * interp); } + + public float getAlpha() { + return 1F - ((float)age / (float)cloudletLife); + } + + private float startingScale = 1; + private float growingScale = 5F; + + public float getScale() { + return startingScale + ((float)age / (float)cloudletLife) * growingScale; + } + + public Cloudlet setScale(float start, float grow) { + this.startingScale = start; + this.growingScale = grow; + return this; + } + + private double motionMult = 1F; + + public Cloudlet setMotion(double mult) { + this.motionMult = mult; + return this; + } } @Override diff --git a/src/main/java/com/hbm/render/entity/effect/RenderTorex.java b/src/main/java/com/hbm/render/entity/effect/RenderTorex.java index 3fc1195ed..661b57773 100644 --- a/src/main/java/com/hbm/render/entity/effect/RenderTorex.java +++ b/src/main/java/com/hbm/render/entity/effect/RenderTorex.java @@ -84,8 +84,8 @@ public class RenderTorex extends Render { private void tessellateCloudlet(Tessellator tess, double posX, double posY, double posZ, Cloudlet cloud, float interp) { - float alpha = 1F - ((float)cloud.age / (float)EntityNukeTorex.cloudletLife); - float scale = 1F + ((float)cloud.age / (float)EntityNukeTorex.cloudletLife) * 5; + float alpha = cloud.getAlpha(); + float scale = cloud.getScale(); float f1 = ActiveRenderInfo.rotationX; float f2 = ActiveRenderInfo.rotationZ; @@ -93,8 +93,6 @@ public class RenderTorex extends Render { float f4 = ActiveRenderInfo.rotationXY; float f5 = ActiveRenderInfo.rotationXZ; - //Random rand = new Random((long) ((posX * 5 + posY * 25 + posZ * 125) * 1000D)); - float brightness = 0.75F * cloud.colorMod; Vec3 color = cloud.getInterpColor(interp); tess.setColorRGBA_F((float)color.xCoord * brightness, (float)color.yCoord * brightness, (float)color.zCoord * brightness, alpha); From 2952e175b5ad3737954c60f529f797fbb4d06c4f Mon Sep 17 00:00:00 2001 From: Boblet Date: Tue, 21 Jun 2022 16:56:51 +0200 Subject: [PATCH 2/4] fixes and fusion power ports --- .../java/com/hbm/handler/ToolAbility.java | 10 ++++++++- .../machine/TileEntityFurnaceIron.java | 21 ++++++++++++++++--- .../tileentity/machine/TileEntityITER.java | 18 +++++++++++++--- 3 files changed, 42 insertions(+), 7 deletions(-) diff --git a/src/main/java/com/hbm/handler/ToolAbility.java b/src/main/java/com/hbm/handler/ToolAbility.java index babf7af38..77eb41b7d 100644 --- a/src/main/java/com/hbm/handler/ToolAbility.java +++ b/src/main/java/com/hbm/handler/ToolAbility.java @@ -97,7 +97,7 @@ public abstract class ToolAbility { int meta = world.getBlockMetadata(x, y, z); int refMeta = world.getBlockMetadata(refX, refY, refZ); - if(b != ref) + if(!isSameBlock(b, ref)) return; if(meta != refMeta) @@ -122,6 +122,14 @@ public abstract class ToolAbility { } } } + + private boolean isSameBlock(Block b1, Block b2) { + + if(b1 == b2) return true; + if((b1 == Blocks.redstone_ore && b2 == Blocks.lit_redstone_ore) || (b1 == Blocks.lit_redstone_ore && b2 == Blocks.redstone_ore)) return true; + + return false; + } @Override public String getName() { diff --git a/src/main/java/com/hbm/tileentity/machine/TileEntityFurnaceIron.java b/src/main/java/com/hbm/tileentity/machine/TileEntityFurnaceIron.java index a4b79c8e3..889ceeb15 100644 --- a/src/main/java/com/hbm/tileentity/machine/TileEntityFurnaceIron.java +++ b/src/main/java/com/hbm/tileentity/machine/TileEntityFurnaceIron.java @@ -3,13 +3,11 @@ package com.hbm.tileentity.machine; import com.hbm.inventory.UpgradeManager; import com.hbm.inventory.container.ContainerFurnaceIron; import com.hbm.inventory.gui.GUIFurnaceIron; -import com.hbm.items.ModItems; import com.hbm.items.machine.ItemMachineUpgrade.UpgradeType; import com.hbm.module.ModuleBurnTime; import com.hbm.tileentity.IGUIProvider; import com.hbm.tileentity.TileEntityMachineBase; -import api.hbm.energy.IBatteryItem; import cpw.mods.fml.relauncher.Side; import cpw.mods.fml.relauncher.SideOnly; import net.minecraft.client.gui.GuiScreen; @@ -18,7 +16,6 @@ import net.minecraft.inventory.Container; import net.minecraft.item.ItemStack; import net.minecraft.item.crafting.FurnaceRecipes; import net.minecraft.nbt.NBTTagCompound; -import net.minecraft.tileentity.TileEntityFurnace; import net.minecraft.util.AxisAlignedBB; import net.minecraft.world.World; import net.minecraftforge.common.util.ForgeDirection; @@ -180,6 +177,24 @@ public class TileEntityFurnaceIron extends TileEntityMachineBase implements IGUI public boolean canExtractItem(int i, ItemStack itemStack, int j) { return i == 3; } + + @Override + public void readFromNBT(NBTTagCompound nbt) { + super.readFromNBT(nbt); + + this.maxBurnTime = nbt.getInteger("maxBurnTime"); + this.burnTime = nbt.getInteger("burnTime"); + this.progress = nbt.getInteger("progress"); + } + + @Override + public void writeToNBT(NBTTagCompound nbt) { + super.writeToNBT(nbt); + + nbt.setInteger("maxBurnTime", maxBurnTime); + nbt.setInteger("burnTime", burnTime); + nbt.setInteger("progress", progress); + } @Override public Container provideContainer(int ID, EntityPlayer player, World world, int x, int y, int z) { diff --git a/src/main/java/com/hbm/tileentity/machine/TileEntityITER.java b/src/main/java/com/hbm/tileentity/machine/TileEntityITER.java index fbbc253c8..63f66db13 100644 --- a/src/main/java/com/hbm/tileentity/machine/TileEntityITER.java +++ b/src/main/java/com/hbm/tileentity/machine/TileEntityITER.java @@ -82,6 +82,7 @@ public class TileEntityITER extends TileEntityMachineBase implements IEnergyUser if (age == 9 || age == 19) fillFluidInit(tanks[1].getTankType()); + this.updateConnections(); power = Library.chargeTEFromItems(slots, 0, power, maxPower); /// START Processing part /// @@ -165,9 +166,6 @@ public class TileEntityITER extends TileEntityMachineBase implements IEnergyUser this.networkPack(data, 250); /// END Notif packets /// - - this.trySubscribe(worldObj, xCoord, yCoord + 3, zCoord, ForgeDirection.UP); - this.trySubscribe(worldObj, xCoord, yCoord - 3, zCoord, ForgeDirection.DOWN); } else { @@ -185,6 +183,20 @@ public class TileEntityITER extends TileEntityMachineBase implements IEnergyUser } } + private void updateConnections() { + + this.trySubscribe(worldObj, xCoord, yCoord + 3, zCoord, ForgeDirection.UP); + this.trySubscribe(worldObj, xCoord, yCoord - 3, zCoord, ForgeDirection.DOWN); + + Vec3 vec = Vec3.createVectorHelper(5.75, 0, 0); + + for(int i = 0; i < 16; i++) { + vec.rotateAroundY((float) (Math.PI / 8)); + this.trySubscribe(worldObj, xCoord + (int)vec.xCoord, yCoord + 3, zCoord + (int)vec.zCoord, ForgeDirection.UP); + this.trySubscribe(worldObj, xCoord + (int)vec.xCoord, yCoord - 3, zCoord + (int)vec.zCoord, ForgeDirection.DOWN); + } + } + private void explode() { this.disassemble(); From c98a011141c43b23f607c81da3f6342f96a4eb98 Mon Sep 17 00:00:00 2001 From: Bob Date: Tue, 21 Jun 2022 22:56:20 +0200 Subject: [PATCH 3/4] manual artillery contoller --- .../projectile/EntityArtilleryShell.java | 1 + src/main/java/com/hbm/items/ModItems.java | 3 + .../items/tool/ItemDesignatorArtyRange.java | 93 ++++++++++++++ .../turret/TileEntityTurretArty.java | 113 +++++++++++++++++- .../hbm/textures/items/designator_arty.png | Bin 0 -> 299 bytes .../textures/items/designator_arty_range.png | Bin 0 -> 259 bytes 6 files changed, 206 insertions(+), 4 deletions(-) create mode 100644 src/main/java/com/hbm/items/tool/ItemDesignatorArtyRange.java create mode 100644 src/main/resources/assets/hbm/textures/items/designator_arty.png create mode 100644 src/main/resources/assets/hbm/textures/items/designator_arty_range.png diff --git a/src/main/java/com/hbm/entity/projectile/EntityArtilleryShell.java b/src/main/java/com/hbm/entity/projectile/EntityArtilleryShell.java index 94db45ec8..59c7cb984 100644 --- a/src/main/java/com/hbm/entity/projectile/EntityArtilleryShell.java +++ b/src/main/java/com/hbm/entity/projectile/EntityArtilleryShell.java @@ -1,5 +1,6 @@ package com.hbm.entity.projectile; +import com.hbm.entity.effect.EntityNukeTorex; import com.hbm.entity.logic.IChunkLoader; import cpw.mods.fml.relauncher.Side; diff --git a/src/main/java/com/hbm/items/ModItems.java b/src/main/java/com/hbm/items/ModItems.java index 897408806..7eaa6edb2 100644 --- a/src/main/java/com/hbm/items/ModItems.java +++ b/src/main/java/com/hbm/items/ModItems.java @@ -1212,6 +1212,7 @@ public class ModItems { public static Item designator; public static Item designator_range; public static Item designator_manual; + public static Item designator_arty_range; public static Item linker; public static Item reactor_sensor; public static Item oil_detector; @@ -3976,6 +3977,7 @@ public class ModItems { designator = new ItemDesingator().setUnlocalizedName("designator").setMaxStackSize(1).setCreativeTab(MainRegistry.missileTab).setTextureName(RefStrings.MODID + ":designator"); designator_range = new ItemDesingatorRange().setUnlocalizedName("designator_range").setFull3D().setMaxStackSize(1).setCreativeTab(MainRegistry.missileTab).setTextureName(RefStrings.MODID + ":designator_range_alt"); designator_manual = new ItemDesingatorManual().setUnlocalizedName("designator_manual").setMaxStackSize(1).setCreativeTab(MainRegistry.missileTab).setTextureName(RefStrings.MODID + ":designator_manual"); + designator_arty_range = new ItemDesignatorArtyRange().setUnlocalizedName("designator_arty_range").setCreativeTab(MainRegistry.missileTab).setTextureName(RefStrings.MODID + ":designator_arty_range"); missile_assembly = new Item().setUnlocalizedName("missile_assembly").setMaxStackSize(1).setCreativeTab(MainRegistry.partsTab).setTextureName(RefStrings.MODID + ":missile_assembly"); missile_generic = new Item().setUnlocalizedName("missile_generic").setMaxStackSize(1).setCreativeTab(MainRegistry.missileTab).setTextureName(RefStrings.MODID + ":missile_generic"); missile_anti_ballistic = new Item().setUnlocalizedName("missile_anti_ballistic").setMaxStackSize(1).setCreativeTab(MainRegistry.missileTab).setTextureName(RefStrings.MODID + ":missile_anti_ballistic"); @@ -6926,6 +6928,7 @@ public class ModItems { GameRegistry.registerItem(designator, designator.getUnlocalizedName()); GameRegistry.registerItem(designator_range, designator_range.getUnlocalizedName()); GameRegistry.registerItem(designator_manual, designator_manual.getUnlocalizedName()); + GameRegistry.registerItem(designator_arty_range, designator_arty_range.getUnlocalizedName()); GameRegistry.registerItem(turret_control, turret_control.getUnlocalizedName()); GameRegistry.registerItem(turret_chip, turret_chip.getUnlocalizedName()); //GameRegistry.registerItem(turret_biometry, turret_biometry.getUnlocalizedName()); diff --git a/src/main/java/com/hbm/items/tool/ItemDesignatorArtyRange.java b/src/main/java/com/hbm/items/tool/ItemDesignatorArtyRange.java new file mode 100644 index 000000000..b69f70150 --- /dev/null +++ b/src/main/java/com/hbm/items/tool/ItemDesignatorArtyRange.java @@ -0,0 +1,93 @@ +package com.hbm.items.tool; + +import java.util.List; + +import com.hbm.blocks.ModBlocks; +import com.hbm.blocks.turret.TurretArty; +import com.hbm.lib.Library; +import com.hbm.tileentity.turret.TileEntityTurretArty; + +import net.minecraft.block.Block; +import net.minecraft.entity.player.EntityPlayer; +import net.minecraft.item.Item; +import net.minecraft.item.ItemStack; +import net.minecraft.nbt.NBTTagCompound; +import net.minecraft.tileentity.TileEntity; +import net.minecraft.util.EnumChatFormatting; +import net.minecraft.util.MovingObjectPosition; +import net.minecraft.world.World; + +public class ItemDesignatorArtyRange extends Item { + + public ItemDesignatorArtyRange() { + this.setFull3D(); + this.setMaxStackSize(1); + } + + @Override + public void addInformation(ItemStack itemstack, EntityPlayer player, List list, boolean bool) { + if(itemstack.getTagCompound() == null) { + list.add(EnumChatFormatting.RED + "No turret linked!"); + } else { + list.add(EnumChatFormatting.YELLOW + "Linked to " + itemstack.stackTagCompound.getInteger("x") + ", " + itemstack.stackTagCompound.getInteger("y") + ", " + itemstack.stackTagCompound.getInteger("z")); + } + } + + @Override + public boolean onItemUse(ItemStack stack, EntityPlayer player, World world, int x, int y, int z, int side, float hitX, float hitY, float hitZ) { + + Block b = world.getBlock(x, y, z); + + if(b == ModBlocks.turret_arty) { + int pos[] = ((TurretArty) b).findCore(world, x, y, z); + + if(pos == null) + return false; + + TileEntity te = world.getTileEntity(pos[0], pos[1], pos[2]); + + if(te instanceof TileEntityTurretArty) { + + if(world.isRemote) + return true; + + if(!stack.hasTagCompound()) + stack.stackTagCompound = new NBTTagCompound(); + + stack.stackTagCompound.setInteger("x", pos[0]); + stack.stackTagCompound.setInteger("y", pos[1]); + stack.stackTagCompound.setInteger("z", pos[2]); + world.playSoundAtEntity(player, "hbm:item.techBleep", 1.0F, 1.0F); + return true; + } + } + + return false; + } + + @Override + public ItemStack onItemRightClick(ItemStack stack, World world, EntityPlayer player) { + + if(!stack.hasTagCompound()) + return stack; + + MovingObjectPosition pos = Library.rayTrace(player, 500, 1); + int x = pos.blockX; + int y = pos.blockY; + int z = pos.blockZ; + + if(!world.isRemote) { + TileEntity te = world.getTileEntity(stack.stackTagCompound.getInteger("x"), stack.stackTagCompound.getInteger("y"), stack.stackTagCompound.getInteger("z")); + + if(te instanceof TileEntityTurretArty) { + TileEntityTurretArty arty = (TileEntityTurretArty) te; + if(arty.mode == arty.MODE_MANUAL) { + arty.enqueueTarget(x + 0.5, y + 0.5, z + 0.5); + world.playSoundAtEntity(player, "hbm:item.techBoop", 1.0F, 1.0F); + } + } + } + + return stack; + } +} diff --git a/src/main/java/com/hbm/tileentity/turret/TileEntityTurretArty.java b/src/main/java/com/hbm/tileentity/turret/TileEntityTurretArty.java index f3206da5d..7728a7e13 100644 --- a/src/main/java/com/hbm/tileentity/turret/TileEntityTurretArty.java +++ b/src/main/java/com/hbm/tileentity/turret/TileEntityTurretArty.java @@ -16,12 +16,9 @@ import com.hbm.tileentity.IGUIProvider; import cpw.mods.fml.common.network.NetworkRegistry.TargetPoint; import net.minecraft.client.gui.GuiScreen; import net.minecraft.entity.Entity; -import net.minecraft.entity.EntityLivingBase; import net.minecraft.entity.player.EntityPlayer; import net.minecraft.inventory.Container; import net.minecraft.nbt.NBTTagCompound; -import net.minecraft.potion.Potion; -import net.minecraft.util.AxisAlignedBB; import net.minecraft.util.Vec3; import net.minecraft.world.World; @@ -35,6 +32,8 @@ public class TileEntityTurretArty extends TileEntityTurretBaseNT implements IGUI private boolean retracting = false; public double barrelPos = 0; public double lastBarrelPos = 0; + + private List targetQueue = new ArrayList(); static List configs = new ArrayList(); @@ -46,6 +45,10 @@ public class TileEntityTurretArty extends TileEntityTurretBaseNT implements IGUI configs.add(BulletConfigSyncingUtil.SHELL_W9); } + public void enqueueTarget(double x, double y, double z) { + this.targetQueue.add(Vec3.createVectorHelper(x, y, z)); + } + @Override protected List getAmmoList() { return configs; @@ -195,7 +198,104 @@ public class TileEntityTurretArty extends TileEntityTurretBaseNT implements IGUI } } - super.updateEntity(); + if(this.mode == this.MODE_MANUAL) { + if(!this.targetQueue.isEmpty()) { + this.tPos = this.targetQueue.get(0); + } + } else { + this.targetQueue.clear(); + } + + if(worldObj.isRemote) { + this.lastRotationPitch = this.rotationPitch; + this.lastRotationYaw = this.rotationYaw; + } + + this.aligned = false; + + if(!worldObj.isRemote) { + + if(this.target != null && !target.isEntityAlive()) { + this.target = null; + this.stattrak++; + } + } + + if(target != null && this.mode != this.MODE_MANUAL) { + if(!this.entityInLOS(this.target)) { + this.target = null; + } + } + + if(!worldObj.isRemote) { + + if(target != null) { + this.tPos = this.getEntityPos(target); + } else { + if(this.mode != this.MODE_MANUAL) { + this.tPos = null; + } + } + } + + if(isOn() && hasPower()) { + + if(tPos != null) + this.alignTurret(); + } else { + + this.target = null; + this.tPos = null; + } + + if(!worldObj.isRemote) { + + if(this.target != null && !target.isEntityAlive()) { + this.target = null; + this.tPos = null; + this.stattrak++; + } + + if(isOn() && hasPower()) { + searchTimer--; + + this.setPower(this.getPower() - this.getConsumption()); + + if(searchTimer <= 0) { + searchTimer = this.getDecetorInterval(); + + if(this.target == null) + this.seekNewTarget(); + } + } else { + searchTimer = 0; + } + + if(this.aligned) { + this.updateFiringTick(); + } + + this.power = Library.chargeTEFromItems(slots, 10, this.power, this.getMaxPower()); + + NBTTagCompound data = this.writePacket(); + this.networkPack(data, 250); + + } else { + + Vec3 vec = Vec3.createVectorHelper(this.getBarrelLength(), 0, 0); + vec.rotateAroundZ((float) -this.rotationPitch); + vec.rotateAroundY((float) -(this.rotationYaw + Math.PI * 0.5)); + + //this will fix the interpolation error when the turret crosses the 360° point + if(Math.abs(this.lastRotationYaw - this.rotationYaw) > Math.PI) { + + if(this.lastRotationYaw < this.rotationYaw) + this.lastRotationYaw += Math.PI * 2; + else + this.lastRotationYaw -= Math.PI * 2; + } + } + this.didJustShoot = false; } @@ -220,6 +320,11 @@ public class TileEntityTurretArty extends TileEntityTurretBaseNT implements IGUI vec.rotateAroundY((float) -(this.rotationYaw + Math.PI * 0.5)); this.didJustShoot = true; + if(this.mode == this.MODE_MANUAL && !this.targetQueue.isEmpty()) { + this.targetQueue.remove(0); + this.tPos = null; + } + NBTTagCompound data = new NBTTagCompound(); data.setString("type", "vanillaExt"); data.setString("mode", "largeexplode"); diff --git a/src/main/resources/assets/hbm/textures/items/designator_arty.png b/src/main/resources/assets/hbm/textures/items/designator_arty.png new file mode 100644 index 0000000000000000000000000000000000000000..29d9482423384557abe60753f5c2475d2f1ff54f GIT binary patch literal 299 zcmeAS@N?(olHy`uVBq!ia0vp^0wB!63?wyl`GbKJV{wqX6T`Z5GB1G~mUKs7M+SzC z{oH>NS%G}x0G|-oyu7^l`1pDThFA5*ukywJZ>j&kq5S{+=>OAv{%0{TNHYDGWV)Rz z_rF*9c82KfDiff-fK|4qfRtcKkYDhBG{B&`c4iV#lC!`gvY3H^?*IrhW?k##1PZ2j zx;Tbt1m~WPNS%G}T0G|-o+qrW8r}_NfQm>$(@V{5NVA20Cb?iK;|DERk|1#SNs47DLG(V8y zE(!7r{tpKXUjB@qfWn*w9+AZi419+`m{C;2s{tq&;_2cTq7fW>##`us0ta(IhM@L$ z`vUJDS0=VjwsGB*%w*=K^6#kd$FC>%HahT#2{f5U=w&u+IHG#M_1K3=2}?d(CMv04 oh>|iq|Bf|kZ}_V3%PrINWpdabGb9CE1Dem^>FVdQ&MBb@0Ih>sKmY&$ literal 0 HcmV?d00001 From aebcf90026391bfd6c387db995c6de26b9bfb6f0 Mon Sep 17 00:00:00 2001 From: Boblet Date: Wed, 22 Jun 2022 16:58:48 +0200 Subject: [PATCH 4/4] iron furnace fix, artillery shells --- .../projectile/EntityArtilleryShell.java | 39 +++++++++- .../com/hbm/items/weapon/ItemAmmoArty.java | 73 ++++++++++++++----- .../machine/TileEntityFurnaceIron.java | 1 + .../turret/TileEntityTurretArty.java | 3 + 4 files changed, 94 insertions(+), 22 deletions(-) diff --git a/src/main/java/com/hbm/entity/projectile/EntityArtilleryShell.java b/src/main/java/com/hbm/entity/projectile/EntityArtilleryShell.java index 59c7cb984..aa3932408 100644 --- a/src/main/java/com/hbm/entity/projectile/EntityArtilleryShell.java +++ b/src/main/java/com/hbm/entity/projectile/EntityArtilleryShell.java @@ -1,10 +1,12 @@ package com.hbm.entity.projectile; -import com.hbm.entity.effect.EntityNukeTorex; import com.hbm.entity.logic.IChunkLoader; +import com.hbm.items.weapon.ItemAmmoArty; +import com.hbm.items.weapon.ItemAmmoArty.ArtilleryShell; import cpw.mods.fml.relauncher.Side; import cpw.mods.fml.relauncher.SideOnly; +import net.minecraft.nbt.NBTTagCompound; import net.minecraft.util.MathHelper; import net.minecraft.util.MovingObjectPosition; import net.minecraft.util.Vec3; @@ -33,12 +35,18 @@ public class EntityArtilleryShell extends EntityThrowableNT implements IChunkLoa private double targetX; private double targetY; private double targetZ; + private boolean shouldWhistle = false; private boolean didWhistle = false; public EntityArtilleryShell(World world) { super(world); this.ignoreFrustumCheck = true; } + + @Override + protected void entityInit() { + this.dataWatcher.addObject(10, new Integer(0)); + } @Override @SideOnly(Side.CLIENT) @@ -46,19 +54,36 @@ public class EntityArtilleryShell extends EntityThrowableNT implements IChunkLoa return true; } + public EntityArtilleryShell setType(int type) { + this.dataWatcher.updateObject(10, type); + return this; + } + + public ArtilleryShell getType() { + try { + return ItemAmmoArty.types[this.dataWatcher.getWatchableObjectInt(10)]; + } catch(Exception ex) { + return ItemAmmoArty.types[0]; + } + } + public void setTarget(int x, int y, int z) { this.targetX = x; this.targetY = y; this.targetZ = z; } + public void setWhistle(boolean whistle) { + this.shouldWhistle = whistle; + } + @Override public void onUpdate() { if(!worldObj.isRemote) { super.onUpdate(); - if(!didWhistle) { + if(!didWhistle && this.shouldWhistle) { double speed = Math.sqrt(this.motionX * this.motionX + this.motionZ * this.motionZ); double deltaX = this.posX - this.targetX; double deltaZ = this.posZ - this.targetZ; @@ -128,6 +153,16 @@ public class EntityArtilleryShell extends EntityThrowableNT implements IChunkLoa } } + @Override + public void writeEntityToNBT(NBTTagCompound nbt) { + super.writeEntityToNBT(nbt); + } + + @Override + public void readEntityFromNBT(NBTTagCompound nbt) { + super.readEntityFromNBT(nbt); + } + @Override protected float getAirDrag() { return 1.0F; diff --git a/src/main/java/com/hbm/items/weapon/ItemAmmoArty.java b/src/main/java/com/hbm/items/weapon/ItemAmmoArty.java index 7fd5cd5e3..ca959594c 100644 --- a/src/main/java/com/hbm/items/weapon/ItemAmmoArty.java +++ b/src/main/java/com/hbm/items/weapon/ItemAmmoArty.java @@ -2,9 +2,9 @@ package com.hbm.items.weapon; import java.util.List; +import com.hbm.entity.projectile.EntityArtilleryShell; import com.hbm.lib.RefStrings; import com.hbm.main.MainRegistry; -import com.hbm.util.EnumUtil; import cpw.mods.fml.relauncher.Side; import cpw.mods.fml.relauncher.SideOnly; @@ -13,45 +13,40 @@ import net.minecraft.creativetab.CreativeTabs; import net.minecraft.item.Item; import net.minecraft.item.ItemStack; import net.minecraft.util.IIcon; +import net.minecraft.util.MovingObjectPosition; public class ItemAmmoArty extends Item { - public static enum EnumArtyType { - NORMAL("ammo_arty"), - CLASSIC("ammo_arty_classic"), - EXPLOSIVE("ammo_arty_he"), - MINI_NUKE("ammo_arty_mini_nuke"), - NUKE("ammo_arty_nuke"); - - private String name; - - private EnumArtyType(String texture) { - this.name = texture; - } - } + public static ArtilleryShell[] types = new ArtilleryShell[5]; + public int NORMAL = 0; + public int CLASSIC = 1; + public int EXPLOSIVE = 2; + public int MINI_NUKE = 3; + public int NUKE = 4; public ItemAmmoArty() { this.setHasSubtypes(true); this.setCreativeTab(MainRegistry.weaponTab); + init(); } @Override @SideOnly(Side.CLIENT) public void getSubItems(Item item, CreativeTabs tab, List list) { - for(int i = 0; i < EnumArtyType.values().length; i++) { + for(int i = 0; i < types.length; i++) { list.add(new ItemStack(item, 1, i)); } } - private IIcon[] icons = new IIcon[EnumArtyType.values().length]; + private IIcon[] icons = new IIcon[types.length]; @SideOnly(Side.CLIENT) public void registerIcons(IIconRegister reg) { - this.icons = new IIcon[EnumArtyType.values().length]; + this.icons = new IIcon[types.length]; for(int i = 0; i < icons.length; i++) { - this.icons[i] = reg.registerIcon(RefStrings.MODID + ":" + EnumArtyType.values()[i].name); + this.icons[i] = reg.registerIcon(RefStrings.MODID + ":" + types[i].name); } } @@ -63,7 +58,45 @@ public class ItemAmmoArty extends Item { @Override public String getUnlocalizedName(ItemStack stack) { - EnumArtyType num = EnumUtil.grabEnumSafely(EnumArtyType.class, stack.getItemDamage()); - return "item." + num.name; + return "item." + types[Math.abs(stack.getItemDamage()) % types.length].name; + } + + public static abstract class ArtilleryShell { + + String name; + + public ArtilleryShell(String name) { + this.name = name; + } + + public abstract void onImpact(EntityArtilleryShell shell, MovingObjectPosition mop); + } + + private void init() { + this.types[NORMAL] = new ArtilleryShell("ammo_arty") { + @Override public void onImpact(EntityArtilleryShell shell, MovingObjectPosition mop) { + shell.setDead(); + } + }; + this.types[CLASSIC] = new ArtilleryShell("ammo_arty") { + @Override public void onImpact(EntityArtilleryShell shell, MovingObjectPosition mop) { + shell.setDead(); + } + }; + this.types[EXPLOSIVE] = new ArtilleryShell("ammo_arty") { + @Override public void onImpact(EntityArtilleryShell shell, MovingObjectPosition mop) { + shell.setDead(); + } + }; + this.types[MINI_NUKE] = new ArtilleryShell("ammo_arty") { + @Override public void onImpact(EntityArtilleryShell shell, MovingObjectPosition mop) { + shell.setDead(); + } + }; + this.types[NUKE] = new ArtilleryShell("ammo_arty") { + @Override public void onImpact(EntityArtilleryShell shell, MovingObjectPosition mop) { + shell.setDead(); + } + }; } } diff --git a/src/main/java/com/hbm/tileentity/machine/TileEntityFurnaceIron.java b/src/main/java/com/hbm/tileentity/machine/TileEntityFurnaceIron.java index 889ceeb15..2b8fcab0b 100644 --- a/src/main/java/com/hbm/tileentity/machine/TileEntityFurnaceIron.java +++ b/src/main/java/com/hbm/tileentity/machine/TileEntityFurnaceIron.java @@ -202,6 +202,7 @@ public class TileEntityFurnaceIron extends TileEntityMachineBase implements IGUI } @Override + @SideOnly(Side.CLIENT) public GuiScreen provideGUI(int ID, EntityPlayer player, World world, int x, int y, int z) { return new GUIFurnaceIron(player.inventory, this); } diff --git a/src/main/java/com/hbm/tileentity/turret/TileEntityTurretArty.java b/src/main/java/com/hbm/tileentity/turret/TileEntityTurretArty.java index 7728a7e13..050a1f007 100644 --- a/src/main/java/com/hbm/tileentity/turret/TileEntityTurretArty.java +++ b/src/main/java/com/hbm/tileentity/turret/TileEntityTurretArty.java @@ -14,6 +14,8 @@ import com.hbm.packet.PacketDispatcher; import com.hbm.tileentity.IGUIProvider; import cpw.mods.fml.common.network.NetworkRegistry.TargetPoint; +import cpw.mods.fml.relauncher.Side; +import cpw.mods.fml.relauncher.SideOnly; import net.minecraft.client.gui.GuiScreen; import net.minecraft.entity.Entity; import net.minecraft.entity.player.EntityPlayer; @@ -367,6 +369,7 @@ public class TileEntityTurretArty extends TileEntityTurretBaseNT implements IGUI } @Override + @SideOnly(Side.CLIENT) public GuiScreen provideGUI(int ID, EntityPlayer player, World world, int x, int y, int z) { return new GUITurretArty(player.inventory, this); }