mirror of
https://github.com/HbmMods/Hbm-s-Nuclear-Tech-GIT.git
synced 2026-02-24 15:00:48 +00:00
Merge pull request #2098 from Dash1269/ntmain-accelerator-tweaks
PA Dipole tweaks and particle serialisation
This commit is contained in:
commit
31dc235dc1
@ -66,12 +66,15 @@ public class TileEntityPADipole extends TileEntityCooledBase implements IGUIProv
|
||||
@Override
|
||||
public void onEnter(Particle particle, ForgeDirection dir) {
|
||||
EnumCoilType type = null;
|
||||
boolean isInline = dir.equals(getExitDir(particle));
|
||||
|
||||
int mult = 1;
|
||||
if(slots[1] != null && slots[1].getItem() == ModItems.pa_coil) {
|
||||
type = EnumUtil.grabEnumSafely(EnumCoilType.class, slots[1].getItemDamage());
|
||||
|
||||
if(type.diMin > particle.momentum) mult *= 10;
|
||||
if(type.diDistMin > particle.distanceTraveled) mult *= 10;
|
||||
if(isInline) mult = 1;
|
||||
}
|
||||
|
||||
if(!isCool()) particle.crash(PAState.CRASH_NOCOOL);
|
||||
@ -81,20 +84,26 @@ public class TileEntityPADipole extends TileEntityCooledBase implements IGUIProv
|
||||
|
||||
if(particle.invalid) return;
|
||||
|
||||
particle.resetDistance();
|
||||
if (isInline) {
|
||||
particle.addDistance(3);
|
||||
} else {
|
||||
particle.resetDistance();
|
||||
}
|
||||
|
||||
this.power -= this.usage * mult;
|
||||
}
|
||||
|
||||
@Override
|
||||
public BlockPos getExitPos(Particle particle) {
|
||||
if(particle.momentum >= this.threshold) {
|
||||
ForgeDirection dir = this.ditToForgeDir(checkRedstone() ? dirRedstone : dirUpper);
|
||||
particle.dir = dir;
|
||||
return new BlockPos(xCoord, yCoord, zCoord).offset(dir, 2);
|
||||
}
|
||||
ForgeDirection dir = this.ditToForgeDir(dirLower);
|
||||
particle.dir = dir;
|
||||
return new BlockPos(xCoord, yCoord, zCoord).offset(dir, 2);
|
||||
particle.dir = getExitDir(particle);
|
||||
return new BlockPos(xCoord, yCoord, zCoord).offset(particle.dir, 2);
|
||||
}
|
||||
|
||||
public ForgeDirection getExitDir(Particle particle) {
|
||||
int dit = particle.momentum < this.threshold
|
||||
? dirLower : checkRedstone()
|
||||
? dirRedstone : dirUpper;
|
||||
return ditToForgeDir(dit);
|
||||
}
|
||||
|
||||
public boolean checkRedstone() {
|
||||
|
||||
@ -233,6 +233,47 @@ public class TileEntityPASource extends TileEntityCooledBase implements IGUIProv
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void writeToNBT(NBTTagCompound nbt) {
|
||||
super.writeToNBT(nbt);
|
||||
NBTTagCompound particleTag = new NBTTagCompound();
|
||||
particleTag.setInteger("x", particle.x);
|
||||
particleTag.setInteger("y", particle.y);
|
||||
particleTag.setInteger("z", particle.z);
|
||||
particleTag.setByte("dir", (byte) particle.dir.ordinal());
|
||||
particleTag.setInteger("momentum", particle.momentum);
|
||||
particleTag.setInteger("defocus", particle.defocus);
|
||||
particleTag.setInteger("dist", particle.distanceTraveled);
|
||||
|
||||
NBTTagCompound inputTag1 = new NBTTagCompound();
|
||||
NBTTagCompound inputTag2 = new NBTTagCompound();
|
||||
particle.input1.writeToNBT(inputTag1);
|
||||
particle.input2.writeToNBT(inputTag2);
|
||||
|
||||
particleTag.setTag("input1", inputTag1);
|
||||
particleTag.setTag("input2", inputTag2);
|
||||
nbt.setTag("particle", particleTag);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void readFromNBT(NBTTagCompound nbt) {
|
||||
super.readFromNBT(nbt);
|
||||
if(!nbt.hasKey("particle")) return;
|
||||
|
||||
NBTTagCompound particleTag = nbt.getCompoundTag("particle");
|
||||
int x = particleTag.getInteger("x");
|
||||
int y = particleTag.getInteger("y");
|
||||
int z = particleTag.getInteger("z");
|
||||
ForgeDirection dir = EnumUtil.grabEnumSafely(ForgeDirection.class, particleTag.getInteger("dir"));
|
||||
ItemStack input1 = ItemStack.loadItemStackFromNBT(particleTag.getCompoundTag("input1"));
|
||||
ItemStack input2 = ItemStack.loadItemStackFromNBT(particleTag.getCompoundTag("input2"));
|
||||
|
||||
this.particle = new Particle(this, x, y, z, dir, input1, input2);
|
||||
this.particle.momentum = particleTag.getInteger("momentum");
|
||||
this.particle.defocus = particleTag.getInteger("defocus");
|
||||
this.particle.distanceTraveled = particleTag.getInteger("dist");
|
||||
}
|
||||
|
||||
public static class Particle {
|
||||
|
||||
private TileEntityPASource source;
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user