357 revolver migration, new fallout rain system

This commit is contained in:
HbmMods 2019-02-06 13:01:25 +01:00
parent e9a2e6c895
commit a089178fbf
11 changed files with 367 additions and 82 deletions

View File

@ -7,92 +7,154 @@ import com.hbm.explosion.NukeEnvironmentalEffect;
import com.hbm.lib.Library;
import com.hbm.potion.HbmPotion;
import net.minecraft.block.Block;
import net.minecraft.block.material.Material;
import net.minecraft.entity.Entity;
import net.minecraft.entity.EntityLivingBase;
import net.minecraft.init.Blocks;
import net.minecraft.nbt.NBTTagCompound;
import net.minecraft.potion.PotionEffect;
import net.minecraft.util.AxisAlignedBB;
import net.minecraft.util.Vec3;
import net.minecraft.world.World;
public class EntityFalloutRain extends Entity {
public int maxAge = 1000;
public int age;
public int revProgress;
public int radProgress;
public EntityFalloutRain(World p_i1582_1_) {
super(p_i1582_1_);
this.setSize(4, 20);
this.ignoreFrustumCheck = true;
this.isImmuneToFire = true;
this.age = 0;
}
public EntityFalloutRain(World p_i1582_1_, int maxAge) {
super(p_i1582_1_);
this.setSize(4, 20);
this.isImmuneToFire = true;
this.maxAge = maxAge;
}
@Override
public void onUpdate() {
//super.onUpdate();
this.age++;
if(!worldObj.isRemote) {
int count = (int)(Math.pow(getScale(), 2) * Math.PI / 500);
if(count > 50)
count = 50;
int maxEff = 15;
int currEff = 0;
for(int i = 0; i < count; i++) {
int x = (int) (posX + rand.nextInt((int) ((getScale() + 1) * 2)) - getScale());
int z = (int) (posZ + rand.nextInt((int) ((getScale() + 1) * 2)) - getScale());
int y = worldObj.getHeightValue(x, z) - 1;
double dist = Math.sqrt(Math.pow(posX - x, 2) + Math.pow(posZ - z, 2));
if(dist <= getScale()) {
if(currEff < maxEff && rand.nextInt(30) == 0) {
NukeEnvironmentalEffect.applyStandardAOE(worldObj, x, y, z, 5, 3);
currEff++;
} else if(worldObj.getBlock(x, y, z) == Blocks.grass) {
worldObj.setBlock(x, y, z, ModBlocks.waste_earth);
}
}
for(int i = 0; i < 256; i++) {
Vec3 vec = Vec3.createVectorHelper(radProgress, 0, 0);
double circum = radProgress * 2 * Math.PI * 2;
double part = 360D / circum;
vec.rotateAroundY((float) (part * revProgress));
int x = (int) (posX + vec.xCoord);
int z = (int) (posZ + vec.zCoord);
//int y = worldObj.getHeightValue(x, z) - 1;
//if(worldObj.getBlock(x, y, z) == Blocks.grass)
// worldObj.setBlock(x, y, z, ModBlocks.waste_earth);
stomp(x, z);
revProgress++;
if(revProgress > circum) {
revProgress = 0;
radProgress++;
}
if(radProgress > getScale())
this.setDead();
}
List<Object> list = worldObj.getEntitiesWithinAABBExcludingEntity(this, AxisAlignedBB.getBoundingBox(posX - getScale(), 0, posZ - getScale(), posX + getScale(), 256, posZ + getScale()));
for(Object o : list) {
if(o instanceof EntityLivingBase) {
EntityLivingBase entity = (EntityLivingBase) o;
if(Math.sqrt(Math.pow(entity.posX - posX, 2) + Math.pow(entity.posZ - posZ, 2)) <= getScale()) {
//Library.applyRadiation(entity, 30, 9, 0, 0);
entity.addPotionEffect(new PotionEffect(HbmPotion.radiation.id, 30 * 20, 2));
}
}
}
if(this.age >= this.maxAge)
{
this.age = 0;
this.setDead();
}
//System.out.println(age + " " + maxAge);
}
}
private void stomp(int x, int z) {
for(int y = 255; y >= 0; y--) {
Block b = worldObj.getBlock(x, y, z);
int meta = worldObj.getBlockMetadata(x, y, z);
if(b.getMaterial() == Material.air)
continue;
if (b == Blocks.leaves || b == Blocks.leaves2) {
worldObj.setBlock(x, y, z, Blocks.air);
}
else if(b == Blocks.grass) {
worldObj.setBlock(x, y, z, ModBlocks.waste_earth);
return;
} else if(b == Blocks.mycelium) {
worldObj.setBlock(x, y, z, ModBlocks.waste_mycelium);
return;
} else if(b == Blocks.sand) {
if(rand.nextInt(20) == 0)
worldObj.setBlock(x, y, z, meta == 0 ? ModBlocks.waste_trinitite : ModBlocks.waste_trinitite_red);
return;
}
else if (b == Blocks.clay) {
worldObj.setBlock(x, y, z, Blocks.hardened_clay);
return;
}
else if (b == Blocks.mossy_cobblestone) {
worldObj.setBlock(x, y, z, Blocks.coal_ore);
return;
}
else if (b == Blocks.coal_ore) {
int ra = rand.nextInt(10);
if (ra < 3) {
worldObj.setBlock(x, y, z, Blocks.diamond_ore);
}
if (ra == 3) {
worldObj.setBlock(x, y, z, Blocks.emerald_ore);
}
return;
}
else if (b == Blocks.log || b == Blocks.log2) {
worldObj.setBlock(x, y, z, ModBlocks.waste_log);
}
else if (b == Blocks.brown_mushroom_block || b == Blocks.red_mushroom_block) {
if (meta == 10) {
worldObj.setBlock(x, y, z, ModBlocks.waste_log);
} else {
worldObj.setBlock(x, y, z, Blocks.air,0,2);
}
}
else if (b.getMaterial() == Material.wood && b.isOpaqueCube() && b != ModBlocks.waste_log) {
worldObj.setBlock(x, y, z, ModBlocks.waste_planks);
}
else if (b == ModBlocks.ore_uranium) {
if (rand.nextInt(30) == 0)
worldObj.setBlock(x, y, z, ModBlocks.ore_schrabidium);
return;
}
else if (b == ModBlocks.ore_nether_uranium) {
if (rand.nextInt(30) == 0)
worldObj.setBlock(x, y, z, ModBlocks.ore_nether_schrabidium);
return;
//this piece stops the "stomp" from reaching below ground
} else if(b.isNormalCube()) {
return;
}
}
}
@Override
protected void entityInit() {
@ -101,16 +163,16 @@ public class EntityFalloutRain extends Entity {
@Override
protected void readEntityFromNBT(NBTTagCompound p_70037_1_) {
age = p_70037_1_.getShort("age");
setScale(p_70037_1_.getInteger("scale"));
maxAge = p_70037_1_.getShort("maxAge");
revProgress = p_70037_1_.getInteger("revProgress");
radProgress = p_70037_1_.getInteger("radProgress");
}
@Override
protected void writeEntityToNBT(NBTTagCompound p_70014_1_) {
p_70014_1_.setShort("age", (short)age);
p_70014_1_.setInteger("scale", getScale());
p_70014_1_.setShort("maxAge", (short)maxAge);
p_70014_1_.setInteger("revProgress", revProgress);
p_70014_1_.setInteger("radProgress", radProgress);
}

View File

@ -221,13 +221,13 @@ public class EntityBulletBase extends Entity implements IProjectile {
victim.attackEntityFrom(damagesource, dmg);
} catch (Exception x) { }
}
if(!config.doesPenetrate)
if(!worldObj.isRemote)
onEntityImpact(victim);
else
if(!worldObj.isRemote)
onEntityHurt(victim);
if(!worldObj.isRemote) {
if(!config.doesPenetrate)
onEntityImpact(victim);
else
onEntityHurt(victim);
}
//handle block collision
} else if(worldObj.getBlock(movement.blockX, movement.blockY, movement.blockZ).getMaterial() != Material.air) {
@ -374,12 +374,12 @@ public class EntityBulletBase extends Entity implements IProjectile {
}
}
if(config.explosive > 0 && !worldObj.isRemote)
worldObj.newExplosion(this, posX, posY, posZ, config.explosive, config.incendiary > 0, true);
if(config.jolt > 0 && !worldObj.isRemote)
ExplosionLarge.jolt(worldObj, posX, posY, posZ, config.jolt, 150, 0.25);
if(config.explosive > 0 && !worldObj.isRemote)
worldObj.newExplosion(this, posX, posY, posZ, config.explosive, config.incendiary > 0, true);
if(config.shrapnel > 0 && !worldObj.isRemote)
ExplosionLarge.spawnShrapnels(worldObj, posX, posY, posZ, config.shrapnel);

View File

@ -35,6 +35,7 @@ public class BulletConfigSyncingUtil {
public static final int SCHRABIDIUM_REVOLVER = 0x06;
public static final int NIGHT_REVOLVER = 0x07;
public static final int NIGHT2_REVOLVER = 0x08;
public static final int SATURNITE_REVOLVER = 0x09;
public static final int G20_NORMAL = 0x10;
public static final int G20_SLUG = 0x11;
@ -96,6 +97,7 @@ public class BulletConfigSyncingUtil {
configSet.add(new ConfigKeyPair(Gun357MagnumFactory.getRevSchrabidiumConfig(), SCHRABIDIUM_REVOLVER));
configSet.add(new ConfigKeyPair(Gun357MagnumFactory.getRevNightmareConfig(), NIGHT_REVOLVER));
configSet.add(new ConfigKeyPair(Gun357MagnumFactory.getRevNightmare2Config(), NIGHT2_REVOLVER));
configSet.add(new ConfigKeyPair(Gun357MagnumFactory.getRevSteelConfig().setToFire(3), SATURNITE_REVOLVER));
configSet.add(new ConfigKeyPair(Gun20GaugeFactory.get20GaugeConfig(), G20_NORMAL));
configSet.add(new ConfigKeyPair(Gun20GaugeFactory.get20GaugeSlugConfig(), G20_SLUG));

View File

@ -97,5 +97,11 @@ public class BulletConfiguration {
this.trail = trail;
return this;
}
public BulletConfiguration setToFire(int duration) {
this.incendiary = duration;
return this;
}
}

View File

@ -39,6 +39,10 @@ public class GunConfiguration {
public int reloadDuration;
//duration of every animation cycle
public int firingDuration;
//sound path to the reload sound
public String reloadSound;
//sound path to the shooting sound
public String firingSound;
//how much ammo the clip can hold, 0 if drawn from inventory
public int ammoCap;
@ -67,4 +71,8 @@ public class GunConfiguration {
public static final int RELOAD_FULL = 1;
public static final int RELOAD_SINGLE = 2;
public static final String RSOUND_REVOLVER = "";
public static final String RSOUND_RIFLE = "";
public static final String RSOUND_SHOTGUN = "";
}

View File

@ -13,7 +13,7 @@ import net.minecraft.potion.PotionEffect;
public class Gun357MagnumFactory {
public static GunConfiguration getRevolverConfig() {
public static GunConfiguration getBaseConfig() {
GunConfiguration config = new GunConfiguration();
@ -31,17 +31,153 @@ public class Gun357MagnumFactory {
config.reloadType = GunConfiguration.RELOAD_FULL;
config.allowsInfinity = true;
config.crosshair = Crosshair.L_CLASSIC;
config.durability = 350;
return config;
}
public static GunConfiguration getRevolverIronConfig() {
GunConfiguration config = getBaseConfig();
config.durability = 2000;
config.name = "FFI Viper";
config.manufacturer = "FlimFlam Industries";
config.config = new ArrayList<Integer>();
config.config.add(BulletConfigSyncingUtil.IRON_REVOLVER);
return config;
}
public static GunConfiguration getRevolverConfig() {
GunConfiguration config = getBaseConfig();
config.durability = 3500;
config.name = "FFI Viper Inox";
config.manufacturer = "FlimFlam Industries";
config.config = new ArrayList<Integer>();
config.config.add(BulletConfigSyncingUtil.STEEL_REVOLVER);
return config;
}
public static GunConfiguration getRevolverSaturniteConfig() {
GunConfiguration config = getBaseConfig();
config.durability = 3500;
config.name = "FFI Viper D-25A";
config.manufacturer = "FlimFlam Industries";
config.config = new ArrayList<Integer>();
config.config.add(BulletConfigSyncingUtil.SATURNITE_REVOLVER);
return config;
}
public static GunConfiguration getRevolverLeadConfig() {
GunConfiguration config = getBaseConfig();
config.durability = 2000;
config.name = "FFI Viper Lead";
config.manufacturer = "FlimFlam Industries";
config.config = new ArrayList<Integer>();
config.config.add(BulletConfigSyncingUtil.LEAD_REVOLVER);
return config;
}
public static GunConfiguration getRevolverGoldConfig() {
GunConfiguration config = getBaseConfig();
config.durability = 2500;
config.name = "FFI Viper Bling";
config.manufacturer = "FlimFlam Industries";
config.config = new ArrayList<Integer>();
config.config.add(BulletConfigSyncingUtil.GOLD_REVOLVER);
return config;
}
public static GunConfiguration getRevolverCursedConfig() {
GunConfiguration config = getBaseConfig();
config.rateOfFire = 7;
config.ammoCap = 17;
config.durability = 5000;
config.name = "Britannia Standard Issue Motorized Handgun";
config.manufacturer = "BAE Systems plc";
config.config = new ArrayList<Integer>();
config.config.add(BulletConfigSyncingUtil.CURSED_REVOLVER);
return config;
}
public static GunConfiguration getRevolverSchrabidiumConfig() {
GunConfiguration config = getBaseConfig();
config.durability = 7500;
config.name = "FFI Viper Ultra";
config.manufacturer = "FlimFlam Industries";
config.config = new ArrayList<Integer>();
config.config.add(BulletConfigSyncingUtil.SCHRABIDIUM_REVOLVER);
return config;
}
public static GunConfiguration getRevolverNightmareConfig() {
GunConfiguration config = getBaseConfig();
config.durability = 4000;
config.name = "FFI Viper N1";
config.manufacturer = "FlimFlam Industries";
config.config = new ArrayList<Integer>();
config.config.add(BulletConfigSyncingUtil.NIGHT_REVOLVER);
return config;
}
public static GunConfiguration getRevolverNightmare2Config() {
GunConfiguration config = getBaseConfig();
config.durability = 4000;
config.name = "FFI Viper N2";
config.manufacturer = "FlimFlam Industries";
config.config = new ArrayList<Integer>();
config.config.add(BulletConfigSyncingUtil.NIGHT2_REVOLVER);
return config;
}
//// // // // // ////// ////// //////
// // // // // // // // //
//// // // // // //// // //////
// // // // // // // // //
//// ////// ////// ////// ////// // //////
public static BulletConfiguration getRevIronConfig() {
BulletConfiguration bullet = BulletConfigFactory.standardBulletConfig();
@ -127,12 +263,15 @@ public class Gun357MagnumFactory {
BulletConfiguration bullet = BulletConfigFactory.standardBulletConfig();
bullet.ammo = ModItems.gun_revolver_nightmare_ammo;
bullet.ammo = ModItems.gun_revolver_nightmare2_ammo;
bullet.spread *= 10;
bullet.bulletsMin = 4;
bullet.bulletsMax = 6;
bullet.dmgMin = 50;
bullet.dmgMax = 150;
bullet.destroysBlocks = true;
bullet.style = bullet.STYLE_BOLT;
bullet.trail = bullet.BOLT_NIGHTMARE;
return bullet;
}

View File

@ -2309,21 +2309,21 @@ public class ModItems {
gun_revolver_ammo = new Item().setUnlocalizedName("gun_revolver_ammo").setCreativeTab(MainRegistry.weaponTab).setTextureName(RefStrings.MODID + ":gun_revolver_ammo");
//gun_revolver = new GunRevolver(gun_revolver_ammo, 10, 25, false, false).setMaxDamage(500).setUnlocalizedName("gun_revolver").setCreativeTab(MainRegistry.weaponTab).setTextureName(RefStrings.MODID + ":gun_revolver");
gun_revolver = new ItemGunBase(Gun357MagnumFactory.getRevolverConfig()).setUnlocalizedName("gun_revolver").setCreativeTab(MainRegistry.weaponTab).setTextureName(RefStrings.MODID + ":gun_revolver");
gun_revolver_saturnite = new GunRevolver(gun_revolver_ammo, 20, 35, false, false).setMaxDamage(2500).setUnlocalizedName("gun_revolver_saturnite").setCreativeTab(MainRegistry.weaponTab).setTextureName(RefStrings.MODID + ":gun_revolver_saturnite");
gun_revolver_saturnite = new ItemGunBase(Gun357MagnumFactory.getRevolverSaturniteConfig()).setUnlocalizedName("gun_revolver_saturnite").setCreativeTab(MainRegistry.weaponTab).setTextureName(RefStrings.MODID + ":gun_revolver_saturnite");
gun_revolver_iron_ammo = new Item().setUnlocalizedName("gun_revolver_iron_ammo").setCreativeTab(MainRegistry.weaponTab).setTextureName(RefStrings.MODID + ":gun_revolver_iron_ammo");
gun_revolver_iron = new GunRevolver(gun_revolver_iron_ammo, 5, 15, false, false).setMaxDamage(100).setUnlocalizedName("gun_revolver_iron").setCreativeTab(MainRegistry.weaponTab).setTextureName(RefStrings.MODID + ":gun_revolver_iron");
gun_revolver_iron = new ItemGunBase(Gun357MagnumFactory.getRevolverIronConfig()).setMaxDamage(100).setUnlocalizedName("gun_revolver_iron").setCreativeTab(MainRegistry.weaponTab).setTextureName(RefStrings.MODID + ":gun_revolver_iron");
gun_revolver_gold_ammo = new Item().setUnlocalizedName("gun_revolver_gold_ammo").setCreativeTab(MainRegistry.weaponTab).setTextureName(RefStrings.MODID + ":gun_revolver_gold_ammo");
gun_revolver_gold = new GunRevolver(gun_revolver_gold_ammo, 20, 30, false, false).setMaxDamage(1000).setUnlocalizedName("gun_revolver_gold").setCreativeTab(MainRegistry.weaponTab).setTextureName(RefStrings.MODID + ":gun_revolver_gold");
gun_revolver_gold = new ItemGunBase(Gun357MagnumFactory.getRevolverGoldConfig()).setMaxDamage(1000).setUnlocalizedName("gun_revolver_gold").setCreativeTab(MainRegistry.weaponTab).setTextureName(RefStrings.MODID + ":gun_revolver_gold");
gun_revolver_lead_ammo = new Item().setUnlocalizedName("gun_revolver_lead_ammo").setCreativeTab(MainRegistry.weaponTab).setTextureName(RefStrings.MODID + ":gun_revolver_lead_ammo");
gun_revolver_lead = new GunRevolver(gun_revolver_lead_ammo, 5, 15, false, true).setMaxDamage(250).setUnlocalizedName("gun_revolver_lead").setCreativeTab(MainRegistry.weaponTab).setTextureName(RefStrings.MODID + ":gun_revolver_lead");
gun_revolver_lead = new ItemGunBase(Gun357MagnumFactory.getRevolverLeadConfig()).setMaxDamage(250).setUnlocalizedName("gun_revolver_lead").setCreativeTab(MainRegistry.weaponTab).setTextureName(RefStrings.MODID + ":gun_revolver_lead");
gun_revolver_schrabidium_ammo = new ItemRadioactive().setUnlocalizedName("gun_revolver_schrabidium_ammo").setCreativeTab(MainRegistry.weaponTab).setTextureName(RefStrings.MODID + ":gun_revolver_schrabidium_ammo");
gun_revolver_schrabidium = new GunRevolver(gun_revolver_schrabidium_ammo, 10000, 100000, true, false).setMaxDamage(100000).setUnlocalizedName("gun_revolver_schrabidium").setCreativeTab(MainRegistry.weaponTab).setTextureName(RefStrings.MODID + ":gun_revolver_schrabidium");
gun_revolver_schrabidium = new ItemGunBase(Gun357MagnumFactory.getRevolverSchrabidiumConfig()).setMaxDamage(100000).setUnlocalizedName("gun_revolver_schrabidium").setCreativeTab(MainRegistry.weaponTab).setTextureName(RefStrings.MODID + ":gun_revolver_schrabidium");
gun_revolver_cursed_ammo = new ItemCustomLore().setUnlocalizedName("gun_revolver_cursed_ammo").setCreativeTab(MainRegistry.weaponTab).setTextureName(RefStrings.MODID + ":gun_revolver_cursed_ammo");
gun_revolver_cursed = new GunRevolver(gun_revolver_cursed_ammo, 25, 40, false, false).setMaxDamage(5000).setUnlocalizedName("gun_revolver_cursed").setCreativeTab(MainRegistry.weaponTab).setTextureName(RefStrings.MODID + ":gun_revolver_cursed");
gun_revolver_cursed = new ItemGunBase(Gun357MagnumFactory.getRevolverCursedConfig()).setMaxDamage(5000).setUnlocalizedName("gun_revolver_cursed").setCreativeTab(MainRegistry.weaponTab).setTextureName(RefStrings.MODID + ":gun_revolver_cursed");
gun_revolver_nightmare_ammo = new ItemCustomLore().setUnlocalizedName("gun_revolver_nightmare_ammo").setCreativeTab(MainRegistry.weaponTab).setTextureName(RefStrings.MODID + ":gun_revolver_nightmare_ammo");
gun_revolver_nightmare = new GunNightmare().setMaxDamage(6).setUnlocalizedName("gun_revolver_nightmare").setCreativeTab(MainRegistry.weaponTab).setTextureName(RefStrings.MODID + ":gun_revolver_nightmare");
gun_revolver_nightmare = new ItemGunBase(Gun357MagnumFactory.getRevolverNightmareConfig()).setMaxDamage(6).setUnlocalizedName("gun_revolver_nightmare").setCreativeTab(MainRegistry.weaponTab).setTextureName(RefStrings.MODID + ":gun_revolver_nightmare");
gun_revolver_nightmare2_ammo = new ItemCustomLore().setUnlocalizedName("gun_revolver_nightmare2_ammo").setCreativeTab(MainRegistry.weaponTab).setTextureName(RefStrings.MODID + ":gun_revolver_nightmare2_ammo");
gun_revolver_nightmare2 = new GunNightmare().setMaxDamage(6).setUnlocalizedName("gun_revolver_nightmare2").setCreativeTab(MainRegistry.weaponTab).setTextureName(RefStrings.MODID + ":gun_revolver_nightmare2");
gun_revolver_nightmare2 = new ItemGunBase(Gun357MagnumFactory.getRevolverNightmare2Config()).setMaxDamage(6).setUnlocalizedName("gun_revolver_nightmare2").setCreativeTab(MainRegistry.weaponTab).setTextureName(RefStrings.MODID + ":gun_revolver_nightmare2");
gun_revolver_pip_ammo = new ItemCustomLore().setUnlocalizedName("gun_revolver_pip_ammo").setCreativeTab(null).setTextureName(RefStrings.MODID + ":gun_revolver_pip_ammo");
gun_revolver_pip = new GunRevolver(ammo_44_pip, 25, 35, false, false).setMaxDamage(1000).setUnlocalizedName("gun_revolver_pip").setCreativeTab(MainRegistry.weaponTab).setTextureName(RefStrings.MODID + ":gun_revolver_pip");
gun_revolver_nopip_ammo = new Item().setUnlocalizedName("gun_revolver_nopip_ammo").setCreativeTab(null).setTextureName(RefStrings.MODID + ":gun_revolver_nopip_ammo");

View File

@ -11,6 +11,7 @@ import com.hbm.handler.BulletConfiguration;
import com.hbm.handler.GunConfiguration;
import com.hbm.interfaces.IHoldableWeapon;
import com.hbm.items.ModItems;
import com.hbm.main.MainRegistry;
import com.hbm.packet.GunButtonPacket;
import com.hbm.packet.PacketDispatcher;
import com.hbm.render.misc.RenderScreenOverlay.Crosshair;
@ -292,6 +293,12 @@ public class ItemGunBase extends Item implements IHoldableWeapon {
dura = 0;
list.add("Durability: " + dura + " / " + mainConfig.durability);
if(MainRegistry.enableDebugMode) {
list.add("");
list.add("Name: " + mainConfig.name);
list.add("Manufacturer: " + mainConfig.manufacturer);
}
}
/*//returns main config from itemstack

View File

@ -2,6 +2,9 @@ package com.hbm.main;
import com.hbm.entity.mob.EntityHunterChopper;
import com.hbm.entity.projectile.EntityChopperMine;
import com.hbm.handler.BulletConfigSyncingUtil;
import com.hbm.handler.BulletConfiguration;
import com.hbm.handler.GunConfiguration;
import com.hbm.interfaces.IHoldableWeapon;
import com.hbm.items.ModItems;
import com.hbm.items.tool.ItemGeigerCounter;
@ -25,6 +28,7 @@ import net.minecraft.client.Minecraft;
import net.minecraft.client.multiplayer.WorldClient;
import net.minecraft.client.renderer.entity.RenderPlayer;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.item.Item;
import net.minecraft.util.ChunkCoordinates;
import net.minecraft.util.ResourceLocation;
import net.minecraft.world.chunk.Chunk;
@ -41,6 +45,21 @@ public class ModEventHandlerClient {
EntityPlayer player = Minecraft.getMinecraft().thePlayer;
if(event.type == ElementType.HOTBAR && player.getHeldItem() != null && player.getHeldItem().getItem() instanceof ItemGunBase) {
ItemGunBase gun = ((ItemGunBase)player.getHeldItem().getItem());
GunConfiguration gcfg = gun.mainConfig;
BulletConfiguration bcfg = BulletConfigSyncingUtil.pullConfig(gun.mainConfig.config.get(ItemGunBase.getMagType(player.getHeldItem())));
Item ammo = bcfg.ammo;
int count = ItemGunBase.getMag(player.getHeldItem());
int max = gcfg.ammoCap;
RenderScreenOverlay.renderAmmo(event.resolution, Minecraft.getMinecraft().ingameGUI, ammo, count, max);
//RenderScreenOverlay.renderRadCounter(event.resolution, 0, Minecraft.getMinecraft().ingameGUI);
}
if(event.type == ElementType.HOTBAR) {
if(player.inventory.hasItem(ModItems.geiger_counter)) {
@ -53,10 +72,13 @@ public class ModEventHandlerClient {
RenderScreenOverlay.renderRadCounter(event.resolution, rads, Minecraft.getMinecraft().ingameGUI);
}
} else if(event.type == ElementType.CROSSHAIRS && player.getHeldItem() != null && player.getHeldItem().getItem() instanceof IHoldableWeapon) {
}
if(event.type == ElementType.CROSSHAIRS && player.getHeldItem() != null && player.getHeldItem().getItem() instanceof IHoldableWeapon) {
event.setCanceled(true);
RenderScreenOverlay.renderCustomCrosshairs(event.resolution, Minecraft.getMinecraft().ingameGUI, ((IHoldableWeapon)player.getHeldItem().getItem()).getCrosshair());
}
}

View File

@ -49,7 +49,7 @@ public class RenderBullet extends Render {
switch(style) {
case BulletConfiguration.STYLE_NORMAL: renderBullet(trail); break;
case BulletConfiguration.STYLE_BOLT: renderDart(0.25F, 0.0F, 0.75F); break;
case BulletConfiguration.STYLE_BOLT: renderDart(trail); break;
case BulletConfiguration.STYLE_FLECHETTE: renderFlechette(); break;
case BulletConfiguration.STYLE_FOLLY: renderBullet(trail); break;
case BulletConfiguration.STYLE_PELLET: renderBuckshot(); break;
@ -203,7 +203,17 @@ public class RenderBullet extends Render {
GL11.glPopMatrix();
}
private void renderDart(float red, float green, float blue) {
private void renderDart(int style) {
float red = 1F;
float green = 1F;
float blue = 1F;
switch(style) {
case BulletConfiguration.BOLT_LASER: red = 1F; green = 0F; blue = 0F; break;
case BulletConfiguration.BOLT_NIGHTMARE: red = 1F; green = 1F; blue = 0F; break;
case BulletConfiguration.BOLT_LACUNAE: red = 0.25F; green = 0F; blue = 0.75F; break;
}
GL11.glPushMatrix();
GL11.glDisable(GL11.GL_TEXTURE_2D);

View File

@ -3,6 +3,7 @@ package com.hbm.render.misc;
import static net.minecraftforge.client.event.RenderGameOverlayEvent.ElementType.CROSSHAIRS;
import org.lwjgl.opengl.GL11;
import org.lwjgl.opengl.GL12;
import com.hbm.lib.RefStrings;
@ -10,12 +11,18 @@ import net.minecraft.client.Minecraft;
import net.minecraft.client.gui.Gui;
import net.minecraft.client.gui.ScaledResolution;
import net.minecraft.client.renderer.OpenGlHelper;
import net.minecraft.client.renderer.RenderHelper;
import net.minecraft.client.renderer.entity.RenderItem;
import net.minecraft.item.Item;
import net.minecraft.item.ItemStack;
import net.minecraft.util.ResourceLocation;
import net.minecraftforge.client.GuiIngameForge;
public class RenderScreenOverlay {
private static final ResourceLocation misc = new ResourceLocation(RefStrings.MODID + ":textures/misc/overlay_misc.png");
private static final ResourceLocation hud = new ResourceLocation("textures/gui/widgets.png");
private static final RenderItem itemRenderer = RenderItem.getInstance();
private static long lastSurvey;
private static float prevResult;
@ -102,6 +109,28 @@ public class RenderScreenOverlay {
Minecraft.getMinecraft().renderEngine.bindTexture(hud);
}
public static void renderAmmo(ScaledResolution resolution, Gui gui, Item ammo, int count, int max) {
GL11.glPushMatrix();
Minecraft mc = Minecraft.getMinecraft();
int pX = resolution.getScaledWidth() / 2 + 62 + 36;
int pZ = resolution.getScaledHeight() - 19;
Minecraft.getMinecraft().fontRenderer.drawString("x" + count, pX + 14, pZ + 6, 0xFFFFFF);
GL11.glDisable(GL11.GL_BLEND);
GL11.glEnable(GL12.GL_RESCALE_NORMAL);
RenderHelper.enableGUIStandardItemLighting();
itemRenderer.renderItemAndEffectIntoGUI(mc.fontRenderer, mc.getTextureManager(), new ItemStack(ammo), pX, pZ);
RenderHelper.disableStandardItemLighting();
GL11.glDisable(GL12.GL_RESCALE_NORMAL);
GL11.glPopMatrix();
Minecraft.getMinecraft().renderEngine.bindTexture(hud);
}
public enum Crosshair {
CROSS(1, 55, 16),