diff --git a/block/AEBaseBlock.java b/block/AEBaseBlock.java index ab274292..ee1f840a 100644 --- a/block/AEBaseBlock.java +++ b/block/AEBaseBlock.java @@ -48,6 +48,7 @@ import appeng.util.LookDirection; import appeng.util.Platform; import appeng.util.SettingsFrom; import cpw.mods.fml.common.registry.GameRegistry; +import cpw.mods.fml.relauncher.ReflectionHelper; import cpw.mods.fml.relauncher.Side; import cpw.mods.fml.relauncher.SideOnly; @@ -158,6 +159,11 @@ public class AEBaseBlock extends BlockContainer implements IAEFeature return getRendererInstance().getTexture( ForgeDirection.getOrientation( direction ) ); } + public IIcon unmappedGetIcon(IBlockAccess w, int x, int y, int z, int s) + { + return super.getIcon( w, x, y, z, s ); + } + @Override public IIcon getIcon(IBlockAccess w, int x, int y, int z, int s) { @@ -169,6 +175,7 @@ public class AEBaseBlock extends BlockContainer implements IAEFeature AEBaseTile.registerTileItem( c, new ItemStackSrc( this, 0 ) ); GameRegistry.registerTileEntity( tileEntityType = c, FeatureFullname ); isInventory = IInventory.class.isAssignableFrom( c ); + setTileProvider( hasBlockTileEntity() ); } protected void setfeature(EnumSet f) @@ -181,6 +188,13 @@ public class AEBaseBlock extends BlockContainer implements IAEFeature setLightOpacity( 15 ); setLightLevel( 0 ); setHardness( 1.2F ); + setTileProvider( false ); + } + + // update Block value. + private void setTileProvider(boolean b) + { + ReflectionHelper.setPrivateValue( Block.class, this, b, "isTileProvider" ); } protected AEBaseBlock(Class c, Material mat, String subname) { @@ -231,12 +245,6 @@ public class AEBaseBlock extends BlockContainer implements IAEFeature return tileEntityType != null; } - @Override - final public boolean hasTileEntity(int metadata) - { - return hasBlockTileEntity(); - } - public Class getTileEntityClass() { return tileEntityType; @@ -267,14 +275,18 @@ public class AEBaseBlock extends BlockContainer implements IAEFeature @Override final public TileEntity createNewTileEntity(World var1, int var2) { - try + if ( hasBlockTileEntity() ) { - return tileEntityType.newInstance(); - } - catch (Throwable e) - { - throw new RuntimeException( e ); + try + { + return tileEntityType.newInstance(); + } + catch (Throwable e) + { + throw new RuntimeException( e ); + } } + return null; } final public T getTileEntity(IBlockAccess w, int x, int y, int z) @@ -294,7 +306,7 @@ public class AEBaseBlock extends BlockContainer implements IAEFeature return false; } - protected void customRotateBlock(IOrientable rotateable, ForgeDirection axis) + protected void customRotateBlock(IOrientable rotatable, ForgeDirection axis) { } @@ -302,28 +314,28 @@ public class AEBaseBlock extends BlockContainer implements IAEFeature @Override final public boolean rotateBlock(World w, int x, int y, int z, ForgeDirection axis) { - IOrientable rotateable = null; + IOrientable rotatable = null; if ( hasBlockTileEntity() ) { - rotateable = (AEBaseTile) getTileEntity( w, x, y, z ); + rotatable = (AEBaseTile) getTileEntity( w, x, y, z ); } else if ( this instanceof IOrientableBlock ) { - rotateable = ((IOrientableBlock) this).getOrientable( w, x, y, z ); + rotatable = ((IOrientableBlock) this).getOrientable( w, x, y, z ); } - if ( rotateable != null && rotateable.canBeRotated() ) + if ( rotatable != null && rotatable.canBeRotated() ) { if ( hasCustomRotation() ) { - customRotateBlock( rotateable, axis ); + customRotateBlock( rotatable, axis ); return true; } else { - ForgeDirection forward = rotateable.getForward(); - ForgeDirection up = rotateable.getUp(); + ForgeDirection forward = rotatable.getForward(); + ForgeDirection up = rotatable.getUp(); for (int rs = 0; rs < 4; rs++) { @@ -332,14 +344,14 @@ public class AEBaseBlock extends BlockContainer implements IAEFeature if ( this.isValidOrientation( w, x, y, z, forward, up ) ) { - rotateable.setOrientation( forward, up ); + rotatable.setOrientation( forward, up ); return true; } } } } - return false; + return super.rotateBlock( w, x, y, z, axis ); } public ForgeDirection mapRotation(IOrientable ori, ForgeDirection dir) diff --git a/block/AEDecorativeBlock.java b/block/AEDecorativeBlock.java new file mode 100644 index 00000000..34a929e6 --- /dev/null +++ b/block/AEDecorativeBlock.java @@ -0,0 +1,26 @@ +package appeng.block; + +import net.minecraft.block.material.Material; +import net.minecraft.util.IIcon; +import net.minecraft.world.IBlockAccess; + +public class AEDecorativeBlock extends AEBaseBlock +{ + + protected AEDecorativeBlock(Class c, Material mat) { + super( c, mat ); + } + + @Override + public IIcon getIcon(IBlockAccess w, int x, int y, int z, int s) + { + return super.unmappedGetIcon( w, x, y, z, s ); + } + + @Override + public int getRenderType() + { + return 0; + } + +} diff --git a/block/misc/BlockInterface.java b/block/misc/BlockInterface.java index 9674f1fd..e4a3312c 100644 --- a/block/misc/BlockInterface.java +++ b/block/misc/BlockInterface.java @@ -37,11 +37,11 @@ public class BlockInterface extends AEBaseBlock } @Override - protected void customRotateBlock(IOrientable rotateable, ForgeDirection axis) + protected void customRotateBlock(IOrientable rotatable, ForgeDirection axis) { - if ( rotateable instanceof TileInterface ) + if ( rotatable instanceof TileInterface ) { - ((TileInterface) rotateable).setSide( axis ); + ((TileInterface) rotatable).setSide( axis ); } } diff --git a/block/solids/BlockFluix.java b/block/solids/BlockFluix.java index a30d8a4c..ecb8414f 100644 --- a/block/solids/BlockFluix.java +++ b/block/solids/BlockFluix.java @@ -3,14 +3,10 @@ package appeng.block.solids; import java.util.EnumSet; import net.minecraft.block.material.Material; -import net.minecraft.world.IBlockAccess; -import appeng.api.util.IOrientable; -import appeng.api.util.IOrientableBlock; -import appeng.block.AEBaseBlock; +import appeng.block.AEDecorativeBlock; import appeng.core.features.AEFeature; -import appeng.helpers.LocationRotation; -public class BlockFluix extends AEBaseBlock implements IOrientableBlock +public class BlockFluix extends AEDecorativeBlock { public BlockFluix() { @@ -18,10 +14,4 @@ public class BlockFluix extends AEBaseBlock implements IOrientableBlock setfeature( EnumSet.of( AEFeature.DecorativeQuartzBlocks ) ); } - @Override - public IOrientable getOrientable(final IBlockAccess w, final int x, final int y, final int z) - { - return new LocationRotation( w, x, y, z ); - } - } diff --git a/block/solids/BlockQuartz.java b/block/solids/BlockQuartz.java index 424b1c58..20bb1f8c 100644 --- a/block/solids/BlockQuartz.java +++ b/block/solids/BlockQuartz.java @@ -3,10 +3,10 @@ package appeng.block.solids; import java.util.EnumSet; import net.minecraft.block.material.Material; -import appeng.block.AEBaseBlock; +import appeng.block.AEDecorativeBlock; import appeng.core.features.AEFeature; -public class BlockQuartz extends AEBaseBlock +public class BlockQuartz extends AEDecorativeBlock { public BlockQuartz() { diff --git a/block/solids/BlockQuartzChiseled.java b/block/solids/BlockQuartzChiseled.java index f24fa45d..896d6997 100644 --- a/block/solids/BlockQuartzChiseled.java +++ b/block/solids/BlockQuartzChiseled.java @@ -3,10 +3,10 @@ package appeng.block.solids; import java.util.EnumSet; import net.minecraft.block.material.Material; -import appeng.block.AEBaseBlock; +import appeng.block.AEDecorativeBlock; import appeng.core.features.AEFeature; -public class BlockQuartzChiseled extends AEBaseBlock +public class BlockQuartzChiseled extends AEDecorativeBlock { public BlockQuartzChiseled() { diff --git a/block/solids/BlockSkyStone.java b/block/solids/BlockSkyStone.java index 44b5f171..eb7a4657 100644 --- a/block/solids/BlockSkyStone.java +++ b/block/solids/BlockSkyStone.java @@ -9,23 +9,28 @@ import net.minecraft.client.renderer.texture.IIconRegister; import net.minecraft.creativetab.CreativeTabs; import net.minecraft.item.Item; import net.minecraft.item.ItemStack; +import net.minecraft.tileentity.TileEntity; import net.minecraft.util.IIcon; import net.minecraft.util.MovingObjectPosition; import net.minecraft.world.IBlockAccess; import net.minecraft.world.World; import net.minecraftforge.common.MinecraftForge; import net.minecraftforge.event.entity.player.PlayerEvent; +import rblocks.api.RotatableBlockEnable; import appeng.api.util.IOrientable; import appeng.api.util.IOrientableBlock; import appeng.block.AEBaseBlock; +import appeng.core.AppEng; import appeng.core.WorldSettings; import appeng.core.features.AEFeature; import appeng.helpers.LocationRotation; import appeng.helpers.NullRotation; +import appeng.integration.abstraction.IRB; import cpw.mods.fml.common.eventhandler.SubscribeEvent; import cpw.mods.fml.relauncher.Side; import cpw.mods.fml.relauncher.SideOnly; +@RotatableBlockEnable public class BlockSkyStone extends AEBaseBlock implements IOrientableBlock { @@ -79,8 +84,20 @@ public class BlockSkyStone extends AEBaseBlock implements IOrientableBlock @Override public IOrientable getOrientable(final IBlockAccess w, final int x, final int y, final int z) { + if ( AppEng.instance.isIntegrationEnabled( "RB" ) ) + { + TileEntity te = w.getTileEntity( x, y, z ); + if ( te != null ) + { + IOrientable out = ((IRB) AppEng.instance.getIntegration( "RB" )).getOrientable( te ); + if ( out != null ) + return out; + } + } + if ( w.getBlockMetadata( x, y, z ) == 0 ) return new LocationRotation( w, x, y, z ); + return new NullRotation(); } @@ -145,4 +162,10 @@ public class BlockSkyStone extends AEBaseBlock implements IOrientableBlock WorldSettings.getInstance().getCompass().updateArea( w, x, y, z ); } + // use AE2's enderer, no rotatable blocks. + int getRealRenderType() + { + return getRenderType(); + } + } diff --git a/core/AppEng.java b/core/AppEng.java index 35ab2d0d..f6b5fb01 100644 --- a/core/AppEng.java +++ b/core/AppEng.java @@ -87,6 +87,7 @@ public class AppEng // IntegrationSide.BOTH, "Forestry", "Forestry", "Forestry", // Forestry // IntegrationSide.BOTH, "Mekanism", "Mekanism", "Mekanism", // MeK IntegrationSide.CLIENT, "Waila", "Waila", "Waila", // Waila + IntegrationSide.BOTH, "Rotatable Blocks", "RotatableBlocks", "RB", // RB IntegrationSide.CLIENT, "Inventory Tweaks", "inventorytweaks", "InvTweaks", // INV IntegrationSide.CLIENT, "Not Enough Items", "NotEnoughItems", "NEI", // NEI IntegrationSide.CLIENT, "Craft Guide", "craftguide", "CraftGuide", // CraftGuide diff --git a/helpers/LocationRotation.java b/helpers/LocationRotation.java index fdde4a2d..b8f70048 100644 --- a/helpers/LocationRotation.java +++ b/helpers/LocationRotation.java @@ -43,6 +43,6 @@ public class LocationRotation implements IOrientable @Override public boolean canBeRotated() { - return true; + return false; } } diff --git a/integration/abstraction/IRB.java b/integration/abstraction/IRB.java new file mode 100644 index 00000000..0770759f --- /dev/null +++ b/integration/abstraction/IRB.java @@ -0,0 +1,11 @@ +package appeng.integration.abstraction; + +import net.minecraft.tileentity.TileEntity; +import appeng.api.util.IOrientable; + +public interface IRB +{ + + IOrientable getOrientable(TileEntity te); + +} diff --git a/integration/modules/RB.java b/integration/modules/RB.java new file mode 100644 index 00000000..122d200d --- /dev/null +++ b/integration/modules/RB.java @@ -0,0 +1,69 @@ +package appeng.integration.modules; + +import net.minecraft.tileentity.TileEntity; +import net.minecraftforge.common.util.ForgeDirection; +import rblocks.api.IOrientable; +import appeng.integration.BaseModule; +import appeng.integration.abstraction.IRB; + +public class RB extends BaseModule implements IRB +{ + + private class RBWrapper implements appeng.api.util.IOrientable + { + + final private IOrientable internal; + + public RBWrapper(IOrientable ww) { + internal = ww; + } + + @Override + public boolean canBeRotated() + { + return internal.canBeRotated(); + } + + @Override + public ForgeDirection getForward() + { + return internal.getForward(); + } + + @Override + public ForgeDirection getUp() + { + return internal.getUp(); + } + + @Override + public void setOrientation(ForgeDirection Forward, ForgeDirection Up) + { + internal.setOrientation( Forward, Up ); + } + + }; + + public static RB instance; + + @Override + public void Init() throws Throwable + { + TestClass( IOrientable.class ); + } + + @Override + public void PostInit() throws Throwable + { + + } + + @Override + public appeng.api.util.IOrientable getOrientable(TileEntity te) + { + if ( te instanceof IOrientable ) + return new RBWrapper( (IOrientable) te ); + return null; + } + +} diff --git a/util/inv/AdaptorIInventory.java b/util/inv/AdaptorIInventory.java index 5608dff1..d8e48f25 100644 --- a/util/inv/AdaptorIInventory.java +++ b/util/inv/AdaptorIInventory.java @@ -240,7 +240,7 @@ public class AdaptorIInventory extends InventoryAdaptor } else if ( is != null ) { - if ( Platform.isSameItem( is, left ) ) + if ( Platform.isSameItemPrecise( is, left ) ) { if ( is.stackSize < stack_limit ) { @@ -303,7 +303,7 @@ public class AdaptorIInventory extends InventoryAdaptor } else { - if ( Platform.isSameItem( is, left ) ) + if ( Platform.isSameItemPrecise( is, left ) ) { if ( is.stackSize < stack_limit ) {