reformatted all src files (#141)

This commit is contained in:
YoungOnion
2022-09-17 05:08:02 -06:00
committed by GitHub
parent 3328bfcda2
commit 9011273229
1056 changed files with 88127 additions and 110597 deletions
@@ -19,31 +19,27 @@
package appeng.debug;
import java.util.List;
import appeng.block.AEBaseTileBlock;
import appeng.core.AppEng;
import net.minecraft.block.material.Material;
import net.minecraft.world.World;
import net.minecraftforge.common.ForgeChunkManager;
import net.minecraftforge.common.ForgeChunkManager.LoadingCallback;
import net.minecraftforge.common.ForgeChunkManager.Ticket;
import appeng.block.AEBaseTileBlock;
import appeng.core.AppEng;
import java.util.List;
public class BlockChunkloader extends AEBaseTileBlock implements LoadingCallback
{
public class BlockChunkloader extends AEBaseTileBlock implements LoadingCallback {
public BlockChunkloader()
{
super( Material.IRON );
ForgeChunkManager.setForcedChunkLoadingCallback( AppEng.instance(), this );
}
public BlockChunkloader() {
super(Material.IRON);
ForgeChunkManager.setForcedChunkLoadingCallback(AppEng.instance(), this);
}
@Override
public void ticketsLoaded( final List<Ticket> tickets, final World world )
{
@Override
public void ticketsLoaded(final List<Ticket> tickets, final World world) {
}
}
}
@@ -19,8 +19,7 @@
package appeng.debug;
import javax.annotation.Nullable;
import appeng.block.AEBaseTileBlock;
import net.minecraft.block.material.Material;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.item.ItemStack;
@@ -29,27 +28,23 @@ import net.minecraft.util.EnumHand;
import net.minecraft.util.math.BlockPos;
import net.minecraft.world.World;
import appeng.block.AEBaseTileBlock;
import javax.annotation.Nullable;
public class BlockCubeGenerator extends AEBaseTileBlock
{
public class BlockCubeGenerator extends AEBaseTileBlock {
public BlockCubeGenerator()
{
super( Material.IRON );
}
public BlockCubeGenerator() {
super(Material.IRON);
}
@Override
public boolean onActivated( final World w, final BlockPos pos, final EntityPlayer player, final EnumHand hand, final @Nullable ItemStack heldItem, final EnumFacing side, final float hitX, final float hitY, final float hitZ )
{
final TileCubeGenerator tcg = this.getTileEntity( w, pos );
if( tcg != null )
{
tcg.click( player );
}
@Override
public boolean onActivated(final World w, final BlockPos pos, final EntityPlayer player, final EnumHand hand, final @Nullable ItemStack heldItem, final EnumFacing side, final float hitX, final float hitY, final float hitZ) {
final TileCubeGenerator tcg = this.getTileEntity(w, pos);
if (tcg != null) {
tcg.click(player);
}
return true;
}
return true;
}
}
@@ -19,17 +19,14 @@
package appeng.debug;
import appeng.block.AEBaseTileBlock;
import net.minecraft.block.material.Material;
import appeng.block.AEBaseTileBlock;
public class BlockEnergyGenerator extends AEBaseTileBlock {
public class BlockEnergyGenerator extends AEBaseTileBlock
{
public BlockEnergyGenerator()
{
super( Material.IRON );
}
public BlockEnergyGenerator() {
super(Material.IRON);
}
}
+5 -8
View File
@@ -19,17 +19,14 @@
package appeng.debug;
import appeng.block.AEBaseTileBlock;
import net.minecraft.block.material.Material;
import appeng.block.AEBaseTileBlock;
public class BlockItemGen extends AEBaseTileBlock {
public class BlockItemGen extends AEBaseTileBlock
{
public BlockItemGen()
{
super( Material.IRON );
}
public BlockItemGen() {
super(Material.IRON);
}
}
@@ -19,8 +19,7 @@
package appeng.debug;
import javax.annotation.Nullable;
import appeng.block.AEBaseTileBlock;
import net.minecraft.block.material.Material;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.item.ItemStack;
@@ -29,23 +28,20 @@ import net.minecraft.util.EnumHand;
import net.minecraft.util.math.BlockPos;
import net.minecraft.world.World;
import appeng.block.AEBaseTileBlock;
import javax.annotation.Nullable;
public class BlockPhantomNode extends AEBaseTileBlock
{
public class BlockPhantomNode extends AEBaseTileBlock {
public BlockPhantomNode()
{
super( Material.IRON );
}
public BlockPhantomNode() {
super(Material.IRON);
}
@Override
public boolean onActivated( final World w, final BlockPos pos, final EntityPlayer player, final EnumHand hand, final @Nullable ItemStack heldItem, final EnumFacing side, final float hitX, final float hitY, final float hitZ )
{
final TilePhantomNode tpn = this.getTileEntity( w, pos );
tpn.triggerCrashMode();
return true;
}
@Override
public boolean onActivated(final World w, final BlockPos pos, final EntityPlayer player, final EnumHand hand, final @Nullable ItemStack heldItem, final EnumFacing side, final float hitX, final float hitY, final float hitZ) {
final TilePhantomNode tpn = this.getTileEntity(w, pos);
tpn.triggerCrashMode();
return true;
}
}
+41 -52
View File
@@ -19,8 +19,10 @@
package appeng.debug;
import java.util.List;
import appeng.core.AELog;
import appeng.core.AppEng;
import appeng.tile.AEBaseTile;
import appeng.util.Platform;
import net.minecraft.entity.player.EntityPlayerMP;
import net.minecraft.server.MinecraftServer;
import net.minecraft.util.ITickable;
@@ -31,64 +33,51 @@ import net.minecraftforge.common.ForgeChunkManager.Ticket;
import net.minecraftforge.common.ForgeChunkManager.Type;
import net.minecraftforge.fml.common.FMLCommonHandler;
import appeng.core.AELog;
import appeng.core.AppEng;
import appeng.tile.AEBaseTile;
import appeng.util.Platform;
import java.util.List;
public class TileChunkLoader extends AEBaseTile implements ITickable
{
public class TileChunkLoader extends AEBaseTile implements ITickable {
private boolean requestTicket = true;
private Ticket ct = null;
private boolean requestTicket = true;
private Ticket ct = null;
@Override
public void update()
{
if( this.requestTicket )
{
this.requestTicket = false;
this.initTicket();
}
}
@Override
public void update() {
if (this.requestTicket) {
this.requestTicket = false;
this.initTicket();
}
}
private void initTicket()
{
if( Platform.isClient() )
{
return;
}
private void initTicket() {
if (Platform.isClient()) {
return;
}
this.ct = ForgeChunkManager.requestTicket( AppEng.instance(), this.world, Type.NORMAL );
this.ct = ForgeChunkManager.requestTicket(AppEng.instance(), this.world, Type.NORMAL);
if( this.ct == null )
{
final MinecraftServer server = FMLCommonHandler.instance().getMinecraftServerInstance();
if( server != null )
{
final List<EntityPlayerMP> pl = server.getPlayerList().getPlayers();
for( final EntityPlayerMP p : pl )
{
p.sendMessage( new TextComponentString( "Can't chunk load.." ) );
}
}
return;
}
if (this.ct == null) {
final MinecraftServer server = FMLCommonHandler.instance().getMinecraftServerInstance();
if (server != null) {
final List<EntityPlayerMP> pl = server.getPlayerList().getPlayers();
for (final EntityPlayerMP p : pl) {
p.sendMessage(new TextComponentString("Can't chunk load.."));
}
}
return;
}
AELog.info( "New Ticket " + this.ct.toString() );
ForgeChunkManager.forceChunk( this.ct, new ChunkPos( this.pos.getX() >> 4, this.pos.getZ() >> 4 ) );
}
AELog.info("New Ticket " + this.ct);
ForgeChunkManager.forceChunk(this.ct, new ChunkPos(this.pos.getX() >> 4, this.pos.getZ() >> 4));
}
@Override
public void invalidate()
{
if( Platform.isClient() )
{
return;
}
@Override
public void invalidate() {
if (Platform.isClient()) {
return;
}
AELog.info( "Released Ticket " + this.ct.toString() );
ForgeChunkManager.releaseTicket( this.ct );
}
AELog.info("Released Ticket " + this.ct.toString());
ForgeChunkManager.releaseTicket(this.ct);
}
}
@@ -19,6 +19,9 @@
package appeng.debug;
import appeng.core.AppEng;
import appeng.tile.AEBaseTile;
import appeng.util.Platform;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.item.Item;
import net.minecraft.item.ItemStack;
@@ -28,99 +31,75 @@ import net.minecraft.util.ITickable;
import net.minecraft.util.math.BlockPos;
import net.minecraft.util.text.TextComponentString;
import appeng.core.AppEng;
import appeng.tile.AEBaseTile;
import appeng.util.Platform;
public class TileCubeGenerator extends AEBaseTile implements ITickable {
public class TileCubeGenerator extends AEBaseTile implements ITickable
{
private int size = 3;
private ItemStack is = ItemStack.EMPTY;
private int countdown = 20 * 10;
private EntityPlayer who = null;
private int size = 3;
private ItemStack is = ItemStack.EMPTY;
private int countdown = 20 * 10;
private EntityPlayer who = null;
@Override
public void update() {
if (!this.is.isEmpty() && Platform.isServer()) {
this.countdown--;
@Override
public void update()
{
if( !this.is.isEmpty() && Platform.isServer() )
{
this.countdown--;
if (this.countdown % 20 == 0) {
for (final EntityPlayer e : AppEng.proxy.getPlayers()) {
e.sendMessage(new TextComponentString("Spawning in... " + (this.countdown / 20)));
}
}
if( this.countdown % 20 == 0 )
{
for( final EntityPlayer e : AppEng.proxy.getPlayers() )
{
e.sendMessage( new TextComponentString( "Spawning in... " + ( this.countdown / 20 ) ) );
}
}
if (this.countdown <= 0) {
this.spawn();
}
}
}
if( this.countdown <= 0 )
{
this.spawn();
}
}
}
private void spawn() {
this.world.setBlockToAir(this.pos);
private void spawn()
{
this.world.setBlockToAir( this.pos );
final Item i = this.is.getItem();
final EnumFacing side = EnumFacing.UP;
final Item i = this.is.getItem();
final EnumFacing side = EnumFacing.UP;
final int half = (int) Math.floor(this.size / 2);
final int half = (int) Math.floor( this.size / 2 );
for (int y = 0; y < this.size; y++) {
for (int x = -half; x < half; x++) {
for (int z = -half; z < half; z++) {
final BlockPos p = this.pos.add(x, y - 1, z);
i.onItemUse(this.who, this.world, p, EnumHand.MAIN_HAND, side, 0.5f, 0.0f, 0.5f);
}
}
}
}
for( int y = 0; y < this.size; y++ )
{
for( int x = -half; x < half; x++ )
{
for( int z = -half; z < half; z++ )
{
final BlockPos p = this.pos.add( x, y - 1, z );
i.onItemUse( this.who, this.world, p, EnumHand.MAIN_HAND, side, 0.5f, 0.0f, 0.5f );
}
}
}
}
void click(final EntityPlayer player) {
if (Platform.isServer()) {
final ItemStack hand = player.inventory.getCurrentItem();
this.who = player;
void click( final EntityPlayer player )
{
if( Platform.isServer() )
{
final ItemStack hand = player.inventory.getCurrentItem();
this.who = player;
if (hand.isEmpty()) {
this.is = ItemStack.EMPTY;
if( hand.isEmpty() )
{
this.is = ItemStack.EMPTY;
if (player.isSneaking()) {
this.size--;
} else {
this.size++;
}
if( player.isSneaking() )
{
this.size--;
}
else
{
this.size++;
}
if (this.size < 3) {
this.size = 3;
}
if (this.size > 64) {
this.size = 64;
}
if( this.size < 3 )
{
this.size = 3;
}
if( this.size > 64 )
{
this.size = 64;
}
player.sendMessage( new TextComponentString( "Size: " + this.size ) );
}
else
{
this.countdown = 20 * 10;
this.is = hand;
}
}
}
player.sendMessage(new TextComponentString("Size: " + this.size));
} else {
this.countdown = 20 * 10;
this.is = hand;
}
}
}
}
@@ -19,12 +19,8 @@
package appeng.debug;
import java.util.EnumSet;
import javax.annotation.Nullable;
import appeng.tile.AEBaseTile;
import com.google.common.math.IntMath;
import net.minecraft.tileentity.TileEntity;
import net.minecraft.util.EnumFacing;
import net.minecraft.util.ITickable;
@@ -32,108 +28,92 @@ import net.minecraftforge.common.capabilities.Capability;
import net.minecraftforge.energy.CapabilityEnergy;
import net.minecraftforge.energy.IEnergyStorage;
import appeng.tile.AEBaseTile;
import javax.annotation.Nullable;
import java.util.EnumSet;
public class TileEnergyGenerator extends AEBaseTile implements ITickable, IEnergyStorage
{
/**
* The base energy injected each tick.
* Adjacent TileEnergyGenerators will increase it to pow(base, #generators).
*/
private static final int BASE_ENERGY = 8;
public class TileEnergyGenerator extends AEBaseTile implements ITickable, IEnergyStorage {
/**
* The base energy injected each tick.
* Adjacent TileEnergyGenerators will increase it to pow(base, #generators).
*/
private static final int BASE_ENERGY = 8;
@Override
public void update()
{
int tier = 1;
final EnumSet<EnumFacing> validEnergyReceivers = EnumSet.noneOf( EnumFacing.class );
@Override
public void update() {
int tier = 1;
final EnumSet<EnumFacing> validEnergyReceivers = EnumSet.noneOf(EnumFacing.class);
for( EnumFacing facing : EnumFacing.values() )
{
final TileEntity te = this.getWorld().getTileEntity( this.getPos().offset( facing ) );
for (EnumFacing facing : EnumFacing.values()) {
final TileEntity te = this.getWorld().getTileEntity(this.getPos().offset(facing));
if( te instanceof TileEnergyGenerator )
{
tier++;
}
if (te instanceof TileEnergyGenerator) {
tier++;
}
if( te != null && te.hasCapability( CapabilityEnergy.ENERGY, facing.getOpposite() ) )
{
validEnergyReceivers.add( facing );
}
if (te != null && te.hasCapability(CapabilityEnergy.ENERGY, facing.getOpposite())) {
validEnergyReceivers.add(facing);
}
}
}
final int energyToInsert = IntMath.pow( BASE_ENERGY, tier );
final int energyToInsert = IntMath.pow(BASE_ENERGY, tier);
for( EnumFacing facing : validEnergyReceivers )
{
final TileEntity te = this.getWorld().getTileEntity( this.getPos().offset( facing ) );
final IEnergyStorage cap = te.getCapability( CapabilityEnergy.ENERGY, facing.getOpposite() );
for (EnumFacing facing : validEnergyReceivers) {
final TileEntity te = this.getWorld().getTileEntity(this.getPos().offset(facing));
final IEnergyStorage cap = te.getCapability(CapabilityEnergy.ENERGY, facing.getOpposite());
if( cap.canReceive() )
{
if (cap.canReceive()) {
cap.receiveEnergy( energyToInsert, false );
}
}
}
cap.receiveEnergy(energyToInsert, false);
}
}
}
@Override
public boolean hasCapability( Capability<?> capability, @Nullable EnumFacing facing )
{
if( capability == CapabilityEnergy.ENERGY )
{
return true;
}
return super.hasCapability( capability, facing );
}
@Override
public boolean hasCapability(Capability<?> capability, @Nullable EnumFacing facing) {
if (capability == CapabilityEnergy.ENERGY) {
return true;
}
return super.hasCapability(capability, facing);
}
@Override
@Nullable
public <T> T getCapability( Capability<T> capability, @Nullable EnumFacing facing )
{
if( capability == CapabilityEnergy.ENERGY )
{
return (T) this;
}
return super.getCapability( capability, facing );
}
@Override
@Nullable
public <T> T getCapability(Capability<T> capability, @Nullable EnumFacing facing) {
if (capability == CapabilityEnergy.ENERGY) {
return (T) this;
}
return super.getCapability(capability, facing);
}
@Override
public int receiveEnergy( int maxReceive, boolean simulate )
{
return 0;
}
@Override
public int receiveEnergy(int maxReceive, boolean simulate) {
return 0;
}
@Override
public int extractEnergy( int maxExtract, boolean simulate )
{
return maxExtract;
}
@Override
public int extractEnergy(int maxExtract, boolean simulate) {
return maxExtract;
}
@Override
public int getEnergyStored()
{
return Integer.MAX_VALUE;
}
@Override
public int getEnergyStored() {
return Integer.MAX_VALUE;
}
@Override
public int getMaxEnergyStored()
{
return Integer.MAX_VALUE;
}
@Override
public int getMaxEnergyStored() {
return Integer.MAX_VALUE;
}
@Override
public boolean canExtract()
{
return true;
}
@Override
public boolean canExtract() {
return true;
}
@Override
public boolean canReceive()
{
return false;
}
@Override
public boolean canReceive() {
return false;
}
}
+76 -98
View File
@@ -19,12 +19,7 @@
package appeng.debug;
import java.util.ArrayDeque;
import java.util.Queue;
import javax.annotation.Nonnull;
import javax.annotation.Nullable;
import appeng.tile.AEBaseTile;
import net.minecraft.init.Items;
import net.minecraft.item.Item;
import net.minecraft.item.ItemStack;
@@ -34,113 +29,96 @@ import net.minecraftforge.common.capabilities.Capability;
import net.minecraftforge.items.CapabilityItemHandler;
import net.minecraftforge.items.IItemHandler;
import appeng.tile.AEBaseTile;
import javax.annotation.Nonnull;
import javax.annotation.Nullable;
import java.util.ArrayDeque;
import java.util.Queue;
public class TileItemGen extends AEBaseTile
{
public class TileItemGen extends AEBaseTile {
private static final Queue<ItemStack> POSSIBLE_ITEMS = new ArrayDeque<>();
private static final Queue<ItemStack> POSSIBLE_ITEMS = new ArrayDeque<>();
private final IItemHandler handler = new QueuedItemHandler();
private final IItemHandler handler = new QueuedItemHandler();
public TileItemGen()
{
if( POSSIBLE_ITEMS.isEmpty() )
{
for( final Object obj : Item.REGISTRY )
{
final Item mi = (Item) obj;
if( mi != null && mi != Items.AIR )
{
if( mi.isDamageable() )
{
for( int dmg = 0; dmg < mi.getMaxDamage(); dmg++ )
{
POSSIBLE_ITEMS.add( new ItemStack( mi, 1, dmg ) );
}
}
else
{
final NonNullList<ItemStack> list = NonNullList.create();
mi.getSubItems( mi.getCreativeTab(), list );
POSSIBLE_ITEMS.addAll( list );
}
}
}
}
}
public TileItemGen() {
if (POSSIBLE_ITEMS.isEmpty()) {
for (final Object obj : Item.REGISTRY) {
final Item mi = (Item) obj;
if (mi != null && mi != Items.AIR) {
if (mi.isDamageable()) {
for (int dmg = 0; dmg < mi.getMaxDamage(); dmg++) {
POSSIBLE_ITEMS.add(new ItemStack(mi, 1, dmg));
}
} else {
final NonNullList<ItemStack> list = NonNullList.create();
mi.getSubItems(mi.getCreativeTab(), list);
POSSIBLE_ITEMS.addAll(list);
}
}
}
}
}
@Override
public boolean hasCapability( Capability<?> capability, @Nullable EnumFacing facing )
{
if( CapabilityItemHandler.ITEM_HANDLER_CAPABILITY == capability )
{
return true;
}
return super.hasCapability( capability, facing );
}
@Override
public boolean hasCapability(Capability<?> capability, @Nullable EnumFacing facing) {
if (CapabilityItemHandler.ITEM_HANDLER_CAPABILITY == capability) {
return true;
}
return super.hasCapability(capability, facing);
}
@Override
@Nullable
public <T> T getCapability( Capability<T> capability, @Nullable EnumFacing facing )
{
if( CapabilityItemHandler.ITEM_HANDLER_CAPABILITY == capability )
{
return (T) this.handler;
}
return super.getCapability( capability, facing );
}
@Override
@Nullable
public <T> T getCapability(Capability<T> capability, @Nullable EnumFacing facing) {
if (CapabilityItemHandler.ITEM_HANDLER_CAPABILITY == capability) {
return (T) this.handler;
}
return super.getCapability(capability, facing);
}
class QueuedItemHandler implements IItemHandler
{
class QueuedItemHandler implements IItemHandler {
@Override
@Nonnull
public ItemStack insertItem( int slot, @Nonnull ItemStack stack, boolean simulate )
{
return stack;
}
@Override
@Nonnull
public ItemStack insertItem(int slot, @Nonnull ItemStack stack, boolean simulate) {
return stack;
}
@Override
@Nonnull
public ItemStack getStackInSlot( int slot )
{
return POSSIBLE_ITEMS.peek() != null ? POSSIBLE_ITEMS.peek().copy() : ItemStack.EMPTY;
}
@Override
@Nonnull
public ItemStack getStackInSlot(int slot) {
return POSSIBLE_ITEMS.peek() != null ? POSSIBLE_ITEMS.peek().copy() : ItemStack.EMPTY;
}
@Override
public int getSlots()
{
return 1;
}
@Override
public int getSlots() {
return 1;
}
@Override
public int getSlotLimit( int slot )
{
return 1;
}
@Override
public int getSlotLimit(int slot) {
return 1;
}
@Override
@Nonnull
public ItemStack extractItem( int slot, int amount, boolean simulate )
{
final ItemStack is = POSSIBLE_ITEMS.peek();
@Override
@Nonnull
public ItemStack extractItem(int slot, int amount, boolean simulate) {
final ItemStack is = POSSIBLE_ITEMS.peek();
if( is == null )
{
return ItemStack.EMPTY;
}
if (is == null) {
return ItemStack.EMPTY;
}
return simulate ? is.copy() : this.getNextItem();
}
return simulate ? is.copy() : this.getNextItem();
}
private ItemStack getNextItem()
{
final ItemStack is = POSSIBLE_ITEMS.poll();
private ItemStack getNextItem() {
final ItemStack is = POSSIBLE_ITEMS.poll();
POSSIBLE_ITEMS.add(is);
return is.copy();
}
}
POSSIBLE_ITEMS.add( is );
return is.copy();
}
};
}
+26 -33
View File
@@ -19,48 +19,41 @@
package appeng.debug;
import java.util.EnumSet;
import net.minecraft.util.EnumFacing;
import appeng.api.networking.IGridNode;
import appeng.api.util.AEPartLocation;
import appeng.me.helpers.AENetworkProxy;
import appeng.tile.grid.AENetworkTile;
import net.minecraft.util.EnumFacing;
import java.util.EnumSet;
public class TilePhantomNode extends AENetworkTile
{
public class TilePhantomNode extends AENetworkTile {
private AENetworkProxy proxy = null;
private boolean crashMode = false;
private AENetworkProxy proxy = null;
private boolean crashMode = false;
@Override
public IGridNode getGridNode( final AEPartLocation dir )
{
if( !this.crashMode )
{
return super.getGridNode( dir );
}
@Override
public IGridNode getGridNode(final AEPartLocation dir) {
if (!this.crashMode) {
return super.getGridNode(dir);
}
return this.proxy.getNode();
}
return this.proxy.getNode();
}
@Override
public void onReady()
{
super.onReady();
this.proxy = this.createProxy();
this.proxy.onReady();
this.crashMode = true;
}
@Override
public void onReady() {
super.onReady();
this.proxy = this.createProxy();
this.proxy.onReady();
this.crashMode = true;
}
void triggerCrashMode()
{
if( this.proxy != null )
{
this.crashMode = true;
this.proxy.setValidSides( EnumSet.allOf( EnumFacing.class ) );
}
}
void triggerCrashMode() {
if (this.proxy != null) {
this.crashMode = true;
this.proxy.setValidSides(EnumSet.allOf(EnumFacing.class));
}
}
}
+122 -158
View File
@@ -19,19 +19,6 @@
package appeng.debug;
import java.util.HashSet;
import java.util.Set;
import net.minecraft.command.ICommandSender;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.tileentity.TileEntity;
import net.minecraft.util.EnumActionResult;
import net.minecraft.util.EnumFacing;
import net.minecraft.util.EnumHand;
import net.minecraft.util.math.BlockPos;
import net.minecraft.util.text.TextComponentString;
import net.minecraft.world.World;
import appeng.api.networking.IGridConnection;
import appeng.api.networking.IGridHost;
import appeng.api.networking.IGridNode;
@@ -51,172 +38,149 @@ import appeng.me.cache.TickManagerCache;
import appeng.parts.p2p.PartP2PTunnel;
import appeng.tile.networking.TileController;
import appeng.util.Platform;
import net.minecraft.command.ICommandSender;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.tileentity.TileEntity;
import net.minecraft.util.EnumActionResult;
import net.minecraft.util.EnumFacing;
import net.minecraft.util.EnumHand;
import net.minecraft.util.math.BlockPos;
import net.minecraft.util.text.TextComponentString;
import net.minecraft.world.World;
import java.util.HashSet;
import java.util.Set;
public class ToolDebugCard extends AEBaseItem
{
@Override
public EnumActionResult onItemUseFirst( final EntityPlayer player, final World world, final BlockPos pos, final EnumFacing side, final float hitX, final float hitY, final float hitZ, final EnumHand hand )
{
if( Platform.isClient() )
{
return EnumActionResult.PASS;
}
public class ToolDebugCard extends AEBaseItem {
@Override
public EnumActionResult onItemUseFirst(final EntityPlayer player, final World world, final BlockPos pos, final EnumFacing side, final float hitX, final float hitY, final float hitZ, final EnumHand hand) {
if (Platform.isClient()) {
return EnumActionResult.PASS;
}
if( player.isSneaking() )
{
int grids = 0;
int totalNodes = 0;
if (player.isSneaking()) {
int grids = 0;
int totalNodes = 0;
for( final Grid g : TickHandler.INSTANCE.getGridList() )
{
grids++;
totalNodes += g.getNodes().size();
}
for (final Grid g : TickHandler.INSTANCE.getGridList()) {
grids++;
totalNodes += g.getNodes().size();
}
this.outputMsg( player, "Grids: " + grids );
this.outputMsg( player, "Total Nodes: " + totalNodes );
}
else
{
final TileEntity te = world.getTileEntity( pos );
this.outputMsg(player, "Grids: " + grids);
this.outputMsg(player, "Total Nodes: " + totalNodes);
} else {
final TileEntity te = world.getTileEntity(pos);
if( te instanceof IGridHost )
{
final GridNode node = (GridNode) ( (IGridHost) te ).getGridNode( AEPartLocation.fromFacing( side ) );
if( node != null )
{
final Grid g = node.getInternalGrid();
final IGridNode center = g.getPivot();
this.outputMsg( player, "This Node: " + node.toString() );
this.outputMsg( player, "Center Node: " + center.toString() );
if (te instanceof IGridHost) {
final GridNode node = (GridNode) ((IGridHost) te).getGridNode(AEPartLocation.fromFacing(side));
if (node != null) {
final Grid g = node.getInternalGrid();
final IGridNode center = g.getPivot();
this.outputMsg(player, "This Node: " + node);
this.outputMsg(player, "Center Node: " + center);
final IPathingGrid pg = g.getCache( IPathingGrid.class );
if( pg.getControllerState() == ControllerState.CONTROLLER_ONLINE )
{
final IPathingGrid pg = g.getCache(IPathingGrid.class);
if (pg.getControllerState() == ControllerState.CONTROLLER_ONLINE) {
Set<IGridNode> next = new HashSet<>();
next.add( node );
Set<IGridNode> next = new HashSet<>();
next.add(node);
final int maxLength = 10000;
final int maxLength = 10000;
int length = 0;
outer:
while( !next.isEmpty() )
{
final Iterable<IGridNode> current = next;
next = new HashSet<>();
int length = 0;
outer:
while (!next.isEmpty()) {
final Iterable<IGridNode> current = next;
next = new HashSet<>();
for( final IGridNode n : current )
{
if( n.getMachine() instanceof TileController )
{
break outer;
}
for (final IGridNode n : current) {
if (n.getMachine() instanceof TileController) {
break outer;
}
for( final IGridConnection c : n.getConnections() )
{
next.add( c.getOtherSide( n ) );
}
}
for (final IGridConnection c : n.getConnections()) {
next.add(c.getOtherSide(n));
}
}
length++;
length++;
if( length > maxLength )
{
break;
}
}
if (length > maxLength) {
break;
}
}
this.outputMsg( player, "Cable Distance: " + length );
}
this.outputMsg(player, "Cable Distance: " + length);
}
if( center.getMachine() instanceof PartP2PTunnel )
{
this.outputMsg( player, "Freq: " + ( (PartP2PTunnel) center.getMachine() ).getFrequency() );
}
if (center.getMachine() instanceof PartP2PTunnel) {
this.outputMsg(player, "Freq: " + ((PartP2PTunnel) center.getMachine()).getFrequency());
}
final TickManagerCache tmc = g.getCache( ITickManager.class );
for( final Class<? extends IGridHost> c : g.getMachineClasses() )
{
int o = 0;
long nanos = 0;
for( final IGridNode oj : g.getMachines( c ) )
{
o++;
nanos += tmc.getAvgNanoTime( oj );
}
final TickManagerCache tmc = g.getCache(ITickManager.class);
for (final Class<? extends IGridHost> c : g.getMachineClasses()) {
int o = 0;
long nanos = 0;
for (final IGridNode oj : g.getMachines(c)) {
o++;
nanos += tmc.getAvgNanoTime(oj);
}
if( nanos < 0 )
{
this.outputMsg( player, c.getSimpleName() + " - " + o );
}
else
{
this.outputMsg( player, c.getSimpleName() + " - " + o + "; " + this.timeMeasurement( nanos ) );
}
}
}
else
{
this.outputMsg( player, "No Node Available." );
}
}
else
{
this.outputMsg( player, "Not Networked Block" );
}
if (nanos < 0) {
this.outputMsg(player, c.getSimpleName() + " - " + o);
} else {
this.outputMsg(player, c.getSimpleName() + " - " + o + "; " + this.timeMeasurement(nanos));
}
}
} else {
this.outputMsg(player, "No Node Available.");
}
} else {
this.outputMsg(player, "Not Networked Block");
}
if( te instanceof IPartHost )
{
final IPart center = ( (IPartHost) te ).getPart( AEPartLocation.INTERNAL );
( (IPartHost) te ).markForUpdate();
if( center != null )
{
final GridNode n = (GridNode) center.getGridNode();
this.outputMsg( player, "Node Channels: " + n.usedChannels() );
for( final IGridConnection gc : n.getConnections() )
{
final AEPartLocation fd = gc.getDirection( n );
if( fd != AEPartLocation.INTERNAL )
{
this.outputMsg( player, fd.toString() + ": " + gc.getUsedChannels() );
}
}
}
}
if (te instanceof IPartHost) {
final IPart center = ((IPartHost) te).getPart(AEPartLocation.INTERNAL);
((IPartHost) te).markForUpdate();
if (center != null) {
final GridNode n = (GridNode) center.getGridNode();
this.outputMsg(player, "Node Channels: " + n.usedChannels());
for (final IGridConnection gc : n.getConnections()) {
final AEPartLocation fd = gc.getDirection(n);
if (fd != AEPartLocation.INTERNAL) {
this.outputMsg(player, fd + ": " + gc.getUsedChannels());
}
}
}
}
if( te instanceof IAEPowerStorage )
{
final IAEPowerStorage ps = (IAEPowerStorage) te;
this.outputMsg( player, "Energy: " + ps.getAECurrentPower() + " / " + ps.getAEMaxPower() );
if (te instanceof IAEPowerStorage) {
final IAEPowerStorage ps = (IAEPowerStorage) te;
this.outputMsg(player, "Energy: " + ps.getAECurrentPower() + " / " + ps.getAEMaxPower());
if( te instanceof IGridHost )
{
final IGridNode node = ( (IGridHost) te ).getGridNode( AEPartLocation.fromFacing( side ) );
if( node != null && node.getGrid() != null )
{
final IEnergyGrid eg = node.getGrid().getCache( IEnergyGrid.class );
this.outputMsg( player, "GridEnergy: " + eg.getStoredPower() + " : " + eg.getEnergyDemand( Double.MAX_VALUE ) );
}
}
}
}
return EnumActionResult.SUCCESS;
}
if (te instanceof IGridHost) {
final IGridNode node = ((IGridHost) te).getGridNode(AEPartLocation.fromFacing(side));
if (node != null && node.getGrid() != null) {
final IEnergyGrid eg = node.getGrid().getCache(IEnergyGrid.class);
this.outputMsg(player, "GridEnergy: " + eg.getStoredPower() + " : " + eg.getEnergyDemand(Double.MAX_VALUE));
}
}
}
}
return EnumActionResult.SUCCESS;
}
private void outputMsg( final ICommandSender player, final String string )
{
player.sendMessage( new TextComponentString( string ) );
}
private void outputMsg(final ICommandSender player, final String string) {
player.sendMessage(new TextComponentString(string));
}
private String timeMeasurement( final long nanos )
{
final long ms = nanos / 100000;
if( nanos <= 100000 )
{
return nanos + "ns";
}
return ( ms / 10.0f ) + "ms";
}
private String timeMeasurement(final long nanos) {
final long ms = nanos / 100000;
if (nanos <= 100000) {
return nanos + "ns";
}
return (ms / 10.0f) + "ms";
}
}
+36 -43
View File
@@ -19,9 +19,9 @@
package appeng.debug;
import java.util.ArrayList;
import java.util.List;
import appeng.core.AELog;
import appeng.items.AEBaseItem;
import appeng.util.Platform;
import net.minecraft.block.state.IBlockState;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.util.EnumActionResult;
@@ -30,56 +30,49 @@ import net.minecraft.util.EnumHand;
import net.minecraft.util.math.BlockPos;
import net.minecraft.world.World;
import appeng.core.AELog;
import appeng.items.AEBaseItem;
import appeng.util.Platform;
import java.util.ArrayList;
import java.util.List;
public class ToolEraser extends AEBaseItem
{
public class ToolEraser extends AEBaseItem {
private static final int BLOCK_ERASE_LIMIT = 90000;
private static final int BLOCK_ERASE_LIMIT = 90000;
@Override
public EnumActionResult onItemUseFirst( final EntityPlayer player, final World world, final BlockPos pos, final EnumFacing side, final float hitX, final float hitY, final float hitZ, final EnumHand hand )
{
if( Platform.isClient() )
{
return EnumActionResult.PASS;
}
@Override
public EnumActionResult onItemUseFirst(final EntityPlayer player, final World world, final BlockPos pos, final EnumFacing side, final float hitX, final float hitY, final float hitZ, final EnumHand hand) {
if (Platform.isClient()) {
return EnumActionResult.PASS;
}
final IBlockState state = world.getBlockState( pos );
final IBlockState state = world.getBlockState(pos);
List<BlockPos> next = new ArrayList<>();
next.add( pos );
List<BlockPos> next = new ArrayList<>();
next.add(pos);
int blocks = 0;
while( blocks < BLOCK_ERASE_LIMIT && !next.isEmpty() )
{
final List<BlockPos> c = next;
next = new ArrayList<>();
int blocks = 0;
while (blocks < BLOCK_ERASE_LIMIT && !next.isEmpty()) {
final List<BlockPos> c = next;
next = new ArrayList<>();
for( final BlockPos wc : c )
{
final IBlockState c_state = world.getBlockState( wc );
for (final BlockPos wc : c) {
final IBlockState c_state = world.getBlockState(wc);
if( state == c_state )
{
blocks++;
world.setBlockToAir( wc );
if (state == c_state) {
blocks++;
world.setBlockToAir(wc);
next.add( wc.add( 1, 0, 0 ) );
next.add( wc.add( -1, 0, 0 ) );
next.add( wc.add( 0, 1, 0 ) );
next.add( wc.add( 0, -1, 0 ) );
next.add( wc.add( 0, 0, 1 ) );
next.add( wc.add( 0, 0, -1 ) );
}
}
}
next.add(wc.add(1, 0, 0));
next.add(wc.add(-1, 0, 0));
next.add(wc.add(0, 1, 0));
next.add(wc.add(0, -1, 0));
next.add(wc.add(0, 0, 1));
next.add(wc.add(0, 0, -1));
}
}
}
AELog.info( "Delete " + blocks + " blocks" );
AELog.info("Delete " + blocks + " blocks");
return EnumActionResult.SUCCESS;
}
return EnumActionResult.SUCCESS;
}
}
@@ -19,6 +19,10 @@
package appeng.debug;
import appeng.items.AEBaseItem;
import appeng.util.Platform;
import appeng.worldgen.MeteoritePlacer;
import appeng.worldgen.meteorite.StandardWorld;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.util.EnumActionResult;
import net.minecraft.util.EnumFacing;
@@ -27,30 +31,21 @@ import net.minecraft.util.math.BlockPos;
import net.minecraft.util.text.TextComponentString;
import net.minecraft.world.World;
import appeng.items.AEBaseItem;
import appeng.util.Platform;
import appeng.worldgen.MeteoritePlacer;
import appeng.worldgen.meteorite.StandardWorld;
public class ToolMeteoritePlacer extends AEBaseItem {
@Override
public EnumActionResult onItemUseFirst(final EntityPlayer player, final World world, final BlockPos pos, final EnumFacing side, final float hitX, final float hitY, final float hitZ, final EnumHand hand) {
if (Platform.isClient()) {
return EnumActionResult.PASS;
}
public class ToolMeteoritePlacer extends AEBaseItem
{
@Override
public EnumActionResult onItemUseFirst( final EntityPlayer player, final World world, final BlockPos pos, final EnumFacing side, final float hitX, final float hitY, final float hitZ, final EnumHand hand )
{
if( Platform.isClient() )
{
return EnumActionResult.PASS;
}
final MeteoritePlacer mp = new MeteoritePlacer();
final boolean worked = mp.spawnMeteorite(new StandardWorld(world), pos.getX(), pos.getY(), pos.getZ());
final MeteoritePlacer mp = new MeteoritePlacer();
final boolean worked = mp.spawnMeteorite( new StandardWorld( world ), pos.getX(), pos.getY(), pos.getZ() );
if (!worked) {
player.sendMessage(new TextComponentString("Un-suitable Location."));
}
if( !worked )
{
player.sendMessage( new TextComponentString( "Un-suitable Location." ) );
}
return EnumActionResult.SUCCESS;
}
return EnumActionResult.SUCCESS;
}
}
+105 -135
View File
@@ -19,6 +19,14 @@
package appeng.debug;
import appeng.api.networking.IGrid;
import appeng.api.networking.IGridHost;
import appeng.api.networking.IGridNode;
import appeng.api.networking.spatial.ISpatialCache;
import appeng.api.util.AEPartLocation;
import appeng.api.util.DimensionalCoord;
import appeng.items.AEBaseItem;
import appeng.util.Platform;
import net.minecraft.block.Block;
import net.minecraft.block.state.IBlockState;
import net.minecraft.command.ICommandSender;
@@ -33,150 +41,112 @@ import net.minecraft.util.text.TextComponentString;
import net.minecraft.world.World;
import net.minecraftforge.common.DimensionManager;
import appeng.api.networking.IGrid;
import appeng.api.networking.IGridHost;
import appeng.api.networking.IGridNode;
import appeng.api.networking.spatial.ISpatialCache;
import appeng.api.util.AEPartLocation;
import appeng.api.util.DimensionalCoord;
import appeng.items.AEBaseItem;
import appeng.util.Platform;
public class ToolReplicatorCard extends AEBaseItem {
@Override
public EnumActionResult onItemUseFirst(final EntityPlayer player, final World world, final BlockPos pos, final EnumFacing side, final float hitX, final float hitY, final float hitZ, final EnumHand hand) {
if (Platform.isClient()) {
return EnumActionResult.PASS;
}
public class ToolReplicatorCard extends AEBaseItem
{
@Override
public EnumActionResult onItemUseFirst( final EntityPlayer player, final World world, final BlockPos pos, final EnumFacing side, final float hitX, final float hitY, final float hitZ, final EnumHand hand )
{
if( Platform.isClient() )
{
return EnumActionResult.PASS;
}
int x = pos.getX();
int y = pos.getY();
int z = pos.getZ();
int x = pos.getX();
int y = pos.getY();
int z = pos.getZ();
if (player.isSneaking()) {
if (world.getTileEntity(pos) instanceof IGridHost) {
final NBTTagCompound tag = new NBTTagCompound();
tag.setInteger("x", x);
tag.setInteger("y", y);
tag.setInteger("z", z);
tag.setInteger("side", side.ordinal());
tag.setInteger("dimid", world.provider.getDimension());
player.getHeldItem(hand).setTagCompound(tag);
} else {
this.outputMsg(player, "This is not a Grid Tile.");
}
} else {
final NBTTagCompound ish = player.getHeldItem(hand).getTagCompound();
if (ish != null) {
final int src_x = ish.getInteger("x");
final int src_y = ish.getInteger("y");
final int src_z = ish.getInteger("z");
final int src_side = ish.getInteger("side");
final int dimid = ish.getInteger("dimid");
final World src_w = DimensionManager.getWorld(dimid);
if( player.isSneaking() )
{
if( world.getTileEntity( pos ) instanceof IGridHost )
{
final NBTTagCompound tag = new NBTTagCompound();
tag.setInteger( "x", x );
tag.setInteger( "y", y );
tag.setInteger( "z", z );
tag.setInteger( "side", side.ordinal() );
tag.setInteger( "dimid", world.provider.getDimension() );
player.getHeldItem( hand ).setTagCompound( tag );
}
else
{
this.outputMsg( player, "This is not a Grid Tile." );
}
}
else
{
final NBTTagCompound ish = player.getHeldItem( hand ).getTagCompound();
if( ish != null )
{
final int src_x = ish.getInteger( "x" );
final int src_y = ish.getInteger( "y" );
final int src_z = ish.getInteger( "z" );
final int src_side = ish.getInteger( "side" );
final int dimid = ish.getInteger( "dimid" );
final World src_w = DimensionManager.getWorld( dimid );
final TileEntity te = src_w.getTileEntity(new BlockPos(src_x, src_y, src_z));
if (te instanceof IGridHost) {
final IGridHost gh = (IGridHost) te;
final EnumFacing sideOff = EnumFacing.VALUES[src_side];
final EnumFacing currentSideOff = side;
final IGridNode n = gh.getGridNode(AEPartLocation.fromFacing(sideOff));
if (n != null) {
final IGrid g = n.getGrid();
if (g != null) {
final ISpatialCache sc = g.getCache(ISpatialCache.class);
if (sc.isValidRegion()) {
final DimensionalCoord min = sc.getMin();
final DimensionalCoord max = sc.getMax();
final TileEntity te = src_w.getTileEntity( new BlockPos( src_x, src_y, src_z ) );
if( te instanceof IGridHost )
{
final IGridHost gh = (IGridHost) te;
final EnumFacing sideOff = EnumFacing.VALUES[src_side];
final EnumFacing currentSideOff = side;
final IGridNode n = gh.getGridNode( AEPartLocation.fromFacing( sideOff ) );
if( n != null )
{
final IGrid g = n.getGrid();
if( g != null )
{
final ISpatialCache sc = g.getCache( ISpatialCache.class );
if( sc.isValidRegion() )
{
final DimensionalCoord min = sc.getMin();
final DimensionalCoord max = sc.getMax();
x += currentSideOff.getFrontOffsetX();
y += currentSideOff.getFrontOffsetY();
z += currentSideOff.getFrontOffsetZ();
x += currentSideOff.getFrontOffsetX();
y += currentSideOff.getFrontOffsetY();
z += currentSideOff.getFrontOffsetZ();
final int min_x = min.x;
final int min_y = min.y;
final int min_z = min.z;
final int min_x = min.x;
final int min_y = min.y;
final int min_z = min.z;
final int rel_x = min.x - src_x + x;
final int rel_y = min.y - src_y + y;
final int rel_z = min.z - src_z + z;
final int rel_x = min.x - src_x + x;
final int rel_y = min.y - src_y + y;
final int rel_z = min.z - src_z + z;
final int scale_x = max.x - min.x;
final int scale_y = max.y - min.y;
final int scale_z = max.z - min.z;
final int scale_x = max.x - min.x;
final int scale_y = max.y - min.y;
final int scale_z = max.z - min.z;
for (int i = 1; i < scale_x; i++) {
for (int j = 1; j < scale_y; j++) {
for (int k = 1; k < scale_z; k++) {
final BlockPos p = new BlockPos(min_x + i, min_y + j, min_z + k);
final BlockPos d = new BlockPos(i + rel_x, j + rel_y, k + rel_z);
final IBlockState state = src_w.getBlockState(p);
final Block blk = state.getBlock();
final IBlockState prev = world.getBlockState(d);
for( int i = 1; i < scale_x; i++ )
{
for( int j = 1; j < scale_y; j++ )
{
for( int k = 1; k < scale_z; k++ )
{
final BlockPos p = new BlockPos( min_x + i, min_y + j, min_z + k );
final BlockPos d = new BlockPos( i + rel_x, j + rel_y, k + rel_z );
final IBlockState state = src_w.getBlockState( p );
final Block blk = state.getBlock();
final IBlockState prev = world.getBlockState( d );
world.setBlockState(d, state);
if (blk != null && blk.hasTileEntity(state)) {
final TileEntity ote = src_w.getTileEntity(p);
final TileEntity nte = blk.createTileEntity(world, state);
final NBTTagCompound data = new NBTTagCompound();
ote.writeToNBT(data);
nte.readFromNBT(data.copy());
world.setTileEntity(d, nte);
}
world.notifyBlockUpdate(d, prev, state, 3);
}
}
}
} else {
this.outputMsg(player, "requires valid spatial pylon setup.");
}
} else {
this.outputMsg(player, "no grid?");
}
} else {
this.outputMsg(player, "No grid node?");
}
} else {
this.outputMsg(player, "Src is no longer a grid block?");
}
} else {
this.outputMsg(player, "No Source Defined");
}
}
return EnumActionResult.SUCCESS;
}
world.setBlockState( d, state );
if( blk != null && blk.hasTileEntity( state ) )
{
final TileEntity ote = src_w.getTileEntity( p );
final TileEntity nte = blk.createTileEntity( world, state );
final NBTTagCompound data = new NBTTagCompound();
ote.writeToNBT( data );
nte.readFromNBT( data.copy() );
world.setTileEntity( d, nte );
}
world.notifyBlockUpdate( d, prev, state, 3 );
}
}
}
}
else
{
this.outputMsg( player, "requires valid spatial pylon setup." );
}
}
else
{
this.outputMsg( player, "no grid?" );
}
}
else
{
this.outputMsg( player, "No grid node?" );
}
}
else
{
this.outputMsg( player, "Src is no longer a grid block?" );
}
}
else
{
this.outputMsg( player, "No Source Defined" );
}
}
return EnumActionResult.SUCCESS;
}
private void outputMsg( final ICommandSender player, final String string )
{
player.sendMessage( new TextComponentString( string ) );
}
private void outputMsg(final ICommandSender player, final String string) {
player.sendMessage(new TextComponentString(string));
}
}