mirror of
https://github.com/HbmMods/Hbm-s-Nuclear-Tech-GIT.git
synced 2026-08-10 17:55:44 +00:00
ough2
ough2
This commit is contained in:
parent
798382bf42
commit
3a0523462c
@ -46,10 +46,10 @@ import net.minecraftforge.common.util.ForgeDirection;
|
|||||||
public class TileEntityBatterySocket extends TileEntityBatteryBase implements IRORValueProvider, IRORInteractive, IInfoProviderEC {
|
public class TileEntityBatterySocket extends TileEntityBatteryBase implements IRORValueProvider, IRORInteractive, IInfoProviderEC {
|
||||||
|
|
||||||
public boolean frame = false;
|
public boolean frame = false;
|
||||||
|
|
||||||
public static BulletConfig discharge;
|
public static BulletConfig discharge;
|
||||||
public static BiConsumer<EntityBulletBeamBase, MovingObjectPosition> BEAM_DISCHARGE_HIT = (beam, mop) -> {
|
public static BiConsumer<EntityBulletBeamBase, MovingObjectPosition> BEAM_DISCHARGE_HIT = (beam, mop) -> {
|
||||||
|
|
||||||
if(mop.typeOfHit == mop.typeOfHit.BLOCK) {
|
if(mop.typeOfHit == mop.typeOfHit.BLOCK) {
|
||||||
beam.worldObj.func_147480_a(mop.blockX, mop.blockY, mop.blockZ, false);
|
beam.worldObj.func_147480_a(mop.blockX, mop.blockY, mop.blockZ, false);
|
||||||
explodeDischarge(beam.worldObj, mop.hitVec.xCoord, mop.hitVec.yCoord, mop.hitVec.zCoord);
|
explodeDischarge(beam.worldObj, mop.hitVec.xCoord, mop.hitVec.yCoord, mop.hitVec.zCoord);
|
||||||
@ -59,7 +59,7 @@ public class TileEntityBatterySocket extends TileEntityBatteryBase implements IR
|
|||||||
explodeDischarge(beam.worldObj, mop.hitVec.xCoord, mop.hitVec.yCoord, mop.hitVec.zCoord);
|
explodeDischarge(beam.worldObj, mop.hitVec.xCoord, mop.hitVec.yCoord, mop.hitVec.zCoord);
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
public static void explodeDischarge(World world, double x, double y, double z) {
|
public static void explodeDischarge(World world, double x, double y, double z) {
|
||||||
ExplosionVNT vnt = new ExplosionVNT(world, x, y, z, 5F);
|
ExplosionVNT vnt = new ExplosionVNT(world, x, y, z, 5F);
|
||||||
vnt.setEntityProcessor(new EntityProcessorCrossSmooth(1, 20).setDamageClass(DamageClass.ELECTRIC));
|
vnt.setEntityProcessor(new EntityProcessorCrossSmooth(1, 20).setDamageClass(DamageClass.ELECTRIC));
|
||||||
@ -68,7 +68,7 @@ public class TileEntityBatterySocket extends TileEntityBatteryBase implements IR
|
|||||||
vnt.explode();
|
vnt.explode();
|
||||||
world.playSoundEffect(x, y, z, "hbm:entity.ufoBlast", 5.0F, 0.9F + world.rand.nextFloat() * 0.2F);
|
world.playSoundEffect(x, y, z, "hbm:entity.ufoBlast", 5.0F, 0.9F + world.rand.nextFloat() * 0.2F);
|
||||||
}
|
}
|
||||||
|
|
||||||
static {
|
static {
|
||||||
discharge = new BulletConfig().setupDamageClass(DamageClass.ELECTRIC).setBeam().setSpread(0.0F).setLife(3).setThresholdNegation(20F).setArmorPiercing(0.5F).setRenderRotations(false).setDoesPenetrate(true)
|
discharge = new BulletConfig().setupDamageClass(DamageClass.ELECTRIC).setBeam().setSpread(0.0F).setLife(3).setThresholdNegation(20F).setArmorPiercing(0.5F).setRenderRotations(false).setDoesPenetrate(true)
|
||||||
.setOnBeamImpact(BEAM_DISCHARGE_HIT);
|
.setOnBeamImpact(BEAM_DISCHARGE_HIT);
|
||||||
@ -83,7 +83,7 @@ public class TileEntityBatterySocket extends TileEntityBatteryBase implements IR
|
|||||||
public int damageTimer;
|
public int damageTimer;
|
||||||
public int damageTarget;
|
public int damageTarget;
|
||||||
public double scPowerMult = 1D;
|
public double scPowerMult = 1D;
|
||||||
|
|
||||||
public TileEntityBatterySocket() {
|
public TileEntityBatterySocket() {
|
||||||
super(1);
|
super(1);
|
||||||
}
|
}
|
||||||
@ -97,7 +97,7 @@ public class TileEntityBatterySocket extends TileEntityBatteryBase implements IR
|
|||||||
super.updateEntity();
|
super.updateEntity();
|
||||||
|
|
||||||
if(!worldObj.isRemote) {
|
if(!worldObj.isRemote) {
|
||||||
|
|
||||||
if(hasSCLoaded()) {
|
if(hasSCLoaded()) {
|
||||||
if(this.damageTarget == 0) pickNewSCTarget();
|
if(this.damageTarget == 0) pickNewSCTarget();
|
||||||
this.damageTimer++;
|
this.damageTimer++;
|
||||||
@ -114,30 +114,30 @@ public class TileEntityBatterySocket extends TileEntityBatteryBase implements IR
|
|||||||
|
|
||||||
this.log[19] = avg;
|
this.log[19] = avg;
|
||||||
} else {
|
} else {
|
||||||
|
|
||||||
if(worldObj.getTotalWorldTime() % 20 == 0) {
|
if(worldObj.getTotalWorldTime() % 20 == 0) {
|
||||||
frame = !worldObj.getBlock(xCoord, yCoord + 2, zCoord).isAir(worldObj, xCoord, yCoord + 2, zCoord);
|
frame = !worldObj.getBlock(xCoord, yCoord + 2, zCoord).isAir(worldObj, xCoord, yCoord + 2, zCoord);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
protected boolean hasSCLoaded() {
|
protected boolean hasSCLoaded() {
|
||||||
return slots[0] != null && slots[0].getItem() == ModItems.battery_sc && slots[0].getItemDamage() != EnumBatterySC.EMPTY.ordinal();
|
return slots[0] != null && slots[0].getItem() == ModItems.battery_sc && slots[0].getItemDamage() != EnumBatterySC.EMPTY.ordinal();
|
||||||
}
|
}
|
||||||
|
|
||||||
protected void pickNewSCTarget() {
|
protected void pickNewSCTarget() {
|
||||||
this.damageTimer = 0;
|
this.damageTimer = 0;
|
||||||
//this.damageTarget = 100;
|
//this.damageTarget = 100;
|
||||||
this.damageTarget = 1200 + worldObj.rand.nextInt(2400); // 1-3 minutes;
|
this.damageTarget = 1200 + worldObj.rand.nextInt(2400); // 1-3 minutes;
|
||||||
this.markChanged();
|
this.markChanged();
|
||||||
}
|
}
|
||||||
|
|
||||||
protected void discharge() {
|
protected void discharge() {
|
||||||
pickNewSCTarget();
|
pickNewSCTarget();
|
||||||
|
|
||||||
ForgeDirection dir = ForgeDirection.getOrientation(this.getBlockMetadata() - 10);
|
ForgeDirection dir = ForgeDirection.getOrientation(this.getBlockMetadata() - 10);
|
||||||
ForgeDirection rot = dir.getRotation(ForgeDirection.UP);
|
ForgeDirection rot = dir.getRotation(ForgeDirection.UP);
|
||||||
|
|
||||||
double x = xCoord + 0.5 - dir.offsetX * 0.5 + rot.offsetX * 0.5;
|
double x = xCoord + 0.5 - dir.offsetX * 0.5 + rot.offsetX * 0.5;
|
||||||
double y = yCoord + 1;
|
double y = yCoord + 1;
|
||||||
double z = zCoord + 0.5 - dir.offsetZ * 0.5 + rot.offsetX * 0.5;
|
double z = zCoord + 0.5 - dir.offsetZ * 0.5 + rot.offsetX * 0.5;
|
||||||
@ -156,15 +156,15 @@ public class TileEntityBatterySocket extends TileEntityBatteryBase implements IR
|
|||||||
initialDelta.multiply(1.125D / dominantAxis); // move 1.125 blocks outwards
|
initialDelta.multiply(1.125D / dominantAxis); // move 1.125 blocks outwards
|
||||||
sub.setPosition(xCoord + initialDelta.xCoord, yCoord + initialDelta.yCoord, zCoord + initialDelta.zCoord);
|
sub.setPosition(xCoord + initialDelta.xCoord, yCoord + initialDelta.yCoord, zCoord + initialDelta.zCoord);
|
||||||
Vec3NT actualDelta = new Vec3NT(target.posX - sub.posX, target.posY + target.height / 2 - sub.posY, target.posZ - sub.posZ);
|
Vec3NT actualDelta = new Vec3NT(target.posX - sub.posX, target.posY + target.height / 2 - sub.posY, target.posZ - sub.posZ);
|
||||||
|
|
||||||
sub.setRotationsFromVector(actualDelta);
|
sub.setRotationsFromVector(actualDelta);
|
||||||
sub.performHitscanExternal(actualDelta.lengthVector());
|
sub.performHitscanExternal(actualDelta.lengthVector());
|
||||||
worldObj.spawnEntityInWorld(sub);
|
worldObj.spawnEntityInWorld(sub);
|
||||||
}
|
}
|
||||||
|
|
||||||
explodeDischarge(worldObj, x + worldObj.rand.nextGaussian() * 0.5, y + worldObj.rand.nextGaussian() * 0.5, z + worldObj.rand.nextGaussian() * 0.5);
|
explodeDischarge(worldObj, x + worldObj.rand.nextGaussian() * 0.5, y + worldObj.rand.nextGaussian() * 0.5, z + worldObj.rand.nextGaussian() * 0.5);
|
||||||
}
|
}
|
||||||
|
|
||||||
protected void fluctuate() {
|
protected void fluctuate() {
|
||||||
double steppy = 1D / 100D;
|
double steppy = 1D / 100D;
|
||||||
this.scPowerMult += (steppy * (worldObj.rand.nextDouble() * 2 - 1));
|
this.scPowerMult += (steppy * (worldObj.rand.nextDouble() * 2 - 1));
|
||||||
@ -233,18 +233,18 @@ public class TileEntityBatterySocket extends TileEntityBatteryBase implements IR
|
|||||||
return power;
|
return power;
|
||||||
}
|
}
|
||||||
@Override public long getMaxPower() { return maxPowerFromStack(slots[0]); }
|
@Override public long getMaxPower() { return maxPowerFromStack(slots[0]); }
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void setPower(long power) {
|
public void setPower(long power) {
|
||||||
if(slots[0] == null || !(slots[0].getItem() instanceof IBatteryItem)) return;
|
if(slots[0] == null || !(slots[0].getItem() instanceof IBatteryItem)) return;
|
||||||
((IBatteryItem) slots[0].getItem()).setCharge(slots[0], power);
|
((IBatteryItem) slots[0].getItem()).setCharge(slots[0], power);
|
||||||
}
|
}
|
||||||
|
|
||||||
public static long powerFromStack(ItemStack stack) {
|
public static long powerFromStack(ItemStack stack) {
|
||||||
if(stack == null || !(stack.getItem() instanceof IBatteryItem)) return 0;
|
if(stack == null || !(stack.getItem() instanceof IBatteryItem)) return 0;
|
||||||
return ((IBatteryItem) stack.getItem()).getCharge(stack);
|
return ((IBatteryItem) stack.getItem()).getCharge(stack);
|
||||||
}
|
}
|
||||||
|
|
||||||
public static long maxPowerFromStack(ItemStack stack) {
|
public static long maxPowerFromStack(ItemStack stack) {
|
||||||
if(stack == null || !(stack.getItem() instanceof IBatteryItem)) return 0;
|
if(stack == null || !(stack.getItem() instanceof IBatteryItem)) return 0;
|
||||||
return ((IBatteryItem) stack.getItem()).getMaxCharge(stack);
|
return ((IBatteryItem) stack.getItem()).getMaxCharge(stack);
|
||||||
@ -319,6 +319,7 @@ public class TileEntityBatterySocket extends TileEntityBatteryBase implements IR
|
|||||||
public String[] getFunctionInfo() {
|
public String[] getFunctionInfo() {
|
||||||
return new String[] {
|
return new String[] {
|
||||||
PREFIX_VALUE + "fill",
|
PREFIX_VALUE + "fill",
|
||||||
|
PREFIX_VALUE + "maxfill",
|
||||||
PREFIX_VALUE + "fillpercent",
|
PREFIX_VALUE + "fillpercent",
|
||||||
PREFIX_VALUE + "delta",
|
PREFIX_VALUE + "delta",
|
||||||
PREFIX_FUNCTION + "setmode" + NAME_SEPARATOR + "mode (0-3)",
|
PREFIX_FUNCTION + "setmode" + NAME_SEPARATOR + "mode (0-3)",
|
||||||
@ -332,6 +333,7 @@ public class TileEntityBatterySocket extends TileEntityBatteryBase implements IR
|
|||||||
@Override
|
@Override
|
||||||
public String provideRORValue(String name) {
|
public String provideRORValue(String name) {
|
||||||
if((PREFIX_VALUE + "fill").equals(name)) return "" + this.getPower();
|
if((PREFIX_VALUE + "fill").equals(name)) return "" + this.getPower();
|
||||||
|
if((PREFIX_VALUE + "maxfill").equals(name)) return "" + this.getMaxPower();
|
||||||
if((PREFIX_VALUE + "fillpercent").equals(name)) return "" + this.getPower() * 100 / (Math.max(this.getMaxPower(), 1));
|
if((PREFIX_VALUE + "fillpercent").equals(name)) return "" + this.getPower() * 100 / (Math.max(this.getMaxPower(), 1));
|
||||||
if((PREFIX_VALUE + "delta").equals(name)) return "" + delta;
|
if((PREFIX_VALUE + "delta").equals(name)) return "" + delta;
|
||||||
return null;
|
return null;
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user