Run formatter
This commit is contained in:
parent
61c44a831b
commit
08258fd6ef
606 changed files with 13464 additions and 22975 deletions
|
@ -22,42 +22,35 @@ import net.minecraftforge.common.MinecraftForge;
|
|||
|
||||
import java.util.List;
|
||||
|
||||
public class TileTeleposer extends TileInventory implements ITickable
|
||||
{
|
||||
public class TileTeleposer extends TileInventory implements ITickable {
|
||||
//TODO FUTURE: Make AreaDescriptor for Teleposer perhaps?
|
||||
public static final String TELEPOSER_RANGE = "teleposerRange";
|
||||
|
||||
private int previousInput;
|
||||
|
||||
public TileTeleposer()
|
||||
{
|
||||
public TileTeleposer() {
|
||||
super(1, "teleposer");
|
||||
}
|
||||
|
||||
@Override
|
||||
public void deserialize(NBTTagCompound tagCompound)
|
||||
{
|
||||
public void deserialize(NBTTagCompound tagCompound) {
|
||||
super.deserialize(tagCompound);
|
||||
previousInput = tagCompound.getInteger(Constants.NBT.PREVIOUS_INPUT);
|
||||
}
|
||||
|
||||
@Override
|
||||
public NBTTagCompound serialize(NBTTagCompound tagCompound)
|
||||
{
|
||||
public NBTTagCompound serialize(NBTTagCompound tagCompound) {
|
||||
super.serialize(tagCompound);
|
||||
tagCompound.setInteger(Constants.NBT.PREVIOUS_INPUT, previousInput);
|
||||
return tagCompound;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void update()
|
||||
{
|
||||
if (!getWorld().isRemote)
|
||||
{
|
||||
public void update() {
|
||||
if (!getWorld().isRemote) {
|
||||
int currentInput = getWorld().getStrongPower(pos);
|
||||
|
||||
if (previousInput == 0 && currentInput != 0)
|
||||
{
|
||||
if (previousInput == 0 && currentInput != 0) {
|
||||
initiateTeleport();
|
||||
}
|
||||
|
||||
|
@ -65,33 +58,25 @@ public class TileTeleposer extends TileInventory implements ITickable
|
|||
}
|
||||
}
|
||||
|
||||
public void initiateTeleport()
|
||||
{
|
||||
if (!getWorld().isRemote && canInitiateTeleport(this) && getBlockType() instanceof BlockTeleposer)
|
||||
{
|
||||
public void initiateTeleport() {
|
||||
if (!getWorld().isRemote && canInitiateTeleport(this) && getBlockType() instanceof BlockTeleposer) {
|
||||
ItemStack focusStack = NBTHelper.checkNBT(getStackInSlot(0));
|
||||
ItemTelepositionFocus focus = (ItemTelepositionFocus) focusStack.getItem();
|
||||
BlockPos focusPos = focus.getBlockPos(getStackInSlot(0));
|
||||
World focusWorld = focus.getWorld(getStackInSlot(0));
|
||||
|
||||
if (focusWorld != null && focusWorld.getTileEntity(focusPos) instanceof TileTeleposer && !focusWorld.getTileEntity(focusPos).equals(this))
|
||||
{
|
||||
if (focusWorld != null && focusWorld.getTileEntity(focusPos) instanceof TileTeleposer && !focusWorld.getTileEntity(focusPos).equals(this)) {
|
||||
final int focusLevel = (getStackInSlot(0).getItemDamage() + 1);
|
||||
final int lpToBeDrained = (int) (0.5F * Math.sqrt((pos.getX() - focusPos.getX()) * (pos.getX() - focusPos.getX()) + (pos.getY() - focusPos.getY() + 1) * (pos.getY() - focusPos.getY() + 1) + (pos.getZ() - focusPos.getZ()) * (pos.getZ() - focusPos.getZ())));
|
||||
|
||||
if (NetworkHelper.getSoulNetwork(focus.getOwnerUUID(focusStack)).syphonAndDamage(PlayerHelper.getPlayerFromUUID(focus.getOwnerUUID(focusStack)), lpToBeDrained * (focusLevel * 2 - 1) * (focusLevel * 2 - 1) * (focusLevel * 2 - 1)))
|
||||
{
|
||||
if (NetworkHelper.getSoulNetwork(focus.getOwnerUUID(focusStack)).syphonAndDamage(PlayerHelper.getPlayerFromUUID(focus.getOwnerUUID(focusStack)), lpToBeDrained * (focusLevel * 2 - 1) * (focusLevel * 2 - 1) * (focusLevel * 2 - 1))) {
|
||||
int blocksTransported = 0;
|
||||
|
||||
for (int i = -(focusLevel - 1); i <= (focusLevel - 1); i++)
|
||||
{
|
||||
for (int j = 0; j <= (focusLevel * 2 - 2); j++)
|
||||
{
|
||||
for (int k = -(focusLevel - 1); k <= (focusLevel - 1); k++)
|
||||
{
|
||||
for (int i = -(focusLevel - 1); i <= (focusLevel - 1); i++) {
|
||||
for (int j = 0; j <= (focusLevel * 2 - 2); j++) {
|
||||
for (int k = -(focusLevel - 1); k <= (focusLevel - 1); k++) {
|
||||
TeleposeEvent event = new TeleposeEvent(getWorld(), pos.add(i, 1 + j, k), focusWorld, focusPos.add(i, 1 + j, k));
|
||||
if (Utils.swapLocations(event.initalWorld, event.initialBlockPos, event.finalWorld, event.finalBlockPos) && !MinecraftForge.EVENT_BUS.post(event))
|
||||
{
|
||||
if (Utils.swapLocations(event.initalWorld, event.initialBlockPos, event.finalWorld, event.finalBlockPos) && !MinecraftForge.EVENT_BUS.post(event)) {
|
||||
blocksTransported++;
|
||||
}
|
||||
}
|
||||
|
@ -107,37 +92,27 @@ public class TileTeleposer extends TileInventory implements ITickable
|
|||
AxisAlignedBB focusArea = new AxisAlignedBB(focusPos.getX(), focusPos.getY() + 1, focusPos.getZ(), focusPos.getX() + 1, Math.min(focusWorld.getHeight(), focusPos.getY() + 2 * focusLevel), focusPos.getZ() + 1).expand(focusLevel - 1, 0, focusLevel - 1);
|
||||
focusWorldEntities = focusWorld.getEntitiesWithinAABB(Entity.class, focusArea);
|
||||
|
||||
if (focusWorld.equals(getWorld()))
|
||||
{
|
||||
if (!originalWorldEntities.isEmpty())
|
||||
{
|
||||
for (Entity entity : originalWorldEntities)
|
||||
{
|
||||
if (focusWorld.equals(getWorld())) {
|
||||
if (!originalWorldEntities.isEmpty()) {
|
||||
for (Entity entity : originalWorldEntities) {
|
||||
TeleportQueue.getInstance().addITeleport(new Teleports.TeleportSameDim(new BlockPos(entity.posX - pos.getX() + focusPos.getX(), entity.posY - pos.getY() + focusPos.getY(), entity.posZ - pos.getZ() + focusPos.getZ()), entity, focusStack.getTagCompound().getString(Constants.NBT.OWNER_UUID), true));
|
||||
}
|
||||
}
|
||||
|
||||
if (!focusWorldEntities.isEmpty())
|
||||
{
|
||||
for (Entity entity : focusWorldEntities)
|
||||
{
|
||||
if (!focusWorldEntities.isEmpty()) {
|
||||
for (Entity entity : focusWorldEntities) {
|
||||
TeleportQueue.getInstance().addITeleport(new Teleports.TeleportSameDim(new BlockPos(entity.posX - pos.getX() + focusPos.getX(), entity.posY - pos.getY() + focusPos.getY(), entity.posZ - pos.getZ() + focusPos.getZ()), entity, focusStack.getTagCompound().getString(Constants.NBT.OWNER_UUID), true));
|
||||
}
|
||||
}
|
||||
} else
|
||||
{
|
||||
if (!originalWorldEntities.isEmpty())
|
||||
{
|
||||
for (Entity entity : originalWorldEntities)
|
||||
{
|
||||
} else {
|
||||
if (!originalWorldEntities.isEmpty()) {
|
||||
for (Entity entity : originalWorldEntities) {
|
||||
TeleportQueue.getInstance().addITeleport(new Teleports.TeleportToDim(new BlockPos(entity.posX - pos.getX() + focusPos.getX(), entity.posY - pos.getY() + focusPos.getY(), entity.posZ - pos.getZ() + focusPos.getZ()), entity, focusStack.getTagCompound().getString(Constants.NBT.OWNER_UUID), getWorld(), focusWorld.provider.getDimension(), true));
|
||||
}
|
||||
}
|
||||
|
||||
if (!focusWorldEntities.isEmpty())
|
||||
{
|
||||
for (Entity entity : focusWorldEntities)
|
||||
{
|
||||
if (!focusWorldEntities.isEmpty()) {
|
||||
for (Entity entity : focusWorldEntities) {
|
||||
TeleportQueue.getInstance().addITeleport(new Teleports.TeleportToDim(new BlockPos(entity.posX - pos.getX() + focusPos.getX(), entity.posY - pos.getY() + focusPos.getY(), entity.posZ - pos.getZ() + focusPos.getZ()), entity, focusStack.getTagCompound().getString(Constants.NBT.OWNER_UUID), focusWorld, getWorld().provider.getDimension(), true));
|
||||
}
|
||||
}
|
||||
|
@ -147,8 +122,7 @@ public class TileTeleposer extends TileInventory implements ITickable
|
|||
}
|
||||
}
|
||||
|
||||
private boolean canInitiateTeleport(TileTeleposer teleposer)
|
||||
{
|
||||
private boolean canInitiateTeleport(TileTeleposer teleposer) {
|
||||
return !teleposer.getStackInSlot(0).isEmpty() && teleposer.getStackInSlot(0).getItem() instanceof ItemTelepositionFocus && !Strings.isNullOrEmpty(((ItemTelepositionFocus) teleposer.getStackInSlot(0).getItem()).getOwnerName(teleposer.getStackInSlot(0)));
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue