Most of the 1.8 Port.

This commit is contained in:
AlgorithmX2
2015-06-15 19:44:59 -05:00
parent 17465e68e8
commit 38afde724b
824 changed files with 12120 additions and 9158 deletions
+30 -3
View File
@@ -22,18 +22,22 @@ package appeng.items;
import java.util.EnumSet;
import java.util.List;
import com.google.common.base.Optional;
import net.minecraft.client.renderer.texture.TextureMap;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.item.Item;
import net.minecraft.item.ItemStack;
import net.minecraftforge.fml.relauncher.Side;
import net.minecraftforge.fml.relauncher.SideOnly;
import appeng.client.ClientHelper;
import appeng.client.texture.IAESprite;
import appeng.core.features.AEFeature;
import appeng.core.features.FeatureNameExtractor;
import appeng.core.features.IAEFeature;
import appeng.core.features.IFeatureHandler;
import appeng.core.features.ItemFeatureHandler;
import com.google.common.base.Optional;
public abstract class AEBaseItem extends Item implements IAEFeature
{
@@ -93,4 +97,27 @@ public abstract class AEBaseItem extends Item implements IAEFeature
{
super.addInformation( stack, player, lines, displayMoreInfo );
}
@SideOnly(Side.CLIENT)
protected IAESprite myIcon = null;
@SideOnly(Side.CLIENT)
public void registerIcons(
ClientHelper proxy, String name )
{
proxy.setIcon( this, 0, name );
}
public IAESprite getIcon(
ItemStack is )
{
return myIcon;
}
@SideOnly(Side.CLIENT)
public void registerCustomIcon(
TextureMap map )
{
}
}
@@ -20,7 +20,6 @@ package appeng.items.contents;
import net.minecraft.item.ItemStack;
import appeng.tile.inventory.AppEngInternalInventory;
import appeng.util.Platform;
@@ -20,7 +20,6 @@ package appeng.items.contents;
import net.minecraft.item.ItemStack;
import appeng.parts.automation.StackUpgradeInventory;
import appeng.util.Platform;
@@ -21,7 +21,7 @@ package appeng.items.contents;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.item.ItemStack;
import net.minecraft.util.IChatComponent;
import appeng.api.implementations.guiobjects.INetworkTool;
import appeng.api.implementations.items.IUpgradeModule;
import appeng.api.networking.IGridHost;
@@ -78,15 +78,15 @@ public class NetworkToolViewer implements INetworkTool
}
@Override
public String getInventoryName()
public String getName()
{
return this.inv.getInventoryName();
return this.inv.getName();
}
@Override
public boolean hasCustomInventoryName()
public boolean hasCustomName()
{
return this.inv.hasCustomInventoryName();
return this.inv.hasCustomName();
}
@Override
@@ -109,15 +109,15 @@ public class NetworkToolViewer implements INetworkTool
}
@Override
public void openInventory()
public void openInventory(EntityPlayer player)
{
this.inv.openInventory();
this.inv.openInventory(player);
}
@Override
public void closeInventory()
public void closeInventory(EntityPlayer player)
{
this.inv.closeInventory();
this.inv.closeInventory(player);
}
@Override
@@ -137,4 +137,37 @@ public class NetworkToolViewer implements INetworkTool
{
return this.gh;
}
@Override
public int getField(
int id )
{
return inv.getField( id );
}
@Override
public void setField(
int id,
int value )
{
inv.setField( id, value );
}
@Override
public int getFieldCount()
{
return inv.getFieldCount();
}
@Override
public void clear()
{
inv.clear();
}
@Override
public IChatComponent getDisplayName()
{
return inv.getDisplayName();
}
}
@@ -21,7 +21,6 @@ package appeng.items.contents;
import net.minecraft.item.ItemStack;
import net.minecraft.nbt.NBTTagCompound;
import appeng.api.config.Actionable;
import appeng.api.config.PowerMultiplier;
import appeng.api.config.Settings;
@@ -20,7 +20,6 @@ package appeng.items.contents;
import net.minecraft.item.ItemStack;
import appeng.api.implementations.guiobjects.IGuiItemObject;
@@ -31,10 +31,6 @@ import java.util.Map.Entry;
import java.util.regex.Matcher;
import java.util.regex.Pattern;
import com.google.common.base.Preconditions;
import com.google.common.collect.ImmutableSet;
import net.minecraft.client.renderer.texture.IIconRegister;
import net.minecraft.creativetab.CreativeTabs;
import net.minecraft.entity.Entity;
import net.minecraft.entity.item.EntityItem;
@@ -44,12 +40,13 @@ import net.minecraft.item.Item;
import net.minecraft.item.ItemStack;
import net.minecraft.nbt.NBTTagCompound;
import net.minecraft.tileentity.TileEntity;
import net.minecraft.util.IIcon;
import net.minecraft.util.BlockPos;
import net.minecraft.util.EnumFacing;
import net.minecraft.util.Vec3;
import net.minecraft.world.World;
import net.minecraftforge.common.util.ForgeDirection;
import net.minecraftforge.fml.relauncher.Side;
import net.minecraftforge.fml.relauncher.SideOnly;
import net.minecraftforge.oredict.OreDictionary;
import appeng.api.config.Upgrades;
import appeng.api.implementations.IUpgradeableHost;
import appeng.api.implementations.items.IItemGroup;
@@ -58,7 +55,7 @@ import appeng.api.implementations.items.IUpgradeModule;
import appeng.api.implementations.tiles.ISegmentedInventory;
import appeng.api.parts.IPartHost;
import appeng.api.parts.SelectedPart;
import appeng.client.texture.MissingIcon;
import appeng.client.ClientHelper;
import appeng.core.AEConfig;
import appeng.core.features.AEFeature;
import appeng.core.features.IStackSrc;
@@ -68,6 +65,9 @@ import appeng.items.AEBaseItem;
import appeng.util.InventoryAdaptor;
import appeng.util.Platform;
import com.google.common.base.Preconditions;
import com.google.common.collect.ImmutableSet;
public final class ItemMultiMaterial extends AEBaseItem implements IStorageComponent, IUpgradeModule
{
@@ -258,22 +258,25 @@ public final class ItemMultiMaterial extends AEBaseItem implements IStorageCompo
}
}
@Override
public IIcon getIconFromDamage( int dmg )
{
if( this.dmgToMaterial.containsKey( dmg ) )
{
return this.dmgToMaterial.get( dmg ).IIcon;
}
return new MissingIcon( this );
}
@Override
public String getUnlocalizedName( ItemStack is )
{
return "item.appliedenergistics2." + this.nameOf( is );
}
@Override
@SideOnly(Side.CLIENT)
public void registerIcons(
ClientHelper proxy,
String name )
{
for ( MaterialType type : MaterialType.values() )
{
if ( type != MaterialType.InvalidType )
proxy.setIcon( this, type.damageValue, name +"."+ type.name() );
}
}
private String nameOf( ItemStack is )
{
if( is == null )
@@ -314,33 +317,24 @@ public final class ItemMultiMaterial extends AEBaseItem implements IStorageCompo
}
@Override
public void registerIcons( IIconRegister icoRegister )
{
for( MaterialType mat : MaterialType.values() )
{
if( mat.damageValue != -1 )
{
ItemStack what = new ItemStack( this, 1, mat.damageValue );
if( this.getTypeByStack( what ) != MaterialType.InvalidType )
{
String tex = "appliedenergistics2:" + this.nameOf( what );
mat.IIcon = icoRegister.registerIcon( tex );
}
}
}
}
@Override
public boolean onItemUseFirst( ItemStack is, EntityPlayer player, World world, int x, int y, int z, int side, float hitX, float hitY, float hitZ )
public boolean onItemUseFirst(
ItemStack is,
EntityPlayer player,
World world,
BlockPos pos,
EnumFacing side,
float hitX,
float hitY,
float hitZ )
{
if( player.isSneaking() )
{
TileEntity te = world.getTileEntity( x, y, z );
TileEntity te = world.getTileEntity( pos );
IInventory upgrades = null;
if( te instanceof IPartHost )
{
SelectedPart sp = ( (IPartHost) te ).selectPart( Vec3.createVectorHelper( hitX, hitY, hitZ ) );
SelectedPart sp = ( (IPartHost) te ).selectPart( new Vec3( hitX, hitY, hitZ ) );
if( sp.part instanceof IUpgradeableHost )
{
upgrades = ( (ISegmentedInventory) sp.part ).getInventoryByName( "upgrades" );
@@ -358,7 +352,7 @@ public final class ItemMultiMaterial extends AEBaseItem implements IStorageCompo
if( u != null )
{
InventoryAdaptor ad = InventoryAdaptor.getAdaptor( upgrades, ForgeDirection.UNKNOWN );
InventoryAdaptor ad = InventoryAdaptor.getAdaptor( upgrades, EnumFacing.UP );
if( ad != null )
{
if( player.worldObj.isRemote )
@@ -373,7 +367,7 @@ public final class ItemMultiMaterial extends AEBaseItem implements IStorageCompo
}
}
return super.onItemUseFirst( is, player, world, x, y, z, side, hitX, hitY, hitZ );
return super.onItemUseFirst( is, player, world, pos, side, hitX, hitY, hitZ );
}
@Override
@@ -403,7 +397,9 @@ public final class ItemMultiMaterial extends AEBaseItem implements IStorageCompo
if( location instanceof EntityItem && eqi instanceof EntityItem )
{
( (EntityItem) eqi ).delayBeforeCanPickup = ( (EntityItem) location ).delayBeforeCanPickup;
// TODO: Entity Pick up time?
// needs fixing?
// ( (EntityItem) eqi ).setPickupDelay( ( (EntityItem) location ).pick;
}
return eqi;
@@ -21,15 +21,13 @@ package appeng.items.materials;
import java.util.EnumSet;
import net.minecraft.client.renderer.texture.TextureAtlasSprite;
import net.minecraft.entity.Entity;
import net.minecraft.item.Item;
import net.minecraft.item.ItemStack;
import net.minecraft.util.IIcon;
import cpw.mods.fml.common.registry.EntityRegistry;
import cpw.mods.fml.relauncher.Side;
import cpw.mods.fml.relauncher.SideOnly;
import net.minecraftforge.fml.common.registry.EntityRegistry;
import net.minecraftforge.fml.relauncher.Side;
import net.minecraftforge.fml.relauncher.SideOnly;
import appeng.core.AppEng;
import appeng.core.features.AEFeature;
import appeng.core.features.MaterialStackSrc;
@@ -85,9 +83,9 @@ public enum MaterialType
BlankPattern( 52 ), CardCrafting( 53 );
private final EnumSet<AEFeature> features;
// IIcon for the material.
// TextureAtlasSprite for the material.
@SideOnly( Side.CLIENT )
public IIcon IIcon;
public TextureAtlasSprite IIcon;
public Item itemInstance;
public int damageValue;
// stack!
@@ -21,28 +21,30 @@ package appeng.items.misc;
import java.util.EnumSet;
import java.util.List;
import javax.annotation.Nullable;
import net.minecraft.block.Block;
import net.minecraft.block.material.Material;
import net.minecraft.client.renderer.texture.IIconRegister;
import net.minecraft.client.Minecraft;
import net.minecraft.client.renderer.ItemMeshDefinition;
import net.minecraft.client.resources.model.ModelResourceLocation;
import net.minecraft.creativetab.CreativeTabs;
import net.minecraft.entity.Entity;
import net.minecraft.entity.item.EntityItem;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.init.Items;
import net.minecraft.item.Item;
import net.minecraft.item.ItemStack;
import net.minecraft.nbt.NBTTagCompound;
import net.minecraft.util.IIcon;
import net.minecraft.world.World;
import cpw.mods.fml.common.registry.EntityRegistry;
import net.minecraftforge.fml.common.registry.EntityRegistry;
import net.minecraftforge.fml.relauncher.Side;
import net.minecraftforge.fml.relauncher.SideOnly;
import appeng.api.AEApi;
import appeng.api.definitions.IMaterials;
import appeng.api.implementations.items.IGrowableCrystal;
import appeng.api.recipes.ResolverResult;
import appeng.client.ClientHelper;
import appeng.core.AppEng;
import appeng.core.features.AEFeature;
import appeng.core.localization.ButtonToolTips;
@@ -63,9 +65,9 @@ public class ItemCrystalSeed extends AEBaseItem implements IGrowableCrystal
public static final int FLUIX = SINGLE_OFFSET * 2;
public static final int FINAL_STAGE = SINGLE_OFFSET * 3;
final IIcon[] certus = new IIcon[3];
final IIcon[] fluix = new IIcon[3];
final IIcon[] nether = new IIcon[3];
final ModelResourceLocation[] certus = new ModelResourceLocation[3];
final ModelResourceLocation[] fluix = new ModelResourceLocation[3];
final ModelResourceLocation[] nether = new ModelResourceLocation[3];
public ItemCrystalSeed()
{
@@ -75,6 +77,71 @@ public class ItemCrystalSeed extends AEBaseItem implements IGrowableCrystal
EntityRegistry.registerModEntity( EntityGrowingCrystal.class, EntityGrowingCrystal.class.getSimpleName(), EntityIds.get( EntityGrowingCrystal.class ), AppEng.instance(), 16, 4, true );
}
@Override
@SideOnly(Side.CLIENT)
public void registerIcons( ClientHelper ir, String name )
{
String preFix = name+".";
this.certus[0] = ir.setIcon( this, preFix + "Certus" );
this.certus[1] = ir.setIcon( this, preFix + "Certus2" );
this.certus[2] = ir.setIcon( this, preFix + "Certus3" );
this.nether[0] = ir.setIcon( this, preFix + "Nether" );
this.nether[1] = ir.setIcon( this, preFix + "Nether2" );
this.nether[2] = ir.setIcon( this, preFix + "Nether3" );
this.fluix[0] = ir.setIcon( this, preFix + "Fluix" );
this.fluix[1] = ir.setIcon( this, preFix + "Fluix2" );
this.fluix[2] = ir.setIcon( this, preFix + "Fluix3" );
Minecraft.getMinecraft().getRenderItem().getItemModelMesher().register( this, new ItemMeshDefinition(){
@Override
public ModelResourceLocation getModelLocation(
ItemStack stack )
{
ModelResourceLocation[] list = null;
int damage = getProgress( stack );
if( damage < CERTUS + SINGLE_OFFSET )
{
list = certus;
}
else if( damage < NETHER + SINGLE_OFFSET )
{
damage -= NETHER;
list = nether;
}
else if( damage < FLUIX + SINGLE_OFFSET )
{
damage -= FLUIX;
list = fluix;
}
if( list == null )
{
return new ModelResourceLocation( "diamond" );
}
if( damage < LEVEL_OFFSET )
{
return list[0];
}
else if( damage < LEVEL_OFFSET * 2 )
{
return list[1];
}
else
{
return list[2];
}
}
});
}
@Nullable
public static ResolverResult getResolver( int certus2 )
{
@@ -220,72 +287,6 @@ public class ItemCrystalSeed extends AEBaseItem implements IGrowableCrystal
return FINAL_STAGE;
}
@Override
public IIcon getIcon( ItemStack stack, int pass )
{
return this.getIconIndex( stack );
}
@Override
public IIcon getIconIndex( ItemStack stack )
{
IIcon[] list = null;
int damage = this.getProgress( stack );
if( damage < CERTUS + SINGLE_OFFSET )
{
list = this.certus;
}
else if( damage < NETHER + SINGLE_OFFSET )
{
damage -= NETHER;
list = this.nether;
}
else if( damage < FLUIX + SINGLE_OFFSET )
{
damage -= FLUIX;
list = this.fluix;
}
if( list == null )
{
return Items.diamond.getIconFromDamage( 0 );
}
if( damage < LEVEL_OFFSET )
{
return list[0];
}
else if( damage < LEVEL_OFFSET * 2 )
{
return list[1];
}
else
{
return list[2];
}
}
@Override
public void registerIcons( IIconRegister ir )
{
String preFix = "appliedenergistics2:ItemCrystalSeed.";
this.certus[0] = ir.registerIcon( preFix + "Certus" );
this.certus[1] = ir.registerIcon( preFix + "Certus2" );
this.certus[2] = ir.registerIcon( preFix + "Certus3" );
this.nether[0] = ir.registerIcon( preFix + "Nether" );
this.nether[1] = ir.registerIcon( preFix + "Nether2" );
this.nether[2] = ir.registerIcon( preFix + "Nether3" );
this.fluix[0] = ir.registerIcon( preFix + "Fluix" );
this.fluix[1] = ir.registerIcon( preFix + "Fluix2" );
this.fluix[2] = ir.registerIcon( preFix + "Fluix3" );
}
@Override
public boolean hasCustomEntity( ItemStack stack )
{
@@ -303,7 +304,9 @@ public class ItemCrystalSeed extends AEBaseItem implements IGrowableCrystal
if( location instanceof EntityItem )
{
egc.delayBeforeCanPickup = ( (EntityItem) location ).delayBeforeCanPickup;
// TODO: DELAY BEFORE PICKUP
// NEEDS FIXING?!?!
// egc.delayBeforeCanPickup = ( (EntityItem) location ).delayBeforeCanPickup;
}
return egc;
@@ -24,18 +24,23 @@ import java.util.List;
import java.util.Map;
import java.util.WeakHashMap;
import net.minecraft.client.Minecraft;
import net.minecraft.client.renderer.ItemMeshDefinition;
import net.minecraft.client.resources.model.ModelResourceLocation;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.entity.player.InventoryPlayer;
import net.minecraft.item.ItemStack;
import net.minecraft.util.BlockPos;
import net.minecraft.util.EnumChatFormatting;
import net.minecraft.util.EnumFacing;
import net.minecraft.world.World;
import net.minecraftforge.client.MinecraftForgeClient;
import net.minecraftforge.fml.relauncher.Side;
import net.minecraftforge.fml.relauncher.SideOnly;
import appeng.api.AEApi;
import appeng.api.implementations.ICraftingPatternItem;
import appeng.api.networking.crafting.ICraftingPatternDetails;
import appeng.api.storage.data.IAEItemStack;
import appeng.client.render.items.ItemEncodedPatternRenderer;
import appeng.client.ClientHelper;
import appeng.core.CommonHelper;
import appeng.core.features.AEFeature;
import appeng.core.localization.GuiText;
@@ -53,12 +58,50 @@ public class ItemEncodedPattern extends AEBaseItem implements ICraftingPatternIt
{
this.setFeature( EnumSet.of( AEFeature.Patterns ) );
this.setMaxStackSize( 1 );
if( Platform.isClient() )
{
MinecraftForgeClient.registerItemRenderer( this, new ItemEncodedPatternRenderer() );
}
}
@SideOnly(Side.CLIENT)
ModelResourceLocation res;
@SideOnly(Side.CLIENT)
ModelResourceLocation encodedPatternModel; // TODO: make encoded pattern model!
@Override
public void registerIcons(
ClientHelper proxy,
String name )
{
encodedPatternModel = res = proxy.setIcon( this, name );
Minecraft.getMinecraft().getRenderItem().getItemModelMesher().register( this, new ItemMeshDefinition(){
boolean recursive = false;
@Override
public ModelResourceLocation getModelLocation(
ItemStack stack )
{
if ( recursive == false )
{
this.recursive = true;
ItemEncodedPattern iep = (ItemEncodedPattern) stack.getItem();
ItemStack is = iep.getOutput( stack );
if ( Minecraft.getMinecraft().thePlayer.isSneaking() )
{
return encodedPatternModel;
}
this.recursive = false;
}
return res;
}
});
}
@Override
public ItemStack onItemRightClick( ItemStack stack, World w, EntityPlayer player )
{
@@ -68,7 +111,15 @@ public class ItemEncodedPattern extends AEBaseItem implements ICraftingPatternIt
}
@Override
public boolean onItemUseFirst( ItemStack stack, EntityPlayer player, World world, int x, int y, int z, int side, float hitX, float hitY, float hitZ )
public boolean onItemUseFirst(
ItemStack stack,
EntityPlayer player,
World world,
BlockPos pos,
EnumFacing side,
float hitX,
float hitY,
float hitZ )
{
return this.clearPattern( stack, player );
}
@@ -22,17 +22,19 @@ package appeng.items.misc;
import java.util.EnumSet;
import java.util.List;
import net.minecraft.client.Minecraft;
import net.minecraft.client.renderer.ItemMeshDefinition;
import net.minecraft.client.resources.model.ModelResourceLocation;
import net.minecraft.creativetab.CreativeTabs;
import net.minecraft.item.Item;
import net.minecraft.item.ItemStack;
import net.minecraftforge.client.MinecraftForgeClient;
import net.minecraftforge.fml.relauncher.Side;
import net.minecraftforge.fml.relauncher.SideOnly;
import appeng.api.util.AEColor;
import appeng.client.render.items.PaintBallRender;
import appeng.client.ClientHelper;
import appeng.core.features.AEFeature;
import appeng.core.localization.GuiText;
import appeng.items.AEBaseItem;
import appeng.util.Platform;
public class ItemPaintBall extends AEBaseItem
@@ -44,13 +46,30 @@ public class ItemPaintBall extends AEBaseItem
{
this.setFeature( EnumSet.of( AEFeature.PaintBalls ) );
this.setHasSubtypes( true );
if( Platform.isClient() )
{
MinecraftForgeClient.registerItemRenderer( this, new PaintBallRender() );
}
}
@Override
@SideOnly(Side.CLIENT)
public void registerIcons( ClientHelper ir, String name )
{
final ModelResourceLocation sloc = ir.setIcon( this, name + "Shimmer" );
final ModelResourceLocation loc = ir.setIcon( this, name );
Minecraft.getMinecraft().getRenderItem().getItemModelMesher().register( this, new ItemMeshDefinition(){
@Override
public ModelResourceLocation getModelLocation(
ItemStack stack )
{
if ( isLumen(stack) )
return sloc;
return loc;
}
});
}
@Override
public String getItemStackDisplayName( ItemStack is )
{
@@ -61,6 +80,31 @@ public class ItemPaintBall extends AEBaseItem
{
return ( is.getItemDamage() >= DAMAGE_THRESHOLD ? GuiText.Lumen.getLocal() + ' ' : "" ) + this.getColor( is );
}
@Override
public int getColorFromItemStack(
ItemStack stack,
int renderPass )
{
AEColor col = getColor(stack);
int colorValue = stack.getItemDamage() >= 20 ? col.mediumVariant : col.mediumVariant;
int r = ( colorValue >> 16 ) & 0xff;
int g = ( colorValue >> 8 ) & 0xff;
int b = ( colorValue ) & 0xff;
int full = (int) ( 255 * 0.3 );
float fail = 0.7f;
if( stack.getItemDamage() >= 20 )
{
return (int)( full + r * fail ) << 16 | (int)( full + g * fail ) << 8 | (int)( full + b * fail ) | 0xff << 24;
}
else
{
return r << 16 | g << 8 | b | 0xff << 24 ;
}
}
public AEColor getColor( ItemStack is )
{
@@ -26,6 +26,7 @@ import java.util.List;
import net.minecraft.block.Block;
import net.minecraft.block.BlockGlass;
import net.minecraft.block.BlockStainedGlass;
import net.minecraft.client.renderer.texture.TextureMap;
import net.minecraft.creativetab.CreativeTabs;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.init.Blocks;
@@ -33,26 +34,25 @@ import net.minecraft.init.Items;
import net.minecraft.item.Item;
import net.minecraft.item.ItemStack;
import net.minecraft.nbt.NBTTagCompound;
import net.minecraft.util.BlockPos;
import net.minecraft.util.EnumFacing;
import net.minecraft.util.EnumWorldBlockLayer;
import net.minecraft.util.ResourceLocation;
import net.minecraft.world.World;
import net.minecraftforge.client.MinecraftForgeClient;
import net.minecraftforge.common.util.ForgeDirection;
import cpw.mods.fml.common.registry.GameRegistry;
import cpw.mods.fml.common.registry.GameRegistry.UniqueIdentifier;
import cpw.mods.fml.relauncher.Side;
import cpw.mods.fml.relauncher.SideOnly;
import net.minecraftforge.fml.common.registry.GameRegistry;
import net.minecraftforge.fml.common.registry.GameRegistry.UniqueIdentifier;
import appeng.api.AEApi;
import appeng.api.exceptions.MissingDefinition;
import appeng.api.parts.IAlphaPassItem;
import appeng.api.util.AEPartLocation;
import appeng.block.solids.OreQuartz;
import appeng.client.render.BusRenderer;
import appeng.client.texture.BaseIcon;
import appeng.core.AppEng;
import appeng.core.FacadeConfig;
import appeng.core.features.AEFeature;
import appeng.facade.FacadePart;
import appeng.facade.IFacadeItem;
import appeng.items.AEBaseItem;
import appeng.util.Platform;
public class ItemFacade extends AEBaseItem implements IFacadeItem, IAlphaPassItem
@@ -64,23 +64,20 @@ public class ItemFacade extends AEBaseItem implements IFacadeItem, IAlphaPassIte
{
this.setFeature( EnumSet.of( AEFeature.Facades ) );
this.setHasSubtypes( true );
if( Platform.isClient() )
{
MinecraftForgeClient.registerItemRenderer( this, BusRenderer.INSTANCE );
}
}
@Override
@SideOnly( Side.CLIENT )
public int getSpriteNumber()
public boolean onItemUseFirst(
ItemStack is,
EntityPlayer player,
World world,
BlockPos pos,
EnumFacing side,
float hitX,
float hitY,
float hitZ )
{
return 0;
}
@Override
public boolean onItemUse( ItemStack is, EntityPlayer player, World w, int x, int y, int z, int side, float hitX, float hitY, float hitZ )
{
return AEApi.instance().partHelper().placeBus( is, x, y, z, side, player, w );
return AEApi.instance().partHelper().placeBus( is, pos, side, player, world );
}
@Override
@@ -160,7 +157,7 @@ public class ItemFacade extends AEBaseItem implements IFacadeItem, IAlphaPassIte
int metadata = l.getItem().getMetadata( l.getItemDamage() );
boolean hasTile = b.hasTileEntity( metadata );
boolean hasTile = b.hasTileEntity( b.getStateFromMeta( metadata ) );
boolean enableGlass = b instanceof BlockGlass || b instanceof BlockStainedGlass;
boolean disableOre = b instanceof OreQuartz;
@@ -188,7 +185,7 @@ public class ItemFacade extends AEBaseItem implements IFacadeItem, IAlphaPassIte
}
@Override
public FacadePart createPartFromItemStack( ItemStack is, ForgeDirection side )
public FacadePart createPartFromItemStack( ItemStack is, AEPartLocation side )
{
ItemStack in = this.getTextureItem( is );
if( in != null )
@@ -232,6 +229,9 @@ public class ItemFacade extends AEBaseItem implements IFacadeItem, IAlphaPassIte
{
if( data.hasKey( "modid" ) && data.hasKey( "itemname" ) )
{
if ( data.getString( "modid" ).equals( "minecraft" ) )
return Block.getBlockFromName( data.getString( "itemname" ) );
return GameRegistry.findBlock( data.getString( "modid" ), data.getString( "itemname" ) );
}
else
@@ -287,11 +287,18 @@ public class ItemFacade extends AEBaseItem implements IFacadeItem, IAlphaPassIte
}
Block blk = Block.getBlockFromItem( out.getItem() );
if( blk != null && blk.canRenderInPass( 1 ) )
if( blk != null && blk.canRenderInLayer( EnumWorldBlockLayer.TRANSLUCENT ) )
{
return true;
}
return false;
}
@Override
public void registerCustomIcon(
TextureMap map )
{
myIcon = new BaseIcon( map.registerSprite( new ResourceLocation( AppEng.MOD_ID, "blocks/ItemFacade" ) ));
}
}
@@ -33,26 +33,28 @@ import java.util.Set;
import javax.annotation.Nonnull;
import javax.annotation.Nullable;
import com.google.common.base.Preconditions;
import net.minecraft.client.renderer.texture.IIconRegister;
import net.minecraft.client.renderer.texture.TextureMap;
import net.minecraft.creativetab.CreativeTabs;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.item.Item;
import net.minecraft.item.ItemStack;
import net.minecraft.util.IIcon;
import net.minecraft.util.BlockPos;
import net.minecraft.util.EnumFacing;
import net.minecraft.util.ResourceLocation;
import net.minecraft.world.World;
import cpw.mods.fml.relauncher.Side;
import cpw.mods.fml.relauncher.SideOnly;
import net.minecraftforge.fml.relauncher.Side;
import net.minecraftforge.fml.relauncher.SideOnly;
import appeng.api.AEApi;
import appeng.api.implementations.items.IItemGroup;
import appeng.api.parts.IPart;
import appeng.api.parts.IPartHelper;
import appeng.api.parts.IPartItem;
import appeng.api.util.AEColor;
import appeng.client.texture.BaseIcon;
import appeng.client.texture.IAESprite;
import appeng.client.texture.MissingIcon;
import appeng.core.AEConfig;
import appeng.core.AppEng;
import appeng.core.features.AEFeature;
import appeng.core.features.ItemStackSrc;
import appeng.core.features.NameResolver;
@@ -61,6 +63,8 @@ import appeng.integration.IntegrationRegistry;
import appeng.integration.IntegrationType;
import appeng.items.AEBaseItem;
import com.google.common.base.Preconditions;
public final class ItemMultiPart extends AEBaseItem implements IPartItem, IItemGroup
{
@@ -171,22 +175,17 @@ public final class ItemMultiPart extends AEBaseItem implements IPartItem, IItemG
}
@Override
@SideOnly( Side.CLIENT )
public int getSpriteNumber()
public boolean onItemUse(
ItemStack is,
EntityPlayer player,
World w,
BlockPos pos,
EnumFacing side,
float hitX,
float hitY,
float hitZ )
{
return 0;
}
@Override
public IIcon getIconFromDamage( int dmg )
{
return this.registered.get( dmg ).ico;
}
@Override
public boolean onItemUse( ItemStack is, EntityPlayer player, World w, int x, int y, int z, int side, float hitX, float hitY, float hitZ )
{
return AEApi.instance().partHelper().placeBus( is, x, y, z, side, player, w );
return AEApi.instance().partHelper().placeBus( is, pos, side, player, w );
}
@Override
@@ -195,6 +194,31 @@ public final class ItemMultiPart extends AEBaseItem implements IPartItem, IItemG
return "item.appliedenergistics2." + this.getName( is );
}
@Override
@SideOnly(Side.CLIENT)
public void registerCustomIcon(
TextureMap map )
{
for( Entry<Integer, PartTypeWithVariant> part : this.registered.entrySet() )
{
part.getValue().texture= new BaseIcon( map.registerSprite( new ResourceLocation( AppEng.MOD_ID, "blocks/" + this.getName( new ItemStack( this, 1, part.getKey() ) ) )) );
}
}
@Override
public IAESprite getIcon(
ItemStack is )
{
for( Entry<Integer, PartTypeWithVariant> part : this.registered.entrySet() )
{
if ( is.getMetadata() == part.getKey() )
return part.getValue().texture;
}
return new MissingIcon( this );
}
@Override
public String getItemStackDisplayName( ItemStack is )
{
@@ -227,16 +251,6 @@ public final class ItemMultiPart extends AEBaseItem implements IPartItem, IItemG
}
}
@Override
public void registerIcons( IIconRegister par1IconRegister )
{
for( Entry<Integer, PartTypeWithVariant> part : this.registered.entrySet() )
{
String tex = "appliedenergistics2:" + this.getName( new ItemStack( this, 1, part.getKey() ) );
part.getValue().ico = par1IconRegister.registerIcon( tex );
}
}
public String getName( ItemStack is )
{
Preconditions.checkNotNull( is );
@@ -358,9 +372,9 @@ public final class ItemMultiPart extends AEBaseItem implements IPartItem, IItemG
private final PartType part;
private final int variant;
@SideOnly( Side.CLIENT )
private IIcon ico;
@SideOnly(Side.CLIENT)
public IAESprite texture = null;
private PartTypeWithVariant( PartType part, int variant )
{
assert part != null;
@@ -379,4 +393,5 @@ public final class ItemMultiPart extends AEBaseItem implements IPartItem, IItemG
return o1.getValue().part.name().compareTo( o2.getValue().part.name() );
}
}
}
@@ -31,9 +31,9 @@ import appeng.integration.IntegrationType;
import appeng.parts.automation.PartAnnihilationPlane;
import appeng.parts.automation.PartExportBus;
import appeng.parts.automation.PartFormationPlane;
import appeng.parts.automation.PartIdentityAnnihilationPlane;
import appeng.parts.automation.PartImportBus;
import appeng.parts.automation.PartLevelEmitter;
import appeng.parts.automation.PartIdentityAnnihilationPlane;
import appeng.parts.misc.PartCableAnchor;
import appeng.parts.misc.PartInterface;
import appeng.parts.misc.PartInvertedToggleBus;
@@ -44,12 +44,9 @@ import appeng.parts.networking.PartCableGlass;
import appeng.parts.networking.PartCableSmart;
import appeng.parts.networking.PartDenseCable;
import appeng.parts.networking.PartQuartzFiber;
import appeng.parts.p2p.PartP2PIC2Power;
import appeng.parts.p2p.PartP2PItems;
import appeng.parts.p2p.PartP2PLight;
import appeng.parts.p2p.PartP2PLiquids;
import appeng.parts.p2p.PartP2POpenComputers;
import appeng.parts.p2p.PartP2PRFPower;
import appeng.parts.p2p.PartP2PRedstone;
import appeng.parts.p2p.PartP2PTunnelME;
import appeng.parts.reporting.PartConversionMonitor;
@@ -151,13 +148,13 @@ public enum PartType
P2PTunnelLiquids( 463, EnumSet.of( AEFeature.P2PTunnel, AEFeature.P2PTunnelLiquids ), EnumSet.noneOf( IntegrationType.class ), PartP2PLiquids.class, GuiText.FluidTunnel ),
P2PTunnelEU( 465, EnumSet.of( AEFeature.P2PTunnel, AEFeature.P2PTunnelEU ), EnumSet.of( IntegrationType.IC2 ), PartP2PIC2Power.class, GuiText.EUTunnel ),
//P2PTunnelEU( 465, EnumSet.of( AEFeature.P2PTunnel, AEFeature.P2PTunnelEU ), EnumSet.of( IntegrationType.IC2 ), PartP2PIC2Power.class, GuiText.EUTunnel ),
P2PTunnelRF( 466, EnumSet.of( AEFeature.P2PTunnel, AEFeature.P2PTunnelRF ), EnumSet.of( IntegrationType.RF ), PartP2PRFPower.class, GuiText.RFTunnel ),
//P2PTunnelRF( 466, EnumSet.of( AEFeature.P2PTunnel, AEFeature.P2PTunnelRF ), EnumSet.of( IntegrationType.RF ), PartP2PRFPower.class, GuiText.RFTunnel ),
P2PTunnelLight( 467, EnumSet.of( AEFeature.P2PTunnel, AEFeature.P2PTunnelLight ), EnumSet.noneOf( IntegrationType.class ), PartP2PLight.class, GuiText.LightTunnel ),
P2PTunnelOpenComputers( 468, EnumSet.of( AEFeature.P2PTunnel, AEFeature.P2PTunnelOpenComputers ), EnumSet.of( IntegrationType.OpenComputers ), PartP2POpenComputers.class, GuiText.OCTunnel ),
//P2PTunnelOpenComputers( 468, EnumSet.of( AEFeature.P2PTunnel, AEFeature.P2PTunnelOpenComputers ), EnumSet.of( IntegrationType.OpenComputers ), PartP2POpenComputers.class, GuiText.OCTunnel ),
InterfaceTerminal( 480, EnumSet.of( AEFeature.InterfaceTerminal ), EnumSet.noneOf( IntegrationType.class ), PartInterfaceTerminal.class );
@@ -23,15 +23,13 @@ import java.util.EnumSet;
import java.util.List;
import java.util.Set;
import com.google.common.base.Optional;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.entity.player.InventoryPlayer;
import net.minecraft.inventory.IInventory;
import net.minecraft.item.ItemStack;
import net.minecraft.util.BlockPos;
import net.minecraft.util.EnumFacing;
import net.minecraft.world.World;
import net.minecraftforge.common.util.ForgeDirection;
import appeng.api.AEApi;
import appeng.api.config.FuzzyMode;
import appeng.api.config.IncludeExclude;
@@ -55,6 +53,8 @@ import appeng.items.materials.MaterialType;
import appeng.util.InventoryAdaptor;
import appeng.util.Platform;
import com.google.common.base.Optional;
public final class ItemBasicStorageCell extends AEBaseItem implements IStorageCell, IItemGroup
{
@@ -241,7 +241,7 @@ public final class ItemBasicStorageCell extends AEBaseItem implements IStorageCe
IMEInventoryHandler inv = AEApi.instance().registries().cell().getCellInventory( stack, null, StorageChannel.ITEMS );
if( inv != null && playerInventory.getCurrentItem() == stack )
{
InventoryAdaptor ia = InventoryAdaptor.getAdaptor( player, ForgeDirection.UNKNOWN );
InventoryAdaptor ia = InventoryAdaptor.getAdaptor( player, EnumFacing.UP );
IItemList<IAEItemStack> list = inv.getAvailableItems( StorageChannel.ITEMS.createList() );
if( list.isEmpty() && ia != null )
{
@@ -289,7 +289,15 @@ public final class ItemBasicStorageCell extends AEBaseItem implements IStorageCe
}
@Override
public boolean onItemUseFirst( ItemStack stack, EntityPlayer player, World world, int x, int y, int z, int side, float hitX, float hitY, float hitZ )
public boolean onItemUseFirst(
ItemStack stack,
EntityPlayer player,
World world,
BlockPos pos,
EnumFacing side,
float hitX,
float hitY,
float hitZ )
{
return this.disassembleDrive( stack, world, player );
}
@@ -23,7 +23,6 @@ import java.util.EnumSet;
import net.minecraft.inventory.IInventory;
import net.minecraft.item.ItemStack;
import appeng.api.config.FuzzyMode;
import appeng.api.storage.ICellWorkbenchItem;
import appeng.core.features.AEFeature;
@@ -22,14 +22,11 @@ package appeng.items.storage;
import java.util.EnumSet;
import java.util.List;
import com.google.common.base.Optional;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.item.ItemStack;
import net.minecraft.nbt.NBTTagCompound;
import net.minecraft.world.World;
import net.minecraftforge.common.DimensionManager;
import appeng.api.implementations.TransitionResult;
import appeng.api.implementations.items.ISpatialStorageCell;
import appeng.api.util.WorldCoord;
@@ -41,6 +38,8 @@ import appeng.spatial.StorageHelper;
import appeng.spatial.StorageWorldProvider;
import appeng.util.Platform;
import com.google.common.base.Optional;
public class ItemSpatialStorageCell extends AEBaseItem implements ISpatialStorageCell
{
@@ -23,7 +23,6 @@ import java.util.EnumSet;
import net.minecraft.inventory.IInventory;
import net.minecraft.item.ItemStack;
import appeng.api.AEApi;
import appeng.api.config.FuzzyMode;
import appeng.api.config.Upgrades;
@@ -22,8 +22,6 @@ package appeng.items.tools;
import java.util.EnumSet;
import java.util.List;
import com.mojang.authlib.GameProfile;
import net.minecraft.entity.EntityLivingBase;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.item.ItemStack;
@@ -31,7 +29,6 @@ import net.minecraft.nbt.NBTTagCompound;
import net.minecraft.nbt.NBTUtil;
import net.minecraft.world.World;
import net.minecraftforge.client.MinecraftForgeClient;
import appeng.api.config.SecurityPermissions;
import appeng.api.features.IPlayerRegistry;
import appeng.api.implementations.items.IBiometricCard;
@@ -42,6 +39,8 @@ import appeng.core.localization.GuiText;
import appeng.items.AEBaseItem;
import appeng.util.Platform;
import com.mojang.authlib.GameProfile;
public class ToolBiometricCard extends AEBaseItem implements IBiometricCard
{
@@ -114,7 +113,7 @@ public class ToolBiometricCard extends AEBaseItem implements IBiometricCard
if( profile != null )
{
NBTTagCompound pNBT = new NBTTagCompound();
NBTUtil.func_152460_a( pNBT, profile );
NBTUtil.writeGameProfile( pNBT, profile );
tag.setTag( "profile", pNBT );
}
else
@@ -129,7 +128,7 @@ public class ToolBiometricCard extends AEBaseItem implements IBiometricCard
NBTTagCompound tag = Platform.openNbtData( is );
if( tag.hasKey( "profile" ) )
{
return NBTUtil.func_152459_a( tag.getCompoundTag( "profile" ) );
return NBTUtil.readGameProfileFromNBT( tag.getCompoundTag( "profile" ) );
}
return null;
}
@@ -25,9 +25,10 @@ import java.util.List;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.item.ItemStack;
import net.minecraft.nbt.NBTTagCompound;
import net.minecraft.util.BlockPos;
import net.minecraft.util.EnumFacing;
import net.minecraft.util.StatCollector;
import net.minecraft.world.World;
import appeng.api.implementations.items.IMemoryCard;
import appeng.api.implementations.items.MemoryCardMessages;
import appeng.core.features.AEFeature;
@@ -138,7 +139,15 @@ public class ToolMemoryCard extends AEBaseItem implements IMemoryCard
}
@Override
public boolean onItemUse( ItemStack is, EntityPlayer player, World w, int x, int y, int z, int side, float hx, float hy, float hz )
public boolean onItemUse(
ItemStack is,
EntityPlayer player,
World w,
BlockPos pos,
EnumFacing side,
float hx,
float hy,
float hz )
{
if( player.isSneaking() && !w.isRemote )
{
@@ -149,12 +158,15 @@ public class ToolMemoryCard extends AEBaseItem implements IMemoryCard
}
else
{
return super.onItemUse( is, player, w, x, y, z, side, hx, hy, hz );
return super.onItemUse( is, player, w, pos, side, hx, hy, hz );
}
}
@Override
public boolean doesSneakBypassUse( World world, int x, int y, int z, EntityPlayer player )
public boolean doesSneakBypassUse(
World world,
BlockPos pos,
EntityPlayer player )
{
return true;
}
@@ -21,25 +21,22 @@ package appeng.items.tools;
import java.util.EnumSet;
import com.google.common.base.Optional;
import net.minecraft.block.Block;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.item.ItemStack;
import net.minecraft.tileentity.TileEntity;
import net.minecraft.util.BlockPos;
import net.minecraft.util.EnumFacing;
import net.minecraft.util.MovingObjectPosition;
import net.minecraft.util.Vec3;
import net.minecraft.world.World;
import net.minecraftforge.common.util.ForgeDirection;
import buildcraft.api.tools.IToolWrench;
import appeng.api.implementations.guiobjects.IGuiItem;
import appeng.api.implementations.guiobjects.IGuiItemObject;
import appeng.api.implementations.items.IAEWrench;
import appeng.api.networking.IGridHost;
import appeng.api.parts.IPartHost;
import appeng.api.parts.SelectedPart;
import appeng.api.util.AEPartLocation;
import appeng.api.util.DimensionalCoord;
import appeng.api.util.INetworkToolAgent;
import appeng.client.ClientHelper;
@@ -53,9 +50,11 @@ import appeng.items.contents.NetworkToolViewer;
import appeng.transformer.annotations.Integration.Interface;
import appeng.util.Platform;
import com.google.common.base.Optional;
@Interface( iface = "buildcraft.api.tools.IToolWrench", iname = "BC" )
public class ToolNetworkTool extends AEBaseItem implements IGuiItem, IAEWrench, IToolWrench
public class ToolNetworkTool extends AEBaseItem implements IGuiItem, IAEWrench // TODO: BC Wrench
{
public ToolNetworkTool()
@@ -68,9 +67,9 @@ public class ToolNetworkTool extends AEBaseItem implements IGuiItem, IAEWrench,
}
@Override
public IGuiItemObject getGuiObject( ItemStack is, World world, int x, int y, int z )
public IGuiItemObject getGuiObject( ItemStack is, World world, BlockPos pos )
{
TileEntity te = world.getTileEntity( x, y, z );
TileEntity te = world.getTileEntity( pos );
return new NetworkToolViewer( is, (IGridHost) ( te instanceof IGridHost ? te : null ) );
}
@@ -83,29 +82,33 @@ public class ToolNetworkTool extends AEBaseItem implements IGuiItem, IAEWrench,
if( mop == null )
{
this.onItemUseFirst( it, p, w, 0, 0, 0, -1, 0, 0, 0 );
this.onItemUseFirst( it, p, w, new BlockPos(0,0,0), null, 0,0,0 ); // eh?
}
else
{
int i = mop.blockX;
int j = mop.blockY;
int k = mop.blockZ;
if( w.getBlock( i, j, k ).isAir( w, i, j, k ) )
if( w.getBlockState( mop.getBlockPos() ).getBlock().isAir( w, mop.getBlockPos() ) )
{
this.onItemUseFirst( it, p, w, 0, 0, 0, -1, 0, 0, 0 );
this.onItemUseFirst( it, p, w, new BlockPos(0,0,0), null, 0,0,0 ); // eh?
}
}
}
return it;
}
@Override
public boolean onItemUseFirst( ItemStack is, EntityPlayer player, World world, int x, int y, int z, int side, float hitX, float hitY, float hitZ )
public boolean onItemUseFirst(
ItemStack stack,
EntityPlayer player,
World world,
BlockPos pos,
EnumFacing side,
float hitX,
float hitY,
float hitZ )
{
MovingObjectPosition mop = new MovingObjectPosition( x, y, z, side, Vec3.createVectorHelper( hitX, hitY, hitZ ) );
TileEntity te = world.getTileEntity( x, y, z );
MovingObjectPosition mop = new MovingObjectPosition( new Vec3( hitX, hitY, hitZ ), side, pos );
TileEntity te = world.getTileEntity( pos );
if( te instanceof IPartHost )
{
SelectedPart part = ( (IPartHost) te ).selectPart( mop.hitVec );
@@ -124,35 +127,38 @@ public class ToolNetworkTool extends AEBaseItem implements IGuiItem, IAEWrench,
if( Platform.isClient() )
{
NetworkHandler.instance.sendToServer( new PacketClick( x, y, z, side, hitX, hitY, hitZ ) );
NetworkHandler.instance.sendToServer( new PacketClick( pos, side, hitX, hitY, hitZ ) );
}
return true;
}
@Override
public boolean doesSneakBypassUse( World world, int x, int y, int z, EntityPlayer player )
public boolean doesSneakBypassUse(
World world,
BlockPos pos,
EntityPlayer player )
{
return true;
}
public boolean serverSideToolLogic( ItemStack is, EntityPlayer p, World w, int x, int y, int z, int side, float hitX, float hitY, float hitZ )
public boolean serverSideToolLogic( ItemStack is, EntityPlayer p, World w, BlockPos pos, EnumFacing side, float hitX, float hitY, float hitZ )
{
if( side >= 0 )
if( side != null )
{
if( !Platform.hasPermissions( new DimensionalCoord( w, x, y, z ), p ) )
if( !Platform.hasPermissions( new DimensionalCoord( w, pos ), p ) )
{
return false;
}
Block b = w.getBlock( x, y, z );
Block b = w.getBlockState( pos ).getBlock();
if( b != null && !p.isSneaking() )
{
TileEntity te = w.getTileEntity( x, y, z );
TileEntity te = w.getTileEntity( pos );
if( !( te instanceof IGridHost ) )
{
if( b.rotateBlock( w, x, y, z, ForgeDirection.getOrientation( side ) ) )
if( b.rotateBlock( w, pos, side ) )
{
b.onNeighborBlockChange( w, x, y, z, Platform.AIR_BLOCK );
b.onNeighborBlockChange( w, pos, Platform.AIR_BLOCK.getDefaultState(), Platform.AIR_BLOCK );
p.swingItem();
return !w.isRemote;
}
@@ -166,47 +172,41 @@ public class ToolNetworkTool extends AEBaseItem implements IGuiItem, IAEWrench,
return true;
}
TileEntity te = w.getTileEntity( x, y, z );
TileEntity te = w.getTileEntity( pos );
if( te instanceof IGridHost )
{
Platform.openGUI( p, te, ForgeDirection.getOrientation( side ), GuiBridge.GUI_NETWORK_STATUS );
Platform.openGUI( p, te, AEPartLocation.fromFacing( side ), GuiBridge.GUI_NETWORK_STATUS );
}
else
{
Platform.openGUI( p, null, ForgeDirection.UNKNOWN, GuiBridge.GUI_NETWORK_TOOL );
Platform.openGUI( p, null, AEPartLocation.INTERNAL, GuiBridge.GUI_NETWORK_TOOL );
}
return true;
}
else
{
b.onBlockActivated( w, x, y, z, p, side, hitX, hitY, hitZ );
b.onBlockActivated( w, pos, w.getBlockState( pos ), p, side, hitX, hitY, hitZ );
}
}
else
{
Platform.openGUI( p, null, ForgeDirection.UNKNOWN, GuiBridge.GUI_NETWORK_TOOL );
Platform.openGUI( p, null, AEPartLocation.INTERNAL, GuiBridge.GUI_NETWORK_TOOL );
}
return false;
}
@Override
public boolean canWrench( ItemStack is, EntityPlayer player, int x, int y, int z )
public boolean canWrench(
ItemStack wrench,
EntityPlayer player,
BlockPos pos )
{
return true;
}
@Override
public boolean canWrench( EntityPlayer player, int x, int y, int z )
{
return true;
}
@Override
public void wrenchUsed( EntityPlayer player, int x, int y, int z )
{
player.swingItem();
}
// TODO: BC WRENCH INTEGRATION
}
@@ -21,12 +21,9 @@ package appeng.items.tools.powered;
import java.util.EnumSet;
import com.google.common.base.Optional;
import net.minecraft.entity.EntityLivingBase;
import net.minecraft.item.ItemStack;
import net.minecraft.util.DamageSource;
import appeng.core.AEConfig;
import appeng.core.features.AEFeature;
import appeng.core.sync.packets.PacketLightning;
@@ -34,6 +31,8 @@ import appeng.items.tools.powered.powersink.AEBasePoweredItem;
import appeng.server.ServerHelper;
import appeng.util.Platform;
import com.google.common.base.Optional;
public class ToolChargedStaff extends AEBasePoweredItem
{
@@ -54,9 +53,9 @@ public class ToolChargedStaff extends AEBasePoweredItem
{
for( int x = 0; x < 2; x++ )
{
float dx = (float) ( Platform.getRandomFloat() * target.width + target.boundingBox.minX );
float dy = (float) ( Platform.getRandomFloat() * target.height + target.boundingBox.minY );
float dz = (float) ( Platform.getRandomFloat() * target.width + target.boundingBox.minZ );
float dx = (float) ( Platform.getRandomFloat() * target.width + target.getBoundingBox().minX );
float dy = (float) ( Platform.getRandomFloat() * target.height + target.getBoundingBox().minY );
float dz = (float) ( Platform.getRandomFloat() * target.width + target.getBoundingBox().minZ );
ServerHelper.proxy.sendToAllNearExcept( null, dx, dy, dz, 32.0, target.worldObj, new PacketLightning( dx, dy, dz ) );
}
}
@@ -28,22 +28,25 @@ import java.util.List;
import java.util.Map;
import java.util.Set;
import com.google.common.base.Optional;
import net.minecraft.block.Block;
import net.minecraft.block.BlockColored;
import net.minecraft.block.BlockDispenser;
import net.minecraft.block.BlockStainedGlass;
import net.minecraft.block.BlockStainedGlassPane;
import net.minecraft.block.state.IBlockState;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.init.Blocks;
import net.minecraft.inventory.IInventory;
import net.minecraft.item.EnumDyeColor;
import net.minecraft.item.ItemSnowball;
import net.minecraft.item.ItemStack;
import net.minecraft.nbt.NBTTagCompound;
import net.minecraft.tileentity.TileEntity;
import net.minecraft.util.BlockPos;
import net.minecraft.util.EnumFacing;
import net.minecraft.world.World;
import net.minecraftforge.client.MinecraftForgeClient;
import net.minecraftforge.common.util.ForgeDirection;
import net.minecraftforge.oredict.OreDictionary;
import appeng.api.AEApi;
import appeng.api.config.Actionable;
import appeng.api.config.FuzzyMode;
@@ -78,6 +81,8 @@ import appeng.util.ItemSorters;
import appeng.util.Platform;
import appeng.util.item.AEItemStack;
import com.google.common.base.Optional;
public class ToolColorApplicator extends AEBasePoweredItem implements IStorageCell, IItemGroup, IBlockTool, IMouseWheelItem
{
@@ -116,9 +121,17 @@ public class ToolColorApplicator extends AEBasePoweredItem implements IStorageCe
}
@Override
public boolean onItemUse( ItemStack is, EntityPlayer p, World w, int x, int y, int z, int side, float hitX, float hitY, float hitZ )
public boolean onItemUse(
ItemStack is,
EntityPlayer p,
World w,
BlockPos pos,
EnumFacing side,
float hitX,
float hitY,
float hitZ )
{
Block blk = w.getBlock( x, y, z );
Block blk = w.getBlockState( pos ).getBlock();
double powerPerUse = 100;
ItemStack paintBall = this.getColor( is );
@@ -138,21 +151,20 @@ public class ToolColorApplicator extends AEBasePoweredItem implements IStorageCe
paintBall = null;
}
if( !Platform.hasPermissions( new DimensionalCoord( w, x, y, z ), p ) )
if( !Platform.hasPermissions( new DimensionalCoord( w, pos ), p ) )
{
return false;
}
if( paintBall != null && paintBall.getItem() instanceof ItemSnowball )
{
ForgeDirection orientation = ForgeDirection.getOrientation( side );
TileEntity te = w.getTileEntity( x, y, z );
TileEntity te = w.getTileEntity( pos );
// clean cables.
if( te instanceof IColorableTile )
{
if( this.getAECurrentPower( is ) > powerPerUse && ( (IColorableTile) te ).getColor() != AEColor.Transparent )
{
if( ( (IColorableTile) te ).recolourBlock( orientation, AEColor.Transparent, p ) )
if( ( (IColorableTile) te ).recolourBlock( side, AEColor.Transparent, p ) )
{
inv.extractItems( AEItemStack.create( paintBall ), Actionable.MODULATE, new BaseActionSource() );
this.extractAEPower( is, powerPerUse );
@@ -162,13 +174,13 @@ public class ToolColorApplicator extends AEBasePoweredItem implements IStorageCe
}
// clean paint balls..
Block testBlk = w.getBlock( x + orientation.offsetX, y + orientation.offsetY, z + orientation.offsetZ );
TileEntity painted = w.getTileEntity( x + orientation.offsetX, y + orientation.offsetY, z + orientation.offsetZ );
Block testBlk = w.getBlockState( pos.offset( side ) ).getBlock();
TileEntity painted = w.getTileEntity( pos.offset( side ) );
if( this.getAECurrentPower( is ) > powerPerUse && testBlk instanceof BlockPaint && painted instanceof TilePaint )
{
inv.extractItems( AEItemStack.create( paintBall ), Actionable.MODULATE, new BaseActionSource() );
this.extractAEPower( is, powerPerUse );
( (TilePaint) painted ).cleanSide( orientation.getOpposite() );
( (TilePaint) painted ).cleanSide( side.getOpposite() );
return true;
}
}
@@ -178,7 +190,7 @@ public class ToolColorApplicator extends AEBasePoweredItem implements IStorageCe
if( color != null && this.getAECurrentPower( is ) > powerPerUse )
{
if( color != AEColor.Transparent && this.recolourBlock( blk, ForgeDirection.getOrientation( side ), w, x, y, z, ForgeDirection.getOrientation( side ), color, p ) )
if( color != AEColor.Transparent && this.recolourBlock( blk, side, w, pos, side, color, p ) )
{
inv.extractItems( AEItemStack.create( paintBall ), Actionable.MODULATE, new BaseActionSource() );
this.extractAEPower( is, powerPerUse );
@@ -352,69 +364,67 @@ public class ToolColorApplicator extends AEBasePoweredItem implements IStorageCe
}
}
private boolean recolourBlock( Block blk, ForgeDirection side, World w, int x, int y, int z, ForgeDirection orientation, AEColor newColor, EntityPlayer p )
private boolean recolourBlock( Block blk, EnumFacing side, World w, BlockPos pos, EnumFacing orientation, AEColor newColor, EntityPlayer p )
{
if( blk == Blocks.carpet )
IBlockState state = w.getBlockState( pos );
if( blk instanceof BlockColored )
{
int meta = w.getBlockMetadata( x, y, z );
if( newColor.ordinal() == meta )
EnumDyeColor color = ( EnumDyeColor ) state.getValue( BlockColored.COLOR );
if( newColor.dye == color )
{
return false;
}
return w.setBlock( x, y, z, Blocks.carpet, newColor.ordinal(), 3 );
return w.setBlockState( pos, state.withProperty( BlockColored.COLOR, newColor.dye ) );
}
if( blk == Blocks.glass )
{
return w.setBlock( x, y, z, Blocks.stained_glass, newColor.ordinal(), 3 );
return w.setBlockState( pos, Blocks.stained_glass.getDefaultState().withProperty( BlockStainedGlass.COLOR, newColor.dye) );
}
if( blk == Blocks.stained_glass )
{
int meta = w.getBlockMetadata( x, y, z );
if( newColor.ordinal() == meta )
EnumDyeColor color = ( EnumDyeColor ) state.getValue( BlockStainedGlass.COLOR );
if( newColor.dye == color )
{
return false;
}
return w.setBlock( x, y, z, Blocks.stained_glass, newColor.ordinal(), 3 );
return w.setBlockState( pos, state.withProperty( BlockStainedGlass.COLOR, newColor.dye ) );
}
if( blk == Blocks.glass_pane )
{
return w.setBlock( x, y, z, Blocks.stained_glass_pane, newColor.ordinal(), 3 );
return w.setBlockState( pos, Blocks.stained_glass_pane.getDefaultState().withProperty( BlockStainedGlassPane.COLOR, newColor.dye) );
}
if( blk == Blocks.stained_glass_pane )
{
int meta = w.getBlockMetadata( x, y, z );
if( newColor.ordinal() == meta )
EnumDyeColor color = ( EnumDyeColor ) state.getValue( BlockStainedGlassPane.COLOR );
if( newColor.dye == color )
{
return false;
}
return w.setBlock( x, y, z, Blocks.stained_glass_pane, newColor.ordinal(), 3 );
return w.setBlockState( pos, state.withProperty( BlockStainedGlassPane.COLOR, newColor.dye ) );
}
if( blk == Blocks.hardened_clay )
{
return w.setBlock( x, y, z, Blocks.stained_hardened_clay, newColor.ordinal(), 3 );
}
if( blk == Blocks.stained_hardened_clay )
{
int meta = w.getBlockMetadata( x, y, z );
if( newColor.ordinal() == meta )
{
return false;
}
return w.setBlock( x, y, z, Blocks.stained_hardened_clay, newColor.ordinal(), 3 );
return w.setBlockState( pos, Blocks.stained_hardened_clay.getDefaultState().withProperty( BlockColored.COLOR, newColor.dye ) );
}
if( blk instanceof BlockCableBus )
{
return ( (BlockCableBus) blk ).recolourBlock( w, x, y, z, side, newColor.ordinal(), p );
return ( (BlockCableBus) blk ).recolorBlock( w, pos, side, newColor.dye, p );
}
return blk.recolourBlock( w, x, y, z, side, newColor.ordinal() );
return blk.recolorBlock( w, pos, side, newColor.dye );
}
public void cycleColors( ItemStack is, ItemStack paintBall, int i )
@@ -25,12 +25,11 @@ import java.util.HashMap;
import java.util.List;
import java.util.Map;
import com.google.common.base.Optional;
import net.minecraft.block.Block;
import net.minecraft.block.BlockDispenser;
import net.minecraft.block.BlockTNT;
import net.minecraft.block.material.Material;
import net.minecraft.block.state.IBlockState;
import net.minecraft.entity.EntityLivingBase;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.init.Blocks;
@@ -38,12 +37,11 @@ import net.minecraft.init.Items;
import net.minecraft.item.ItemBlock;
import net.minecraft.item.ItemStack;
import net.minecraft.item.crafting.FurnaceRecipes;
import net.minecraft.util.BlockPos;
import net.minecraft.util.EnumFacing;
import net.minecraft.util.MovingObjectPosition;
import net.minecraft.util.MovingObjectPosition.MovingObjectType;
import net.minecraft.world.World;
import net.minecraftforge.common.util.ForgeDirection;
import net.minecraftforge.oredict.OreDictionary;
import appeng.api.util.DimensionalCoord;
import appeng.block.misc.BlockTinyTNT;
import appeng.core.AEConfig;
@@ -54,6 +52,8 @@ import appeng.items.tools.powered.powersink.AEBasePoweredItem;
import appeng.util.InWorldToolOperationResult;
import appeng.util.Platform;
import com.google.common.base.Optional;
public class ToolEntropyManipulator extends AEBasePoweredItem implements IBlockTool
{
@@ -69,21 +69,21 @@ public class ToolEntropyManipulator extends AEBasePoweredItem implements IBlockT
this.heatUp = new HashMap<InWorldToolOperationIngredient, InWorldToolOperationResult>();
this.coolDown = new HashMap<InWorldToolOperationIngredient, InWorldToolOperationResult>();
this.coolDown.put( new InWorldToolOperationIngredient( Blocks.stone, 0 ), new InWorldToolOperationResult( new ItemStack( Blocks.cobblestone ) ) );
this.coolDown.put( new InWorldToolOperationIngredient( Blocks.stonebrick, 0 ), new InWorldToolOperationResult( new ItemStack( Blocks.stonebrick, 1, 2 ) ) );
this.coolDown.put( new InWorldToolOperationIngredient( Blocks.lava, OreDictionary.WILDCARD_VALUE ), new InWorldToolOperationResult( new ItemStack( Blocks.obsidian ) ) );
this.coolDown.put( new InWorldToolOperationIngredient( Blocks.flowing_lava, OreDictionary.WILDCARD_VALUE ), new InWorldToolOperationResult( new ItemStack( Blocks.obsidian ) ) );
this.coolDown.put( new InWorldToolOperationIngredient( Blocks.grass, OreDictionary.WILDCARD_VALUE ), new InWorldToolOperationResult( new ItemStack( Blocks.dirt ) ) );
this.coolDown.put( new InWorldToolOperationIngredient( Blocks.stone.getDefaultState() ), new InWorldToolOperationResult( new ItemStack( Blocks.cobblestone ) ) );
this.coolDown.put( new InWorldToolOperationIngredient( Blocks.stonebrick.getDefaultState() ), new InWorldToolOperationResult( new ItemStack( Blocks.stonebrick, 1, 2 ) ) );
this.coolDown.put( new InWorldToolOperationIngredient( Blocks.lava, true ), new InWorldToolOperationResult( new ItemStack( Blocks.obsidian ) ) );
this.coolDown.put( new InWorldToolOperationIngredient( Blocks.flowing_lava, true ), new InWorldToolOperationResult( new ItemStack( Blocks.obsidian ) ) );
this.coolDown.put( new InWorldToolOperationIngredient( Blocks.grass, true ), new InWorldToolOperationResult( new ItemStack( Blocks.dirt ) ) );
List<ItemStack> snowBalls = new ArrayList<ItemStack>();
snowBalls.add( new ItemStack( Items.snowball ) );
this.coolDown.put( new InWorldToolOperationIngredient( Blocks.flowing_water, OreDictionary.WILDCARD_VALUE ), new InWorldToolOperationResult( null, snowBalls ) );
this.coolDown.put( new InWorldToolOperationIngredient( Blocks.water, OreDictionary.WILDCARD_VALUE ), new InWorldToolOperationResult( new ItemStack( Blocks.ice ) ) );
this.coolDown.put( new InWorldToolOperationIngredient( Blocks.flowing_water, true ), new InWorldToolOperationResult( null, snowBalls ) );
this.coolDown.put( new InWorldToolOperationIngredient( Blocks.water, true ), new InWorldToolOperationResult( new ItemStack( Blocks.ice ) ) );
this.heatUp.put( new InWorldToolOperationIngredient( Blocks.ice, 0 ), new InWorldToolOperationResult( new ItemStack( Blocks.water ) ) );
this.heatUp.put( new InWorldToolOperationIngredient( Blocks.flowing_water, OreDictionary.WILDCARD_VALUE ), new InWorldToolOperationResult() );
this.heatUp.put( new InWorldToolOperationIngredient( Blocks.water, OreDictionary.WILDCARD_VALUE ), new InWorldToolOperationResult() );
this.heatUp.put( new InWorldToolOperationIngredient( Blocks.snow, OreDictionary.WILDCARD_VALUE ), new InWorldToolOperationResult( new ItemStack( Blocks.flowing_water ) ) );
this.heatUp.put( new InWorldToolOperationIngredient( Blocks.ice.getDefaultState() ), new InWorldToolOperationResult( new ItemStack( Blocks.water ) ) );
this.heatUp.put( new InWorldToolOperationIngredient( Blocks.flowing_water, true ), new InWorldToolOperationResult() );
this.heatUp.put( new InWorldToolOperationIngredient( Blocks.water, true ), new InWorldToolOperationResult() );
this.heatUp.put( new InWorldToolOperationIngredient( Blocks.snow, true ), new InWorldToolOperationResult( new ItemStack( Blocks.flowing_water ) ) );
}
@Override
@@ -95,19 +95,27 @@ public class ToolEntropyManipulator extends AEBasePoweredItem implements IBlockT
private static class InWorldToolOperationIngredient
{
private final Block blockID;
private final int metadata;
private final IBlockState state;
private boolean blockOnly;
public InWorldToolOperationIngredient( Block blockID, int metadata )
public InWorldToolOperationIngredient( IBlockState state )
{
this.blockID = blockID;
this.metadata = metadata;
this.state = state;
blockOnly = false;
}
public InWorldToolOperationIngredient(
Block blk,
boolean b )
{
state = blk.getDefaultState();
blockOnly = b;
}
@Override
public int hashCode()
{
return this.blockID.hashCode() ^ this.metadata;
return state.getBlock().hashCode();
}
@Override
@@ -122,77 +130,79 @@ public class ToolEntropyManipulator extends AEBasePoweredItem implements IBlockT
return false;
}
InWorldToolOperationIngredient other = (InWorldToolOperationIngredient) obj;
return this.blockID == other.blockID && this.metadata == other.metadata;
return state == other.state && ( blockOnly && state.getBlock() == other.state.getBlock() );
}
}
private void heat( Block blockID, int metadata, World w, int x, int y, int z )
private void heat( IBlockState state, World w, BlockPos pos )
{
InWorldToolOperationResult r = this.heatUp.get( new InWorldToolOperationIngredient( blockID, metadata ) );
InWorldToolOperationResult r = this.heatUp.get( new InWorldToolOperationIngredient( state ) );
if( r == null )
{
r = this.heatUp.get( new InWorldToolOperationIngredient( blockID, OreDictionary.WILDCARD_VALUE ) );
r = this.heatUp.get( new InWorldToolOperationIngredient( state.getBlock(), true ) );
}
if( r.BlockItem != null )
{
w.setBlock( x, y, z, Block.getBlockFromItem( r.BlockItem.getItem() ), r.BlockItem.getItemDamage(), 3 );
Block blk = Block.getBlockFromItem( r.BlockItem.getItem() );
w.setBlockState( pos, blk.getStateFromMeta( r.BlockItem.getItemDamage() ), 3 );
}
else
{
w.setBlock( x, y, z, Platform.AIR_BLOCK, 0, 3 );
w.setBlockToAir( pos );
}
if( r.Drops != null )
{
Platform.spawnDrops( w, x, y, z, r.Drops );
Platform.spawnDrops( w, pos, r.Drops );
}
}
private boolean canHeat( Block blockID, int metadata )
private boolean canHeat( IBlockState state )
{
InWorldToolOperationResult r = this.heatUp.get( new InWorldToolOperationIngredient( blockID, metadata ) );
InWorldToolOperationResult r = this.heatUp.get( new InWorldToolOperationIngredient( state ) );
if( r == null )
{
r = this.heatUp.get( new InWorldToolOperationIngredient( blockID, OreDictionary.WILDCARD_VALUE ) );
r = this.heatUp.get( new InWorldToolOperationIngredient( state.getBlock(), true ) );
}
return r != null;
}
private void cool( Block blockID, int metadata, World w, int x, int y, int z )
private void cool( IBlockState state, World w, BlockPos pos )
{
InWorldToolOperationResult r = this.coolDown.get( new InWorldToolOperationIngredient( blockID, metadata ) );
InWorldToolOperationResult r = this.coolDown.get( new InWorldToolOperationIngredient( state ) );
if( r == null )
{
r = this.coolDown.get( new InWorldToolOperationIngredient( blockID, OreDictionary.WILDCARD_VALUE ) );
r = this.coolDown.get( new InWorldToolOperationIngredient( state.getBlock(), true ) );
}
if( r.BlockItem != null )
{
w.setBlock( x, y, z, Block.getBlockFromItem( r.BlockItem.getItem() ), r.BlockItem.getItemDamage(), 3 );
Block blk = Block.getBlockFromItem( r.BlockItem.getItem() );
w.setBlockState( pos, blk.getStateFromMeta( r.BlockItem.getItemDamage() ), 3 );
}
else
{
w.setBlock( x, y, z, Platform.AIR_BLOCK, 0, 3 );
w.setBlockToAir( pos );
}
if( r.Drops != null )
{
Platform.spawnDrops( w, x, y, z, r.Drops );
Platform.spawnDrops( w, pos, r.Drops );
}
}
private boolean canCool( Block blockID, int metadata )
private boolean canCool( IBlockState state )
{
InWorldToolOperationResult r = this.coolDown.get( new InWorldToolOperationIngredient( blockID, metadata ) );
InWorldToolOperationResult r = this.coolDown.get( new InWorldToolOperationIngredient( state ) );
if( r == null )
{
r = this.coolDown.get( new InWorldToolOperationIngredient( blockID, OreDictionary.WILDCARD_VALUE ) );
r = this.coolDown.get( new InWorldToolOperationIngredient( state.getBlock(), true ) );
}
return r != null;
@@ -223,15 +233,11 @@ public class ToolEntropyManipulator extends AEBasePoweredItem implements IBlockT
{
if( target.typeOfHit == MovingObjectType.BLOCK )
{
int x = target.blockX;
int y = target.blockY;
int z = target.blockZ;
if( w.getBlock( x, y, z ).getMaterial() == Material.lava || w.getBlock( x, y, z ).getMaterial() == Material.water )
if( w.getBlockState( target.getBlockPos() ).getBlock().getMaterial() == Material.lava || w.getBlockState( target.getBlockPos() ).getBlock().getMaterial() == Material.water )
{
if( Platform.hasPermissions( new DimensionalCoord( w, x, y, z ), p ) )
if( Platform.hasPermissions( new DimensionalCoord( w, target.getBlockPos() ), p ) )
{
this.onItemUse( item, p, w, x, y, z, 0, 0.0F, 0.0F, 0.0F );
this.onItemUse( item, p, w, target.getBlockPos(), EnumFacing.UP, 0.0F, 0.0F, 0.0F );
}
}
}
@@ -239,26 +245,34 @@ public class ToolEntropyManipulator extends AEBasePoweredItem implements IBlockT
return item;
}
@Override
public boolean onItemUse( ItemStack item, EntityPlayer p, World w, int x, int y, int z, int side, float hitX, float hitY, float hitZ )
public boolean onItemUse(
ItemStack item,
EntityPlayer p,
World w,
BlockPos pos,
EnumFacing side,
float hitX,
float hitY,
float hitZ )
{
if( this.getAECurrentPower( item ) > 1600 )
{
if( !p.canPlayerEdit( x, y, z, side, item ) )
if( !p.canPlayerEdit( pos, side, item ) )
{
return false;
}
Block blockID = w.getBlock( x, y, z );
int metadata = w.getBlockMetadata( x, y, z );
IBlockState state = w.getBlockState( pos );
Block blockID = state.getBlock();
if( p.isSneaking() )
{
if( this.canCool( blockID, metadata ) )
if( this.canCool( state ) )
{
this.extractAEPower( item, 1600 );
this.cool( blockID, metadata, w, x, y, z );
this.cool( state, w, pos );
return true;
}
}
@@ -266,39 +280,39 @@ public class ToolEntropyManipulator extends AEBasePoweredItem implements IBlockT
{
if( blockID instanceof BlockTNT )
{
w.setBlock( x, y, z, Platform.AIR_BLOCK, 0, 3 );
( (BlockTNT) blockID ).func_150114_a( w, x, y, z, 1, p );
w.setBlockToAir( pos );
( (BlockTNT) blockID ).explode( w, pos, state, p );
return true;
}
if( blockID instanceof BlockTinyTNT )
{
w.setBlock( x, y, z, Platform.AIR_BLOCK, 0, 3 );
( (BlockTinyTNT) blockID ).startFuse( w, x, y, z, p );
w.setBlockToAir( pos );
( (BlockTinyTNT) blockID ).startFuse( w, pos, p );
return true;
}
if( this.canHeat( blockID, metadata ) )
if( this.canHeat( state ) )
{
this.extractAEPower( item, 1600 );
this.heat( blockID, metadata, w, x, y, z );
this.heat( state, w, pos );
return true;
}
ItemStack[] stack = Platform.getBlockDrops( w, x, y, z );
ItemStack[] stack = Platform.getBlockDrops( w, pos );
List<ItemStack> out = new ArrayList<ItemStack>();
boolean hasFurnaceable = false;
boolean canFurnaceable = true;
for( ItemStack i : stack )
{
ItemStack result = FurnaceRecipes.smelting().getSmeltingResult( i );
ItemStack result = FurnaceRecipes.instance().getSmeltingResult( i );
if( result != null )
{
if( result.getItem() instanceof ItemBlock )
{
if( Block.getBlockFromItem( result.getItem() ) == blockID && result.getItem().getDamage( result ) == metadata )
if( Block.getBlockFromItem( result.getItem() ) == blockID && result.getItem().getDamage( result ) == blockID.getMetaFromState( state ) )
{
canFurnaceable = false;
}
@@ -317,41 +331,39 @@ public class ToolEntropyManipulator extends AEBasePoweredItem implements IBlockT
{
this.extractAEPower( item, 1600 );
InWorldToolOperationResult or = InWorldToolOperationResult.getBlockOperationResult( out.toArray( new ItemStack[out.size()] ) );
w.playSoundEffect( x + 0.5D, y + 0.5D, z + 0.5D, "fire.ignite", 1.0F, itemRand.nextFloat() * 0.4F + 0.8F );
w.playSoundEffect( pos.getX() + 0.5D, pos.getY() + 0.5D, pos.getZ() + 0.5D, "fire.ignite", 1.0F, itemRand.nextFloat() * 0.4F + 0.8F );
if( or.BlockItem == null )
{
w.setBlock( x, y, z, Platform.AIR_BLOCK, 0, 3 );
w.setBlockState( pos, Platform.AIR_BLOCK.getDefaultState(), 3 );
}
else
{
w.setBlock( x, y, z, Block.getBlockFromItem( or.BlockItem.getItem() ), or.BlockItem.getItemDamage(), 3 );
Block blk = Block.getBlockFromItem( or.BlockItem.getItem() );
w.setBlockState( pos, blk.getStateFromMeta( or.BlockItem.getItemDamage() ), 3 );
}
if( or.Drops != null )
{
Platform.spawnDrops( w, x, y, z, or.Drops );
Platform.spawnDrops( w, pos, or.Drops );
}
return true;
}
else
{
ForgeDirection dir = ForgeDirection.getOrientation( side );
x += dir.offsetX;
y += dir.offsetY;
z += dir.offsetZ;
BlockPos offsetPos = pos.offset( side );
if( !p.canPlayerEdit( x, y, z, side, item ) )
if( !p.canPlayerEdit( offsetPos, side, item ) )
{
return false;
}
if( w.isAirBlock( x, y, z ) )
if( w.isAirBlock( offsetPos ) )
{
this.extractAEPower( item, 1600 );
w.playSoundEffect( x + 0.5D, y + 0.5D, z + 0.5D, "fire.ignite", 1.0F, itemRand.nextFloat() * 0.4F + 0.8F );
w.setBlock( x, y, z, Blocks.fire );
w.playSoundEffect( offsetPos.getX() + 0.5D, offsetPos.getY() + 0.5D, offsetPos.getZ() + 0.5D, "fire.ignite", 1.0F, itemRand.nextFloat() * 0.4F + 0.8F );
w.setBlockState( offsetPos, Blocks.fire.getDefaultState() );
}
return true;
@@ -22,8 +22,6 @@ package appeng.items.tools.powered;
import java.util.EnumSet;
import java.util.List;
import com.google.common.base.Optional;
import net.minecraft.block.Block;
import net.minecraft.block.BlockDispenser;
import net.minecraft.entity.Entity;
@@ -35,14 +33,14 @@ import net.minecraft.inventory.IInventory;
import net.minecraft.item.ItemStack;
import net.minecraft.tileentity.TileEntity;
import net.minecraft.util.AxisAlignedBB;
import net.minecraft.util.BlockPos;
import net.minecraft.util.DamageSource;
import net.minecraft.util.EnumFacing;
import net.minecraft.util.MathHelper;
import net.minecraft.util.MovingObjectPosition;
import net.minecraft.util.MovingObjectPosition.MovingObjectType;
import net.minecraft.util.Vec3;
import net.minecraft.world.World;
import net.minecraftforge.common.util.ForgeDirection;
import appeng.api.AEApi;
import appeng.api.config.Actionable;
import appeng.api.config.FuzzyMode;
@@ -75,8 +73,11 @@ import appeng.items.misc.ItemPaintBall;
import appeng.items.tools.powered.powersink.AEBasePoweredItem;
import appeng.me.storage.CellInventoryHandler;
import appeng.tile.misc.TilePaint;
import appeng.util.LookDirection;
import appeng.util.Platform;
import com.google.common.base.Optional;
public class ToolMassCannon extends AEBasePoweredItem implements IStorageCell
{
@@ -155,26 +156,18 @@ public class ToolMassCannon extends AEBasePoweredItem implements IStorageCell
{
return item;
}
LookDirection dir = Platform.getPlayerRay( p, p.getEyeHeight() );
float f = 1.0F;
float f1 = p.prevRotationPitch + ( p.rotationPitch - p.prevRotationPitch ) * f;
float f2 = p.prevRotationYaw + ( p.rotationYaw - p.prevRotationYaw ) * f;
double d0 = p.prevPosX + ( p.posX - p.prevPosX ) * f;
double d1 = p.prevPosY + ( p.posY - p.prevPosY ) * f + 1.62D - p.yOffset;
double d2 = p.prevPosZ + ( p.posZ - p.prevPosZ ) * f;
Vec3 vec3 = Vec3.createVectorHelper( d0, d1, d2 );
float f3 = MathHelper.cos( -f2 * 0.017453292F - (float) Math.PI );
float f4 = MathHelper.sin( -f2 * 0.017453292F - (float) Math.PI );
float f5 = -MathHelper.cos( -f1 * 0.017453292F );
float f6 = MathHelper.sin( -f1 * 0.017453292F );
float f7 = f4 * f5;
float f8 = f3 * f5;
double d3 = 32.0D;
Vec3 vec31 = vec3.addVector( f7 * d3, f6 * d3, f8 * d3 );
Vec3 direction = Vec3.createVectorHelper( f7 * d3, f6 * d3, f8 * d3 );
Vec3 vec3 = dir.a;
Vec3 vec31 = dir.b;
Vec3 direction = vec31.subtract( vec3 );
direction.normalize();
double d0 = vec3.xCoord;
double d1 = vec3.yCoord;
double d2 = vec3.zCoord;
float penetration = AEApi.instance().registries().matterCannon().getPenetration( ammo ); // 196.96655f;
if( penetration <= 0 )
{
@@ -206,7 +199,7 @@ public class ToolMassCannon extends AEBasePoweredItem implements IStorageCell
private void shootPaintBalls( ItemStack type, World w, EntityPlayer p, Vec3 vec3, Vec3 vec31, Vec3 direction, double d0, double d1, double d2 )
{
AxisAlignedBB bb = AxisAlignedBB.getBoundingBox( Math.min( vec3.xCoord, vec31.xCoord ), Math.min( vec3.yCoord, vec31.yCoord ), Math.min( vec3.zCoord, vec31.zCoord ), Math.max( vec3.xCoord, vec31.xCoord ), Math.max( vec3.yCoord, vec31.yCoord ), Math.max( vec3.zCoord, vec31.zCoord ) ).expand( 16, 16, 16 );
AxisAlignedBB bb = AxisAlignedBB.fromBounds( Math.min( vec3.xCoord, vec31.xCoord ), Math.min( vec3.yCoord, vec31.yCoord ), Math.min( vec3.zCoord, vec31.zCoord ), Math.max( vec3.xCoord, vec31.xCoord ), Math.max( vec3.yCoord, vec31.yCoord ), Math.max( vec3.zCoord, vec31.zCoord ) ).expand( 16, 16, 16 );
Entity entity = null;
List list = w.getEntitiesWithinAABBExcludingEntity( p, bb );
@@ -229,7 +222,7 @@ public class ToolMassCannon extends AEBasePoweredItem implements IStorageCell
float f1 = 0.3F;
AxisAlignedBB boundingBox = entity1.boundingBox.expand( f1, f1, f1 );
AxisAlignedBB boundingBox = entity1.getBoundingBox().expand( f1, f1, f1 );
MovingObjectPosition movingObjectPosition = boundingBox.calculateIntercept( vec3, vec31 );
if( movingObjectPosition != null )
@@ -248,7 +241,7 @@ public class ToolMassCannon extends AEBasePoweredItem implements IStorageCell
MovingObjectPosition pos = w.rayTraceBlocks( vec3, vec31, false );
Vec3 vec = Vec3.createVectorHelper( d0, d1, d2 );
Vec3 vec = new Vec3( d0, d1, d2 );
if( entity != null && pos != null && pos.hitVec.squareDistanceTo( vec ) > closest )
{
pos = new MovingObjectPosition( entity );
@@ -283,7 +276,7 @@ public class ToolMassCannon extends AEBasePoweredItem implements IStorageCell
if( pos.entityHit instanceof EntitySheep )
{
EntitySheep sh = (EntitySheep) pos.entityHit;
sh.setFleeceColor( col.ordinal() );
sh.setFleeceColor( col.dye );
}
pos.entityHit.attackEntityFrom( DamageSource.causePlayerDamage( p ), 0 );
@@ -291,33 +284,28 @@ public class ToolMassCannon extends AEBasePoweredItem implements IStorageCell
}
else if( pos.typeOfHit == MovingObjectType.BLOCK )
{
ForgeDirection side = ForgeDirection.getOrientation( pos.sideHit );
EnumFacing side = pos.sideHit;
BlockPos hitPos = pos.getBlockPos().offset( side );
int x = pos.blockX + side.offsetX;
int y = pos.blockY + side.offsetY;
int z = pos.blockZ + side.offsetZ;
if( !Platform.hasPermissions( new DimensionalCoord( w, x, y, z ), p ) )
if( !Platform.hasPermissions( new DimensionalCoord( w, hitPos ), p ) )
{
return;
}
Block whatsThere = w.getBlock( x, y, z );
if( whatsThere.isReplaceable( w, x, y, z ) && w.isAirBlock( x, y, z ) )
Block whatsThere = w.getBlockState( hitPos ).getBlock();
if( whatsThere.isReplaceable( w, hitPos ) && w.isAirBlock( hitPos ) )
{
for( Block paintBlock : AEApi.instance().definitions().blocks().paint().maybeBlock().asSet() )
{
w.setBlock( x, y, z, paintBlock, 0, 3 );
w.setBlockState( hitPos, paintBlock.getDefaultState(), 3 );
}
}
TileEntity te = w.getTileEntity( x, y, z );
TileEntity te = w.getTileEntity( hitPos );
if( te instanceof TilePaint )
{
pos.hitVec.xCoord -= x;
pos.hitVec.yCoord -= y;
pos.hitVec.zCoord -= z;
( (TilePaint) te ).addBlot( type, side.getOpposite(), pos.hitVec );
Vec3 hp = pos.hitVec.subtract( hitPos.getX(), hitPos.getY(), hitPos.getZ() );
( (TilePaint) te ).addBlot( type, side.getOpposite(), hp );
}
}
}
@@ -330,7 +318,7 @@ public class ToolMassCannon extends AEBasePoweredItem implements IStorageCell
{
hasDestroyed = false;
AxisAlignedBB bb = AxisAlignedBB.getBoundingBox( Math.min( vec3.xCoord, vec31.xCoord ), Math.min( vec3.yCoord, vec31.yCoord ), Math.min( vec3.zCoord, vec31.zCoord ), Math.max( vec3.xCoord, vec31.xCoord ), Math.max( vec3.yCoord, vec31.yCoord ), Math.max( vec3.zCoord, vec31.zCoord ) ).expand( 16, 16, 16 );
AxisAlignedBB bb = AxisAlignedBB.fromBounds( Math.min( vec3.xCoord, vec31.xCoord ), Math.min( vec3.yCoord, vec31.yCoord ), Math.min( vec3.zCoord, vec31.zCoord ), Math.max( vec3.xCoord, vec31.xCoord ), Math.max( vec3.yCoord, vec31.yCoord ), Math.max( vec3.zCoord, vec31.zCoord ) ).expand( 16, 16, 16 );
Entity entity = null;
List list = w.getEntitiesWithinAABBExcludingEntity( p, bb );
@@ -353,7 +341,7 @@ public class ToolMassCannon extends AEBasePoweredItem implements IStorageCell
float f1 = 0.3F;
AxisAlignedBB boundingBox = entity1.boundingBox.expand( f1, f1, f1 );
AxisAlignedBB boundingBox = entity1.getBoundingBox().expand( f1, f1, f1 );
MovingObjectPosition movingObjectPosition = boundingBox.calculateIntercept( vec3, vec31 );
if( movingObjectPosition != null )
@@ -370,7 +358,7 @@ public class ToolMassCannon extends AEBasePoweredItem implements IStorageCell
}
}
Vec3 vec = Vec3.createVectorHelper( d0, d1, d2 );
Vec3 vec = new Vec3( d0, d1, d2 );
MovingObjectPosition pos = w.rayTraceBlocks( vec3, vec31, true );
if( entity != null && pos != null && pos.hitVec.squareDistanceTo( vec ) > closest )
{
@@ -429,20 +417,19 @@ public class ToolMassCannon extends AEBasePoweredItem implements IStorageCell
}
else
{
Block b = w.getBlock( pos.blockX, pos.blockY, pos.blockZ );
Block b = w.getBlockState( pos.getBlockPos() ).getBlock();
// int meta = w.getBlockMetadata(
// pos.blockX, pos.blockY, pos.blockZ );
float hardness = b.getBlockHardness( w, pos.blockX, pos.blockY, pos.blockZ ) * 9.0f;
float hardness = b.getBlockHardness( w, pos.getBlockPos() ) * 9.0f;
if( hardness >= 0.0 )
{
if( penetration > hardness && Platform.hasPermissions( new DimensionalCoord( w, pos.blockX, pos.blockY, pos.blockZ ), p ) )
if( penetration > hardness && Platform.hasPermissions( new DimensionalCoord( w, pos.getBlockPos() ), p ) )
{
hasDestroyed = true;
penetration -= hardness;
penetration *= 0.60;
w.func_147480_a( pos.blockX, pos.blockY, pos.blockZ, true );
// w.destroyBlock( pos.blockX, pos.blockY, pos.blockZ, true );
w.destroyBlock( pos.getBlockPos(), true );
}
}
}
@@ -23,17 +23,13 @@ import java.util.EnumSet;
import java.util.List;
import java.util.Set;
import com.google.common.base.Optional;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.inventory.IInventory;
import net.minecraft.item.ItemStack;
import net.minecraft.util.BlockPos;
import net.minecraft.world.World;
import net.minecraftforge.common.util.ForgeDirection;
import cpw.mods.fml.relauncher.Side;
import cpw.mods.fml.relauncher.SideOnly;
import net.minecraftforge.fml.relauncher.Side;
import net.minecraftforge.fml.relauncher.SideOnly;
import appeng.api.AEApi;
import appeng.api.config.FuzzyMode;
import appeng.api.implementations.guiobjects.IGuiItem;
@@ -45,6 +41,7 @@ import appeng.api.storage.ICellInventoryHandler;
import appeng.api.storage.IMEInventory;
import appeng.api.storage.StorageChannel;
import appeng.api.storage.data.IAEItemStack;
import appeng.api.util.AEPartLocation;
import appeng.core.AEConfig;
import appeng.core.features.AEFeature;
import appeng.core.localization.GuiText;
@@ -56,6 +53,8 @@ import appeng.items.tools.powered.powersink.AEBasePoweredItem;
import appeng.me.storage.CellInventoryHandler;
import appeng.util.Platform;
import com.google.common.base.Optional;
public class ToolPortableCell extends AEBasePoweredItem implements IStorageCell, IGuiItem, IItemGroup
{
@@ -68,7 +67,7 @@ public class ToolPortableCell extends AEBasePoweredItem implements IStorageCell,
@Override
public ItemStack onItemRightClick( ItemStack item, World w, EntityPlayer player )
{
Platform.openGUI( player, null, ForgeDirection.UNKNOWN, GuiBridge.GUI_PORTABLE_CELL );
Platform.openGUI( player, null, AEPartLocation.INTERNAL, GuiBridge.GUI_PORTABLE_CELL );
return item;
}
@@ -190,8 +189,8 @@ public class ToolPortableCell extends AEBasePoweredItem implements IStorageCell,
}
@Override
public IGuiItemObject getGuiObject( ItemStack is, World w, int x, int y, int z )
public IGuiItemObject getGuiObject( ItemStack is, World w, BlockPos pos )
{
return new PortableCellViewer( is, x );
return new PortableCellViewer( is, pos.getX() );
}
}
@@ -22,17 +22,13 @@ package appeng.items.tools.powered;
import java.util.EnumSet;
import java.util.List;
import com.google.common.base.Optional;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.item.ItemStack;
import net.minecraft.nbt.NBTTagCompound;
import net.minecraft.util.StatCollector;
import net.minecraft.world.World;
import cpw.mods.fml.relauncher.Side;
import cpw.mods.fml.relauncher.SideOnly;
import net.minecraftforge.fml.relauncher.Side;
import net.minecraftforge.fml.relauncher.SideOnly;
import appeng.api.AEApi;
import appeng.api.config.Settings;
import appeng.api.config.SortDir;
@@ -48,6 +44,8 @@ import appeng.util.ConfigManager;
import appeng.util.IConfigManagerHost;
import appeng.util.Platform;
import com.google.common.base.Optional;
public class ToolWirelessTerminal extends AEBasePoweredItem implements IWirelessTermHandler
{
@@ -22,7 +22,7 @@ package appeng.items.tools.powered.powersink;
import com.google.common.base.Optional;
public abstract class AEBasePoweredItem extends RedstoneFlux
public abstract class AEBasePoweredItem extends AERootPoweredItem
{
public AEBasePoweredItem( double powerCapacity, Optional<String> subName )
{
@@ -22,14 +22,11 @@ package appeng.items.tools.powered.powersink;
import java.text.MessageFormat;
import java.util.List;
import com.google.common.base.Optional;
import net.minecraft.creativetab.CreativeTabs;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.item.Item;
import net.minecraft.item.ItemStack;
import net.minecraft.nbt.NBTTagCompound;
import appeng.api.config.AccessRestriction;
import appeng.api.config.PowerUnits;
import appeng.api.implementations.items.IAEItemPowerStorage;
@@ -37,6 +34,8 @@ import appeng.core.localization.GuiText;
import appeng.items.AEBaseItem;
import appeng.util.Platform;
import com.google.common.base.Optional;
public abstract class AERootPoweredItem extends AEBaseItem implements IAEItemPowerStorage
{
@@ -21,17 +21,16 @@ package appeng.items.tools.quartz;
import java.util.EnumSet;
import com.google.common.base.Optional;
import net.minecraft.item.ItemAxe;
import net.minecraft.item.ItemStack;
import appeng.core.features.AEFeature;
import appeng.core.features.IAEFeature;
import appeng.core.features.IFeatureHandler;
import appeng.core.features.ItemFeatureHandler;
import appeng.util.Platform;
import com.google.common.base.Optional;
public class ToolQuartzAxe extends ItemAxe implements IAEFeature
{
@@ -21,21 +21,22 @@ package appeng.items.tools.quartz;
import java.util.EnumSet;
import com.google.common.base.Optional;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.item.ItemStack;
import net.minecraft.util.BlockPos;
import net.minecraft.util.EnumFacing;
import net.minecraft.world.World;
import net.minecraftforge.common.util.ForgeDirection;
import appeng.api.implementations.guiobjects.IGuiItem;
import appeng.api.implementations.guiobjects.IGuiItemObject;
import appeng.api.util.AEPartLocation;
import appeng.core.features.AEFeature;
import appeng.core.sync.GuiBridge;
import appeng.items.AEBaseItem;
import appeng.items.contents.QuartzKnifeObj;
import appeng.util.Platform;
import com.google.common.base.Optional;
public class ToolQuartzCuttingKnife extends AEBaseItem implements IGuiItem
{
@@ -52,11 +53,19 @@ public class ToolQuartzCuttingKnife extends AEBaseItem implements IGuiItem
}
@Override
public boolean onItemUse( ItemStack is, EntityPlayer p, World w, int x, int y, int z, int s, float hitX, float hitY, float hitZ )
public boolean onItemUse(
ItemStack stack,
EntityPlayer p,
World worldIn,
BlockPos pos,
EnumFacing side,
float hitX,
float hitY,
float hitZ )
{
if( Platform.isServer() )
{
Platform.openGUI( p, null, ForgeDirection.UNKNOWN, GuiBridge.GUI_QUARTZ_KNIFE );
Platform.openGUI( p, null, AEPartLocation.INTERNAL, GuiBridge.GUI_QUARTZ_KNIFE );
}
return true;
}
@@ -66,18 +75,12 @@ public class ToolQuartzCuttingKnife extends AEBaseItem implements IGuiItem
{
if( Platform.isServer() )
{
Platform.openGUI( p, null, ForgeDirection.UNKNOWN, GuiBridge.GUI_QUARTZ_KNIFE );
Platform.openGUI( p, null, AEPartLocation.INTERNAL, GuiBridge.GUI_QUARTZ_KNIFE );
}
p.swingItem();
return it;
}
@Override
public boolean doesContainerItemLeaveCraftingGrid( ItemStack par1ItemStack )
{
return false;
}
@Override
public boolean getIsRepairable( ItemStack a, ItemStack b )
{
@@ -104,7 +107,7 @@ public class ToolQuartzCuttingKnife extends AEBaseItem implements IGuiItem
}
@Override
public IGuiItemObject getGuiObject( ItemStack is, World world, int x, int y, int z )
public IGuiItemObject getGuiObject( ItemStack is, World world, BlockPos pos )
{
return new QuartzKnifeObj( is );
}
@@ -21,17 +21,16 @@ package appeng.items.tools.quartz;
import java.util.EnumSet;
import com.google.common.base.Optional;
import net.minecraft.item.ItemHoe;
import net.minecraft.item.ItemStack;
import appeng.core.features.AEFeature;
import appeng.core.features.IAEFeature;
import appeng.core.features.IFeatureHandler;
import appeng.core.features.ItemFeatureHandler;
import appeng.util.Platform;
import com.google.common.base.Optional;
public class ToolQuartzHoe extends ItemHoe implements IAEFeature
{
@@ -21,17 +21,16 @@ package appeng.items.tools.quartz;
import java.util.EnumSet;
import com.google.common.base.Optional;
import net.minecraft.item.ItemPickaxe;
import net.minecraft.item.ItemStack;
import appeng.core.features.AEFeature;
import appeng.core.features.IAEFeature;
import appeng.core.features.IFeatureHandler;
import appeng.core.features.ItemFeatureHandler;
import appeng.util.Platform;
import com.google.common.base.Optional;
public class ToolQuartzPickaxe extends ItemPickaxe implements IAEFeature
{
@@ -21,17 +21,16 @@ package appeng.items.tools.quartz;
import java.util.EnumSet;
import com.google.common.base.Optional;
import net.minecraft.item.ItemSpade;
import net.minecraft.item.ItemStack;
import appeng.core.features.AEFeature;
import appeng.core.features.IAEFeature;
import appeng.core.features.IFeatureHandler;
import appeng.core.features.ItemFeatureHandler;
import appeng.util.Platform;
import com.google.common.base.Optional;
public class ToolQuartzSpade extends ItemSpade implements IAEFeature
{
@@ -21,17 +21,16 @@ package appeng.items.tools.quartz;
import java.util.EnumSet;
import com.google.common.base.Optional;
import net.minecraft.item.ItemStack;
import net.minecraft.item.ItemSword;
import appeng.core.features.AEFeature;
import appeng.core.features.IAEFeature;
import appeng.core.features.IFeatureHandler;
import appeng.core.features.ItemFeatureHandler;
import appeng.util.Platform;
import com.google.common.base.Optional;
public class ToolQuartzSword extends ItemSword implements IAEFeature
{
@@ -21,26 +21,23 @@ package appeng.items.tools.quartz;
import java.util.EnumSet;
import com.google.common.base.Optional;
import net.minecraft.block.Block;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.item.ItemStack;
import net.minecraft.util.BlockPos;
import net.minecraft.util.EnumFacing;
import net.minecraft.world.World;
import net.minecraftforge.common.util.ForgeDirection;
import buildcraft.api.tools.IToolWrench;
import appeng.api.implementations.items.IAEWrench;
import appeng.api.util.DimensionalCoord;
import appeng.core.features.AEFeature;
import appeng.items.AEBaseItem;
import appeng.transformer.annotations.Integration.Interface;
import appeng.util.Platform;
import com.google.common.base.Optional;
@Interface( iface = "buildcraft.api.tools.IToolWrench", iname = "BC" )
public class ToolQuartzWrench extends AEBaseItem implements IAEWrench, IToolWrench
//@Interface( iface = "buildcraft.api.tools.IToolWrench", iname = "BC" ) IToolWrench
public class ToolQuartzWrench extends AEBaseItem implements IAEWrench
{
public ToolQuartzWrench( AEFeature type )
@@ -53,20 +50,27 @@ public class ToolQuartzWrench extends AEBaseItem implements IAEWrench, IToolWren
}
@Override
public boolean onItemUseFirst( ItemStack is, EntityPlayer player, World world, int x, int y, int z, int side, float hitX, float hitY, float hitZ )
public boolean onItemUseFirst(
ItemStack stack,
EntityPlayer player,
World world,
BlockPos pos,
EnumFacing side,
float hitX,
float hitY,
float hitZ )
{
Block b = world.getBlock( x, y, z );
if( b != null && !player.isSneaking() && Platform.hasPermissions( new DimensionalCoord( world, x, y, z ), player ) )
Block b = world.getBlockState( pos ).getBlock();
if( b != null && !player.isSneaking() && Platform.hasPermissions( new DimensionalCoord( world, pos ), player ) )
{
if( Platform.isClient() )
{
return !world.isRemote;
}
ForgeDirection mySide = ForgeDirection.getOrientation( side );
if( b.rotateBlock( world, x, y, z, mySide ) )
if( b.rotateBlock( world, pos, side ) )
{
b.onNeighborBlockChange( world, x, y, z, Platform.AIR_BLOCK );
b.onNeighborBlockChange( world, pos, Platform.AIR_BLOCK.getDefaultState(), Platform.AIR_BLOCK );
player.swingItem();
return !world.isRemote;
}
@@ -75,18 +79,25 @@ public class ToolQuartzWrench extends AEBaseItem implements IAEWrench, IToolWren
}
@Override
// public boolean shouldPassSneakingClickToBlock(World w, int x, int y, int z)
public boolean doesSneakBypassUse( World world, int x, int y, int z, EntityPlayer player )
public boolean doesSneakBypassUse(
World world,
BlockPos pos,
EntityPlayer player )
{
return true;
}
@Override
public boolean canWrench( ItemStack is, EntityPlayer player, int x, int y, int z )
public boolean canWrench(
ItemStack wrench,
EntityPlayer player,
BlockPos pos )
{
return true;
}
// TODO: BC Wrench Integration
/*
@Override
public boolean canWrench( EntityPlayer player, int x, int y, int z )
{
@@ -98,4 +109,5 @@ public class ToolQuartzWrench extends AEBaseItem implements IAEWrench, IToolWren
{
player.swingItem();
}
*/
}