this glorified garden hose

This commit is contained in:
Bob 2022-08-18 23:03:59 +02:00
parent 9bdd738fdc
commit 42c154fa6e
11 changed files with 10729 additions and 6 deletions

View File

@ -29,6 +29,26 @@ import net.minecraft.potion.PotionEffect;
public class GunEnergyFactory {
public static GunConfiguration getChemConfig() {
GunConfiguration config = new GunConfiguration();
config.rateOfFire = 1;
config.gunMode = GunConfiguration.MODE_NORMAL;
config.firingMode = GunConfiguration.FIRE_AUTO;
config.allowsInfinity = false;
config.ammoCap = 3_000;
config.durability = 30_000;
config.reloadType = GunConfiguration.RELOAD_FULL;
config.crosshair = Crosshair.CIRCLE;
config.name = "Chemical Thrower";
config.manufacturer = "Langford Research Laboratories";
config.config = new ArrayList<Integer>();
return config;
}
public static GunConfiguration getEMPConfig() {
GunConfiguration config = new GunConfiguration();

View File

@ -1659,6 +1659,7 @@ public class ModItems {
//public static Item gun_mirv_ammo;
public static Item gun_bf;
public static Item gun_bf_ammo;
public static Item gun_chemthrower;
public static Item gun_mp40;
//public static Item gun_mp40_ammo;
public static Item gun_thompson;
@ -4403,6 +4404,7 @@ public class ModItems {
gun_mirv = new ItemGunBase(GunFatmanFactory.getMIRVConfig()).setUnlocalizedName("gun_mirv").setCreativeTab(MainRegistry.weaponTab).setTextureName(RefStrings.MODID + ":gun_mirv");
gun_bf_ammo = new Item().setUnlocalizedName("gun_bf_ammo").setCreativeTab(null).setTextureName(RefStrings.MODID + ":gun_bf_ammo");
gun_bf = new ItemGunBase(GunFatmanFactory.getBELConfig()).setUnlocalizedName("gun_bf").setCreativeTab(null).setTextureName(RefStrings.MODID + ":gun_bf");
gun_chemthrower = new ItemGunChemthrower().setUnlocalizedName("gun_chemthrower").setCreativeTab(MainRegistry.weaponTab).setTextureName(RefStrings.MODID + ":gun_fatman");
//gun_mp40_ammo = new Item().setUnlocalizedName("gun_mp40_ammo").setCreativeTab(null).setTextureName(RefStrings.MODID + ":gun_mp40_ammo");
gun_mp40 = new ItemGunBase(Gun9mmFactory.getMP40Config()).setUnlocalizedName("gun_mp40").setCreativeTab(MainRegistry.weaponTab).setTextureName(RefStrings.MODID + ":gun_mp40");
gun_thompson = new ItemGunBase(Gun9mmFactory.getThompsonConfig()).setUnlocalizedName("gun_thompson").setCreativeTab(MainRegistry.weaponTab).setTextureName(RefStrings.MODID + ":gun_thompson");
@ -7214,6 +7216,7 @@ public class ModItems {
GameRegistry.registerItem(gun_proto, gun_proto.getUnlocalizedName());
GameRegistry.registerItem(gun_mirv, gun_mirv.getUnlocalizedName());
GameRegistry.registerItem(gun_bf, gun_bf.getUnlocalizedName());
GameRegistry.registerItem(gun_chemthrower, gun_chemthrower.getUnlocalizedName());
GameRegistry.registerItem(gun_mp40, gun_mp40.getUnlocalizedName());
GameRegistry.registerItem(gun_thompson, gun_thompson.getUnlocalizedName());
GameRegistry.registerItem(gun_uzi, gun_uzi.getUnlocalizedName());

View File

@ -786,7 +786,7 @@ public class ItemGunBase extends Item implements IHoldableWeapon, IItemHUD {
int dura = ItemGunBase.getItemWear(stack) * 50 / gcfg.durability;
RenderScreenOverlay.renderAmmo(event.resolution, Minecraft.getMinecraft().ingameGUI, ammo, count, max, dura, showammo);
RenderScreenOverlay.renderAmmo(event.resolution, Minecraft.getMinecraft().ingameGUI, new ItemStack(ammo), count, max, dura, showammo);
if(gun.altConfig != null && gun.altConfig.reloadType == GunConfiguration.RELOAD_NONE) {
Item oldAmmo = ammo;
@ -794,7 +794,7 @@ public class ItemGunBase extends Item implements IHoldableWeapon, IItemHUD {
if(ammo != oldAmmo) {
count = ItemGunBase.getBeltSize(player, ammo);
RenderScreenOverlay.renderAmmoAlt(event.resolution, Minecraft.getMinecraft().ingameGUI, ammo, count);
RenderScreenOverlay.renderAmmoAlt(event.resolution, Minecraft.getMinecraft().ingameGUI, new ItemStack(ammo), count);
}
}
}

View File

@ -0,0 +1,226 @@
package com.hbm.items.weapon;
import java.util.List;
import com.hbm.config.GeneralConfig;
import com.hbm.handler.BulletConfigSyncingUtil;
import com.hbm.handler.BulletConfiguration;
import com.hbm.handler.GunConfiguration;
import com.hbm.handler.guncfg.GunEnergyFactory;
import com.hbm.interfaces.IHoldableWeapon;
import com.hbm.inventory.fluid.FluidType;
import com.hbm.inventory.fluid.Fluids;
import com.hbm.items.machine.ItemFluidIcon;
import com.hbm.packet.AuxParticlePacketNT;
import com.hbm.packet.GunAnimationPacket;
import com.hbm.packet.PacketDispatcher;
import com.hbm.render.anim.HbmAnimations.AnimType;
import com.hbm.render.util.RenderScreenOverlay;
import com.hbm.render.util.RenderScreenOverlay.Crosshair;
import api.hbm.fluid.IFillableItem;
import cpw.mods.fml.relauncher.Side;
import cpw.mods.fml.relauncher.SideOnly;
import net.minecraft.client.Minecraft;
import net.minecraft.client.resources.I18n;
import net.minecraft.enchantment.Enchantment;
import net.minecraft.enchantment.EnchantmentHelper;
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.EnumChatFormatting;
import net.minecraft.world.World;
import net.minecraftforge.client.event.RenderGameOverlayEvent.ElementType;
import net.minecraftforge.client.event.RenderGameOverlayEvent.Pre;
public class ItemGunChemthrower extends ItemGunBase implements IFillableItem {
public ItemGunChemthrower() {
super(GunEnergyFactory.getChemConfig());
}
@Override
protected void fire(ItemStack stack, World world, EntityPlayer player) {
System.out.println("nuts");
if(!hasAmmo(stack, player, true))
return;
int bullets = 1;
for(int i = 0; i < bullets; i++) {
spawnProjectile(world, player, stack, 0);
}
useUpAmmo(player, stack, true);
player.inventoryContainer.detectAndSendChanges();
int wear = (int) Math.ceil(10 / (1F + EnchantmentHelper.getEnchantmentLevel(Enchantment.unbreaking.effectId, stack)));
setItemWear(stack, getItemWear(stack) + wear);
//world.playSoundAtEntity(player, mainConfig.firingSound, 1.0F, mainConfig.firingPitch);
}
@Override
public boolean hasAmmo(ItemStack stack, EntityPlayer player, boolean main) {
return getMag(stack) >= 0 + this.getConsumption(stack);
}
@Override
public void useUpAmmo(EntityPlayer player, ItemStack stack, boolean main) {
if(!main && altConfig == null)
return;
GunConfiguration config = mainConfig;
if(!main)
config = altConfig;
if(hasInfinity(stack, config))
return;
if(config.reloadType != mainConfig.RELOAD_NONE) {
setMag(stack, getMag(stack) - this.getConsumption(stack));
} else {
player.inventory.consumeInventoryItem(getBeltType(player, stack, main));
}
}
@Override
public boolean canReload(ItemStack stack, World world, EntityPlayer player) {
return false;
}
protected void spawnProjectile(World world, EntityPlayer player, ItemStack stack, int config) {
//spawn fluid projectile
if(player instanceof EntityPlayerMP)
PacketDispatcher.wrapper.sendTo(new GunAnimationPacket(AnimType.CYCLE.ordinal()), (EntityPlayerMP) player);
}
@Override
public void addInformation(ItemStack stack, EntityPlayer player, List list, boolean bool) {
list.add("Ammo: " + getMag(stack) + " / " + mainConfig.ammoCap + "mB");
list.add("Ammo Type: " + I18n.format(this.getFluidType(stack).getUnlocalizedName()));
int dura = mainConfig.durability - getItemWear(stack);
if(dura < 0)
dura = 0;
list.add("Durability: " + dura + " / " + mainConfig.durability);
list.add("");
list.add("Name: " + mainConfig.name);
list.add("Manufacturer: " + mainConfig.manufacturer);
if(!mainConfig.comment.isEmpty()) {
list.add("");
for(String s : mainConfig.comment)
list.add(EnumChatFormatting.ITALIC + s);
}
if(GeneralConfig.enableExtendedLogging) {
list.add("");
list.add("Type: " + getMagType(stack));
list.add("Is Reloading: " + getIsReloading(stack));
list.add("Reload Cycle: " + getReloadCycle(stack));
list.add("RoF Cooldown: " + getDelay(stack));
}
}
@Override
@SideOnly(Side.CLIENT)
public void renderHUD(Pre event, ElementType type, EntityPlayer player, ItemStack stack) {
ItemGunBase gun = ((ItemGunBase)stack.getItem());
GunConfiguration gcfg = gun.mainConfig;
if(type == ElementType.HOTBAR) {
FluidType fluid = this.getFluidType(stack);
ItemStack ammo = ItemFluidIcon.make(fluid, 1);
int count = ItemGunBase.getMag(stack);
int max = gcfg.ammoCap;
boolean showammo = gcfg.showAmmo;
int dura = ItemGunBase.getItemWear(stack) * 50 / gcfg.durability;
RenderScreenOverlay.renderAmmo(event.resolution, Minecraft.getMinecraft().ingameGUI, ammo, count, max, dura, showammo);
}
if(type == ElementType.CROSSHAIRS && GeneralConfig.enableCrosshairs) {
event.setCanceled(true);
if(!(gcfg.hasSights && player.isSneaking()))
RenderScreenOverlay.renderCustomCrosshairs(event.resolution, Minecraft.getMinecraft().ingameGUI, ((IHoldableWeapon)player.getHeldItem().getItem()).getCrosshair());
else
RenderScreenOverlay.renderCustomCrosshairs(event.resolution, Minecraft.getMinecraft().ingameGUI, Crosshair.NONE);
}
}
@Override
protected void reload2(ItemStack stack, World world, EntityPlayer player) {
this.setIsReloading(stack, false);
}
public FluidType getFluidType(ItemStack stack) {
return Fluids.fromID(this.getMagType(stack));
}
public int getConsumption(ItemStack stack) {
return 3;
}
@Override
public boolean acceptsFluid(FluidType type, ItemStack stack) {
return getFluidType(stack) == type || this.getMag(stack) == 0;
}
public static final int transferSpeed = 50;
@Override
public int tryFill(FluidType type, int amount, ItemStack stack) {
if(!acceptsFluid(type, stack))
return amount;
if(this.getMag(stack) == 0)
this.setMagType(stack, type.getID());
int fill = this.getMag(stack);
int req = this.mainConfig.ammoCap - fill;
int toFill = Math.min(amount, req);
toFill = Math.min(toFill, transferSpeed);
this.setMag(stack, fill + toFill);
return amount - toFill;
}
@Override
public boolean providesFluid(FluidType type, ItemStack stack) {
return getFluidType(stack) == type;
}
@Override
public int tryEmpty(FluidType type, int amount, ItemStack stack) {
int fill = this.getMag(stack);
int toUnload = Math.min(fill, amount);
toUnload = Math.min(toUnload, transferSpeed);
this.setMag(stack, fill - toUnload);
return toUnload;
}
}

View File

@ -491,6 +491,7 @@ public class ClientProxy extends ServerProxy {
MinecraftForgeClient.registerItemRenderer(ModItems.detonator_laser, new ItemRenderDetonatorLaser());
MinecraftForgeClient.registerItemRenderer(ModItems.gun_spas12, new ItemRenderWeaponSpas12());
MinecraftForgeClient.registerItemRenderer(ModItems.gun_glass_cannon, new ItemRenderWeaponGlass());
MinecraftForgeClient.registerItemRenderer(ModItems.gun_chemthrower, new ItemRenderWeaponChemthrower());
//multitool
MinecraftForgeClient.registerItemRenderer(ModItems.multitool_dig, new ItemRenderMultitool());
MinecraftForgeClient.registerItemRenderer(ModItems.multitool_silk, new ItemRenderMultitool());

View File

@ -684,6 +684,7 @@ public class ResourceManager {
public static final IModelCustom nightmare_dark = new HFRWavefrontObject(new ResourceLocation(RefStrings.MODID, "models/weapons/nightmare_dark.obj"));
public static final IModelCustom glass_cannon = new HFRWavefrontObject(new ResourceLocation(RefStrings.MODID, "models/weapons/glass_cannon.obj"));
public static final IModelCustom bio_revolver = new HFRWavefrontObject(new ResourceLocation(RefStrings.MODID, "models/weapons/bio_revolver.obj"));
public static final IModelCustom chemthrower = new HFRWavefrontObject(new ResourceLocation(RefStrings.MODID, "models/weapons/chemthrower.obj")).asDisplayList();
public static final IModelCustom lance = new HFRWavefrontObject(new ResourceLocation(RefStrings.MODID, "models/weapons/lance.obj"));
@ -761,6 +762,7 @@ public class ResourceManager {
public static final ResourceLocation spas_12_tex = new ResourceLocation(RefStrings.MODID, "textures/models/weapons/spas-12.png");
public static final ResourceLocation glass_cannon_panel_tex = new ResourceLocation(RefStrings.MODID, "textures/models/weapons/glass_cannon_panel.png");
public static final ResourceLocation bio_revolver_tex = new ResourceLocation(RefStrings.MODID, "textures/models/weapons/bio_revolver.png");
public static final ResourceLocation chemthrower_tex = new ResourceLocation(RefStrings.MODID, "textures/models/weapons/chemthrower.png");
public static final ResourceLocation lance_tex = new ResourceLocation(RefStrings.MODID, "textures/models/weapons/lance.png");

View File

@ -0,0 +1,105 @@
package com.hbm.render.item.weapon;
import org.lwjgl.opengl.GL11;
import com.hbm.items.weapon.ItemGunChemthrower;
import com.hbm.main.ResourceManager;
import net.minecraft.client.Minecraft;
import net.minecraft.item.ItemStack;
import net.minecraftforge.client.IItemRenderer;
public class ItemRenderWeaponChemthrower implements IItemRenderer {
@Override
public boolean handleRenderType(ItemStack item, ItemRenderType type) {
switch(type) {
case EQUIPPED:
case EQUIPPED_FIRST_PERSON:
case ENTITY:
case INVENTORY:
return true;
default: return false;
}
}
@Override
public boolean shouldUseRenderHelper(ItemRenderType type, ItemStack item, ItemRendererHelper helper) {
return type == ItemRenderType.ENTITY && (helper == ItemRendererHelper.ENTITY_ROTATION || helper == ItemRendererHelper.ENTITY_BOBBING);
}
@Override
public void renderItem(ItemRenderType type, ItemStack item, Object... data) {
GL11.glPushMatrix();
GL11.glEnable(GL11.GL_CULL_FACE);
Minecraft.getMinecraft().renderEngine.bindTexture(ResourceManager.chemthrower_tex);
switch(type) {
case EQUIPPED_FIRST_PERSON:
double s0 = 0.25D;
GL11.glRotated(25, 0, 0, 1);
GL11.glTranslated(1.0, 0.0, 0.0);
GL11.glRotated(170, 0, 1, 0);
GL11.glScaled(s0, s0, s0);
break;
case EQUIPPED:
double scale = 0.125D;
GL11.glScaled(scale, scale, scale);
GL11.glRotatef(20F, 0.0F, 0.0F, 1.0F);
GL11.glRotatef(10, 0.0F, 1.0F, 0.0F);
GL11.glRotatef(15F, 1.0F, 0.0F, 0.0F);
GL11.glTranslatef(4F, -2F, 5F);
break;
case ENTITY:
double s1 = 0.1D;
GL11.glScaled(s1, s1, s1);
break;
case INVENTORY:
GL11.glEnable(GL11.GL_LIGHTING);
double s = 1.5D;
GL11.glTranslated(9, 9, 0);
GL11.glRotated(180, 1, 0, 0);
GL11.glRotated(45, 0, 0, -1);
GL11.glScaled(s, s, -s);
break;
default: break;
}
ItemGunChemthrower chem = (ItemGunChemthrower) item.getItem();
GL11.glShadeModel(GL11.GL_SMOOTH);
ResourceManager.chemthrower.renderPart("Gun");
ResourceManager.chemthrower.renderPart("Hose");
ResourceManager.chemthrower.renderPart("Nozzle");
GL11.glTranslated(0, 0.875, 1.75);
double d = (double) chem.getMag(item) / (double) chem.mainConfig.ammoCap;
GL11.glRotated(135 - d * 270, 1, 0, 0);
GL11.glTranslated(0, -0.875, -1.75);
ResourceManager.chemthrower.renderPart("Gauge");
GL11.glShadeModel(GL11.GL_FLAT);
GL11.glPopMatrix();
}
}

View File

@ -117,7 +117,7 @@ public class RenderScreenOverlay {
Minecraft.getMinecraft().renderEngine.bindTexture(Gui.icons);
}
public static void renderAmmo(ScaledResolution resolution, Gui gui, Item ammo, int count, int max, int dura, boolean renderCount) {
public static void renderAmmo(ScaledResolution resolution, Gui gui, ItemStack ammo, int count, int max, int dura, boolean renderCount) {
GL11.glPushMatrix();
@ -138,7 +138,7 @@ public class RenderScreenOverlay {
GL11.glDisable(GL11.GL_BLEND);
GL11.glEnable(GL12.GL_RESCALE_NORMAL);
RenderHelper.enableGUIStandardItemLighting();
itemRenderer.renderItemAndEffectIntoGUI(mc.fontRenderer, mc.getTextureManager(), new ItemStack(ammo), pX, pZ);
itemRenderer.renderItemAndEffectIntoGUI(mc.fontRenderer, mc.getTextureManager(), ammo, pX, pZ);
RenderHelper.disableStandardItemLighting();
GL11.glDisable(GL12.GL_RESCALE_NORMAL);
@ -146,7 +146,7 @@ public class RenderScreenOverlay {
Minecraft.getMinecraft().renderEngine.bindTexture(Gui.icons);
}
public static void renderAmmoAlt(ScaledResolution resolution, Gui gui, Item ammo, int count) {
public static void renderAmmoAlt(ScaledResolution resolution, Gui gui, ItemStack ammo, int count) {
GL11.glPushMatrix();
@ -162,7 +162,7 @@ public class RenderScreenOverlay {
GL11.glDisable(GL11.GL_BLEND);
GL11.glEnable(GL12.GL_RESCALE_NORMAL);
RenderHelper.enableGUIStandardItemLighting();
itemRenderer.renderItemAndEffectIntoGUI(mc.fontRenderer, mc.getTextureManager(), new ItemStack(ammo), pX, pZ);
itemRenderer.renderItemAndEffectIntoGUI(mc.fontRenderer, mc.getTextureManager(), ammo, pX, pZ);
RenderHelper.disableStandardItemLighting();
GL11.glDisable(GL12.GL_RESCALE_NORMAL);

File diff suppressed because it is too large Load Diff

Binary file not shown.

Before

Width:  |  Height:  |  Size: 1.4 KiB

After

Width:  |  Height:  |  Size: 1.4 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 3.7 KiB