made jetpacks less garbage, new explosion FX test

This commit is contained in:
Bob 2021-01-04 22:14:19 +01:00
parent af7e888376
commit 4462a48648
21 changed files with 671 additions and 274 deletions

Binary file not shown.

After

Width:  |  Height:  |  Size: 20 KiB

View File

@ -0,0 +1,50 @@
package com.hbm.extprop;
import com.hbm.handler.HbmKeybinds.EnumKeybind;
import net.minecraft.entity.Entity;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.nbt.NBTTagCompound;
import net.minecraft.world.World;
import net.minecraftforge.common.IExtendedEntityProperties;
public class HbmExtendedProperties implements IExtendedEntityProperties {
public static final String key = "NTM_EXT_PROPS";
public EntityPlayer player;
private boolean[] keysPressed = new boolean[EnumKeybind.values().length];
public HbmExtendedProperties(EntityPlayer player) {
this.player = player;
}
public static HbmExtendedProperties registerData(EntityPlayer player) {
player.registerExtendedProperties(key, new HbmExtendedProperties(player));
return (HbmExtendedProperties) player.getExtendedProperties(key);
}
public static HbmExtendedProperties getData(EntityPlayer player) {
HbmExtendedProperties props = (HbmExtendedProperties) player.getExtendedProperties(key);
return props != null ? props : registerData(player);
}
public boolean getKeyPressed(EnumKeybind key) {
return keysPressed[key.ordinal()];
}
public void setKeyPressed(EnumKeybind key, boolean pressed) {
keysPressed[key.ordinal()] = pressed;
}
@Override
public void init(Entity entity, World world) { }
@Override
public void saveNBTData(NBTTagCompound compound) { }
@Override
public void loadNBTData(NBTTagCompound compound) { }
}

View File

@ -0,0 +1,8 @@
package com.hbm.handler;
public class HbmKeybinds {
public static enum EnumKeybind {
JETPACK
}
}

View File

@ -12,8 +12,13 @@ import com.hbm.handler.GunConfiguration;
import com.hbm.interfaces.IBulletImpactBehavior;
import com.hbm.interfaces.IBulletUpdateBehavior;
import com.hbm.items.ModItems;
import com.hbm.packet.AuxParticlePacketNT;
import com.hbm.packet.PacketDispatcher;
import com.hbm.render.util.RenderScreenOverlay.Crosshair;
import cpw.mods.fml.common.network.NetworkRegistry.TargetPoint;
import net.minecraft.nbt.NBTTagCompound;
public class GunFatmanFactory {
public static GunConfiguration getFatmanConfig() {
@ -105,6 +110,22 @@ public class GunFatmanFactory {
bullet.ammo = ModItems.gun_fatman_ammo;
bullet.nuke = 0;
bullet.bImpact = new IBulletImpactBehavior() {
@Override
public void behaveBlockHit(EntityBulletBase bullet, int x, int y, int z) {
if(!bullet.worldObj.isRemote) {
NBTTagCompound data = new NBTTagCompound();
data.setString("type", "muke");
PacketDispatcher.wrapper.sendToAllAround(new AuxParticlePacketNT(data, bullet.posX, bullet.posY + 0.5, bullet.posZ), new TargetPoint(bullet.dimension, bullet.posX, bullet.posY, bullet.posZ, 250));
}
}
};
return bullet;
}

View File

@ -3,10 +3,7 @@ package com.hbm.inventory;
import com.hbm.handler.FluidTypeHandler.FluidType;
import com.hbm.inventory.gui.GuiInfoContainer;
import com.hbm.items.ModItems;
import com.hbm.items.armor.JetpackBooster;
import com.hbm.items.armor.JetpackBreak;
import com.hbm.items.armor.JetpackRegular;
import com.hbm.items.armor.JetpackVectorized;
import com.hbm.items.armor.JetpackBase;
import com.hbm.items.machine.ItemFluidIdentifier;
import com.hbm.lib.RefStrings;
import com.hbm.packet.PacketDispatcher;
@ -127,32 +124,12 @@ public class FluidTank {
ItemStack full = null;
if(slots[in] != null) {
//TODO: make an interface to handle cases like these
for(int i = 0; i < 25; i++) {
if(slots[in].getItem() == ModItems.jetpack_boost && this.type.name().equals(FluidType.KEROSENE.name())) {
if(this.fluid > 0 && JetpackBooster.getFuel(slots[in]) < JetpackBooster.maxFuel) {
if(slots[in].getItem() instanceof JetpackBase && ((JetpackBase)slots[in].getItem()).fuel == this.type) {
if(this.fluid > 0 && JetpackBase.getFuel(slots[in]) < ((JetpackBase)slots[in].getItem()).maxFuel) {
this.fluid--;
JetpackBooster.setFuel(slots[in], JetpackBooster.getFuel(slots[in]) + 1);
} else {
return;
}
} else if(slots[in].getItem() == ModItems.jetpack_break && this.type.name().equals(FluidType.KEROSENE.name())) {
if(this.fluid > 0 && JetpackBreak.getFuel(slots[in]) < JetpackBreak.maxFuel) {
this.fluid--;
JetpackBreak.setFuel(slots[in], JetpackBreak.getFuel(slots[in]) + 1);
} else {
return;
}
} else if(slots[in].getItem() == ModItems.jetpack_fly && this.type.name().equals(FluidType.KEROSENE.name())) {
if(this.fluid > 0 && JetpackRegular.getFuel(slots[in]) < JetpackRegular.maxFuel) {
this.fluid--;
JetpackRegular.setFuel(slots[in], JetpackRegular.getFuel(slots[in]) + 1);
} else {
return;
}
} else if(slots[in].getItem() == ModItems.jetpack_vector && this.type.name().equals(FluidType.KEROSENE.name())) {
if(this.fluid > 0 && JetpackVectorized.getFuel(slots[in]) < JetpackVectorized.maxFuel) {
this.fluid--;
JetpackVectorized.setFuel(slots[in], JetpackVectorized.getFuel(slots[in]) + 1);
JetpackBase.setFuel(slots[in], JetpackBase.getFuel(slots[in]) + 1);
} else {
return;
}

View File

@ -28,7 +28,7 @@ public class MagicRecipes {
comps.add(new ComparableStack(matrix.getStackInSlot(i)).makeSingular());
}
Collections.sort(comps);
//Collections.sort(comps);
for(MagicRecipe recipe : recipes) {
if(recipe.matches(comps))
@ -104,7 +104,7 @@ public class MagicRecipes {
public MagicRecipe(ItemStack out, AStack... in) {
this.out = out;
this.in = Arrays.asList(in);
Collections.sort(this.in);
//Collections.sort(this.in);
}
public boolean matches(List<ComparableStack> comps) {

View File

@ -5,6 +5,7 @@ import com.hbm.handler.BucketHandler;
import com.hbm.handler.ToolAbility;
import com.hbm.handler.ToolAbility.LuckAbility;
import com.hbm.handler.WeaponAbility;
import com.hbm.handler.FluidTypeHandler.FluidType;
import com.hbm.handler.guncfg.*;
import com.hbm.items.armor.*;
import com.hbm.items.bomb.*;
@ -4059,9 +4060,9 @@ public class ModItems {
australium_iii = new ArmorAustralium(MainRegistry.aMatAus3, 9, 1).setUnlocalizedName("australium_iii").setMaxStackSize(1).setTextureName(RefStrings.MODID + ":australium_iii");
jetpack_boost = new JetpackBooster(MainRegistry.aMatSteel, 9, 1).setUnlocalizedName("jetpack_boost").setMaxStackSize(1).setTextureName(RefStrings.MODID + ":jetpack_boost");
jetpack_break = new JetpackBreak(MainRegistry.aMatSteel, 9, 1).setUnlocalizedName("jetpack_break").setMaxStackSize(1).setTextureName(RefStrings.MODID + ":jetpack_break");
jetpack_fly = new JetpackRegular(MainRegistry.aMatSteel, 9, 1).setUnlocalizedName("jetpack_fly").setMaxStackSize(1).setTextureName(RefStrings.MODID + ":jetpack_fly");
jetpack_vector = new JetpackVectorized(MainRegistry.aMatSteel, 9, 1).setUnlocalizedName("jetpack_vector").setMaxStackSize(1).setTextureName(RefStrings.MODID + ":jetpack_vector");
jetpack_break = new JetpackBreak(MainRegistry.aMatSteel, 9, 1, FluidType.KEROSENE, 8000).setUnlocalizedName("jetpack_break").setMaxStackSize(1).setTextureName(RefStrings.MODID + ":jetpack_break");
jetpack_fly = new JetpackRegular(MainRegistry.aMatSteel, 9, 1, FluidType.KEROSENE, 12000).setUnlocalizedName("jetpack_fly").setMaxStackSize(1).setTextureName(RefStrings.MODID + ":jetpack_fly");
jetpack_vector = new JetpackVectorized(MainRegistry.aMatSteel, 9, 1, FluidType.KEROSENE, 16000).setUnlocalizedName("jetpack_vector").setMaxStackSize(1).setTextureName(RefStrings.MODID + ":jetpack_vector");
cape_test = new ArmorModel(MainRegistry.enumArmorMaterialEmerald, 9, 1).setUnlocalizedName("cape_test").setCreativeTab(null).setMaxStackSize(1).setTextureName(RefStrings.MODID + ":cape_test");
cape_radiation = new ArmorModel(ArmorMaterial.CHAIN, 9, 1).setUnlocalizedName("cape_radiation").setCreativeTab(MainRegistry.consumableTab).setMaxStackSize(1).setTextureName(RefStrings.MODID + ":cape_radiation");

View File

@ -0,0 +1,78 @@
package com.hbm.items.armor;
import java.util.List;
import com.hbm.handler.FluidTypeHandler.FluidType;
import com.hbm.render.model.ModelJetPack;
import com.hbm.util.I18nUtil;
import cpw.mods.fml.relauncher.Side;
import cpw.mods.fml.relauncher.SideOnly;
import net.minecraft.client.model.ModelBiped;
import net.minecraft.entity.Entity;
import net.minecraft.entity.EntityLivingBase;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.item.ItemArmor;
import net.minecraft.item.ItemStack;
import net.minecraft.nbt.NBTTagCompound;
public abstract class JetpackBase extends ItemArmor {
private ModelJetPack model;
public FluidType fuel;
public int maxFuel;
public JetpackBase(ArmorMaterial mat, int i, int j, FluidType fuel, int maxFuel) {
super(mat, i, j);
this.fuel = fuel;
this.maxFuel = maxFuel;
}
@Override
public void addInformation(ItemStack itemstack, EntityPlayer player, List list, boolean bool) {
list.add(I18nUtil.resolveKey(fuel.getUnlocalizedName()) + ": " + this.getFuel(itemstack) + "mB / " + this.maxFuel + "mB");
}
@Override
public boolean isValidArmor(ItemStack stack, int armorType, Entity entity) {
return armorType == 1;
}
@Override
@SideOnly(Side.CLIENT)
public ModelBiped getArmorModel(EntityLivingBase entityLiving, ItemStack itemStack, int armorSlot) {
if (armorSlot == 1) {
if (model == null) {
this.model = new ModelJetPack();
}
return this.model;
}
return null;
}
protected void useUpFuel(EntityPlayer player, ItemStack stack, int rate) {
if(player.ticksExisted % rate == 0)
this.setFuel(stack, this.getFuel(stack) - 1);
}
public static int getFuel(ItemStack stack) {
if(stack.stackTagCompound == null) {
stack.stackTagCompound = new NBTTagCompound();
return 0;
}
return stack.stackTagCompound.getInteger("fuel");
}
public static void setFuel(ItemStack stack, int i) {
if(stack.stackTagCompound == null) {
stack.stackTagCompound = new NBTTagCompound();
}
stack.stackTagCompound.setInteger("fuel", i);
}
}

View File

@ -1,54 +1,26 @@
package com.hbm.items.armor;
import java.util.List;
import com.hbm.extprop.HbmExtendedProperties;
import com.hbm.handler.FluidTypeHandler.FluidType;
import com.hbm.handler.HbmKeybinds.EnumKeybind;
import com.hbm.main.MainRegistry;
import com.hbm.packet.AuxParticlePacketNT;
import com.hbm.packet.KeybindPacket;
import com.hbm.packet.PacketDispatcher;
import com.hbm.entity.particle.EntityGasFlameFX;
import com.hbm.render.model.ModelJetPack;
import cpw.mods.fml.relauncher.Side;
import cpw.mods.fml.relauncher.SideOnly;
import net.minecraft.client.model.ModelBiped;
import cpw.mods.fml.common.network.NetworkRegistry.TargetPoint;
import net.minecraft.entity.Entity;
import net.minecraft.entity.EntityLivingBase;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.item.ItemArmor;
import net.minecraft.item.ItemStack;
import net.minecraft.nbt.NBTTagCompound;
import net.minecraft.util.Vec3;
import net.minecraft.world.World;
public class JetpackBreak extends ItemArmor {
public class JetpackBreak extends JetpackBase {
private ModelJetPack model;
public static int maxFuel = 1200;
public JetpackBreak(ArmorMaterial p_i45325_1_, int p_i45325_2_, int p_i45325_3_) {
super(p_i45325_1_, p_i45325_2_, p_i45325_3_);
}
@Override
public void addInformation(ItemStack itemstack, EntityPlayer player, List list, boolean bool)
{
list.add("Kerosene: " + this.getFuel(itemstack) + "mB / " + this.maxFuel + "mB");
}
@Override
public boolean isValidArmor(ItemStack stack, int armorType, Entity entity) {
return armorType == 1;
}
@Override
@SideOnly(Side.CLIENT)
public ModelBiped getArmorModel(EntityLivingBase entityLiving, ItemStack itemStack, int armorSlot) {
if (armorSlot == 1) {
if (model == null) {
this.model = new ModelJetPack();
}
return this.model;
}
return null;
public JetpackBreak(ArmorMaterial mat, int i, int j, FluidType fuel, int maxFuel) {
super(mat, i, j, fuel, maxFuel);
}
@Override
@ -57,44 +29,57 @@ public class JetpackBreak extends ItemArmor {
}
public void onArmorTick(World world, EntityPlayer player, ItemStack stack) {
if(player.motionY < -0.25 && this.getFuel(stack) > 0) {
Vec3 vec = Vec3.createVectorHelper(player.getLookVec().xCoord, 0, player.getLookVec().zCoord);
vec.normalize();
player.motionY = -0.25;
HbmExtendedProperties props = HbmExtendedProperties.getData(player);
if(world.isRemote) {
if(player == MainRegistry.proxy.me()) {
boolean last = props.getKeyPressed(EnumKeybind.JETPACK);
boolean current = MainRegistry.proxy.getIsKeyPressed(EnumKeybind.JETPACK);
if(last != current) {
PacketDispatcher.wrapper.sendToServer(new KeybindPacket(EnumKeybind.JETPACK, current));
props.setKeyPressed(EnumKeybind.JETPACK, current);
}
}
} else {
if(getFuel(stack) > 0 && (props.getKeyPressed(EnumKeybind.JETPACK) || (!player.onGround && !player.isSneaking()))) {
if(!world.isRemote) {
EntityGasFlameFX fx = new EntityGasFlameFX(world);
fx.posX = player.posX - vec.xCoord;
fx.posY = player.posY - 1;
fx.posZ = player.posZ - vec.zCoord;
fx.motionY = -0.5;
world.spawnEntityInWorld(fx);
}
player.fallDistance = 0;
this.setFuel(stack, this.getFuel(stack) - 1);
}
NBTTagCompound data = new NBTTagCompound();
data.setString("type", "jetpack");
data.setInteger("player", player.getEntityId());
PacketDispatcher.wrapper.sendToAllAround(new AuxParticlePacketNT(data, player.posX, player.posY, player.posZ), new TargetPoint(world.provider.dimensionId, player.posX, player.posY, player.posZ, 100));
}
}
if(getFuel(stack) > 0) {
if(props.getKeyPressed(EnumKeybind.JETPACK)) {
player.fallDistance = 0;
if(player.motionY < 0.4D)
player.motionY += 0.1D;
world.playSoundEffect(player.posX, player.posY, player.posZ, "hbm:weapon.flamethrowerShoot", 0.25F, 1.5F);
this.useUpFuel(player, stack, 5);
} else if(!player.isSneaking() && !player.onGround) {
player.fallDistance = 0;
if(player.motionY < -1)
player.motionY += 0.2D;
else if(player.motionY < -0.1)
player.motionY += 0.1D;
else if(player.motionY < 0)
player.motionY = 0;
world.playSoundEffect(player.posX, player.posY, player.posZ, "hbm:weapon.flamethrowerShoot", 0.25F, 1.5F);
this.useUpFuel(player, stack, 10);
}
}
}
public static int getFuel(ItemStack stack) {
if(stack.stackTagCompound == null) {
stack.stackTagCompound = new NBTTagCompound();
return 0;
}
return stack.stackTagCompound.getInteger("fuel");
}
public static void setFuel(ItemStack stack, int i) {
if(stack.stackTagCompound == null) {
stack.stackTagCompound = new NBTTagCompound();
}
stack.stackTagCompound.setInteger("fuel", i);
}
}

View File

@ -3,7 +3,16 @@ package com.hbm.items.armor;
import java.util.List;
import com.hbm.entity.particle.EntityGasFlameFX;
import com.hbm.extprop.HbmExtendedProperties;
import com.hbm.handler.FluidTypeHandler.FluidType;
import com.hbm.handler.HbmKeybinds.EnumKeybind;
import com.hbm.main.MainRegistry;
import com.hbm.packet.AuxParticlePacketNT;
import com.hbm.packet.KeybindPacket;
import com.hbm.packet.PacketDispatcher;
import com.hbm.render.model.ModelJetPack;
import cpw.mods.fml.common.network.NetworkRegistry.TargetPoint;
import cpw.mods.fml.relauncher.Side;
import cpw.mods.fml.relauncher.SideOnly;
import net.minecraft.client.model.ModelBiped;
@ -12,42 +21,15 @@ import net.minecraft.entity.EntityLivingBase;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.item.ItemArmor;
import net.minecraft.item.ItemStack;
import net.minecraft.item.ItemArmor.ArmorMaterial;
import net.minecraft.nbt.NBTTagCompound;
import net.minecraft.util.Vec3;
import net.minecraft.world.World;
public class JetpackRegular extends ItemArmor {
public class JetpackRegular extends JetpackBase {
private ModelJetPack model;
public static int maxFuel = 3000;
public JetpackRegular(ArmorMaterial p_i45325_1_, int p_i45325_2_, int p_i45325_3_) {
super(p_i45325_1_, p_i45325_2_, p_i45325_3_);
}
@Override
public void addInformation(ItemStack itemstack, EntityPlayer player, List list, boolean bool)
{
list.add("Kerosene: " + this.getFuel(itemstack) + "mB / " + this.maxFuel + "mB");
}
@Override
public boolean isValidArmor(ItemStack stack, int armorType, Entity entity) {
return armorType == 1;
}
@Override
@SideOnly(Side.CLIENT)
public ModelBiped getArmorModel(EntityLivingBase entityLiving, ItemStack itemStack, int armorSlot) {
if (armorSlot == 1) {
if (model == null) {
this.model = new ModelJetPack();
}
return this.model;
}
return null;
public JetpackRegular(ArmorMaterial mat, int i, int j, FluidType fuel, int maxFuel) {
super(mat, i, j, fuel, maxFuel);
}
@Override
@ -56,45 +38,41 @@ public class JetpackRegular extends ItemArmor {
}
public void onArmorTick(World world, EntityPlayer player, ItemStack stack) {
if(player.isSneaking() && this.getFuel(stack) > 0) {
Vec3 vec = Vec3.createVectorHelper(player.getLookVec().xCoord, 0, player.getLookVec().zCoord);
vec.normalize();
player.motionY += 0.15;
HbmExtendedProperties props = HbmExtendedProperties.getData(player);
if(world.isRemote) {
if(player == MainRegistry.proxy.me()) {
boolean last = props.getKeyPressed(EnumKeybind.JETPACK);
boolean current = MainRegistry.proxy.getIsKeyPressed(EnumKeybind.JETPACK);
if(last != current) {
PacketDispatcher.wrapper.sendToServer(new KeybindPacket(EnumKeybind.JETPACK, current));
props.setKeyPressed(EnumKeybind.JETPACK, current);
}
}
} else {
if(getFuel(stack) > 0 && props.getKeyPressed(EnumKeybind.JETPACK)) {
if(!world.isRemote) {
EntityGasFlameFX fx = new EntityGasFlameFX(world);
fx.posX = player.posX - vec.xCoord;
fx.posY = player.posY - 1;
fx.posZ = player.posZ - vec.zCoord;
fx.motionY = -0.15;
world.spawnEntityInWorld(fx);
}
player.fallDistance = 0;
this.setFuel(stack, this.getFuel(stack) - 1);
}
NBTTagCompound data = new NBTTagCompound();
data.setString("type", "jetpack");
data.setInteger("player", player.getEntityId());
PacketDispatcher.wrapper.sendToAllAround(new AuxParticlePacketNT(data, player.posX, player.posY, player.posZ), new TargetPoint(world.provider.dimensionId, player.posX, player.posY, player.posZ, 100));
}
}
if(getFuel(stack) > 0 && props.getKeyPressed(EnumKeybind.JETPACK)) {
player.fallDistance = 0;
if(player.motionY < 0.4D)
player.motionY += 0.1D;
world.playSoundEffect(player.posX, player.posY, player.posZ, "hbm:weapon.flamethrowerShoot", 0.25F, 1.5F);
this.useUpFuel(player, stack, 5);
}
}
public static int getFuel(ItemStack stack) {
if(stack.stackTagCompound == null) {
stack.stackTagCompound = new NBTTagCompound();
return 0;
}
return stack.stackTagCompound.getInteger("fuel");
}
public static void setFuel(ItemStack stack, int i) {
if(stack.stackTagCompound == null) {
stack.stackTagCompound = new NBTTagCompound();
}
stack.stackTagCompound.setInteger("fuel", i);
}
}

View File

@ -3,8 +3,16 @@ package com.hbm.items.armor;
import java.util.List;
import com.hbm.entity.particle.EntityGasFlameFX;
import com.hbm.extprop.HbmExtendedProperties;
import com.hbm.handler.FluidTypeHandler.FluidType;
import com.hbm.handler.HbmKeybinds.EnumKeybind;
import com.hbm.main.MainRegistry;
import com.hbm.packet.AuxParticlePacketNT;
import com.hbm.packet.KeybindPacket;
import com.hbm.packet.PacketDispatcher;
import com.hbm.render.model.ModelJetPack;
import cpw.mods.fml.common.network.NetworkRegistry.TargetPoint;
import cpw.mods.fml.relauncher.Side;
import cpw.mods.fml.relauncher.SideOnly;
import net.minecraft.client.model.ModelBiped;
@ -13,42 +21,15 @@ import net.minecraft.entity.EntityLivingBase;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.item.ItemArmor;
import net.minecraft.item.ItemStack;
import net.minecraft.item.ItemArmor.ArmorMaterial;
import net.minecraft.nbt.NBTTagCompound;
import net.minecraft.util.Vec3;
import net.minecraft.world.World;
public class JetpackVectorized extends ItemArmor {
public class JetpackVectorized extends JetpackBase {
private ModelJetPack model;
public static int maxFuel = 6000;
public JetpackVectorized(ArmorMaterial p_i45325_1_, int p_i45325_2_, int p_i45325_3_) {
super(p_i45325_1_, p_i45325_2_, p_i45325_3_);
}
@Override
public void addInformation(ItemStack itemstack, EntityPlayer player, List list, boolean bool)
{
list.add("Kerosene: " + this.getFuel(itemstack) + "mB / " + this.maxFuel + "mB");
}
@Override
public boolean isValidArmor(ItemStack stack, int armorType, Entity entity) {
return armorType == 1;
}
@Override
@SideOnly(Side.CLIENT)
public ModelBiped getArmorModel(EntityLivingBase entityLiving, ItemStack itemStack, int armorSlot) {
if (armorSlot == 1) {
if (model == null) {
this.model = new ModelJetPack();
}
return this.model;
}
return null;
public JetpackVectorized(ArmorMaterial mat, int i, int j, FluidType fuel, int maxFuel) {
super(mat, i, j, fuel, maxFuel);
}
@Override
@ -57,49 +38,52 @@ public class JetpackVectorized extends ItemArmor {
}
public void onArmorTick(World world, EntityPlayer player, ItemStack stack) {
if(player.isSneaking() && this.getFuel(stack) > 0) {
Vec3 vec = Vec3.createVectorHelper(player.getLookVec().xCoord, 0, player.getLookVec().zCoord);
vec.normalize();
HbmExtendedProperties props = HbmExtendedProperties.getData(player);
if(world.isRemote) {
if(player == MainRegistry.proxy.me()) {
boolean last = props.getKeyPressed(EnumKeybind.JETPACK);
boolean current = MainRegistry.proxy.getIsKeyPressed(EnumKeybind.JETPACK);
if(last != current) {
PacketDispatcher.wrapper.sendToServer(new KeybindPacket(EnumKeybind.JETPACK, current));
props.setKeyPressed(EnumKeybind.JETPACK, current);
}
}
} else {
if(getFuel(stack) > 0 && props.getKeyPressed(EnumKeybind.JETPACK)) {
player.motionX += vec.xCoord * 0.2;
player.motionY += 0.15;
player.motionZ += vec.zCoord * 0.2;
NBTTagCompound data = new NBTTagCompound();
data.setString("type", "jetpack");
data.setInteger("player", player.getEntityId());
data.setInteger("mode", 1);
PacketDispatcher.wrapper.sendToAllAround(new AuxParticlePacketNT(data, player.posX, player.posY, player.posZ), new TargetPoint(world.provider.dimensionId, player.posX, player.posY, player.posZ, 100));
}
}
if(!world.isRemote) {
EntityGasFlameFX fx = new EntityGasFlameFX(world);
fx.posX = player.posX - vec.xCoord;
fx.posY = player.posY - 1;
fx.posZ = player.posZ - vec.zCoord;
fx.motionX -= vec.xCoord * 0.2;
fx.motionY -= vec.yCoord * 0.2;
fx.motionZ -= vec.zCoord * 0.2;
world.spawnEntityInWorld(fx);
}
player.fallDistance = 0;
this.setFuel(stack, this.getFuel(stack) - 1);
}
if(getFuel(stack) > 0 && props.getKeyPressed(EnumKeybind.JETPACK)) {
if(player.motionY < 0.4D)
player.motionY += 0.1D;
Vec3 look = player.getLookVec();
if(Vec3.createVectorHelper(player.motionX, player.motionY, player.motionZ).lengthVector() < 2) {
player.motionX += look.xCoord * 0.1;
player.motionY += look.yCoord * 0.1;
player.motionZ += look.zCoord * 0.1;
if(look.yCoord > 0)
player.fallDistance = 0;
}
world.playSoundEffect(player.posX, player.posY, player.posZ, "hbm:weapon.flamethrowerShoot", 0.25F, 1.5F);
this.useUpFuel(player, stack, 3);
}
}
public static int getFuel(ItemStack stack) {
if(stack.stackTagCompound == null) {
stack.stackTagCompound = new NBTTagCompound();
return 0;
}
return stack.stackTagCompound.getInteger("fuel");
}
public static void setFuel(ItemStack stack, int i) {
if(stack.stackTagCompound == null) {
stack.stackTagCompound = new NBTTagCompound();
}
stack.stackTagCompound.setInteger("fuel", i);
}
}

View File

@ -3,11 +3,9 @@ package com.hbm.items.special;
import java.util.List;
import java.util.Random;
import com.hbm.handler.FluidTypeHandler.FluidType;
import com.hbm.items.ModItems;
import com.hbm.items.armor.JetpackBooster;
import com.hbm.items.armor.JetpackBreak;
import com.hbm.items.armor.JetpackRegular;
import com.hbm.items.armor.JetpackVectorized;
import com.hbm.items.armor.JetpackBase;
import com.hbm.items.weapon.ItemGunBase;
import com.hbm.lib.ModDamageSource;
import com.hbm.potion.HbmPotion;
@ -291,28 +289,24 @@ public class ItemSyringe extends Item {
}
}
if(this == ModItems.jetpack_tank && player.inventory.armorInventory[2] != null &&
(player.inventory.armorInventory[2].getItem() == ModItems.jetpack_boost || player.inventory.armorInventory[2].getItem() == ModItems.jetpack_break ||
player.inventory.armorInventory[2].getItem() == ModItems.jetpack_fly || player.inventory.armorInventory[2].getItem() == ModItems.jetpack_vector))
{
if(this == ModItems.jetpack_tank && player.inventory.armorInventory[2] != null && player.inventory.armorInventory[2].getItem() instanceof JetpackBase) {
if (!world.isRemote)
{
ItemStack jetpack = player.inventory.armorInventory[2];
int fill = JetpackRegular.getFuel(jetpack) + 1000;
if(jetpack.getItem() == ModItems.jetpack_boost && fill > JetpackBooster.maxFuel)
fill = JetpackBooster.maxFuel;
if(jetpack.getItem() == ModItems.jetpack_break && fill > JetpackBreak.maxFuel)
fill = JetpackBreak.maxFuel;
if(jetpack.getItem() == ModItems.jetpack_fly && fill > JetpackRegular.maxFuel)
fill = JetpackRegular.maxFuel;
if(jetpack.getItem() == ModItems.jetpack_vector && fill > JetpackVectorized.maxFuel)
fill = JetpackVectorized.maxFuel;
JetpackBase jetItem = (JetpackBase) jetpack.getItem();
if(JetpackRegular.getFuel(jetpack) == fill)
if(jetItem.fuel != FluidType.KEROSENE)
return stack;
JetpackRegular.setFuel(jetpack, fill);
int fill = JetpackBase.getFuel(jetpack) + 1000;
if(fill > jetItem.maxFuel)
fill = jetItem.maxFuel;
if(JetpackBase.getFuel(jetpack) == fill)
return stack;
JetpackBase.setFuel(jetpack, fill);
world.playSoundAtEntity(player, "hbm:item.jetpackTank", 1.0F, 1.0F);
stack.stackSize--;

View File

@ -9,6 +9,9 @@ import net.minecraft.client.particle.EntityFireworkSparkFX;
import net.minecraft.client.particle.EntityFlameFX;
import net.minecraft.client.renderer.entity.RenderSnowball;
import net.minecraft.client.renderer.texture.TextureManager;
import net.minecraft.client.settings.GameSettings;
import net.minecraft.client.settings.KeyBinding;
import net.minecraft.entity.Entity;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.item.Item;
import net.minecraft.nbt.NBTTagCompound;
@ -38,6 +41,7 @@ import com.hbm.entity.mob.botprime.EntityBOTPrimeHead;
import com.hbm.entity.mob.sodtekhnologiyah.EntityBallsOTronSegment;
import com.hbm.entity.particle.*;
import com.hbm.entity.projectile.*;
import com.hbm.handler.HbmKeybinds.EnumKeybind;
import com.hbm.items.ModItems;
import com.hbm.particle.*;
import com.hbm.render.block.*;
@ -871,6 +875,61 @@ public class ClientProxy extends ServerProxy {
world.spawnParticle(data.getString("mode"), x, y, z, mX, mY, mZ);
}
if("jetpack".equals(type)) {
Entity ent = world.getEntityByID(data.getInteger("player"));
if(ent instanceof EntityPlayer) {
EntityPlayer p = (EntityPlayer)ent;
Vec3 vec = Vec3.createVectorHelper(0, 0, -0.25);
Vec3 offset = Vec3.createVectorHelper(0.125, 0, 0);
float angle = (float) -Math.toRadians(p.rotationYawHead - (p.rotationYawHead - p.renderYawOffset));
vec.rotateAroundY(angle);
offset.rotateAroundY(angle);
double ix = p.posX + vec.xCoord;
double iy = p.posY + p.eyeHeight - 1;
double iz = p.posZ + vec.zCoord;
double ox = offset.xCoord;
double oz = offset.zCoord;
double moX = 0;
double moY = 0;
double moZ = 0;
int mode = data.getInteger("mode");
if(mode == 0) {
moY -= 0.2;
}
if(mode == 1) {
Vec3 look = p.getLookVec();
moX -= look.xCoord * 0.1D;
moY -= look.yCoord * 0.1D;
moZ -= look.zCoord * 0.1D;
}
Minecraft.getMinecraft().effectRenderer.addEffect(new EntityFlameFX(world, ix + ox, iy, iz + oz, p.motionX + moX * 2, p.motionY + moY * 2, p.motionZ + moZ * 2));
Minecraft.getMinecraft().effectRenderer.addEffect(new EntityFlameFX(world, ix - ox, iy, iz - oz, p.motionX + moX * 2, p.motionY + moY * 2, p.motionZ + moZ * 2));
Minecraft.getMinecraft().effectRenderer.addEffect(new net.minecraft.client.particle.EntitySmokeFX(world, ix + ox, iy, iz + oz, p.motionX + moX * 3, p.motionY + moY * 3, p.motionZ + moZ * 3));
Minecraft.getMinecraft().effectRenderer.addEffect(new net.minecraft.client.particle.EntitySmokeFX(world, ix - ox, iy, iz - oz, p.motionX + moX * 3, p.motionY + moY * 3, p.motionZ + moZ * 3));
}
}
if("muke".equals(type)) {
ParticleMukeWave wave = new ParticleMukeWave(man, world, x, y, z);
ParticleMukeFlash flash = new ParticleMukeFlash(man, world, x, y, z);
Minecraft.getMinecraft().effectRenderer.addEffect(wave);
Minecraft.getMinecraft().effectRenderer.addEffect(flash);
}
if("hadron".equals(type)) {
/*for(int i = 0; i < 30; i++) {
@ -917,5 +976,19 @@ public class ClientProxy extends ServerProxy {
Minecraft.getMinecraft().ingameGUI.func_110326_a(msg, false);
}
@Override
public boolean getIsKeyPressed(EnumKeybind key) {
if(key == EnumKeybind.JETPACK)
return Minecraft.getMinecraft().gameSettings.keyBindJump.getIsKeyPressed();
return false;
}
@Override
public EntityPlayer me() {
return Minecraft.getMinecraft().thePlayer;
}
}

View File

@ -25,6 +25,7 @@ import com.hbm.entity.mob.EntityTaintedCreeper;
import com.hbm.entity.mob.botprime.EntityBOTPrimeHead;
import com.hbm.entity.projectile.EntityBurningFOEQ;
import com.hbm.entity.projectile.EntityMeteor;
import com.hbm.extprop.HbmExtendedProperties;
import com.hbm.handler.BossSpawnHandler;
import com.hbm.handler.RadiationWorldHandler;
import com.hbm.handler.HTTPHandler;
@ -82,6 +83,7 @@ import net.minecraft.world.World;
import net.minecraft.world.chunk.Chunk;
import net.minecraftforge.event.AnvilUpdateEvent;
import net.minecraftforge.event.ServerChatEvent;
import net.minecraftforge.event.entity.EntityEvent;
import net.minecraftforge.event.entity.EntityEvent.EnteringChunk;
import net.minecraftforge.event.entity.EntityJoinWorldEvent;
import net.minecraftforge.event.entity.living.LivingAttackEvent;
@ -129,6 +131,19 @@ public class ModEventHandler
player.inventory.addItemStackToInventory(new ItemStack(ModItems.beta));
}
}
@SubscribeEvent
public void onEntityConstructing(EntityEvent.EntityConstructing event) {
if(event.entity instanceof EntityPlayer) {
EntityPlayer player = (EntityPlayer) event.entity;
if(HbmExtendedProperties.getData(player) == null) {
}
}
}
@SubscribeEvent
public void onEntityDeath(LivingDeathEvent event) {
@ -150,7 +165,7 @@ public class ModEventHandler
if(event.entity instanceof EntityTaintedCreeper && event.source == ModDamageSource.boxcar) {
for(Object o : event.entity.worldObj.playerEntities) {
for(Object o : event.entity.worldObj.getEntitiesWithinAABB(EntityPlayer.class, event.entity.boundingBox.expand(50, 50, 50))) {
EntityPlayer player = (EntityPlayer)o;
player.triggerAchievement(MainRegistry.bobHidden);
}

View File

@ -1,7 +1,9 @@
package com.hbm.main;
import com.hbm.handler.HbmKeybinds.EnumKeybind;
import com.hbm.sound.AudioWrapper;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.nbt.NBTTagCompound;
public class ServerProxy {
@ -25,4 +27,11 @@ public class ServerProxy {
public void playSound(String sound, Object data) { }
public void displayTooltip(String msg) { }
public boolean getIsKeyPressed(EnumKeybind key) {
return false;
}
public EntityPlayer me() {
return null;
}
}

View File

@ -0,0 +1,49 @@
package com.hbm.packet;
import com.hbm.extprop.HbmExtendedProperties;
import com.hbm.handler.HbmKeybinds.EnumKeybind;
import cpw.mods.fml.common.network.simpleimpl.IMessage;
import cpw.mods.fml.common.network.simpleimpl.IMessageHandler;
import cpw.mods.fml.common.network.simpleimpl.MessageContext;
import io.netty.buffer.ByteBuf;
import net.minecraft.entity.player.EntityPlayer;
public class KeybindPacket implements IMessage {
int key;
boolean pressed;
public KeybindPacket() { }
public KeybindPacket(EnumKeybind key, boolean pressed) {
this.key = key.ordinal();
this.pressed = pressed;
}
@Override
public void fromBytes(ByteBuf buf) {
key = buf.readInt();
pressed = buf.readBoolean();
}
@Override
public void toBytes(ByteBuf buf) {
buf.writeInt(key);
buf.writeBoolean(pressed);
}
public static class Handler implements IMessageHandler<KeybindPacket, IMessage> {
@Override
public IMessage onMessage(KeybindPacket m, MessageContext ctx) {
EntityPlayer p = ctx.getServerHandler().playerEntity;
HbmExtendedProperties props = HbmExtendedProperties.getData(p);
props.setKeyPressed(EnumKeybind.values()[m.key], m.pressed);
return null;
}
}
}

View File

@ -95,6 +95,8 @@ public class PacketDispatcher {
wrapper.registerMessage(GunAnimationPacket.Handler.class, GunAnimationPacket.class, i++, Side.CLIENT);
//Sends a funi text to display like a music disc announcement
wrapper.registerMessage(PlayerInformPacket.Handler.class, PlayerInformPacket.class, i++, Side.CLIENT);
//Universal keybind packet
wrapper.registerMessage(KeybindPacket.Handler.class, KeybindPacket.class, i++, Side.SERVER);
}
}

View File

@ -4,6 +4,8 @@ import org.lwjgl.opengl.GL11;
import com.hbm.lib.RefStrings;
import cpw.mods.fml.relauncher.Side;
import cpw.mods.fml.relauncher.SideOnly;
import net.minecraft.client.particle.EntityFX;
import net.minecraft.client.renderer.RenderHelper;
import net.minecraft.client.renderer.Tessellator;
@ -11,6 +13,7 @@ import net.minecraft.client.renderer.texture.TextureManager;
import net.minecraft.util.ResourceLocation;
import net.minecraft.world.World;
@SideOnly(Side.CLIENT)
public class ParticleHadron extends EntityFX {
private static final ResourceLocation texture = new ResourceLocation(RefStrings.MODID + ":textures/particle/hadron.png");

View File

@ -0,0 +1,14 @@
package com.hbm.particle;
import cpw.mods.fml.relauncher.Side;
import cpw.mods.fml.relauncher.SideOnly;
import net.minecraft.client.particle.EntityFX;
import net.minecraft.world.World;
@SideOnly(Side.CLIENT)
public class ParticleMukeCloud extends EntityFX {
public ParticleMukeCloud(World world, double x, double y, double z, double mx, double my, double mz) {
super(world, x, y, z, mx, my, mz);
}
}

View File

@ -0,0 +1,86 @@
package com.hbm.particle;
import java.util.Random;
import org.lwjgl.opengl.GL11;
import com.hbm.lib.RefStrings;
import cpw.mods.fml.relauncher.Side;
import cpw.mods.fml.relauncher.SideOnly;
import net.minecraft.client.particle.EntityFX;
import net.minecraft.client.renderer.RenderHelper;
import net.minecraft.client.renderer.Tessellator;
import net.minecraft.client.renderer.texture.TextureManager;
import net.minecraft.util.ResourceLocation;
import net.minecraft.util.Vec3;
import net.minecraft.world.World;
@SideOnly(Side.CLIENT)
public class ParticleMukeFlash extends EntityFX {
private static final ResourceLocation texture = new ResourceLocation(RefStrings.MODID + ":textures/particle/flare.png");
private TextureManager theRenderEngine;
public ParticleMukeFlash(TextureManager texman, World world, double x, double y, double z) {
super(world, x, y, z);
this.theRenderEngine = texman;
this.particleMaxAge = 20;
}
public int getFXLayer() {
return 3;
}
public void onUpdate() {
super.onUpdate();
}
public void renderParticle(Tessellator tess, float interp, float x, float y, float z, float tx, float tz) {
this.theRenderEngine.bindTexture(texture);
GL11.glColor4f(1.0F, 1.0F, 1.0F, 1.0F);
GL11.glDisable(GL11.GL_LIGHTING);
GL11.glEnable(GL11.GL_BLEND);
GL11.glAlphaFunc(GL11.GL_GREATER, 0);
GL11.glDepthMask(false);
GL11.glBlendFunc(GL11.GL_SRC_ALPHA, GL11.GL_ONE);
RenderHelper.disableStandardItemLighting();
tess.startDrawingQuads();
tess.setNormal(0.0F, 1.0F, 0.0F);
tess.setBrightness(240);
this.particleAlpha = 1 - (((float)this.particleAge + interp) / (float)this.particleMaxAge);
float scale = (this.particleAge + interp) * 0.75F + 5;
tess.setColorRGBA_F(1.0F, 0.9F, 0.75F, this.particleAlpha * 0.5F);
float dX = (float) (this.prevPosX + (this.posX - this.prevPosX) * (double) interp - interpPosX);
float dY = (float) (this.prevPosY + (this.posY - this.prevPosY) * (double) interp - interpPosY);
float dZ = (float) (this.prevPosZ + (this.posZ - this.prevPosZ) * (double) interp - interpPosZ);
Random rand = new Random();
for(int i = 0; i < 16; i++) {
rand.setSeed(i * 31 + 1);
float pX = (float) (dX + rand.nextDouble() * 5 - 2.5);
float pY = (float) (dY + rand.nextDouble() * 3 - 1.5);
float pZ = (float) (dZ + rand.nextDouble() * 5 - 2.5);
tess.addVertexWithUV((double) (pX - x * scale - tx * scale), (double) (pY - y * scale), (double) (pZ - z * scale - tz * scale), 1, 1);
tess.addVertexWithUV((double) (pX - x * scale + tx * scale), (double) (pY + y * scale), (double) (pZ - z * scale + tz * scale), 1, 0);
tess.addVertexWithUV((double) (pX + x * scale + tx * scale), (double) (pY + y * scale), (double) (pZ + z * scale + tz * scale), 0, 0);
tess.addVertexWithUV((double) (pX + x * scale - tx * scale), (double) (pY - y * scale), (double) (pZ + z * scale - tz * scale), 0, 1);
}
tess.draw();
GL11.glPolygonOffset(0.0F, 0.0F);
GL11.glAlphaFunc(GL11.GL_GREATER, 0.1F);
GL11.glEnable(GL11.GL_LIGHTING);
}
}

View File

@ -0,0 +1,70 @@
package com.hbm.particle;
import org.lwjgl.opengl.GL11;
import com.hbm.lib.RefStrings;
import cpw.mods.fml.relauncher.Side;
import cpw.mods.fml.relauncher.SideOnly;
import net.minecraft.client.particle.EntityFX;
import net.minecraft.client.renderer.RenderHelper;
import net.minecraft.client.renderer.Tessellator;
import net.minecraft.client.renderer.texture.TextureManager;
import net.minecraft.util.ResourceLocation;
import net.minecraft.world.World;
@SideOnly(Side.CLIENT)
public class ParticleMukeWave extends EntityFX {
private static final ResourceLocation texture = new ResourceLocation(RefStrings.MODID + ":textures/particle/shockwave.png");
private TextureManager theRenderEngine;
public ParticleMukeWave(TextureManager texman,World world, double x, double y, double z) {
super(world, x, y, z);
this.theRenderEngine = texman;
this.particleMaxAge = 25;
}
public int getFXLayer() {
return 3;
}
public void renderParticle(Tessellator tess, float interp, float x, float y, float z, float tx, float tz) {
this.theRenderEngine.bindTexture(texture);
GL11.glColor4f(1.0F, 1.0F, 1.0F, 1.0F);
GL11.glDisable(GL11.GL_LIGHTING);
GL11.glEnable(GL11.GL_BLEND);
GL11.glAlphaFunc(GL11.GL_GREATER, 0);
GL11.glDepthMask(false);
GL11.glBlendFunc(GL11.GL_SRC_ALPHA, GL11.GL_ONE);
GL11.glDisable(GL11.GL_CULL_FACE);
RenderHelper.disableStandardItemLighting();
tess.startDrawingQuads();
tess.setNormal(0.0F, 1.0F, 0.0F);
tess.setBrightness(240);
this.particleAlpha = 1 - (((float)this.particleAge + interp) / (float)this.particleMaxAge);
float scale = (this.particleAge + interp) * 2F;
tess.setColorRGBA_F(1.0F, 1.0F, 1.0F, this.particleAlpha);
float pX = (float) (this.prevPosX + (this.posX - this.prevPosX) * (double)interp - interpPosX);
float pY = (float) (this.prevPosY + (this.posY - this.prevPosY) * (double)interp - interpPosY);
float pZ = (float) (this.prevPosZ + (this.posZ - this.prevPosZ) * (double)interp - interpPosZ);
tess.addVertexWithUV((double)(pX - 1 * scale), (double)(pY), (double)(pZ - 1 * scale), 1, 1);
tess.addVertexWithUV((double)(pX - 1 * scale), (double)(pY), (double)(pZ + 1 * scale), 1, 0);
tess.addVertexWithUV((double)(pX + 1 * scale), (double)(pY), (double)(pZ + 1 * scale), 0, 0);
tess.addVertexWithUV((double)(pX + 1 * scale), (double)(pY), (double)(pZ - 1 * scale), 0, 1);
tess.draw();
GL11.glPolygonOffset(0.0F, 0.0F);
GL11.glEnable(GL11.GL_CULL_FACE);
GL11.glAlphaFunc(GL11.GL_GREATER, 0.1F);
GL11.glEnable(GL11.GL_LIGHTING);
}
}