diff --git a/src/main/java/com/hbm/blocks/ModBlocks.java b/src/main/java/com/hbm/blocks/ModBlocks.java index e312ecba7..cc2f3e140 100644 --- a/src/main/java/com/hbm/blocks/ModBlocks.java +++ b/src/main/java/com/hbm/blocks/ModBlocks.java @@ -849,6 +849,7 @@ public class ModBlocks { public static Block rbmk_absorber; public static Block rbmk_moderator; public static Block rbmk_console; + public static final int guiID_rbmk_rod = 113; public static Block book_guide; diff --git a/src/main/java/com/hbm/blocks/machine/rbmk/RBMKRod.java b/src/main/java/com/hbm/blocks/machine/rbmk/RBMKRod.java index f4ec08f8c..6c5ecc2b2 100644 --- a/src/main/java/com/hbm/blocks/machine/rbmk/RBMKRod.java +++ b/src/main/java/com/hbm/blocks/machine/rbmk/RBMKRod.java @@ -1,7 +1,11 @@ package com.hbm.blocks.machine.rbmk; +import com.hbm.blocks.ModBlocks; +import com.hbm.main.MainRegistry; import com.hbm.tileentity.machine.rbmk.TileEntityRBMKRod; +import cpw.mods.fml.common.network.internal.FMLNetworkHandler; +import net.minecraft.entity.player.EntityPlayer; import net.minecraft.tileentity.TileEntity; import net.minecraft.world.World; @@ -12,6 +16,25 @@ public class RBMKRod extends RBMKBase { return new TileEntityRBMKRod(); } + @Override + public boolean onBlockActivated(World world, int x, int y, int z, EntityPlayer player, int side, float hitX, float hitY, float hitZ) { + if(world.isRemote) + { + return true; + } else if(!player.isSneaking()) + { + int[] pos = this.findCore(world, x, y, z); + + if(pos == null) + return false; + + FMLNetworkHandler.openGui(player, MainRegistry.instance, ModBlocks.guiID_rbmk_rod, world, pos[0], pos[1], pos[2]); + return true; + } else { + return true; + } + } + @Override public int getRenderType(){ return this.renderIDRods; diff --git a/src/main/java/com/hbm/entity/projectile/EntityBulletBase.java b/src/main/java/com/hbm/entity/projectile/EntityBulletBase.java index 596fd670b..451bb9219 100644 --- a/src/main/java/com/hbm/entity/projectile/EntityBulletBase.java +++ b/src/main/java/com/hbm/entity/projectile/EntityBulletBase.java @@ -427,7 +427,7 @@ public class EntityBulletBase extends Entity implements IProjectile { if(config.bImpact != null) config.bImpact.behaveBlockHit(this, bX, bY, bZ); - if(!worldObj.isRemote) + if(!worldObj.isRemote && !config.liveAfterImpact) this.setDead(); if(config.incendiary > 0 && !this.worldObj.isRemote) { diff --git a/src/main/java/com/hbm/handler/BulletConfiguration.java b/src/main/java/com/hbm/handler/BulletConfiguration.java index ae4625c07..05eaf5e5a 100644 --- a/src/main/java/com/hbm/handler/BulletConfiguration.java +++ b/src/main/java/com/hbm/handler/BulletConfiguration.java @@ -55,6 +55,8 @@ public class BulletConfiguration { public boolean isSpectral; //whether or not the bullet should break glass public boolean doesBreakGlass; + //whether the bullet should stay alive after colliding with a block + public boolean liveAfterImpact; //bullet effects public List effects; diff --git a/src/main/java/com/hbm/handler/GUIHandler.java b/src/main/java/com/hbm/handler/GUIHandler.java index f5513e5f4..f6b71b03a 100644 --- a/src/main/java/com/hbm/handler/GUIHandler.java +++ b/src/main/java/com/hbm/handler/GUIHandler.java @@ -8,6 +8,7 @@ import com.hbm.inventory.inv.InventoryLeadBox; import com.hbm.items.ModItems; import com.hbm.tileentity.bomb.*; import com.hbm.tileentity.machine.*; +import com.hbm.tileentity.machine.rbmk.TileEntityRBMKRod; import com.hbm.tileentity.turret.*; import net.minecraft.entity.player.EntityPlayer; @@ -784,6 +785,13 @@ public class GUIHandler implements IGuiHandler { } return null; } + + case ModBlocks.guiID_rbmk_rod: { + if(entity instanceof TileEntityRBMKRod) { + return new ContainerRBMKRod(player.inventory, (TileEntityRBMKRod) entity); + } + return null; + } } // NON-TE CONTAINERS @@ -1556,6 +1564,13 @@ public class GUIHandler implements IGuiHandler { } return null; } + + case ModBlocks.guiID_rbmk_rod: { + if(entity instanceof TileEntityRBMKRod) { + return new GUIRBMKRod(player.inventory, (TileEntityRBMKRod) entity); + } + return null; + } } // ITEM GUIS diff --git a/src/main/java/com/hbm/handler/guncfg/GunEnergyFactory.java b/src/main/java/com/hbm/handler/guncfg/GunEnergyFactory.java index 908e1d97a..d1aca7661 100644 --- a/src/main/java/com/hbm/handler/guncfg/GunEnergyFactory.java +++ b/src/main/java/com/hbm/handler/guncfg/GunEnergyFactory.java @@ -286,6 +286,7 @@ public class GunEnergyFactory { bullet.bulletsMax = 5; bullet.dmgMin = 10000; bullet.dmgMax = 25000; + bullet.liveAfterImpact = true; bullet.style = bullet.STYLE_BOLT; bullet.trail = bullet.BOLT_ZOMG; diff --git a/src/main/java/com/hbm/inventory/container/ContainerRBMKRod.java b/src/main/java/com/hbm/inventory/container/ContainerRBMKRod.java new file mode 100644 index 000000000..2056fa0df --- /dev/null +++ b/src/main/java/com/hbm/inventory/container/ContainerRBMKRod.java @@ -0,0 +1,62 @@ +package com.hbm.inventory.container; + +import com.hbm.tileentity.machine.rbmk.TileEntityRBMKRod; + +import net.minecraft.entity.player.EntityPlayer; +import net.minecraft.entity.player.InventoryPlayer; +import net.minecraft.inventory.Container; +import net.minecraft.inventory.Slot; +import net.minecraft.item.ItemStack; + +public class ContainerRBMKRod extends Container { + + private TileEntityRBMKRod rbmk; + + public ContainerRBMKRod(InventoryPlayer invPlayer, TileEntityRBMKRod tedf) { + rbmk = tedf; + + this.addSlotToContainer(new Slot(tedf, 0, 80, 45)); + + for(int i = 0; i < 3; i++) { + for(int j = 0; j < 9; j++) { + this.addSlotToContainer(new Slot(invPlayer, j + i * 9 + 9, 8 + j * 18, 84 + i * 18 + 20)); + } + } + + for(int i = 0; i < 9; i++) { + this.addSlotToContainer(new Slot(invPlayer, i, 8 + i * 18, 142 + 20)); + } + } + + @Override + public ItemStack transferStackInSlot(EntityPlayer p_82846_1_, int par2) { + ItemStack var3 = null; + Slot var4 = (Slot) this.inventorySlots.get(par2); + + if(var4 != null && var4.getHasStack()) { + ItemStack var5 = var4.getStack(); + var3 = var5.copy(); + + if(par2 <= rbmk.getSizeInventory() - 1) { + if(!this.mergeItemStack(var5, rbmk.getSizeInventory(), this.inventorySlots.size(), true)) { + return null; + } + } else if(!this.mergeItemStack(var5, 0, rbmk.getSizeInventory(), false)) { + return null; + } + + if(var5.stackSize == 0) { + var4.putStack((ItemStack) null); + } else { + var4.onSlotChanged(); + } + } + + return var3; + } + + @Override + public boolean canInteractWith(EntityPlayer player) { + return rbmk.isUseableByPlayer(player); + } +} diff --git a/src/main/java/com/hbm/inventory/gui/GUIMachineRadar.java b/src/main/java/com/hbm/inventory/gui/GUIMachineRadar.java index 3579892fb..984898875 100644 --- a/src/main/java/com/hbm/inventory/gui/GUIMachineRadar.java +++ b/src/main/java/com/hbm/inventory/gui/GUIMachineRadar.java @@ -21,12 +21,13 @@ import net.minecraft.util.ResourceLocation; public class GUIMachineRadar extends GuiInfoContainer { - private static ResourceLocation texture = new ResourceLocation(RefStrings.MODID + ":textures/gui/gui_radar.png"); + private static ResourceLocation texture = new ResourceLocation(RefStrings.MODID + ":textures/gui/machine/gui_radar.png"); private TileEntityMachineRadar diFurnace; public GUIMachineRadar(InventoryPlayer invPlayer, TileEntityMachineRadar tedf) { super(new ContainerMachineRadar(invPlayer, tedf)); diFurnace = tedf; + texture = new ResourceLocation(RefStrings.MODID + ":textures/gui/machine/gui_radar.png"); this.xSize = 216; this.ySize = 234; @@ -38,9 +39,10 @@ public class GUIMachineRadar extends GuiInfoContainer { this.drawElectricityInfo(this, mouseX, mouseY, guiLeft + 8, guiTop + 221, 200, 7, diFurnace.power, diFurnace.maxPower); - this.drawCustomInfoStat(mouseX, mouseY, guiLeft - 10, guiTop + 103, 8, 8, mouseX, mouseY, I18nUtil.resolveKeyArray("radar.detectMissiles") ); - this.drawCustomInfoStat(mouseX, mouseY, guiLeft - 10, guiTop + 113, 8, 8, mouseX, mouseY, I18nUtil.resolveKeyArray("radar.detectPlayers")); - this.drawCustomInfoStat(mouseX, mouseY, guiLeft - 10, guiTop + 123, 8, 8, mouseX, mouseY, I18nUtil.resolveKeyArray("radar.smartMode")); + this.drawCustomInfoStat(mouseX, mouseY, guiLeft - 10, guiTop + 98, 8, 8, mouseX, mouseY, I18nUtil.resolveKeyArray("radar.detectMissiles") ); + this.drawCustomInfoStat(mouseX, mouseY, guiLeft - 10, guiTop + 108, 8, 8, mouseX, mouseY, I18nUtil.resolveKeyArray("radar.detectPlayers")); + this.drawCustomInfoStat(mouseX, mouseY, guiLeft - 10, guiTop + 118, 8, 8, mouseX, mouseY, I18nUtil.resolveKeyArray("radar.smartMode")); + this.drawCustomInfoStat(mouseX, mouseY, guiLeft - 10, guiTop + 128, 8, 8, mouseX, mouseY, I18nUtil.resolveKeyArray("radar.redMode")); if(!diFurnace.nearbyMissiles.isEmpty()) { for(int[] m : diFurnace.nearbyMissiles) { @@ -65,20 +67,25 @@ public class GUIMachineRadar extends GuiInfoContainer { protected void mouseClicked(int x, int y, int i) { super.mouseClicked(x, y, i); - if(guiLeft -10 <= x && guiLeft + -10 + 8 > x && guiTop + 103 < y && guiTop + 103 + 8 >= y) { + if(guiLeft -10 <= x && guiLeft + -10 + 8 > x && guiTop + 98 < y && guiTop + 98 + 8 >= y) { mc.getSoundHandler().playSound(PositionedSoundRecord.func_147674_a(new ResourceLocation("gui.button.press"), 1.0F)); PacketDispatcher.wrapper.sendToServer(new AuxButtonPacket(diFurnace.xCoord, diFurnace.yCoord, diFurnace.zCoord, 0, 0)); } - if(guiLeft -10 <= x && guiLeft + -10 + 8 > x && guiTop + 113 < y && guiTop + 113 + 8 >= y) { + if(guiLeft -10 <= x && guiLeft + -10 + 8 > x && guiTop + 108 < y && guiTop + 108 + 8 >= y) { mc.getSoundHandler().playSound(PositionedSoundRecord.func_147674_a(new ResourceLocation("gui.button.press"), 1.0F)); PacketDispatcher.wrapper.sendToServer(new AuxButtonPacket(diFurnace.xCoord, diFurnace.yCoord, diFurnace.zCoord, 0, 1)); } - if(guiLeft -10 <= x && guiLeft + -10 + 8 > x && guiTop + 123 < y && guiTop + 123 + 8 >= y) { + if(guiLeft -10 <= x && guiLeft + -10 + 8 > x && guiTop + 118 < y && guiTop + 118 + 8 >= y) { mc.getSoundHandler().playSound(PositionedSoundRecord.func_147674_a(new ResourceLocation("gui.button.press"), 1.0F)); PacketDispatcher.wrapper.sendToServer(new AuxButtonPacket(diFurnace.xCoord, diFurnace.yCoord, diFurnace.zCoord, 0, 2)); } + + if(guiLeft -10 <= x && guiLeft + -10 + 8 > x && guiTop + 128 < y && guiTop + 128 + 8 >= y) { + mc.getSoundHandler().playSound(PositionedSoundRecord.func_147674_a(new ResourceLocation("gui.button.press"), 1.0F)); + PacketDispatcher.wrapper.sendToServer(new AuxButtonPacket(diFurnace.xCoord, diFurnace.yCoord, diFurnace.zCoord, 0, 3)); + } } @Override @@ -93,16 +100,19 @@ public class GUIMachineRadar extends GuiInfoContainer { GL11.glColor4f(1.0F, 1.0F, 1.0F, 1.0F); Minecraft.getMinecraft().getTextureManager().bindTexture(texture); drawTexturedModalRect(guiLeft, guiTop, 0, 0, xSize, ySize); - drawTexturedModalRect(guiLeft - 14, guiTop + 99, 216, 198, 14, 36); + drawTexturedModalRect(guiLeft - 14, guiTop + 94, 216, 198, 14, 46); if(diFurnace.scanMissiles) - drawTexturedModalRect(guiLeft - 10, guiTop + 103, 230, 202, 8, 8); + drawTexturedModalRect(guiLeft - 10, guiTop + 98, 230, 202, 8, 8); if(diFurnace.scanPlayers) - drawTexturedModalRect(guiLeft - 10, guiTop + 113, 230, 212, 8, 8); + drawTexturedModalRect(guiLeft - 10, guiTop + 108, 230, 212, 8, 8); if(diFurnace.smartMode) - drawTexturedModalRect(guiLeft - 10, guiTop + 123, 230, 222, 8, 8); + drawTexturedModalRect(guiLeft - 10, guiTop + 118, 230, 222, 8, 8); + + if(diFurnace.redMode) + drawTexturedModalRect(guiLeft - 10, guiTop + 128, 230, 232, 8, 8); if(diFurnace.power > 0) { int i = (int)diFurnace.getPowerScaled(200); diff --git a/src/main/java/com/hbm/inventory/gui/GUIRBMKRod.java b/src/main/java/com/hbm/inventory/gui/GUIRBMKRod.java new file mode 100644 index 000000000..b048a5926 --- /dev/null +++ b/src/main/java/com/hbm/inventory/gui/GUIRBMKRod.java @@ -0,0 +1,46 @@ +package com.hbm.inventory.gui; + +import org.lwjgl.opengl.GL11; + +import com.hbm.inventory.container.ContainerRBMKRod; +import com.hbm.lib.RefStrings; +import com.hbm.tileentity.machine.rbmk.TileEntityRBMKRod; + +import net.minecraft.client.Minecraft; +import net.minecraft.client.gui.inventory.GuiContainer; +import net.minecraft.client.resources.I18n; +import net.minecraft.entity.player.InventoryPlayer; +import net.minecraft.util.ResourceLocation; + +public class GUIRBMKRod extends GuiContainer { + + private static ResourceLocation texture = new ResourceLocation(RefStrings.MODID + ":textures/gui/reactors/gui_rbmk_element.png"); + private TileEntityRBMKRod rod; + + public GUIRBMKRod(InventoryPlayer invPlayer, TileEntityRBMKRod tedf) { + super(new ContainerRBMKRod(invPlayer, tedf)); + rod = tedf; + + this.xSize = 176; + this.ySize = 186; + } + + @Override + protected void drawGuiContainerForegroundLayer(int i, int j) { + String name = this.rod.hasCustomInventoryName() ? this.rod.getInventoryName() : I18n.format(this.rod.getInventoryName()); + + this.fontRendererObj.drawString(name, this.xSize / 2 - this.fontRendererObj.getStringWidth(name) / 2, 6, 4210752); + this.fontRendererObj.drawString(I18n.format("container.inventory"), 8, this.ySize - 96 + 2, 4210752); + } + + @Override + protected void drawGuiContainerBackgroundLayer(float p_146976_1_, int p_146976_2_, int p_146976_3_) { + GL11.glColor4f(1.0F, 1.0F, 1.0F, 1.0F); + Minecraft.getMinecraft().getTextureManager().bindTexture(texture); + drawTexturedModalRect(guiLeft, guiTop, 0, 0, xSize, ySize); + + if(rod.slots[0] != null) { + drawTexturedModalRect(guiLeft + 34, guiTop + 21, 176, 0, 18, 67); + } + } +} diff --git a/src/main/java/com/hbm/items/ModItems.java b/src/main/java/com/hbm/items/ModItems.java index 7e180ff15..1a326b3b3 100644 --- a/src/main/java/com/hbm/items/ModItems.java +++ b/src/main/java/com/hbm/items/ModItems.java @@ -3082,17 +3082,36 @@ public class ModItems { rod_quad_tritium = new ItemHazard(2F).setUnlocalizedName("rod_quad_tritium").setMaxStackSize(1).setCreativeTab(MainRegistry.controlTab).setContainerItem(ModItems.rod_quad_empty).setTextureName(RefStrings.MODID + ":rod_quad_tritium"); rbmk_fuel_empty = new Item().setUnlocalizedName("rbmk_fuel_empty").setMaxStackSize(1).setCreativeTab(MainRegistry.controlTab).setTextureName(RefStrings.MODID + ":rbmk_fuel_empty"); - //todo: make one item and handle all of this trash with metadata - rbmk_fuel_meu = new ItemRBMKRod("Medium Enriched Uranium").setUnlocalizedName("rbmk_fuel_meu").setTextureName(RefStrings.MODID + ":rbmk_fuel_meu"); - rbmk_fuel_thmeu = new ItemRBMKRod("Thorium with MEU Driver Fuel").setUnlocalizedName("rbmk_fuel_thmeu").setTextureName(RefStrings.MODID + ":rbmk_fuel_thmeu"); - rbmk_fuel_lep = new ItemRBMKRod("Low Enriched Plutonium").setUnlocalizedName("rbmk_fuel_lep").setTextureName(RefStrings.MODID + ":rbmk_fuel_lep"); - rbmk_fuel_mep = new ItemRBMKRod("Medium Enriched Plutonium").setUnlocalizedName("rbmk_fuel_mep").setTextureName(RefStrings.MODID + ":rbmk_fuel_mep"); - rbmk_fuel_mox = new ItemRBMKRod("Mixed LEU & LEP Oxide").setUnlocalizedName("rbmk_fuel_mox").setTextureName(RefStrings.MODID + ":rbmk_fuel_mox"); - rbmk_fuel_les = new ItemRBMKRod("Low Enriched Schrabidium").setUnlocalizedName("rbmk_fuel_les").setTextureName(RefStrings.MODID + ":rbmk_fuel_les"); - rbmk_fuel_mes = new ItemRBMKRod("Medium Enriched Schrabidium").setUnlocalizedName("rbmk_fuel_mes").setTextureName(RefStrings.MODID + ":rbmk_fuel_mes"); - rbmk_fuel_hes = new ItemRBMKRod("Highly Enriched Schrabidium").setUnlocalizedName("rbmk_fuel_hes").setTextureName(RefStrings.MODID + ":rbmk_fuel_hes"); - rbmk_fuel_po210be = new ItemRBMKRod("Polonium-210 & Beryllium Neutron Source").setUnlocalizedName("rbmk_fuel_po210be").setTextureName(RefStrings.MODID + ":rbmk_fuel_po210be"); - rbmk_fuel_pu238be = new ItemRBMKRod("Plutonium-238 & Beryllium Neutron Source").setUnlocalizedName("rbmk_fuel_pu238be").setTextureName(RefStrings.MODID + ":rbmk_fuel_pu238be"); + rbmk_fuel_meu = new ItemRBMKRod("Medium Enriched Uranium") + .setYield(10D) + .setStats(0, 100).setUnlocalizedName("rbmk_fuel_meu").setTextureName(RefStrings.MODID + ":rbmk_fuel_meu"); + rbmk_fuel_thmeu = new ItemRBMKRod("Thorium with MEU Driver Fuel") + .setYield(10D) + .setStats(0, 100).setUnlocalizedName("rbmk_fuel_thmeu").setTextureName(RefStrings.MODID + ":rbmk_fuel_thmeu"); + rbmk_fuel_lep = new ItemRBMKRod("Low Enriched Plutonium") + .setYield(10D) + .setStats(0, 100).setUnlocalizedName("rbmk_fuel_lep").setTextureName(RefStrings.MODID + ":rbmk_fuel_lep"); + rbmk_fuel_mep = new ItemRBMKRod("Medium Enriched Plutonium") + .setYield(10D) + .setStats(15, 100).setUnlocalizedName("rbmk_fuel_mep").setTextureName(RefStrings.MODID + ":rbmk_fuel_mep"); + rbmk_fuel_mox = new ItemRBMKRod("Mixed LEU & LEP Oxide") + .setYield(10D) + .setStats(0, 100).setUnlocalizedName("rbmk_fuel_mox").setTextureName(RefStrings.MODID + ":rbmk_fuel_mox"); + rbmk_fuel_les = new ItemRBMKRod("Low Enriched Schrabidium") + .setYield(10D) + .setStats(0, 100).setUnlocalizedName("rbmk_fuel_les").setTextureName(RefStrings.MODID + ":rbmk_fuel_les"); + rbmk_fuel_mes = new ItemRBMKRod("Medium Enriched Schrabidium") + .setYield(10D) + .setStats(0, 100).setUnlocalizedName("rbmk_fuel_mes").setTextureName(RefStrings.MODID + ":rbmk_fuel_mes"); + rbmk_fuel_hes = new ItemRBMKRod("Highly Enriched Schrabidium") + .setYield(10D) + .setStats(0, 100).setUnlocalizedName("rbmk_fuel_hes").setTextureName(RefStrings.MODID + ":rbmk_fuel_hes"); + rbmk_fuel_po210be = new ItemRBMKRod("Polonium-210 & Beryllium Neutron Source") + .setYield(10D) + .setStats(50, 70).setUnlocalizedName("rbmk_fuel_po210be").setTextureName(RefStrings.MODID + ":rbmk_fuel_po210be"); + rbmk_fuel_pu238be = new ItemRBMKRod("Plutonium-238 & Beryllium Neutron Source") + .setYield(10D) + .setStats(35, 60).setUnlocalizedName("rbmk_fuel_pu238be").setTextureName(RefStrings.MODID + ":rbmk_fuel_pu238be"); trinitite = new ItemHazard().addRadiation(ItemHazard.trn * ItemHazard.ingot).toItem().setUnlocalizedName("trinitite").setCreativeTab(MainRegistry.partsTab).setTextureName(RefStrings.MODID + ":trinitite_new"); nuclear_waste_long = new ItemHazard(5F).setUnlocalizedName("nuclear_waste_long").setCreativeTab(MainRegistry.partsTab).setTextureName(RefStrings.MODID + ":nuclear_waste_long"); diff --git a/src/main/java/com/hbm/items/machine/ItemRBMKRod.java b/src/main/java/com/hbm/items/machine/ItemRBMKRod.java index c4cdefee8..52197502b 100644 --- a/src/main/java/com/hbm/items/machine/ItemRBMKRod.java +++ b/src/main/java/com/hbm/items/machine/ItemRBMKRod.java @@ -8,11 +8,18 @@ import com.hbm.main.MainRegistry; import net.minecraft.entity.player.EntityPlayer; import net.minecraft.item.ItemStack; +import net.minecraft.nbt.NBTTagCompound; import net.minecraft.util.EnumChatFormatting; public class ItemRBMKRod extends ItemHazard { String fullName = ""; + double funcStart; + double funcEnd; + double xGen = 0.5D;; + double xBurn = 50D; + double heat = 1D; + double yield; public ItemRBMKRod(String fullName) { @@ -22,11 +29,113 @@ public class ItemRBMKRod extends ItemHazard { this.setMaxStackSize(1); this.setCreativeTab(MainRegistry.controlTab); } + + public ItemRBMKRod setYield(double yield) { + this.yield = yield; + return this; + } + + public ItemRBMKRod setStats(double funcStart, double funcEnd) { + this.funcStart = funcStart; + this.funcEnd = funcEnd; + return this; + } + + public double burn(ItemStack stack, double flux) { + return 0; + } + + /** + * @param flux [0;100] ...or at least those are sane levels + * @return the amount of reactivity yielded, unmodified by xenon + */ + public double reactivityFunc(double flux) { + return funcStart + (funcEnd - funcStart) * flux / 100D; //goodness gracious i guessed the right formula on the first try! + } + + public double xenonGenFunc(double flux) { + return flux * xGen; + } + + public double xenonBurnFunc(double flux) { + return (flux * flux) / xBurn; + } + + /** + * @param stack + * @return enrichment [0;1] + */ + public double getEnrichment(ItemStack stack) { + return getYield(stack) / ((ItemRBMKRod) stack.getItem()).yield; + } @Override public void addInformation(ItemStack stack, EntityPlayer player, List list, boolean bool) { list.add(EnumChatFormatting.ITALIC + this.fullName); + + if(funcStart > 0) { + list.add(EnumChatFormatting.RED + "Self-igniting"); + } + + list.add(EnumChatFormatting.GREEN + "Depletion: " + (100D - ((getYield(stack) * 1000D / yield) / 10D)) + "%"); + list.add(EnumChatFormatting.LIGHT_PURPLE + "Xenon poison: " + ((getPoison(stack) * 10D) / 10D) + "%"); + list.add(EnumChatFormatting.GOLD + "Heat per tick at full power: " + heat); + list.add(EnumChatFormatting.YELLOW + "Flux function:"); + list.add(EnumChatFormatting.WHITE + " f(0) = " + funcStart); + list.add(EnumChatFormatting.WHITE + " f(1) = " + funcEnd); + list.add(EnumChatFormatting.WHITE + " f(x) = " + funcStart + " + " + (funcEnd - funcStart) + " * x"); + list.add(EnumChatFormatting.YELLOW + "Xenon gen function:"); + list.add(EnumChatFormatting.WHITE + " g(x) = x * " + xGen); + list.add(EnumChatFormatting.YELLOW + "Xenon burn function:"); + list.add(EnumChatFormatting.WHITE + " b(x) = x² * " + xBurn); + super.addInformation(stack, player, list, bool); } + + public static void setYield(ItemStack stack, double yield) { + + if(!stack.hasTagCompound()) + stack.stackTagCompound = new NBTTagCompound(); + + stack.stackTagCompound.setDouble("yield", yield); + } + + public static double getYield(ItemStack stack) { + + if(stack.hasTagCompound()) { + return stack.stackTagCompound.getDouble("yield"); + } + + if(stack.getItem() instanceof ItemRBMKRod) { + return ((ItemRBMKRod)stack.getItem()).yield; + } + + return 0; + } + + public static void setPoison(ItemStack stack, double yield) { + + if(!stack.hasTagCompound()) + stack.stackTagCompound = new NBTTagCompound(); + + stack.stackTagCompound.setDouble("xenon", yield); + } + + public static double getPoison(ItemStack stack) { + + if(stack.hasTagCompound()) { + return stack.stackTagCompound.getDouble("xenon"); + } + + return 0; + } + + public boolean showDurabilityBar(ItemStack stack) { + return getDurabilityForDisplay(stack) < 1D; + } + + public double getDurabilityForDisplay(ItemStack stack) { + return getEnrichment(stack); + } } diff --git a/src/main/java/com/hbm/items/weapon/ItemGunBase.java b/src/main/java/com/hbm/items/weapon/ItemGunBase.java index 908c1c1ff..0d405e614 100644 --- a/src/main/java/com/hbm/items/weapon/ItemGunBase.java +++ b/src/main/java/com/hbm/items/weapon/ItemGunBase.java @@ -223,6 +223,9 @@ public class ItemGunBase extends Item implements IHoldableWeapon, IItemHUD { spawnProjectile(world, player, stack, BulletConfigSyncingUtil.getKey(config)); } + useUpAmmo(player, stack, false); + player.inventoryContainer.detectAndSendChanges(); + setItemWear(stack, getItemWear(stack) + config.wear); } @@ -611,6 +614,7 @@ public class ItemGunBase extends Item implements IHoldableWeapon, IItemHUD { if(config.allowsInfinity && EnchantmentHelper.getEnchantmentLevel(Enchantment.infinity.effectId, stack) > 0) return; + if(config.reloadType != mainConfig.RELOAD_NONE) { setMag(stack, getMag(stack) - 1); } else { diff --git a/src/main/java/com/hbm/items/weapon/ItemGunVortex.java b/src/main/java/com/hbm/items/weapon/ItemGunVortex.java index 916b7c7aa..8b2be3d0c 100644 --- a/src/main/java/com/hbm/items/weapon/ItemGunVortex.java +++ b/src/main/java/com/hbm/items/weapon/ItemGunVortex.java @@ -1,30 +1,244 @@ package com.hbm.items.weapon; +import java.util.List; + +import org.lwjgl.opengl.GL11; + import com.hbm.entity.projectile.EntityBeamVortex; import com.hbm.handler.GunConfiguration; +import com.hbm.lib.Library; +import com.hbm.lib.ModDamageSource; +import com.hbm.main.MainRegistry; import com.hbm.packet.GunAnimationPacket; import com.hbm.packet.PacketDispatcher; +import com.hbm.particle.ParticleVortexCircle; +import com.hbm.particle.ParticleVortexGlow; +import com.hbm.particle.ParticleVortexParticle; import com.hbm.render.anim.HbmAnimations.AnimType; +import com.hbm.util.BobMathUtil; +import com.hbm.util.EntityDamageUtil; +import cpw.mods.fml.common.network.NetworkRegistry.TargetPoint; +import cpw.mods.fml.relauncher.Side; +import cpw.mods.fml.relauncher.SideOnly; +import net.minecraft.client.Minecraft; +import net.minecraft.client.renderer.Tessellator; +import net.minecraft.entity.Entity; +import net.minecraft.entity.EntityLivingBase; import net.minecraft.entity.player.EntityPlayer; import net.minecraft.entity.player.EntityPlayerMP; import net.minecraft.item.ItemStack; +import net.minecraft.nbt.NBTTagCompound; +import net.minecraft.util.MathHelper; +import net.minecraft.util.Vec3; import net.minecraft.world.World; public class ItemGunVortex extends ItemGunBase { - + + @SideOnly(Side.CLIENT) + private long lastFireTime; + public ItemGunVortex(GunConfiguration config) { super(config); } - - //spawns the actual projectile, can be overridden to change projectile entity + + /*@Override protected void spawnProjectile(World world, EntityPlayer player, ItemStack stack, int config) { + //EntityBeamVortex beam = new EntityBeamVortex(world, player); + //world.spawnEntity(beam); + //100 blocks is its current max range, but I'm sure that could be increased if necessary. + List entsOnBeam = Library.rayTraceEntitiesOnLine(player, 100, 1).getRight(); - EntityBeamVortex beam = new EntityBeamVortex(world, player); - world.spawnEntityInWorld(beam); + for(Entity e : entsOnBeam){ + + if(!(e instanceof EntityLivingBase)) + continue; + + float dmg = 30; + EntityDamageUtil.attackEntityFromIgnoreIFrame(e, ModDamageSource.radiation, dmg); + } if(this.mainConfig.animations.containsKey(AnimType.CYCLE) && player instanceof EntityPlayerMP) PacketDispatcher.wrapper.sendTo(new GunAnimationPacket(AnimType.CYCLE.ordinal()), (EntityPlayerMP) player); - + PacketDispatcher.wrapper.sendToAllAround(new GunFXPacket(player, FXType.FIRE), new TargetPoint(world.provider.dimensionId, player.posX, player.posY, player.posZ, 1)); } + + //This method should also solve the supershotgun issue where it doesn't fire some of the time (maybe?) + @Override + @SideOnly(Side.CLIENT) + public void onFireClient(ItemStack stack, EntityPlayer player, boolean shouldDoThirdPerson) { + //If I'm going to do more particle systems like this maybe I should write some kind of abstraction around it to make it less messy. + NBTTagCompound tag = new NBTTagCompound(); + Vec3d pos = null; + if(stack == player.getHeldItemMainhand()){ + pos = new Vec3d(-0.16, -0.20, 1).rotatePitch(-(float) Math.toRadians(player.rotationPitch)).rotateYaw(-(float) Math.toRadians(player.rotationYawHead)); + } else { + pos = new Vec3d(0.16, -0.20, 1).rotatePitch(-(float) Math.toRadians(player.rotationPitch)).rotateYaw(-(float) Math.toRadians(player.rotationYawHead)); + } + pos = pos.add(player.getPositionEyes(1F)); + Vec3d view = BobMathUtil.getVectorFromAngle(BobMathUtil.getEulerAngles(player.getLookVec()).addVector(0, 3, 0)); + Vec3d hitPos = null; + Vec3d hitNormal = null; + RayTraceResult r = Library.rayTraceIncludeEntities(player, 100, MainRegistry.proxy.partialTicks()); + if(r == null || r.typeOfHit == Type.MISS){ + hitPos = player.getLook(MainRegistry.proxy.partialTicks()).scale(100).add(pos); + } else { + hitPos = r.hitVec; + hitNormal = new Vec3d(r.sideHit.getFrontOffsetX(), r.sideHit.getFrontOffsetY(), r.sideHit.getFrontOffsetZ()); + } + + tag.setString("type", "spark"); + tag.setString("mode", "coneBurst"); + tag.setDouble("posX", pos.x-player.motionX); + tag.setDouble("posY", pos.y-player.motionY); + tag.setDouble("posZ", pos.z-player.motionZ); + tag.setDouble("dirX", view.x); + tag.setDouble("dirY", view.y); + tag.setDouble("dirZ", view.z); + tag.setFloat("r", 0.2F); + tag.setFloat("g", 0.8F); + tag.setFloat("b", 0.9F); + tag.setFloat("a", 1.5F); + tag.setInteger("lifetime", 1); + tag.setFloat("width", 0.01F); + tag.setFloat("length", 2F); + tag.setFloat("gravity", 0); + tag.setFloat("angle", 15F); + tag.setInteger("count", 12); + MainRegistry.proxy.effectNT(tag); + + ParticleVortexBeam beam = new ParticleVortexBeam(player.world, pos.x, pos.y, pos.z, hitPos.x, hitPos.y, hitPos.z, shouldDoThirdPerson); + beam.color(0.5F, 0.8F, 0.9F, 2.0F); + beam.width(0.125F); + Minecraft.getMinecraft().effectRenderer.addEffect(beam); + + ParticleVortexFireFlash flash = new ParticleVortexFireFlash(player.world, pos.x, pos.y, pos.z, hitPos.x, hitPos.y, hitPos.z); + flash.color(0.5F, 0.8F, 0.9F, 1F); + flash.width(0.5F); + Minecraft.getMinecraft().effectRenderer.addEffect(flash); + + Vec3 line = hitPos.subtract(pos); + int circleParticles = (int) line.lengthVector(); + for(int i = 0; i < circleParticles; i ++){ + Vec3 circlePos = line.scale(i/(float)circleParticles).add(pos); + ParticleVortexCircle c = new ParticleVortexCircle(player.worldObj, circlePos.x, circlePos.y, circlePos.z, 0.5F+player.worldObj.rand.nextFloat()*0.3F); + c.color(0.5F, 0.8F, 0.9F, 0.15F); + c.lifetime((int) (15+(i/(float)circleParticles)*10)); + Minecraft.getMinecraft().effectRenderer.addEffect(c); + } + + int extraParticles = (int) line.lengthVector(); + for(int i = 0; i < extraParticles; i ++){ + Vec3d circlePos = line.scale((i/(float)circleParticles)*0.25).add(pos); + float randX = (float) (player.worldObj.rand.nextGaussian()-0.5) * 0.01F; + float randY = (float) (player.worldObj.rand.nextGaussian()-0.5) * 0.01F; + float randZ = (float) (player.worldObj.rand.nextGaussian()-0.5) * 0.01F; + ParticleVortexParticle c = new ParticleVortexParticle(player.worldObj, circlePos.x+randX, circlePos.y+randY, circlePos.z+randZ, 0.5F); + c.color(0.5F, 0.8F, 0.9F, 0.15F); + c.lifetime(30); + Minecraft.getMinecraft().effectRenderer.addEffect(c); + } + + ParticleVortexGlow glow = new ParticleVortexGlow(player.worldObj, pos.x, pos.y, pos.z, 2F); + glow.color(0.3F, 0.7F, 1F, 0.5F); + glow.lifetime(15); + Minecraft.getMinecraft().effectRenderer.addEffect(glow); + + if(hitNormal != null){ + Vec3d sparkAxis = line.normalize().scale(0.25); + switch(r.sideHit.getAxis()){ + case X: + sparkAxis = new Vec3d(-sparkAxis.x, sparkAxis.y, sparkAxis.z); + break; + case Y: + sparkAxis = new Vec3d(sparkAxis.x, -sparkAxis.y, sparkAxis.z); + break; + case Z: + sparkAxis = new Vec3d(sparkAxis.x, sparkAxis.y, -sparkAxis.z); + break; + } + tag = new NBTTagCompound(); + tag.setString("type", "spark"); + tag.setString("mode", "coneBurst"); + tag.setDouble("posX", hitPos.x); + tag.setDouble("posY", hitPos.y); + tag.setDouble("posZ", hitPos.z); + tag.setDouble("dirX", sparkAxis.x); + tag.setDouble("dirY", sparkAxis.y+0.1); + tag.setDouble("dirZ", sparkAxis.z); + tag.setFloat("r", 0.2F); + tag.setFloat("g", 0.8F); + tag.setFloat("b", 0.9F); + tag.setFloat("a", 1.5F); + tag.setInteger("lifetime", 20); + tag.setInteger("randLifetime", 30); + tag.setFloat("width", 0.015F); + tag.setFloat("length", 0.5F); + tag.setFloat("gravity", 0.05F); + tag.setFloat("angle", 70F); + tag.setInteger("count", 15); + tag.setFloat("randomVelocity", 0.1F); + MainRegistry.proxy.effectNT(tag); + + ParticleVortexHit hit = new ParticleVortexHit(player.world, hitPos.x, hitPos.y, hitPos.z, 2.5F+player.world.rand.nextFloat()*0.5F, 90); + hit.color(0.4F, 0.8F, 1F, 0.25F); + hit.lifetime(20); + ParticleVortexHit hit2 = new ParticleVortexHit(player.world, hitPos.x, hitPos.y, hitPos.z, 2.5F+player.world.rand.nextFloat()*0.5F, -90); + hit2.color(0.4F, 0.8F, 1F, 0.25F); + hit2.lifetime(20); + Minecraft.getMinecraft().effectRenderer.addEffect(hit); + Minecraft.getMinecraft().effectRenderer.addEffect(hit2); + } + + MainRegistry.proxy.setRecoil(3); + lastFireTime = System.currentTimeMillis(); + } + + @Override + @SideOnly(Side.CLIENT) + public boolean hasCustomHudElement() { + return true; + } + + @Override + @SideOnly(Side.CLIENT) + public void renderHud(ScaledResolution res, GuiIngame gui, ItemStack stack, float partialTicks) { + float x = res.getScaledWidth()/2; + float y = res.getScaledHeight()/2; + + Minecraft.getMinecraft().getTextureManager().bindTexture(ResourceManager.vortex_hud_reticle); + GL11.glTexParameteri(GL11.GL_TEXTURE_2D, GL11.GL_TEXTURE_MAG_FILTER, GL11.GL_LINEAR); + GL11.glColor4f(0.4F, 0.9F, 0.9F, 1.0F); + GL11.glEnable(GL11.GL_BLEND); + GlStateManager.tryBlendFuncSeparate(SourceFactor.SRC_ALPHA, DestFactor.ONE, SourceFactor.ONE, DestFactor.ZERO); + RenderHelper.drawGuiRect(x - 11F, y - 11F, 0, 0, 22, 22, 1, 1); + Minecraft.getMinecraft().getTextureManager().bindTexture(ResourceManager.vortex_hud_circle); + + //Running off of system time gives less wonky results than relying on server updating the nbt tag. + long time = System.currentTimeMillis(); + + //float cooldown = (this.mainConfig.rateOfFire-getDelay(stack)+partialTicks)/(float)this.mainConfig.rateOfFire; + //Adding 0.05 so it doesn't start at nothing makes it look better in my opinion. + //It's 55 instead of 50 (50 ms in one tick) because xon lets you fire slightly before the cooldown is over. This extends the cooldown slightly beyond the real one. + float cooldown = MathHelper.clamp((time-lastFireTime)/(float)(mainConfig.rateOfFire*55), 0, 1)+0.05F; + final int SUBDIVISIONS = 64; + Tessellator tes = Tessellator.instance; + tes.startDrawing(GL11.GL_TRIANGLE_FAN); + + tes.setColorRGBA_F(0.4F, 0.9F, 0.9F, 0.4F); + tes.addVertexWithUV(x, y, 0, 0.5, 0.5); + + for(int i = 0; i < SUBDIVISIONS+1; i ++){ + //Should be quite fast because MathHelper uses a sin table... right? + float ratio = i/(float)SUBDIVISIONS; + float x2 = MathHelper.sin((float) (ratio*Math.PI*2+0.5*Math.PI)); + float y2 = MathHelper.cos((float) (ratio*Math.PI*2+0.5*Math.PI)); + float alphaMult = 1-ratio < cooldown ? 1 : 0; + buf.pos(x+x2*11, y+y2*11, 0).tex(BobMathUtil.remap01(x2, -1, 1), BobMathUtil.remap01(y2, -1, 1)).color(0.4F, 0.9F, 0.9F, 0.4F*alphaMult).endVertex(); + } + tes.draw(); + + GlStateManager.tryBlendFuncSeparate(SourceFactor.SRC_ALPHA, DestFactor.ONE_MINUS_SRC_ALPHA, SourceFactor.ONE, DestFactor.ZERO); + GlStateManager.disableBlend(); + }*/ } diff --git a/src/main/java/com/hbm/particle/ParticleVortexCircle.java b/src/main/java/com/hbm/particle/ParticleVortexCircle.java new file mode 100644 index 000000000..bdde31949 --- /dev/null +++ b/src/main/java/com/hbm/particle/ParticleVortexCircle.java @@ -0,0 +1,5 @@ +package com.hbm.particle; + +public class ParticleVortexCircle { + +} diff --git a/src/main/java/com/hbm/particle/ParticleVortexGlow.java b/src/main/java/com/hbm/particle/ParticleVortexGlow.java new file mode 100644 index 000000000..1f32cd493 --- /dev/null +++ b/src/main/java/com/hbm/particle/ParticleVortexGlow.java @@ -0,0 +1,94 @@ +package com.hbm.particle; + +import org.lwjgl.opengl.GL11; + +import com.hbm.lib.RefStrings; +import com.hbm.util.BobMathUtil; + +import net.minecraft.client.Minecraft; +import net.minecraft.client.particle.EntityFX; +import net.minecraft.client.renderer.Tessellator; +import net.minecraft.util.MathHelper; +import net.minecraft.util.ResourceLocation; +import net.minecraft.util.Vec3; +import net.minecraft.world.World; + +public class ParticleVortexGlow extends EntityFX { + + public static final ResourceLocation fresnel_ms = new ResourceLocation(RefStrings.MODID, "textures/particle/fresnel_ms.png"); + public float workingAlpha; + + public ParticleVortexGlow(World worldIn, double posXIn, double posYIn, double posZIn, float scale) { + super(worldIn, posXIn, posYIn, posZIn); + this.particleScale = scale; + } + + public ParticleVortexGlow color(float colR, float colG, float colB, float colA) { + this.particleRed = colR; + this.particleGreen = colG; + this.particleBlue = colB; + this.particleAlpha = colA; + workingAlpha = colA; + return this; + } + + public ParticleVortexGlow lifetime(int lifetime) { + this.particleMaxAge = lifetime; + return this; + } + + @Override + public void onUpdate() { + this.particleAge++; + if(this.particleAge >= this.particleMaxAge) { + this.setDead(); + } + } + + @Override + public int getFXLayer() { + return 3; + } + + @Override + public void renderParticle(Tessellator tess, float partialTicks, float rotationX, float rotationZ, float rotationYZ, float rotationXY, float rotationXZ) { + + Minecraft.getMinecraft().getTextureManager().bindTexture(fresnel_ms); + GL11.glTexParameteri(GL11.GL_TEXTURE_2D, GL11.GL_TEXTURE_MAG_FILTER, GL11.GL_LINEAR); + GL11.glDisable(GL11.GL_ALPHA_TEST); + GL11.glDepthMask(false); + GL11.glEnable(GL11.GL_BLEND); + GL11.glBlendFunc(GL11.GL_SRC_ALPHA, GL11.GL_ONE); + float timeScale = (this.particleAge + partialTicks) / (float) this.particleMaxAge; + float shrink = MathHelper.clamp_float(1 - BobMathUtil.remap((float) MathHelper.clamp_float(timeScale, 0, 1), 0.6F, 1F, 0.6F, 1F), 0, 1); + this.workingAlpha = shrink * particleAlpha; + + float f4 = 0.1F * (this.particleScale + shrink * particleScale * 4); + + float f5 = (float) (this.prevPosX + (this.posX - this.prevPosX) * (double) partialTicks - interpPosX); + float f6 = (float) (this.prevPosY + (this.posY - this.prevPosY) * (double) partialTicks - interpPosY); + float f7 = (float) (this.prevPosZ + (this.posZ - this.prevPosZ) * (double) partialTicks - interpPosZ); + Vec3[] avec3d = new Vec3[] { + Vec3.createVectorHelper((double) (-rotationX * f4 - rotationXY * f4), (double) (-rotationZ * f4), (double) (-rotationYZ * f4 - rotationXZ * f4)), + Vec3.createVectorHelper((double) (-rotationX * f4 + rotationXY * f4), (double) (rotationZ * f4), (double) (-rotationYZ * f4 + rotationXZ * f4)), + Vec3.createVectorHelper((double) (rotationX * f4 + rotationXY * f4), (double) (rotationZ * f4), (double) (rotationYZ * f4 + rotationXZ * f4)), + Vec3.createVectorHelper((double) (rotationX * f4 - rotationXY * f4), (double) (-rotationZ * f4), (double) (rotationYZ * f4 - rotationXZ * f4)) + }; + + tess.setColorRGBA_F(this.particleRed, this.particleGreen, this.particleBlue, this.particleAlpha); + tess.setNormal(0.0F, 1.0F, 0.0F); + tess.setBrightness(240); + + tess.startDrawingQuads(); + tess.addVertexWithUV((double) f5 + avec3d[0].xCoord, (double) f6 + avec3d[0].yCoord, (double) f7 + avec3d[0].zCoord, 1, 1); + tess.addVertexWithUV((double) f5 + avec3d[1].xCoord, (double) f6 + avec3d[1].yCoord, (double) f7 + avec3d[1].zCoord, 1, 0); + tess.addVertexWithUV((double) f5 + avec3d[2].xCoord, (double) f6 + avec3d[2].yCoord, (double) f7 + avec3d[2].zCoord, 0, 0); + tess.addVertexWithUV((double) f5 + avec3d[3].xCoord, (double) f6 + avec3d[3].yCoord, (double) f7 + avec3d[3].zCoord, 0, 1); + + tess.draw(); + + GL11.glEnable(GL11.GL_ALPHA_TEST); + GL11.glDepthMask(true); + GL11.glDisable(GL11.GL_BLEND); + } +} diff --git a/src/main/java/com/hbm/particle/ParticleVortexParticle.java b/src/main/java/com/hbm/particle/ParticleVortexParticle.java new file mode 100644 index 000000000..fdaf489ee --- /dev/null +++ b/src/main/java/com/hbm/particle/ParticleVortexParticle.java @@ -0,0 +1,119 @@ +package com.hbm.particle; + +import org.lwjgl.opengl.GL11; + +import com.hbm.lib.RefStrings; +import com.hbm.util.BobMathUtil; + +import net.minecraft.client.Minecraft; +import net.minecraft.client.particle.EntityFX; +import net.minecraft.client.renderer.Tessellator; +import net.minecraft.util.MathHelper; +import net.minecraft.util.ResourceLocation; +import net.minecraft.util.Vec3; +import net.minecraft.world.World; + +public class ParticleVortexParticle extends EntityFX { + + public static final ResourceLocation fresnel_ms = new ResourceLocation(RefStrings.MODID, "textures/particle/fresnel_ms.png"); + + public float workingAlpha; + public int timeUntilChange = 0; + + public ParticleVortexParticle(World worldIn, double posXIn, double posYIn, double posZIn, float scale) { + super(worldIn, posXIn, posYIn, posZIn); + this.particleScale = scale; + this.motionX = (rand.nextFloat() - 0.5) * 0.02; + this.motionY = (rand.nextFloat() - 0.5) * 0.02; + this.motionZ = (rand.nextFloat() - 0.5) * 0.02; + timeUntilChange = rand.nextInt(5) + 1; + } + + public ParticleVortexParticle color(float colR, float colG, float colB, float colA) { + this.particleRed = colR; + this.particleGreen = colG; + this.particleBlue = colB; + this.particleAlpha = colA; + workingAlpha = colA; + return this; + } + + public ParticleVortexParticle lifetime(int lifetime) { + this.particleMaxAge = lifetime; + return this; + } + + @Override + public void onUpdate() { + + this.particleAge++; + timeUntilChange--; + + if(this.particleAge >= this.particleMaxAge) { + this.setDead(); + } + + this.prevPosX = posX; + this.prevPosY = posY; + this.prevPosZ = posZ; + this.posX += this.motionX; + this.posY += this.motionY; + this.posZ += this.motionZ; + + if(timeUntilChange == 0) { + timeUntilChange = rand.nextInt(5) + 1; + // Not quite as smooth as the actual noise I think xonotic uses, but + // it's good enough. + this.motionX = (rand.nextFloat() - 0.5) * 0.02; + this.motionY = (rand.nextFloat() - 0.5) * 0.02; + this.motionZ = (rand.nextFloat() - 0.5) * 0.02; + } + } + + @Override + public int getFXLayer() { + return 3; + } + + @Override + public void renderParticle(Tessellator tess, float partialTicks, float rotationX, float rotationZ, float rotationYZ, float rotationXY, float rotationXZ) { + + Minecraft.getMinecraft().getTextureManager().bindTexture(fresnel_ms); + GL11.glTexParameteri(GL11.GL_TEXTURE_2D, GL11.GL_TEXTURE_MAG_FILTER, GL11.GL_LINEAR); + GL11.glDisable(GL11.GL_ALPHA_TEST); + GL11.glDepthMask(false); + GL11.glEnable(GL11.GL_BLEND); + GL11.glBlendFunc(GL11.GL_SRC_ALPHA, GL11.GL_ONE); + float timeScale = (this.particleAge + partialTicks) / (float) this.particleMaxAge; + float shrink = MathHelper.clamp_float(1 - BobMathUtil.remap((float) MathHelper.clamp_float(timeScale, 0, 1), 0.6F, 1F, 0.6F, 1F), 0, 1); + this.workingAlpha = shrink * particleAlpha; + + float f4 = 0.1F * (this.particleScale + shrink * particleScale * 4); + + float f5 = (float) (this.prevPosX + (this.posX - this.prevPosX) * (double) partialTicks - interpPosX); + float f6 = (float) (this.prevPosY + (this.posY - this.prevPosY) * (double) partialTicks - interpPosY); + float f7 = (float) (this.prevPosZ + (this.posZ - this.prevPosZ) * (double) partialTicks - interpPosZ); + Vec3[] avec3d = new Vec3[] { + Vec3.createVectorHelper((double) (-rotationX * f4 - rotationXY * f4), (double) (-rotationZ * f4), (double) (-rotationYZ * f4 - rotationXZ * f4)), + Vec3.createVectorHelper((double) (-rotationX * f4 + rotationXY * f4), (double) (rotationZ * f4), (double) (-rotationYZ * f4 + rotationXZ * f4)), + Vec3.createVectorHelper((double) (rotationX * f4 + rotationXY * f4), (double) (rotationZ * f4), (double) (rotationYZ * f4 + rotationXZ * f4)), + Vec3.createVectorHelper((double) (rotationX * f4 - rotationXY * f4), (double) (-rotationZ * f4), (double) (rotationYZ * f4 - rotationXZ * f4)) + }; + + tess.setColorRGBA_F(this.particleRed, this.particleGreen, this.particleBlue, this.particleAlpha); + tess.setNormal(0.0F, 1.0F, 0.0F); + tess.setBrightness(240); + + tess.startDrawingQuads(); + tess.addVertexWithUV((double) f5 + avec3d[0].xCoord, (double) f6 + avec3d[0].yCoord, (double) f7 + avec3d[0].zCoord, 1, 1); + tess.addVertexWithUV((double) f5 + avec3d[1].xCoord, (double) f6 + avec3d[1].yCoord, (double) f7 + avec3d[1].zCoord, 1, 0); + tess.addVertexWithUV((double) f5 + avec3d[2].xCoord, (double) f6 + avec3d[2].yCoord, (double) f7 + avec3d[2].zCoord, 0, 0); + tess.addVertexWithUV((double) f5 + avec3d[3].xCoord, (double) f6 + avec3d[3].yCoord, (double) f7 + avec3d[3].zCoord, 0, 1); + + tess.draw(); + + GL11.glEnable(GL11.GL_ALPHA_TEST); + GL11.glDepthMask(true); + GL11.glDisable(GL11.GL_BLEND); + } +} diff --git a/src/main/java/com/hbm/render/entity/projectile/RenderBullet.java b/src/main/java/com/hbm/render/entity/projectile/RenderBullet.java index 11ea0b503..b19c898bb 100644 --- a/src/main/java/com/hbm/render/entity/projectile/RenderBullet.java +++ b/src/main/java/com/hbm/render/entity/projectile/RenderBullet.java @@ -316,9 +316,9 @@ public class RenderBullet extends Render { case BulletConfiguration.BOLT_ZOMG: Random rand = new Random(eID * eID); - red = rand.nextInt(2) * 0.8F; - green = rand.nextInt(2) * 0.8F; - blue = rand.nextInt(2) * 0.8F; + red = rand.nextInt(2) * 0.6F; + green = rand.nextInt(2) * 0.6F; + blue = rand.nextInt(2) * 0.6F; break; } diff --git a/src/main/java/com/hbm/tileentity/machine/TileEntityMachineRadar.java b/src/main/java/com/hbm/tileentity/machine/TileEntityMachineRadar.java index a72d67644..150e1a736 100644 --- a/src/main/java/com/hbm/tileentity/machine/TileEntityMachineRadar.java +++ b/src/main/java/com/hbm/tileentity/machine/TileEntityMachineRadar.java @@ -31,6 +31,7 @@ public class TileEntityMachineRadar extends TileEntityTickingBase implements ICo public boolean scanMissiles = true; public boolean scanPlayers = true; public boolean smartMode = true; + public boolean redMode = true; public float prevRotation; public float rotation; @@ -98,6 +99,7 @@ public class TileEntityMachineRadar extends TileEntityTickingBase implements ICo case 0: this.scanMissiles = !this.scanMissiles; break; case 1: this.scanPlayers = !this.scanPlayers; break; case 2: this.smartMode = !this.smartMode; break; + case 3: this.redMode = !this.redMode; break; } } @@ -131,21 +133,39 @@ public class TileEntityMachineRadar extends TileEntityTickingBase implements ICo if(!entList.isEmpty()) { - double maxRange = WeaponConfig.radarRange * Math.sqrt(2D); - - int power = 0; - - for(int i = 0; i < entList.size(); i++) { + /// PROXIMITY /// + if(redMode) { - Entity e = entList.get(i); - double dist = Math.sqrt(Math.pow(e.posX - xCoord, 2) + Math.pow(e.posZ - zCoord, 2)); - int p = 15 - (int)Math.floor(dist / maxRange * 15); + double maxRange = WeaponConfig.radarRange * Math.sqrt(2D); - if(p > power) - power = p; + int power = 0; + + for(int i = 0; i < entList.size(); i++) { + + Entity e = entList.get(i); + double dist = Math.sqrt(Math.pow(e.posX - xCoord, 2) + Math.pow(e.posZ - zCoord, 2)); + int p = 15 - (int)Math.floor(dist / maxRange * 15); + + if(p > power) + power = p; + } + + return power; + + /// TIER /// + } else { + + int power = 0; + + for(int i = 0; i < nearbyMissiles.size(); i++) { + + if(nearbyMissiles.get(i)[3] + 1 > power) { + power = nearbyMissiles.get(i)[3] + 1; + } + } + + return power; } - - return power; } return 0; @@ -158,6 +178,7 @@ public class TileEntityMachineRadar extends TileEntityTickingBase implements ICo data.setBoolean("scanMissiles", scanMissiles); data.setBoolean("scanPlayers", scanPlayers); data.setBoolean("smartMode", smartMode); + data.setBoolean("redMode", redMode); data.setInteger("count", this.nearbyMissiles.size()); for(int i = 0; i < this.nearbyMissiles.size(); i++) { @@ -177,6 +198,7 @@ public class TileEntityMachineRadar extends TileEntityTickingBase implements ICo this.scanMissiles = data.getBoolean("scanMissiles"); this.scanPlayers = data.getBoolean("scanPlayers"); this.smartMode = data.getBoolean("smartMode"); + this.redMode = data.getBoolean("redMode"); int count = data.getInteger("count"); @@ -217,6 +239,7 @@ public class TileEntityMachineRadar extends TileEntityTickingBase implements ICo this.scanMissiles = nbt.getBoolean("scanMissiles"); this.scanPlayers = nbt.getBoolean("scanPlayers"); this.smartMode = nbt.getBoolean("smartMode"); + this.redMode = nbt.getBoolean("redMode"); } @Override @@ -226,6 +249,7 @@ public class TileEntityMachineRadar extends TileEntityTickingBase implements ICo nbt.setBoolean("scanMissiles", scanMissiles); nbt.setBoolean("scanPlayers", scanPlayers); nbt.setBoolean("smartMode", smartMode); + nbt.setBoolean("redMode", redMode); } @Override diff --git a/src/main/java/com/hbm/util/BobMathUtil.java b/src/main/java/com/hbm/util/BobMathUtil.java index 071f5e361..5fb71ca24 100644 --- a/src/main/java/com/hbm/util/BobMathUtil.java +++ b/src/main/java/com/hbm/util/BobMathUtil.java @@ -32,4 +32,7 @@ public class BobMathUtil { return angle; } + public static float remap(float num, float min1, float max1, float min2, float max2){ + return ((num - min1) / (max1 - min1)) * (max2 - min2) + min2; + } } diff --git a/src/main/resources/assets/hbm/lang/de_DE.lang b/src/main/resources/assets/hbm/lang/de_DE.lang index 2b2a8458a..d0b848158 100644 --- a/src/main/resources/assets/hbm/lang/de_DE.lang +++ b/src/main/resources/assets/hbm/lang/de_DE.lang @@ -2308,6 +2308,7 @@ potion.hbm_telekinesis=! ! ! radar.detectMissiles=Raketen erkennen radar.detectPlayers=Spieler erkennen +radar.redMode=Redstone Mode$Ein: Redstonesignal basiert auf Nähe$Aus: Redstonesignal basiert auf Größe radar.smartMode=Smart Mode$Redstonesignal ignoriert aufsteigende Raketen tile.absorber.name=Strahlungs-Absorber diff --git a/src/main/resources/assets/hbm/lang/en_US.lang b/src/main/resources/assets/hbm/lang/en_US.lang index 7068c5c38..c50e3dd13 100644 --- a/src/main/resources/assets/hbm/lang/en_US.lang +++ b/src/main/resources/assets/hbm/lang/en_US.lang @@ -2319,6 +2319,7 @@ potion.hbm_telekinesis=! ! ! radar.detectMissiles=Detect Missiles radar.detectPlayers=Detect Players +radar.redMode=Redstone Mode$On: Redstone output based on range$Off: Redstone output based on tier radar.smartMode=Smart Mode$Redstone output ignores ascending missiles tile.absorber.name=Radiation Absorber diff --git a/src/main/resources/assets/hbm/textures/blocks/block_actinium.png b/src/main/resources/assets/hbm/textures/blocks/block_actinium.png new file mode 100644 index 000000000..b909aa3ba Binary files /dev/null and b/src/main/resources/assets/hbm/textures/blocks/block_actinium.png differ diff --git a/src/main/resources/assets/hbm/textures/blocks/block_lanthanium.png b/src/main/resources/assets/hbm/textures/blocks/block_lanthanium.png new file mode 100644 index 000000000..31479d52d Binary files /dev/null and b/src/main/resources/assets/hbm/textures/blocks/block_lanthanium.png differ diff --git a/src/main/resources/assets/hbm/textures/gui/gui_radar.png b/src/main/resources/assets/hbm/textures/gui/gui_radar.png deleted file mode 100644 index 16276017d..000000000 Binary files a/src/main/resources/assets/hbm/textures/gui/gui_radar.png and /dev/null differ diff --git a/src/main/resources/assets/hbm/textures/gui/machine/gui_radar.png b/src/main/resources/assets/hbm/textures/gui/machine/gui_radar.png new file mode 100644 index 000000000..cd1d186a9 Binary files /dev/null and b/src/main/resources/assets/hbm/textures/gui/machine/gui_radar.png differ diff --git a/src/main/resources/assets/hbm/textures/models/tank_SUPERHOTSTEAM.png b/src/main/resources/assets/hbm/textures/models/tank_SUPERHOTSTEAM.png index c95495fd8..ac8fc1953 100644 Binary files a/src/main/resources/assets/hbm/textures/models/tank_SUPERHOTSTEAM.png and b/src/main/resources/assets/hbm/textures/models/tank_SUPERHOTSTEAM.png differ diff --git a/src/main/resources/assets/hbm/textures/models/tank_ULTRAHOTSTEAM.png b/src/main/resources/assets/hbm/textures/models/tank_ULTRAHOTSTEAM.png new file mode 100644 index 000000000..c95495fd8 Binary files /dev/null and b/src/main/resources/assets/hbm/textures/models/tank_ULTRAHOTSTEAM.png differ diff --git a/src/main/resources/assets/hbm/textures/particle/fresnel_ms.png b/src/main/resources/assets/hbm/textures/particle/fresnel_ms.png new file mode 100644 index 000000000..dad9ee5e4 Binary files /dev/null and b/src/main/resources/assets/hbm/textures/particle/fresnel_ms.png differ