mirror of
https://github.com/HbmMods/Hbm-s-Nuclear-Tech-GIT.git
synced 2026-01-25 10:32:49 +00:00
Merge pull request #1340 from MellowArpeggiation/master
Old-school Super Shotgun animations
This commit is contained in:
commit
1811a41fd5
Binary file not shown.
@ -1820,10 +1820,10 @@ public class ModBlocks {
|
||||
charge_miner = new BlockChargeMiner().setBlockName("charge_miner").setCreativeTab(MainRegistry.nukeTab).setResistance(1.0F);
|
||||
charge_c4 = new BlockChargeC4().setBlockName("charge_c4").setCreativeTab(MainRegistry.nukeTab).setResistance(1.0F);
|
||||
charge_semtex = new BlockChargeSemtex().setBlockName("charge_semtex").setCreativeTab(MainRegistry.nukeTab).setResistance(1.0F);
|
||||
mine_ap = new Landmine(Material.iron).setBlockName("mine_ap").setCreativeTab(MainRegistry.nukeTab).setHardness(1.0F).setBlockTextureName(RefStrings.MODID + ":mine_ap");
|
||||
mine_he = new Landmine(Material.iron).setBlockName("mine_he").setCreativeTab(MainRegistry.nukeTab).setHardness(1.0F).setBlockTextureName(RefStrings.MODID + ":mine_he");
|
||||
mine_shrap = new Landmine(Material.iron).setBlockName("mine_shrap").setCreativeTab(MainRegistry.nukeTab).setHardness(1.0F).setBlockTextureName(RefStrings.MODID + ":mine_shrap");
|
||||
mine_fat = new Landmine(Material.iron).setBlockName("mine_fat").setCreativeTab(MainRegistry.nukeTab).setHardness(1.0F).setBlockTextureName(RefStrings.MODID + ":mine_fat");
|
||||
mine_ap = new Landmine(Material.iron, 1.5D, 1D).setBlockName("mine_ap").setCreativeTab(MainRegistry.nukeTab).setHardness(1.0F).setBlockTextureName(RefStrings.MODID + ":mine_ap");
|
||||
mine_he = new Landmine(Material.iron, 2D, 5D).setBlockName("mine_he").setCreativeTab(MainRegistry.nukeTab).setHardness(1.0F).setBlockTextureName(RefStrings.MODID + ":mine_he");
|
||||
mine_shrap = new Landmine(Material.iron, 1.5D, 1D).setBlockName("mine_shrap").setCreativeTab(MainRegistry.nukeTab).setHardness(1.0F).setBlockTextureName(RefStrings.MODID + ":mine_shrap");
|
||||
mine_fat = new Landmine(Material.iron, 2.5D, 1D).setBlockName("mine_fat").setCreativeTab(MainRegistry.nukeTab).setHardness(1.0F).setBlockTextureName(RefStrings.MODID + ":mine_fat");
|
||||
dynamite = new BlockDynamite().setBlockName("dynamite").setStepSound(Block.soundTypeGrass).setCreativeTab(MainRegistry.nukeTab).setHardness(0.0F).setBlockTextureName(RefStrings.MODID + ":dynamite");
|
||||
tnt = new BlockTNT().setBlockName("tnt_ntm").setStepSound(Block.soundTypeGrass).setCreativeTab(MainRegistry.nukeTab).setHardness(0.0F).setBlockTextureName(RefStrings.MODID + ":tnt");
|
||||
semtex = new BlockSemtex().setBlockName("semtex").setStepSound(Block.soundTypeGrass).setCreativeTab(MainRegistry.nukeTab).setHardness(0.0F).setBlockTextureName(RefStrings.MODID + ":semtex");
|
||||
|
||||
@ -26,8 +26,14 @@ public class Landmine extends BlockContainer implements IBomb {
|
||||
|
||||
public static boolean safeMode = false;
|
||||
|
||||
public Landmine(Material p_i45386_1_) {
|
||||
super(p_i45386_1_);
|
||||
public double range;
|
||||
public double height;
|
||||
|
||||
public Landmine(Material mat, double range, double height) {
|
||||
super(mat);
|
||||
|
||||
this.range = range;
|
||||
this.height = height;
|
||||
}
|
||||
|
||||
@Override
|
||||
@ -56,7 +62,7 @@ public class Landmine extends BlockContainer implements IBomb {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setBlockBoundsBasedOnState(IBlockAccess p_149719_1_, int p_149719_2_, int p_149719_3_, int p_149719_4_) {
|
||||
public void setBlockBoundsBasedOnState(IBlockAccess world, int x, int y, int z) {
|
||||
float f = 0.0625F;
|
||||
if(this == ModBlocks.mine_ap)
|
||||
this.setBlockBounds(6 * f, 0.0F, 6 * f, 10 * f, 2 * f, 10 * f);
|
||||
@ -70,15 +76,7 @@ public class Landmine extends BlockContainer implements IBomb {
|
||||
|
||||
@Override
|
||||
public AxisAlignedBB getCollisionBoundingBoxFromPool(World world, int x, int y, int z) {
|
||||
float f = 0.0625F;
|
||||
if(this == ModBlocks.mine_ap)
|
||||
this.setBlockBounds(6 * f, 0.0F, 6 * f, 10 * f, 2 * f, 10 * f);
|
||||
if(this == ModBlocks.mine_he)
|
||||
this.setBlockBounds(4 * f, 0.0F, 4 * f, 12 * f, 2 * f, 12 * f);
|
||||
if(this == ModBlocks.mine_shrap)
|
||||
this.setBlockBounds(4 * f, 0.0F, 4 * f, 12 * f, 2 * f, 12 * f);
|
||||
if(this == ModBlocks.mine_fat)
|
||||
this.setBlockBounds(5 * f, 0.0F, 4 * f, 11 * f, 6 * f, 12 * f);
|
||||
setBlockBoundsBasedOnState(world, x, y, z);
|
||||
return AxisAlignedBB.getBoundingBox(x + this.minX, y + this.minY, z + this.minZ, x + this.maxX, y + this.maxY, z + this.maxZ);
|
||||
}
|
||||
|
||||
@ -92,14 +90,7 @@ public class Landmine extends BlockContainer implements IBomb {
|
||||
explode(world, x, y, z);
|
||||
}
|
||||
|
||||
boolean flag = false;
|
||||
|
||||
if(!World.doesBlockHaveSolidTopSurface(world, x, y - 1, z) && !BlockFence.func_149825_a(world.getBlock(x, y - 1, z))) {
|
||||
flag = true;
|
||||
}
|
||||
|
||||
if(flag) {
|
||||
|
||||
if(!safeMode) {
|
||||
explode(world, x, y, z);
|
||||
} else {
|
||||
@ -157,18 +148,14 @@ public class Landmine extends BlockContainer implements IBomb {
|
||||
|
||||
if(this == ModBlocks.mine_ap) {
|
||||
world.newExplosion(null, x + 0.5, y + 0.5, z + 0.5, 2.5F, false, false);
|
||||
}
|
||||
if(this == ModBlocks.mine_he) {
|
||||
} else if(this == ModBlocks.mine_he) {
|
||||
ExplosionLarge.explode(world, x + 0.5, y + 0.5, z + 0.5, 3F, true, false, false);
|
||||
world.newExplosion(null, x + 0.5, y + 2, z + 0.5, 15F, false, false);
|
||||
}
|
||||
if(this == ModBlocks.mine_shrap) {
|
||||
} else if(this == ModBlocks.mine_shrap) {
|
||||
ExplosionLarge.explode(world, x + 0.5, y + 0.5, z + 0.5, 1, true, false, false);
|
||||
ExplosionLarge.spawnShrapnelShower(world, x + 0.5, y + 0.5, z + 0.5, 0, 1D, 0, 45, 0.2D);
|
||||
ExplosionLarge.spawnShrapnels(world, x + 0.5, y + 0.5, z + 0.5, 5);
|
||||
}
|
||||
if(this == ModBlocks.mine_fat) {
|
||||
|
||||
} else if(this == ModBlocks.mine_fat) {
|
||||
ExplosionNukeSmall.explode(world, x + 0.5, y + 0.5, z + 0.5, ExplosionNukeSmall.PARAMS_MEDIUM);
|
||||
}
|
||||
}
|
||||
|
||||
@ -115,7 +115,7 @@ public class EntityBulletBaseNT extends EntityThrowableInterp implements IBullet
|
||||
if(gun != null && gun.getItem() instanceof ItemGunBase) {
|
||||
GunConfiguration cfg = ((ItemGunBase) gun.getItem()).mainConfig;
|
||||
|
||||
if(cfg != null && cfg.hasSights && entity.isSneaking()) {
|
||||
if(cfg != null && (cfg.hasSights && entity.isSneaking()) || cfg.isCentered) {
|
||||
offsetShot = false;
|
||||
}
|
||||
}
|
||||
|
||||
@ -42,6 +42,8 @@ public class GunConfiguration implements Cloneable {
|
||||
public boolean animationsLoaded = false;
|
||||
//when sneaking, disables crosshair and centers the bullet spawn point
|
||||
public boolean hasSights;
|
||||
//does this weapon behave like fully sick old-school boomer shooters
|
||||
public boolean isCentered;
|
||||
//texture overlay when sneaking
|
||||
public ResourceLocation scopeTexture;
|
||||
//whether the FOV multiplier should be absolute or multiplicative to other modifiers, multiplicative mode is experimental!
|
||||
|
||||
@ -180,7 +180,7 @@ public class Gun12GaugeFactory {
|
||||
|
||||
GunConfiguration config = new GunConfiguration();
|
||||
|
||||
config.rateOfFire = 20;
|
||||
config.rateOfFire = 30;
|
||||
config.roundsPerCycle = 2;
|
||||
config.gunMode = GunConfiguration.MODE_NORMAL;
|
||||
config.firingMode = GunConfiguration.FIRE_MANUAL;
|
||||
@ -190,33 +190,14 @@ public class Gun12GaugeFactory {
|
||||
config.durability = 3000;
|
||||
config.reloadType = GunConfiguration.RELOAD_NONE;
|
||||
config.allowsInfinity = true;
|
||||
config.hasSights = true;
|
||||
config.isCentered = true;
|
||||
config.crosshair = Crosshair.L_CIRCLE;
|
||||
config.reloadSound = GunConfiguration.RSOUND_REVOLVER;
|
||||
config.firingSound = "hbm:weapon.shottyShoot";
|
||||
|
||||
config.animations.put(AnimType.CYCLE, new BusAnimation()
|
||||
.addBus("SHOTTY_RECOIL", new BusAnimationSequence()
|
||||
.addKeyframePosition(0.5, 0, 0, 50)
|
||||
.addKeyframePosition(0, 0, 0, 50)
|
||||
)
|
||||
.addBus("SHOTTY_BREAK", new BusAnimationSequence()
|
||||
.addKeyframePosition(0, 0, 0, 100) //do nothing for 100ms
|
||||
.addKeyframePosition(0, 0, 60, 200) //open
|
||||
.addKeyframePosition(0, 0, 60, 500) //do nothing for 500ms
|
||||
.addKeyframePosition(0, 0, 0, 200) //close
|
||||
)
|
||||
.addBus("SHOTTY_EJECT", new BusAnimationSequence()
|
||||
.addKeyframePosition(0, 0, 0, 300) //do nothing for 300ms
|
||||
.addKeyframePosition(1, 0, 0, 700) //fling!
|
||||
)
|
||||
.addBus("SHOTTY_INSERT", new BusAnimationSequence()
|
||||
.addKeyframePosition(0, 0, 0, 300) //do nothing for 300ms
|
||||
.addKeyframePosition(1, 0, 1, 0) //reposition
|
||||
.addKeyframePosition(1, 0, 0, 350) //come in from the side
|
||||
.addKeyframePosition(0, 0, 0, 150) //push
|
||||
)
|
||||
);
|
||||
|
||||
config.loadAnimations = i -> {
|
||||
config.animations.put(AnimType.CYCLE, ResourceManager.supershotty_anim.get("Fire"));
|
||||
};
|
||||
|
||||
config.name = "supershotty";
|
||||
config.manufacturer = EnumGunManufacturer.UAC;
|
||||
|
||||
@ -13,6 +13,7 @@ import com.hbm.handler.MultiblockHandlerXR;
|
||||
import com.hbm.items.ModItems;
|
||||
import com.hbm.main.MainRegistry;
|
||||
import com.hbm.saveddata.TomSaveData;
|
||||
import com.hbm.tileentity.bomb.TileEntityLandmine;
|
||||
import com.hbm.tileentity.deco.TileEntityLanternBehemoth;
|
||||
import com.hbm.tileentity.machine.storage.TileEntitySafe;
|
||||
import com.hbm.tileentity.machine.storage.TileEntitySoyuzCapsule;
|
||||
@ -152,6 +153,7 @@ public class HbmWorldGen implements IWorldGenerator {
|
||||
DungeonToolbox.generateOre(world, rand, i, j, WorldConfig.limestoneSpawn, 12, 25, 30, ModBlocks.stone_resource, EnumStoneType.LIMESTONE.ordinal());
|
||||
|
||||
if(rand.nextInt(3) == 0) {
|
||||
@SuppressWarnings("unchecked")
|
||||
WeightedRandomGeneric<BedrockOreDefinition> item = (WeightedRandomGeneric<BedrockOreDefinition>) WeightedRandom.getRandomItem(rand, BedrockOre.weightedOres);
|
||||
BedrockOreDefinition def = item.get();
|
||||
|
||||
@ -394,6 +396,8 @@ public class HbmWorldGen implements IWorldGenerator {
|
||||
|
||||
if(world.getBlock(x, y - 1, z).canPlaceTorchOnTop(world, x, y - 1, z)) {
|
||||
world.setBlock(x, y, z, ModBlocks.mine_ap);
|
||||
TileEntityLandmine landmine = (TileEntityLandmine) world.getTileEntity(x, y, z);
|
||||
landmine.waitingForPlayer = true;
|
||||
|
||||
if(GeneralConfig.enableDebugMode)
|
||||
MainRegistry.logger.info("[Debug] Successfully spawned landmine at " + x + " " + (y) + " " + z);
|
||||
@ -429,6 +433,8 @@ public class HbmWorldGen implements IWorldGenerator {
|
||||
int y = world.getHeightValue(x, z);
|
||||
if(world.getBlock(x, y - 1, z).canPlaceTorchOnTop(world, x, y - 1, z)) {
|
||||
world.setBlock(x, y, z, ModBlocks.mine_he);
|
||||
TileEntityLandmine landmine = (TileEntityLandmine) world.getTileEntity(x, y, z);
|
||||
landmine.waitingForPlayer = true;
|
||||
}
|
||||
}
|
||||
|
||||
@ -768,6 +774,7 @@ public class HbmWorldGen implements IWorldGenerator {
|
||||
DungeonToolbox.generateOre(world, rand, i, j, WorldConfig.netherPlutoniumSpawn, 4, 0, 127, ModBlocks.ore_nether_plutonium, Blocks.netherrack);
|
||||
|
||||
if(rand.nextInt(10) == 0) {
|
||||
@SuppressWarnings("unchecked")
|
||||
WeightedRandomGeneric<BedrockOreDefinition> item = (WeightedRandomGeneric<BedrockOreDefinition>) WeightedRandom.getRandomItem(rand, BedrockOre.weightedOresNether);
|
||||
BedrockOreDefinition def = item.get();
|
||||
int randPosX = i + rand.nextInt(2) + 8;
|
||||
|
||||
@ -851,6 +851,7 @@ public class ResourceManager {
|
||||
public static final HashMap<String, BusAnimation> novac_anim = AnimationLoader.load(new ResourceLocation(RefStrings.MODID, "models/weapons/animations/novac.json"));
|
||||
public static final HashMap<String, BusAnimation> ks23_anim = AnimationLoader.load(new ResourceLocation(RefStrings.MODID, "models/weapons/animations/ks23.json"));
|
||||
public static final HashMap<String, BusAnimation> spas_12_anim = AnimationLoader.load(new ResourceLocation(RefStrings.MODID, "models/weapons/animations/spas12.json"));
|
||||
public static final HashMap<String, BusAnimation> supershotty_anim = AnimationLoader.load(new ResourceLocation(RefStrings.MODID, "models/weapons/animations/supershotty.json"));
|
||||
|
||||
public static final IModelCustom lance = new HFRWavefrontObject(new ResourceLocation(RefStrings.MODID, "models/weapons/lance.obj"));
|
||||
|
||||
|
||||
@ -14,6 +14,7 @@ import com.google.gson.JsonArray;
|
||||
import net.minecraft.client.Minecraft;
|
||||
import net.minecraft.util.ResourceLocation;
|
||||
|
||||
import com.hbm.render.anim.BusAnimationKeyframe.InterpolationType;
|
||||
import com.hbm.render.anim.BusAnimationSequence.Dimension;
|
||||
|
||||
public class AnimationLoader {
|
||||
@ -142,8 +143,9 @@ public class AnimationLoader {
|
||||
|
||||
double value = array.get(0).getAsDouble();
|
||||
int duration = array.get(1).getAsInt();
|
||||
InterpolationType interpolation = array.size() >= 3 ? InterpolationType.valueOf(array.get(2).getAsString()) : InterpolationType.LINEAR;
|
||||
|
||||
return new BusAnimationKeyframe(value, duration);
|
||||
return new BusAnimationKeyframe(value, duration, interpolation);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@ -7,7 +7,7 @@ public class BusAnimationKeyframe {
|
||||
//it's an enum so stuff like accelerated animations between just
|
||||
//two frames could be implemented
|
||||
public static enum InterpolationType {
|
||||
NONE,
|
||||
CONSTANT,
|
||||
LINEAR
|
||||
}
|
||||
|
||||
|
||||
@ -91,11 +91,16 @@ public class BusAnimationSequence {
|
||||
continue;
|
||||
}
|
||||
|
||||
if (currentFrame.interpolationType == InterpolationType.NONE || millis >= endTime) {
|
||||
if (millis >= endTime) {
|
||||
transform[i] = currentFrame.value;
|
||||
continue;
|
||||
}
|
||||
|
||||
if (previousFrame != null && previousFrame.interpolationType == InterpolationType.CONSTANT) {
|
||||
transform[i] = previousFrame.value;
|
||||
continue;
|
||||
}
|
||||
|
||||
double a = currentFrame.value;
|
||||
double b = previousFrame != null ? previousFrame.value : 0;
|
||||
double t = (double)(millis - startTime) / (double)currentFrame.duration;
|
||||
|
||||
@ -5,6 +5,7 @@ import org.lwjgl.opengl.GL11;
|
||||
import com.hbm.items.weapon.ItemGunBase;
|
||||
import com.hbm.main.ResourceManager;
|
||||
import com.hbm.render.anim.HbmAnimations;
|
||||
import com.hbm.render.anim.HbmAnimations.Animation;
|
||||
|
||||
import net.minecraft.client.Minecraft;
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
@ -41,10 +42,6 @@ public class ItemRenderWeaponShotty implements IItemRenderer {
|
||||
GL11.glDisable(GL11.GL_CULL_FACE);
|
||||
GL11.glShadeModel(GL11.GL_SMOOTH);
|
||||
|
||||
String barrel = "Body_Cube.008";
|
||||
String handle = "handle_Cylinder.005";
|
||||
String shells = "boolets_Cylinder.008";
|
||||
|
||||
Minecraft.getMinecraft().renderEngine.bindTexture(ResourceManager.shotty_tex);
|
||||
|
||||
EntityPlayer player = Minecraft.getMinecraft().thePlayer;
|
||||
@ -52,70 +49,55 @@ public class ItemRenderWeaponShotty implements IItemRenderer {
|
||||
switch(type) {
|
||||
|
||||
case EQUIPPED_FIRST_PERSON:
|
||||
|
||||
double[] recoil = HbmAnimations.getRelevantTransformation("SHOTTY_RECOIL");
|
||||
double[] eject = HbmAnimations.getRelevantTransformation("SHOTTY_BREAK");
|
||||
double[] ejectShell = HbmAnimations.getRelevantTransformation("SHOTTY_EJECT");
|
||||
double[] insertShell = HbmAnimations.getRelevantTransformation("SHOTTY_INSERT");
|
||||
|
||||
GL11.glScalef(0.5F, 0.5F, 0.5F);
|
||||
GL11.glRotatef(20F, 0.0F, 0.0F, 1.0F);
|
||||
GL11.glRotatef(-10F, 0.0F, 1.0F, 0.0F);
|
||||
GL11.glTranslatef(1.75F, -0.2F, -0.3F);
|
||||
|
||||
if(player.isSneaking()) {
|
||||
GL11.glTranslatef(0F, 1.0F, -2.05F);
|
||||
GL11.glRotatef(3.5F, 0.0F, 1.0F, 0.0F);
|
||||
} else {
|
||||
|
||||
GL11.glRotated(-eject[2] * 0.25, 0, 0, 1);
|
||||
}
|
||||
GL11.glRotatef(-95F, 0.0F, 1.0F, 0.0F);
|
||||
GL11.glTranslatef(-2.0F, 0.5F, -2.0F);
|
||||
|
||||
GL11.glTranslated(-recoil[0] * 2, 0, 0);
|
||||
GL11.glRotated(recoil[0] * 5, 0, 0, 1);
|
||||
|
||||
GL11.glPushMatrix();
|
||||
GL11.glRotated(-eject[2] * 0.8, 0, 0, 1);
|
||||
ResourceManager.shotty.renderPart(barrel);
|
||||
HbmAnimations.applyRelevantTransformation("Body");
|
||||
ResourceManager.shotty.renderPart("Body");
|
||||
|
||||
GL11.glPushMatrix();
|
||||
GL11.glRotated(ejectShell[0] * 90, 0, 0, 1);
|
||||
GL11.glTranslated(-ejectShell[0] * 10, 0, 0);
|
||||
ResourceManager.shotty.renderPart(shells);
|
||||
GL11.glPopMatrix();
|
||||
|
||||
if(ItemGunBase.getBeltSize(player, ItemGunBase.getBeltType(player, item, true)) > 0) {
|
||||
HbmAnimations.applyRelevantTransformation("Barrel");
|
||||
ResourceManager.shotty.renderPart("Barrel");
|
||||
|
||||
// If we've run out of ammo, stop drawing the shells after ejection has completed
|
||||
Animation anim = HbmAnimations.getRelevantAnim();
|
||||
int millis = anim != null ? (int)(System.currentTimeMillis() - anim.startMillis) : 0;
|
||||
|
||||
if(ItemGunBase.getBeltSize(player, ItemGunBase.getBeltType(player, item, true)) > 0 || millis < 1000) {
|
||||
GL11.glPushMatrix();
|
||||
GL11.glTranslated(-insertShell[0], insertShell[2] * -2, insertShell[2] * -1);
|
||||
ResourceManager.shotty.renderPart(shells);
|
||||
HbmAnimations.applyRelevantTransformation("ShellL");
|
||||
ResourceManager.shotty.renderPart("ShellL");
|
||||
GL11.glPopMatrix();
|
||||
|
||||
GL11.glPushMatrix();
|
||||
HbmAnimations.applyRelevantTransformation("ShellR");
|
||||
ResourceManager.shotty.renderPart("ShellR");
|
||||
GL11.glPopMatrix();
|
||||
}
|
||||
|
||||
GL11.glPopMatrix();
|
||||
|
||||
ResourceManager.shotty.renderPart(handle);
|
||||
|
||||
break;
|
||||
|
||||
case EQUIPPED:
|
||||
|
||||
GL11.glRotatef(-80F, 0.0F, 1.0F, 0.0F);
|
||||
GL11.glRotatef(-170F, 0.0F, 1.0F, 0.0F);
|
||||
GL11.glRotatef(-10F, 0.0F, 0.0F, 1.0F);
|
||||
GL11.glRotatef(10F, 1.0F, 0.0F, 0.0F);
|
||||
GL11.glRotatef(-10F, 1.0F, 0.0F, 0.0F);
|
||||
GL11.glRotatef(5F, 0.0F, 1.0F, 0.0F);
|
||||
GL11.glTranslatef(0.5F, 0.0F, -0.4F);
|
||||
GL11.glTranslatef(-0.4F, 0.0F, -0.5F);
|
||||
GL11.glScaled(0.35, 0.35, 0.35);
|
||||
ResourceManager.shotty.renderPart(handle);
|
||||
ResourceManager.shotty.renderPart(barrel);
|
||||
ResourceManager.shotty.renderPart("Body");
|
||||
ResourceManager.shotty.renderPart("Barrel");
|
||||
|
||||
break;
|
||||
|
||||
case ENTITY:
|
||||
|
||||
GL11.glScaled(0.5, 0.5, 0.5);
|
||||
GL11.glTranslatef(-1.0F, 0.2F, 0.0F);
|
||||
ResourceManager.shotty.renderPart(handle);
|
||||
ResourceManager.shotty.renderPart(barrel);
|
||||
GL11.glTranslatef(0.0F, 0.2F, 0.0F);
|
||||
ResourceManager.shotty.renderPart("Body");
|
||||
ResourceManager.shotty.renderPart("Barrel");
|
||||
break;
|
||||
|
||||
default: break;
|
||||
|
||||
@ -2,13 +2,14 @@ package com.hbm.tileentity.bomb;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import com.hbm.blocks.ModBlocks;
|
||||
import com.hbm.blocks.bomb.Landmine;
|
||||
import com.hbm.main.MainRegistry;
|
||||
|
||||
import cpw.mods.fml.relauncher.Side;
|
||||
import cpw.mods.fml.relauncher.SideOnly;
|
||||
import net.minecraft.block.Block;
|
||||
import net.minecraft.entity.EntityLivingBase;
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.nbt.NBTTagCompound;
|
||||
import net.minecraft.tileentity.TileEntity;
|
||||
import net.minecraft.util.AxisAlignedBB;
|
||||
@ -16,55 +17,59 @@ import net.minecraft.util.AxisAlignedBB;
|
||||
public class TileEntityLandmine extends TileEntity {
|
||||
|
||||
private boolean isPrimed = false;
|
||||
public boolean waitingForPlayer = false;
|
||||
|
||||
public void updateEntity() {
|
||||
if(worldObj.isRemote) return;
|
||||
|
||||
Block block = worldObj.getBlock(xCoord, yCoord, zCoord);
|
||||
|
||||
if(!worldObj.isRemote) {
|
||||
Block block = worldObj.getBlock(xCoord, yCoord, zCoord);
|
||||
double range = 1;
|
||||
double height = 1;
|
||||
if(!(block instanceof Landmine)) return;
|
||||
Landmine landmine = (Landmine) block;
|
||||
|
||||
if (block == ModBlocks.mine_ap) {
|
||||
range = 1.5D;
|
||||
}
|
||||
if (block == ModBlocks.mine_he) {
|
||||
range = 2;
|
||||
height = 5;
|
||||
}
|
||||
if (block == ModBlocks.mine_shrap) {
|
||||
range = 1.5D;
|
||||
}
|
||||
if (block == ModBlocks.mine_fat) {
|
||||
range = 2.5D;
|
||||
}
|
||||
|
||||
if(!isPrimed)
|
||||
range *= 2;
|
||||
|
||||
List<Object> list = worldObj.getEntitiesWithinAABBExcludingEntity(null,
|
||||
AxisAlignedBB.getBoundingBox(xCoord - range, yCoord - height, zCoord - range, xCoord + range + 1, yCoord + height, zCoord + range + 1));
|
||||
|
||||
boolean flag = false;
|
||||
for(Object o : list) {
|
||||
double range = landmine.range;
|
||||
double height = landmine.height;
|
||||
|
||||
if (waitingForPlayer) {
|
||||
range = 25;
|
||||
height = 25;
|
||||
} else if(!isPrimed) {
|
||||
range *= 2;
|
||||
height *= 2;
|
||||
}
|
||||
|
||||
@SuppressWarnings("unchecked")
|
||||
List<Object> list = worldObj.getEntitiesWithinAABBExcludingEntity(null,
|
||||
AxisAlignedBB.getBoundingBox(xCoord - range, yCoord - height, zCoord - range, xCoord + range + 1, yCoord + height, zCoord + range + 1));
|
||||
|
||||
for(Object o : list) {
|
||||
if(waitingForPlayer) {
|
||||
// This mine has been generated by worldgen and is ignoring mobs until a player is close enough
|
||||
// This is to prevent worldgen mines from detonating well before they become gameplay relevant
|
||||
|
||||
if(o instanceof EntityPlayer) {
|
||||
MainRegistry.logger.info("player is in range, enabling");
|
||||
waitingForPlayer = false;
|
||||
return;
|
||||
}
|
||||
} else {
|
||||
if(o instanceof EntityLivingBase) {
|
||||
|
||||
flag = true;
|
||||
|
||||
if(isPrimed) {
|
||||
//why did i do it like that?
|
||||
((Landmine) block).explode(worldObj, xCoord, yCoord, zCoord);
|
||||
// iunno, you tell me
|
||||
landmine.explode(worldObj, xCoord, yCoord, zCoord);
|
||||
}
|
||||
|
||||
|
||||
return;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if(!isPrimed && !flag) {
|
||||
|
||||
this.worldObj.playSoundEffect(this.xCoord, this.yCoord, this.zCoord, "hbm:weapon.fstbmbStart", 3.0F, 1.0F);
|
||||
isPrimed = true;
|
||||
}
|
||||
// After placing, the mine needs to prime itself in order to not immediately kill the placer
|
||||
// The mine will prime itself only after all entities have left its trigger radius * 2
|
||||
// I'm leaving this note because I made a dumb assumption on what this was meant to do
|
||||
if(!isPrimed && !waitingForPlayer) {
|
||||
this.worldObj.playSoundEffect(this.xCoord, this.yCoord, this.zCoord, "hbm:weapon.fstbmbStart", 3.0F, 1.0F);
|
||||
isPrimed = true;
|
||||
}
|
||||
}
|
||||
|
||||
@ -72,18 +77,19 @@ public class TileEntityLandmine extends TileEntity {
|
||||
super.readFromNBT(nbt);
|
||||
|
||||
isPrimed = nbt.getBoolean("primed");
|
||||
waitingForPlayer = nbt.getBoolean("waiting");
|
||||
}
|
||||
|
||||
public void writeToNBT(NBTTagCompound nbt) {
|
||||
super.writeToNBT(nbt);
|
||||
|
||||
nbt.setBoolean("primed", isPrimed);
|
||||
nbt.setBoolean("waiting", waitingForPlayer);
|
||||
}
|
||||
|
||||
@Override
|
||||
@SideOnly(Side.CLIENT)
|
||||
public double getMaxRenderDistanceSquared()
|
||||
{
|
||||
public double getMaxRenderDistanceSquared() {
|
||||
return 65536.0D;
|
||||
}
|
||||
}
|
||||
|
||||
File diff suppressed because one or more lines are too long
File diff suppressed because it is too large
Load Diff
Binary file not shown.
Loading…
x
Reference in New Issue
Block a user