iron furnace fix, artillery shells

This commit is contained in:
Boblet 2022-06-22 16:58:48 +02:00
parent c98a011141
commit aebcf90026
4 changed files with 94 additions and 22 deletions

View File

@ -1,10 +1,12 @@
package com.hbm.entity.projectile; package com.hbm.entity.projectile;
import com.hbm.entity.effect.EntityNukeTorex;
import com.hbm.entity.logic.IChunkLoader; 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.Side;
import cpw.mods.fml.relauncher.SideOnly; import cpw.mods.fml.relauncher.SideOnly;
import net.minecraft.nbt.NBTTagCompound;
import net.minecraft.util.MathHelper; import net.minecraft.util.MathHelper;
import net.minecraft.util.MovingObjectPosition; import net.minecraft.util.MovingObjectPosition;
import net.minecraft.util.Vec3; import net.minecraft.util.Vec3;
@ -33,12 +35,18 @@ public class EntityArtilleryShell extends EntityThrowableNT implements IChunkLoa
private double targetX; private double targetX;
private double targetY; private double targetY;
private double targetZ; private double targetZ;
private boolean shouldWhistle = false;
private boolean didWhistle = false; private boolean didWhistle = false;
public EntityArtilleryShell(World world) { public EntityArtilleryShell(World world) {
super(world); super(world);
this.ignoreFrustumCheck = true; this.ignoreFrustumCheck = true;
} }
@Override
protected void entityInit() {
this.dataWatcher.addObject(10, new Integer(0));
}
@Override @Override
@SideOnly(Side.CLIENT) @SideOnly(Side.CLIENT)
@ -46,19 +54,36 @@ public class EntityArtilleryShell extends EntityThrowableNT implements IChunkLoa
return true; 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) { public void setTarget(int x, int y, int z) {
this.targetX = x; this.targetX = x;
this.targetY = y; this.targetY = y;
this.targetZ = z; this.targetZ = z;
} }
public void setWhistle(boolean whistle) {
this.shouldWhistle = whistle;
}
@Override @Override
public void onUpdate() { public void onUpdate() {
if(!worldObj.isRemote) { if(!worldObj.isRemote) {
super.onUpdate(); super.onUpdate();
if(!didWhistle) { if(!didWhistle && this.shouldWhistle) {
double speed = Math.sqrt(this.motionX * this.motionX + this.motionZ * this.motionZ); double speed = Math.sqrt(this.motionX * this.motionX + this.motionZ * this.motionZ);
double deltaX = this.posX - this.targetX; double deltaX = this.posX - this.targetX;
double deltaZ = this.posZ - this.targetZ; 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 @Override
protected float getAirDrag() { protected float getAirDrag() {
return 1.0F; return 1.0F;

View File

@ -2,9 +2,9 @@ package com.hbm.items.weapon;
import java.util.List; import java.util.List;
import com.hbm.entity.projectile.EntityArtilleryShell;
import com.hbm.lib.RefStrings; import com.hbm.lib.RefStrings;
import com.hbm.main.MainRegistry; import com.hbm.main.MainRegistry;
import com.hbm.util.EnumUtil;
import cpw.mods.fml.relauncher.Side; import cpw.mods.fml.relauncher.Side;
import cpw.mods.fml.relauncher.SideOnly; import cpw.mods.fml.relauncher.SideOnly;
@ -13,45 +13,40 @@ import net.minecraft.creativetab.CreativeTabs;
import net.minecraft.item.Item; import net.minecraft.item.Item;
import net.minecraft.item.ItemStack; import net.minecraft.item.ItemStack;
import net.minecraft.util.IIcon; import net.minecraft.util.IIcon;
import net.minecraft.util.MovingObjectPosition;
public class ItemAmmoArty extends Item { public class ItemAmmoArty extends Item {
public static enum EnumArtyType { public static ArtilleryShell[] types = new ArtilleryShell[5];
NORMAL("ammo_arty"), public int NORMAL = 0;
CLASSIC("ammo_arty_classic"), public int CLASSIC = 1;
EXPLOSIVE("ammo_arty_he"), public int EXPLOSIVE = 2;
MINI_NUKE("ammo_arty_mini_nuke"), public int MINI_NUKE = 3;
NUKE("ammo_arty_nuke"); public int NUKE = 4;
private String name;
private EnumArtyType(String texture) {
this.name = texture;
}
}
public ItemAmmoArty() { public ItemAmmoArty() {
this.setHasSubtypes(true); this.setHasSubtypes(true);
this.setCreativeTab(MainRegistry.weaponTab); this.setCreativeTab(MainRegistry.weaponTab);
init();
} }
@Override @Override
@SideOnly(Side.CLIENT) @SideOnly(Side.CLIENT)
public void getSubItems(Item item, CreativeTabs tab, List list) { 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)); 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) @SideOnly(Side.CLIENT)
public void registerIcons(IIconRegister reg) { 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++) { 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 @Override
public String getUnlocalizedName(ItemStack stack) { public String getUnlocalizedName(ItemStack stack) {
EnumArtyType num = EnumUtil.grabEnumSafely(EnumArtyType.class, stack.getItemDamage()); return "item." + types[Math.abs(stack.getItemDamage()) % types.length].name;
return "item." + num.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();
}
};
} }
} }

View File

@ -202,6 +202,7 @@ public class TileEntityFurnaceIron extends TileEntityMachineBase implements IGUI
} }
@Override @Override
@SideOnly(Side.CLIENT)
public GuiScreen provideGUI(int ID, EntityPlayer player, World world, int x, int y, int z) { public GuiScreen provideGUI(int ID, EntityPlayer player, World world, int x, int y, int z) {
return new GUIFurnaceIron(player.inventory, this); return new GUIFurnaceIron(player.inventory, this);
} }

View File

@ -14,6 +14,8 @@ import com.hbm.packet.PacketDispatcher;
import com.hbm.tileentity.IGUIProvider; import com.hbm.tileentity.IGUIProvider;
import cpw.mods.fml.common.network.NetworkRegistry.TargetPoint; 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.client.gui.GuiScreen;
import net.minecraft.entity.Entity; import net.minecraft.entity.Entity;
import net.minecraft.entity.player.EntityPlayer; import net.minecraft.entity.player.EntityPlayer;
@ -367,6 +369,7 @@ public class TileEntityTurretArty extends TileEntityTurretBaseNT implements IGUI
} }
@Override @Override
@SideOnly(Side.CLIENT)
public GuiScreen provideGUI(int ID, EntityPlayer player, World world, int x, int y, int z) { public GuiScreen provideGUI(int ID, EntityPlayer player, World world, int x, int y, int z) {
return new GUITurretArty(player.inventory, this); return new GUITurretArty(player.inventory, this);
} }