mirror of
https://github.com/HbmMods/Hbm-s-Nuclear-Tech-GIT.git
synced 2026-01-25 10:32:49 +00:00
iron furnace fix, artillery shells
This commit is contained in:
parent
c98a011141
commit
aebcf90026
@ -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;
|
||||
|
||||
@ -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();
|
||||
}
|
||||
};
|
||||
}
|
||||
}
|
||||
|
||||
@ -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);
|
||||
}
|
||||
|
||||
@ -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);
|
||||
}
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user