Relocate Source to proper directory.
This commit is contained in:
@@ -0,0 +1,38 @@
|
||||
package appeng.debug;
|
||||
|
||||
import java.util.EnumSet;
|
||||
import java.util.List;
|
||||
|
||||
import net.minecraft.block.material.Material;
|
||||
import net.minecraft.client.renderer.texture.IIconRegister;
|
||||
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.AEBaseBlock;
|
||||
import appeng.core.AppEng;
|
||||
import appeng.core.features.AEFeature;
|
||||
|
||||
public class BlockChunkloader extends AEBaseBlock implements LoadingCallback
|
||||
{
|
||||
|
||||
public BlockChunkloader() {
|
||||
super( BlockChunkloader.class, Material.iron );
|
||||
setFeature( EnumSet.of( AEFeature.UnsupportedDeveloperTools, AEFeature.Creative ) );
|
||||
setTileEntity( TileChunkLoader.class );
|
||||
ForgeChunkManager.setForcedChunkLoadingCallback( AppEng.instance, this );
|
||||
}
|
||||
|
||||
@Override
|
||||
public void ticketsLoaded(List<Ticket> tickets, World world)
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void registerBlockIcons(IIconRegister iconRegistry)
|
||||
{
|
||||
registerNoIcons();
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,38 @@
|
||||
package appeng.debug;
|
||||
|
||||
import java.util.EnumSet;
|
||||
|
||||
import net.minecraft.block.material.Material;
|
||||
import net.minecraft.client.renderer.texture.IIconRegister;
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.world.World;
|
||||
import appeng.block.AEBaseBlock;
|
||||
import appeng.core.features.AEFeature;
|
||||
|
||||
public class BlockCubeGenerator extends AEBaseBlock
|
||||
{
|
||||
|
||||
public BlockCubeGenerator() {
|
||||
super( BlockCubeGenerator.class, Material.iron );
|
||||
setFeature( EnumSet.of( AEFeature.UnsupportedDeveloperTools, AEFeature.Creative ) );
|
||||
setTileEntity( TileCubeGenerator.class );
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean onActivated(World w, int x, int y, int z,
|
||||
EntityPlayer player, int side, float hitX, float hitY, float hitZ) {
|
||||
|
||||
TileCubeGenerator tcg = getTileEntity(w, x, y, z);
|
||||
if ( tcg != null )
|
||||
tcg.click( player );
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void registerBlockIcons(IIconRegister iconRegistry)
|
||||
{
|
||||
registerNoIcons();
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,25 @@
|
||||
package appeng.debug;
|
||||
|
||||
import java.util.EnumSet;
|
||||
|
||||
import net.minecraft.block.material.Material;
|
||||
import net.minecraft.client.renderer.texture.IIconRegister;
|
||||
import appeng.block.AEBaseBlock;
|
||||
import appeng.core.features.AEFeature;
|
||||
|
||||
public class BlockItemGen extends AEBaseBlock
|
||||
{
|
||||
|
||||
public BlockItemGen() {
|
||||
super( BlockItemGen.class, Material.iron );
|
||||
setFeature( EnumSet.of( AEFeature.UnsupportedDeveloperTools, AEFeature.Creative ) );
|
||||
setTileEntity( TileItemGen.class );
|
||||
}
|
||||
|
||||
@Override
|
||||
public void registerBlockIcons(IIconRegister iconRegistry)
|
||||
{
|
||||
registerNoIcons();
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,35 @@
|
||||
package appeng.debug;
|
||||
|
||||
import java.util.EnumSet;
|
||||
|
||||
import net.minecraft.block.material.Material;
|
||||
import net.minecraft.client.renderer.texture.IIconRegister;
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.world.World;
|
||||
import appeng.block.AEBaseBlock;
|
||||
import appeng.core.features.AEFeature;
|
||||
|
||||
public class BlockPhantomNode extends AEBaseBlock
|
||||
{
|
||||
|
||||
public BlockPhantomNode() {
|
||||
super( BlockPhantomNode.class, Material.iron );
|
||||
setFeature( EnumSet.of( AEFeature.UnsupportedDeveloperTools, AEFeature.Creative ) );
|
||||
setTileEntity( TilePhantomNode.class );
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean onActivated(World w, int x, int y, int z, EntityPlayer player, int side, float hitX, float hitY, float hitZ)
|
||||
{
|
||||
TilePhantomNode tpn = getTileEntity( w, x, y, z );
|
||||
tpn.BOOM();
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void registerBlockIcons(IIconRegister iconRegistry)
|
||||
{
|
||||
registerNoIcons();
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,70 @@
|
||||
package appeng.debug;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import net.minecraft.entity.player.EntityPlayerMP;
|
||||
import net.minecraft.server.MinecraftServer;
|
||||
import net.minecraft.util.ChatComponentText;
|
||||
import net.minecraft.world.ChunkCoordIntPair;
|
||||
import net.minecraftforge.common.ForgeChunkManager;
|
||||
import net.minecraftforge.common.ForgeChunkManager.Ticket;
|
||||
import net.minecraftforge.common.ForgeChunkManager.Type;
|
||||
import appeng.core.AELog;
|
||||
import appeng.core.AppEng;
|
||||
import appeng.tile.AEBaseTile;
|
||||
import appeng.tile.TileEvent;
|
||||
import appeng.tile.events.TileEventType;
|
||||
import appeng.util.Platform;
|
||||
import cpw.mods.fml.common.FMLCommonHandler;
|
||||
|
||||
public class TileChunkLoader extends AEBaseTile
|
||||
{
|
||||
|
||||
boolean requestTicket = true;
|
||||
Ticket ct;
|
||||
|
||||
@TileEvent(TileEventType.TICK)
|
||||
public void Tick_TileChunkLoader()
|
||||
{
|
||||
if ( requestTicket )
|
||||
{
|
||||
requestTicket = false;
|
||||
initTicket();
|
||||
}
|
||||
}
|
||||
|
||||
void initTicket()
|
||||
{
|
||||
if ( Platform.isClient() )
|
||||
return;
|
||||
|
||||
ct = ForgeChunkManager.requestTicket( AppEng.instance, worldObj, Type.NORMAL );
|
||||
|
||||
if ( ct == null )
|
||||
{
|
||||
MinecraftServer server = FMLCommonHandler.instance().getMinecraftServerInstance();
|
||||
if ( server != null )
|
||||
{
|
||||
List<EntityPlayerMP> pl = server.getConfigurationManager().playerEntityList;
|
||||
for (EntityPlayerMP p : pl)
|
||||
{
|
||||
p.addChatMessage( new ChatComponentText( "Can't chunk load.." ) );
|
||||
}
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
||||
AELog.info( "New Ticket " + ct.toString() );
|
||||
ForgeChunkManager.forceChunk( ct, new ChunkCoordIntPair( xCoord >> 4, zCoord >> 4 ) );
|
||||
}
|
||||
|
||||
@Override
|
||||
public void invalidate()
|
||||
{
|
||||
if ( Platform.isClient() )
|
||||
return;
|
||||
|
||||
AELog.info( "Released Ticket " + ct.toString() );
|
||||
ForgeChunkManager.releaseTicket( ct );
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,94 @@
|
||||
package appeng.debug;
|
||||
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.item.Item;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.util.ChatComponentText;
|
||||
import net.minecraftforge.common.util.ForgeDirection;
|
||||
import appeng.core.CommonHelper;
|
||||
import appeng.tile.AEBaseTile;
|
||||
import appeng.tile.TileEvent;
|
||||
import appeng.tile.events.TileEventType;
|
||||
import appeng.util.Platform;
|
||||
|
||||
public class TileCubeGenerator extends AEBaseTile
|
||||
{
|
||||
|
||||
int size = 3;
|
||||
ItemStack is = null;
|
||||
int countdown = 20 * 10;
|
||||
EntityPlayer who;
|
||||
|
||||
@TileEvent(TileEventType.TICK)
|
||||
public void TCG_Tick()
|
||||
{
|
||||
if ( is != null && Platform.isServer() )
|
||||
{
|
||||
countdown--;
|
||||
|
||||
if ( countdown % 20 == 0 )
|
||||
{
|
||||
for (EntityPlayer e : CommonHelper.proxy.getPlayers())
|
||||
{
|
||||
e.addChatMessage( new ChatComponentText( "Spawning in... " + (countdown / 20) ) );
|
||||
}
|
||||
}
|
||||
|
||||
if ( countdown <= 0 )
|
||||
spawn();
|
||||
}
|
||||
}
|
||||
|
||||
void spawn()
|
||||
{
|
||||
worldObj.setBlock( xCoord, yCoord, zCoord, Platform.air, 0, 3 );
|
||||
|
||||
Item i = is.getItem();
|
||||
int side = ForgeDirection.UP.ordinal();
|
||||
|
||||
int half = (int) Math.floor( size / 2 );
|
||||
|
||||
for (int y = 0; y < size; y++)
|
||||
{
|
||||
for (int x = -half; x < half; x++)
|
||||
{
|
||||
for (int z = -half; z < half; z++)
|
||||
{
|
||||
i.onItemUse( is.copy(), who, worldObj, x + xCoord, y + yCoord - 1, z + zCoord, side, 0.5f, 0.0f, 0.5f );
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public void click(EntityPlayer player)
|
||||
{
|
||||
if ( Platform.isServer() )
|
||||
{
|
||||
ItemStack hand = player.inventory.getCurrentItem();
|
||||
who = player;
|
||||
|
||||
if ( hand == null )
|
||||
{
|
||||
is = null;
|
||||
|
||||
if ( player.isSneaking() )
|
||||
size--;
|
||||
else
|
||||
size++;
|
||||
|
||||
if ( size < 3 )
|
||||
size = 3;
|
||||
if ( size > 64 )
|
||||
size = 64;
|
||||
|
||||
player.addChatMessage( new ChatComponentText( "Size: " + size ) );
|
||||
}
|
||||
else
|
||||
{
|
||||
countdown = 20 * 10;
|
||||
is = hand;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,124 @@
|
||||
package appeng.debug;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.LinkedList;
|
||||
import java.util.List;
|
||||
import java.util.Queue;
|
||||
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.inventory.IInventory;
|
||||
import net.minecraft.item.Item;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import appeng.tile.AEBaseTile;
|
||||
|
||||
public class TileItemGen extends AEBaseTile implements IInventory
|
||||
{
|
||||
|
||||
public static Queue<ItemStack> possibleItems = new LinkedList();
|
||||
|
||||
public TileItemGen() {
|
||||
if ( possibleItems.isEmpty() )
|
||||
{
|
||||
for (Object obj : Item.itemRegistry)
|
||||
{
|
||||
Item mi = (Item) obj;
|
||||
if ( mi != null )
|
||||
{
|
||||
if ( mi.isDamageable() )
|
||||
{
|
||||
for (int dmg = 0; dmg < mi.getMaxDamage(); dmg++)
|
||||
possibleItems.add( new ItemStack( mi, 1, dmg ) );
|
||||
}
|
||||
else
|
||||
{
|
||||
List<ItemStack> list = new ArrayList<ItemStack>();
|
||||
mi.getSubItems( mi, mi.getCreativeTab(), list );
|
||||
possibleItems.addAll( list );
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getSizeInventory()
|
||||
{
|
||||
return 1;
|
||||
}
|
||||
|
||||
@Override
|
||||
public ItemStack getStackInSlot(int i)
|
||||
{
|
||||
return getRandomItem();
|
||||
}
|
||||
|
||||
private ItemStack getRandomItem()
|
||||
{
|
||||
return possibleItems.peek();
|
||||
}
|
||||
|
||||
@Override
|
||||
public ItemStack decrStackSize(int i, int j)
|
||||
{
|
||||
ItemStack a = possibleItems.poll();
|
||||
ItemStack out = a.copy();
|
||||
possibleItems.add( a );
|
||||
return out;
|
||||
}
|
||||
|
||||
@Override
|
||||
public ItemStack getStackInSlotOnClosing(int i)
|
||||
{
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setInventorySlotContents(int i, ItemStack itemstack)
|
||||
{
|
||||
ItemStack a = possibleItems.poll();
|
||||
possibleItems.add( a );
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getInventoryName()
|
||||
{
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean hasCustomInventoryName()
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getInventoryStackLimit()
|
||||
{
|
||||
return 1;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void openInventory()
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void closeInventory()
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isItemValidForSlot(int i, ItemStack itemstack)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isUseableByPlayer(EntityPlayer entityplayer)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,42 @@
|
||||
package appeng.debug;
|
||||
|
||||
import java.util.EnumSet;
|
||||
|
||||
import net.minecraftforge.common.util.ForgeDirection;
|
||||
import appeng.api.networking.IGridNode;
|
||||
import appeng.me.helpers.AENetworkProxy;
|
||||
import appeng.tile.grid.AENetworkTile;
|
||||
|
||||
public class TilePhantomNode extends AENetworkTile
|
||||
{
|
||||
|
||||
protected AENetworkProxy RWAR = null;
|
||||
boolean crashMode = false;
|
||||
|
||||
@Override
|
||||
public void onReady()
|
||||
{
|
||||
super.onReady();
|
||||
RWAR = createProxy();
|
||||
RWAR.onReady();
|
||||
crashMode = true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public IGridNode getGridNode(ForgeDirection dir)
|
||||
{
|
||||
if ( !crashMode )
|
||||
return super.getGridNode( dir );
|
||||
|
||||
return RWAR.getNode();
|
||||
}
|
||||
|
||||
public void BOOM()
|
||||
{
|
||||
if ( RWAR != null )
|
||||
{
|
||||
crashMode = true;
|
||||
RWAR.setValidSides( EnumSet.allOf( ForgeDirection.class ) );
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,188 @@
|
||||
package appeng.debug;
|
||||
|
||||
import java.util.EnumSet;
|
||||
import java.util.HashSet;
|
||||
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.tileentity.TileEntity;
|
||||
import net.minecraft.util.ChatComponentText;
|
||||
import net.minecraft.world.World;
|
||||
import net.minecraftforge.common.util.ForgeDirection;
|
||||
import appeng.api.networking.IGridConnection;
|
||||
import appeng.api.networking.IGridHost;
|
||||
import appeng.api.networking.IGridNode;
|
||||
import appeng.api.networking.energy.IAEPowerStorage;
|
||||
import appeng.api.networking.energy.IEnergyGrid;
|
||||
import appeng.api.networking.pathing.ControllerState;
|
||||
import appeng.api.networking.pathing.IPathingGrid;
|
||||
import appeng.api.networking.ticking.ITickManager;
|
||||
import appeng.api.parts.IPart;
|
||||
import appeng.api.parts.IPartHost;
|
||||
import appeng.core.features.AEFeature;
|
||||
import appeng.hooks.TickHandler;
|
||||
import appeng.items.AEBaseItem;
|
||||
import appeng.me.Grid;
|
||||
import appeng.me.GridNode;
|
||||
import appeng.me.cache.TickManagerCache;
|
||||
import appeng.parts.p2p.PartP2PTunnel;
|
||||
import appeng.tile.networking.TileController;
|
||||
import appeng.util.Platform;
|
||||
|
||||
public class ToolDebugCard extends AEBaseItem
|
||||
{
|
||||
|
||||
public ToolDebugCard() {
|
||||
super( ToolDebugCard.class );
|
||||
setFeature( EnumSet.of( AEFeature.UnsupportedDeveloperTools, AEFeature.Creative ) );
|
||||
}
|
||||
|
||||
public String timeMeasurement(long nanos)
|
||||
{
|
||||
long ms = (long) (nanos / 100000);
|
||||
if ( nanos <= 100000 )
|
||||
return nanos + "ns";
|
||||
return (((float) ms) / 10.0f) + "ms";
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean onItemUseFirst(ItemStack stack, EntityPlayer player, World world, int x, int y, int z, int side, float hitX, float hitY, float hitZ)
|
||||
{
|
||||
if ( Platform.isClient() )
|
||||
return false;
|
||||
|
||||
if ( player.isSneaking() )
|
||||
{
|
||||
int grids = 0;
|
||||
int totalNodes = 0;
|
||||
|
||||
for (Grid g : TickHandler.instance.getGridList())
|
||||
{
|
||||
grids++;
|
||||
totalNodes += g.getNodes().size();
|
||||
}
|
||||
|
||||
outputMsg( player, "Grids: " + grids );
|
||||
outputMsg( player, "Total Nodes: " + totalNodes );
|
||||
}
|
||||
else
|
||||
{
|
||||
TileEntity te = world.getTileEntity( x, y, z );
|
||||
|
||||
if ( te instanceof IGridHost )
|
||||
{
|
||||
GridNode node = (GridNode) ((IGridHost) te).getGridNode( ForgeDirection.getOrientation( side ) );
|
||||
if ( node != null )
|
||||
{
|
||||
Grid g = node.getInternalGrid();
|
||||
IGridNode center = g.getPivot();
|
||||
outputMsg( player, "This Node: " + node.toString() );
|
||||
outputMsg( player, "Center Node: " + center.toString() );
|
||||
|
||||
IPathingGrid pg = g.getCache( IPathingGrid.class );
|
||||
if ( pg.getControllerState() == ControllerState.CONTROLLER_ONLINE )
|
||||
{
|
||||
int length = 0;
|
||||
|
||||
HashSet<IGridNode> next = new HashSet();
|
||||
next.add( node );
|
||||
|
||||
int maxLength = 10000;
|
||||
|
||||
outer: while ( ! next.isEmpty() )
|
||||
{
|
||||
HashSet<IGridNode> current = next;
|
||||
next = new HashSet();
|
||||
|
||||
for ( IGridNode n : current )
|
||||
{
|
||||
if ( n.getMachine() instanceof TileController )
|
||||
break outer;
|
||||
|
||||
for ( IGridConnection c : n.getConnections() )
|
||||
next.add( c.getOtherSide( n ) );
|
||||
}
|
||||
|
||||
length++;
|
||||
|
||||
if ( length > maxLength )
|
||||
break;
|
||||
}
|
||||
|
||||
outputMsg( player, "Cable Distance: " + length );
|
||||
}
|
||||
|
||||
if ( center.getMachine() instanceof PartP2PTunnel )
|
||||
{
|
||||
outputMsg( player, "Freq: " + ((PartP2PTunnel) center.getMachine()).freq );
|
||||
}
|
||||
|
||||
TickManagerCache tmc = (TickManagerCache) g.getCache( ITickManager.class );
|
||||
for (Class c : g.getMachineClasses())
|
||||
{
|
||||
int o = 0;
|
||||
long nanos = 0;
|
||||
for (IGridNode oj : g.getMachines( c ))
|
||||
{
|
||||
o++;
|
||||
nanos += tmc.getAvgNanoTime( oj );
|
||||
}
|
||||
|
||||
if ( nanos < 0 )
|
||||
{
|
||||
outputMsg( player, c.getSimpleName() + " - " + o );
|
||||
}
|
||||
else
|
||||
{
|
||||
outputMsg( player, c.getSimpleName() + " - " + o + "; " + timeMeasurement( nanos ) );
|
||||
}
|
||||
}
|
||||
}
|
||||
else
|
||||
outputMsg( player, "No Node Available." );
|
||||
}
|
||||
else
|
||||
outputMsg( player, "Not Networked Block" );
|
||||
|
||||
if ( te instanceof IPartHost )
|
||||
{
|
||||
IPart center = ((IPartHost) te).getPart( ForgeDirection.UNKNOWN );
|
||||
((IPartHost) te).markForUpdate();
|
||||
if ( center != null )
|
||||
{
|
||||
GridNode n = (GridNode) center.getGridNode();
|
||||
outputMsg( player, "Node Channels: " + n.usedChannels() );
|
||||
for (IGridConnection gc : n.getConnections())
|
||||
{
|
||||
ForgeDirection fd = gc.getDirection( n );
|
||||
if ( fd != ForgeDirection.UNKNOWN )
|
||||
outputMsg( player, fd.toString() + ": " + gc.getUsedChannels() );
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if ( te instanceof IAEPowerStorage )
|
||||
{
|
||||
IAEPowerStorage ps = (IAEPowerStorage) te;
|
||||
outputMsg( player, "Energy: " + ps.getAECurrentPower() + " / " + ps.getAEMaxPower() );
|
||||
|
||||
if ( te instanceof IGridHost )
|
||||
{
|
||||
IGridNode node = (IGridNode) ((IGridHost) te).getGridNode( ForgeDirection.getOrientation( side ) );
|
||||
if ( node != null && node.getGrid() != null )
|
||||
{
|
||||
IEnergyGrid eg = node.getGrid().getCache( IEnergyGrid.class );
|
||||
outputMsg( player, "GridEnergy: " + eg.getStoredPower() + " : " + eg.getEnergyDemand( Double.MAX_VALUE ) );
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
private void outputMsg(EntityPlayer player, String string)
|
||||
{
|
||||
player.addChatMessage( new ChatComponentText( string ) );
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,83 @@
|
||||
package appeng.debug;
|
||||
|
||||
import java.util.EnumSet;
|
||||
import java.util.LinkedList;
|
||||
import java.util.List;
|
||||
|
||||
import net.minecraft.block.Block;
|
||||
import net.minecraft.client.renderer.texture.IIconRegister;
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.world.World;
|
||||
import appeng.api.util.WorldCoord;
|
||||
import appeng.client.texture.MissingIcon;
|
||||
import appeng.core.AELog;
|
||||
import appeng.core.features.AEFeature;
|
||||
import appeng.items.AEBaseItem;
|
||||
import appeng.util.Platform;
|
||||
|
||||
public class ToolEraser extends AEBaseItem
|
||||
{
|
||||
|
||||
public ToolEraser() {
|
||||
super( ToolEraser.class );
|
||||
setFeature( EnumSet.of( AEFeature.UnsupportedDeveloperTools, AEFeature.Creative ) );
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean onItemUseFirst(ItemStack stack, EntityPlayer player, World world, int x, int y, int z, int side, float hitX, float hitY, float hitZ)
|
||||
{
|
||||
if ( Platform.isClient() )
|
||||
return false;
|
||||
|
||||
Block blk = world.getBlock( x, y, z );
|
||||
int meta = world.getBlockMetadata( x, y, z );
|
||||
|
||||
int blocks = 0;
|
||||
List<WorldCoord> next = new LinkedList();
|
||||
next.add( new WorldCoord( x, y, z ) );
|
||||
|
||||
while (blocks < 90000 && !next.isEmpty())
|
||||
{
|
||||
|
||||
List<WorldCoord> c = next;
|
||||
next = new LinkedList();
|
||||
|
||||
for (WorldCoord wc : c)
|
||||
{
|
||||
Block c_blk = world.getBlock( wc.x, wc.y, wc.z );
|
||||
int c_meta = world.getBlockMetadata( wc.x, wc.y, wc.z );
|
||||
|
||||
if ( c_blk == blk && c_meta == meta )
|
||||
{
|
||||
blocks++;
|
||||
world.setBlock( wc.x, wc.y, wc.z, Platform.air );
|
||||
|
||||
check( world, wc.x + 1, wc.y, wc.z, next );
|
||||
check( world, wc.x - 1, wc.y, wc.z, next );
|
||||
check( world, wc.x, wc.y + 1, wc.z, next );
|
||||
check( world, wc.x, wc.y - 1, wc.z, next );
|
||||
check( world, wc.x, wc.y, wc.z + 1, next );
|
||||
check( world, wc.x, wc.y, wc.z - 1, next );
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
AELog.info( "Delete " + blocks + " blocks" );
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
private void check(World world, int i, int y, int z, List<WorldCoord> next)
|
||||
{
|
||||
next.add( new WorldCoord( i, y, z ) );
|
||||
}
|
||||
|
||||
@Override
|
||||
public void registerIcons(IIconRegister par1IconRegister)
|
||||
{
|
||||
itemIcon = new MissingIcon( this );
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,45 @@
|
||||
package appeng.debug;
|
||||
|
||||
import java.util.EnumSet;
|
||||
|
||||
import net.minecraft.client.renderer.texture.IIconRegister;
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.util.ChatComponentText;
|
||||
import net.minecraft.world.World;
|
||||
import appeng.client.texture.MissingIcon;
|
||||
import appeng.core.features.AEFeature;
|
||||
import appeng.helpers.MeteoritePlacer;
|
||||
import appeng.items.AEBaseItem;
|
||||
import appeng.util.Platform;
|
||||
|
||||
public class ToolMeteoritePlacer extends AEBaseItem
|
||||
{
|
||||
|
||||
public ToolMeteoritePlacer() {
|
||||
super( ToolMeteoritePlacer.class );
|
||||
setFeature( EnumSet.of( AEFeature.UnsupportedDeveloperTools, AEFeature.Creative ) );
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean onItemUseFirst(ItemStack stack, EntityPlayer player, World world, int x, int y, int z, int side, float hitX, float hitY, float hitZ)
|
||||
{
|
||||
if ( Platform.isClient() )
|
||||
return false;
|
||||
|
||||
MeteoritePlacer mp = new MeteoritePlacer();
|
||||
boolean worked = mp.spawnMeteorite( new MeteoritePlacer.StandardWorld( world ), x, y, z );
|
||||
|
||||
if ( !worked )
|
||||
player.addChatMessage( new ChatComponentText( "Un-suitable Location." ) );
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void registerIcons(IIconRegister par1IconRegister)
|
||||
{
|
||||
itemIcon = new MissingIcon( this );
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,142 @@
|
||||
package appeng.debug;
|
||||
|
||||
import java.util.EnumSet;
|
||||
|
||||
import net.minecraft.block.Block;
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.nbt.NBTTagCompound;
|
||||
import net.minecraft.tileentity.TileEntity;
|
||||
import net.minecraft.util.ChatComponentText;
|
||||
import net.minecraft.world.World;
|
||||
import net.minecraftforge.common.DimensionManager;
|
||||
import net.minecraftforge.common.util.ForgeDirection;
|
||||
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.DimensionalCoord;
|
||||
import appeng.core.features.AEFeature;
|
||||
import appeng.items.AEBaseItem;
|
||||
import appeng.util.Platform;
|
||||
|
||||
public class ToolReplicatorCard extends AEBaseItem
|
||||
{
|
||||
|
||||
public ToolReplicatorCard() {
|
||||
super( ToolReplicatorCard.class );
|
||||
setFeature( EnumSet.of( AEFeature.UnsupportedDeveloperTools, AEFeature.Creative ) );
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean onItemUseFirst(ItemStack stack, EntityPlayer player, World world, int x, int y, int z, int side, float hitX, float hitY, float hitZ)
|
||||
{
|
||||
if ( Platform.isClient() )
|
||||
return false;
|
||||
|
||||
if ( player.isSneaking() )
|
||||
{
|
||||
if ( world.getTileEntity( x, y, z ) instanceof IGridHost )
|
||||
{
|
||||
NBTTagCompound tag = new NBTTagCompound();
|
||||
tag.setInteger( "x", x );
|
||||
tag.setInteger( "y", y );
|
||||
tag.setInteger( "z", z );
|
||||
tag.setInteger( "side", side );
|
||||
tag.setInteger( "dimid", world.provider.dimensionId );
|
||||
stack.setTagCompound( tag );
|
||||
}
|
||||
else
|
||||
outputMsg( player, "This is not a Grid Tile." );
|
||||
}
|
||||
else
|
||||
{
|
||||
NBTTagCompound ish = stack.getTagCompound();
|
||||
if ( ish != null )
|
||||
{
|
||||
int src_x = ish.getInteger( "x" );
|
||||
int src_y = ish.getInteger( "y" );
|
||||
int src_z = ish.getInteger( "z" );
|
||||
int src_side = ish.getInteger( "side" );
|
||||
int dimid = ish.getInteger( "dimid" );
|
||||
World src_w = DimensionManager.getWorld( dimid );
|
||||
|
||||
TileEntity te = src_w.getTileEntity( src_x, src_y, src_z );
|
||||
if ( te instanceof IGridHost )
|
||||
{
|
||||
IGridHost gh = (IGridHost) te;
|
||||
ForgeDirection sideOff = ForgeDirection.getOrientation( src_side );
|
||||
ForgeDirection currentSideOff = ForgeDirection.getOrientation( side );
|
||||
IGridNode n = gh.getGridNode( sideOff );
|
||||
if ( n != null )
|
||||
{
|
||||
IGrid g = n.getGrid();
|
||||
if ( g != null )
|
||||
{
|
||||
ISpatialCache sc = g.getCache( ISpatialCache.class );
|
||||
if ( sc.isValidRegion() )
|
||||
{
|
||||
DimensionalCoord min = sc.getMin();
|
||||
DimensionalCoord max = sc.getMax();
|
||||
|
||||
x += currentSideOff.offsetX;
|
||||
y += currentSideOff.offsetY;
|
||||
z += currentSideOff.offsetZ;
|
||||
|
||||
int min_x = min.x;
|
||||
int min_y = min.y;
|
||||
int min_z = min.z;
|
||||
|
||||
int rel_x = min.x - src_x + x;
|
||||
int rel_y = min.y - src_y + y;
|
||||
int rel_z = min.z - src_z + z;
|
||||
|
||||
int scale_x = max.x - min.x;
|
||||
int scale_y = max.y - min.y;
|
||||
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++)
|
||||
{
|
||||
Block blk = src_w.getBlock( min_x + i, min_y + j, min_z + k );
|
||||
int meta = src_w.getBlockMetadata( min_x + i, min_y + j, min_z + k );
|
||||
world.setBlock( i + rel_x, j + rel_y, k + rel_z, blk, meta, 4 );
|
||||
|
||||
if ( blk != null && blk.hasTileEntity( meta ) )
|
||||
{
|
||||
TileEntity ote = src_w.getTileEntity( min_x + i, min_y + j, min_z + k );
|
||||
TileEntity nte = blk.createTileEntity( world, meta );
|
||||
NBTTagCompound data = new NBTTagCompound();
|
||||
ote.writeToNBT( data );
|
||||
nte.readFromNBT( (NBTTagCompound) data.copy() );
|
||||
world.setTileEntity( i + rel_x, j + rel_y, k + rel_z, nte );
|
||||
}
|
||||
world.markBlockForUpdate( i + rel_x, j + rel_y, k + rel_z );
|
||||
}
|
||||
|
||||
}
|
||||
else
|
||||
outputMsg( player, "requires valid spatial pylon setup." );
|
||||
}
|
||||
else
|
||||
outputMsg( player, "no grid?" );
|
||||
}
|
||||
else
|
||||
outputMsg( player, "No grid node?" );
|
||||
}
|
||||
else
|
||||
outputMsg( player, "Src is no longer a grid block?" );
|
||||
}
|
||||
else
|
||||
outputMsg( player, "No Source Defined" );
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
private void outputMsg(EntityPlayer player, String string)
|
||||
{
|
||||
player.addChatMessage( new ChatComponentText( string ) );
|
||||
}
|
||||
|
||||
}
|
||||
Reference in New Issue
Block a user