Added Sky Rock.
Added Sky Chest.
This commit is contained in:
@@ -0,0 +1,29 @@
|
||||
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.core.features.AEFeature;
|
||||
import appeng.helpers.LocationRotation;
|
||||
|
||||
public class BlockSkyRock extends AEBaseBlock implements IOrientableBlock
|
||||
{
|
||||
|
||||
public BlockSkyRock() {
|
||||
super( BlockSkyRock.class, Material.rock );
|
||||
setfeature( EnumSet.of( AEFeature.Core ) );
|
||||
setHardness( 50 );
|
||||
blockResistance = 150.0f;
|
||||
}
|
||||
|
||||
@Override
|
||||
public IOrientable getOrientable(final IBlockAccess w, final int x, final int y, final int z)
|
||||
{
|
||||
return new LocationRotation( w, x, y, z );
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,75 @@
|
||||
package appeng.block.storage;
|
||||
|
||||
import java.util.Arrays;
|
||||
import java.util.EnumSet;
|
||||
import java.util.List;
|
||||
|
||||
import net.minecraft.block.material.Material;
|
||||
import net.minecraft.client.renderer.texture.IIconRegister;
|
||||
import net.minecraft.entity.Entity;
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.util.AxisAlignedBB;
|
||||
import net.minecraft.util.IIcon;
|
||||
import net.minecraft.world.World;
|
||||
import net.minecraftforge.common.util.ForgeDirection;
|
||||
import appeng.api.AEApi;
|
||||
import appeng.block.AEBaseBlock;
|
||||
import appeng.client.render.BaseBlockRender;
|
||||
import appeng.client.render.blocks.RenderBlockSkyChest;
|
||||
import appeng.core.features.AEFeature;
|
||||
import appeng.core.sync.GuiBridge;
|
||||
import appeng.helpers.ICustomCollision;
|
||||
import appeng.tile.storage.TileSkyChest;
|
||||
import appeng.util.Platform;
|
||||
|
||||
public class BlockSkyChest extends AEBaseBlock implements ICustomCollision
|
||||
{
|
||||
|
||||
public BlockSkyChest() {
|
||||
super( BlockSkyChest.class, Material.rock );
|
||||
setfeature( EnumSet.of( AEFeature.Core ) );
|
||||
setTileEntiy( TileSkyChest.class );
|
||||
isOpaque = isFullSize = false;
|
||||
lightOpacity = 0;
|
||||
setHardness( 50 );
|
||||
blockResistance = 150.0f;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean onActivated(World w, int x, int y, int z, EntityPlayer player, int side, float hitX, float hitY, float hitZ)
|
||||
{
|
||||
if ( Platform.isServer() )
|
||||
Platform.openGUI( player, getTileEntity( w, x, y, z ), ForgeDirection.getOrientation( side ), GuiBridge.GUI_SKYCHEST );
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected Class<? extends BaseBlockRender> getRenderer()
|
||||
{
|
||||
return RenderBlockSkyChest.class;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Iterable<AxisAlignedBB> getSelectedBoundingBoxsFromPool(World w, int x, int y, int z, Entity e, boolean isVisual)
|
||||
{
|
||||
return Arrays.asList( new AxisAlignedBB[] { AxisAlignedBB.getBoundingBox( 0.05, 0.05, 0.05, 0.95, 0.95, 0.95 ) } );
|
||||
}
|
||||
|
||||
@Override
|
||||
public void addCollidingBlockToList(World w, int x, int y, int z, AxisAlignedBB bb, List out, Entity e)
|
||||
{
|
||||
out.add( AxisAlignedBB.getAABBPool().getAABB( 0.05, 0.05, 0.05, 0.95, 0.95, 0.95 ) );
|
||||
}
|
||||
|
||||
@Override
|
||||
public IIcon getIcon(int direction, int metadata)
|
||||
{
|
||||
return AEApi.instance().blocks().blockSkyRock.block().getIcon( direction, metadata );
|
||||
}
|
||||
|
||||
@Override
|
||||
public void registerBlockIcons(IIconRegister iconRegistry)
|
||||
{
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,31 @@
|
||||
package appeng.client.gui.implementations;
|
||||
|
||||
import net.minecraft.entity.player.InventoryPlayer;
|
||||
import appeng.client.gui.AEBaseGui;
|
||||
import appeng.container.implementations.ContainerSkyChest;
|
||||
import appeng.core.localization.GuiText;
|
||||
import appeng.tile.storage.TileSkyChest;
|
||||
|
||||
public class GuiSkyChest extends AEBaseGui
|
||||
{
|
||||
|
||||
public GuiSkyChest(InventoryPlayer inventoryPlayer, TileSkyChest te) {
|
||||
super( new ContainerSkyChest( inventoryPlayer, te ) );
|
||||
this.ySize = 195;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void drawBG(int offsetX, int offsetY, int mouseX, int mouseY)
|
||||
{
|
||||
bindTexture( "guis/skychest.png" );
|
||||
this.drawTexturedModalRect( offsetX, offsetY, 0, 0, xSize, ySize );
|
||||
}
|
||||
|
||||
@Override
|
||||
public void drawFG(int offsetX, int offsetY, int mouseX, int mouseY)
|
||||
{
|
||||
fontRendererObj.drawString( GuiText.SkyChest.getLocal(), 8, 8, 4210752 );
|
||||
fontRendererObj.drawString( GuiText.inventory.getLocal(), 8, ySize - 96 + 2, 4210752 );
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,102 @@
|
||||
package appeng.client.render.blocks;
|
||||
|
||||
import net.minecraft.client.Minecraft;
|
||||
import net.minecraft.client.model.ModelChest;
|
||||
import net.minecraft.client.renderer.RenderBlocks;
|
||||
import net.minecraft.client.renderer.Tessellator;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.util.ResourceLocation;
|
||||
import net.minecraft.world.IBlockAccess;
|
||||
|
||||
import org.lwjgl.opengl.GL11;
|
||||
|
||||
import appeng.block.AEBaseBlock;
|
||||
import appeng.client.render.BaseBlockRender;
|
||||
import appeng.tile.AEBaseTile;
|
||||
import appeng.tile.storage.TileSkyChest;
|
||||
|
||||
public class RenderBlockSkyChest extends BaseBlockRender
|
||||
{
|
||||
|
||||
ModelChest model = new ModelChest();
|
||||
|
||||
public RenderBlockSkyChest() {
|
||||
super( true, 80 );
|
||||
}
|
||||
|
||||
@Override
|
||||
public void renderInventory(AEBaseBlock blk, ItemStack is, RenderBlocks renderer)
|
||||
{
|
||||
GL11.glEnable( 32826 /* GL_RESCALE_NORMAL_EXT */);
|
||||
GL11.glColor4f( 1.0F, 1.0F, 1.0F, 1.0F );
|
||||
|
||||
ResourceLocation loc = new ResourceLocation( "appliedenergistics2", "textures/models/skychest.png" );
|
||||
Minecraft.getMinecraft().getTextureManager().bindTexture( loc );
|
||||
|
||||
float lidangle = 0.0f;
|
||||
|
||||
GL11.glScalef( 1.0F, -1F, -1F );
|
||||
GL11.glTranslatef( -0.0F, -1.0F, -1.0F );
|
||||
|
||||
model.chestLid.offsetY = -(0.9f / 16.0f);
|
||||
model.chestLid.rotateAngleX = -((lidangle * 3.141593F) / 2.0F);
|
||||
model.renderAll();
|
||||
|
||||
GL11.glDisable( 32826 /* GL_RESCALE_NORMAL_EXT */);
|
||||
GL11.glColor4f( 1.0F, 1.0F, 1.0F, 1.0F );
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean renderInWorld(AEBaseBlock blk, IBlockAccess world, int x, int y, int z, RenderBlocks renderer)
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void renderTile(AEBaseBlock block, AEBaseTile tile, Tessellator tess, double x, double y, double z, float partialTick, RenderBlocks renderer)
|
||||
{
|
||||
if ( !(tile instanceof TileSkyChest) )
|
||||
return;
|
||||
|
||||
TileSkyChest skyChest = (TileSkyChest) tile;
|
||||
|
||||
if ( !skyChest.hasWorldObj() )
|
||||
return;
|
||||
|
||||
GL11.glEnable( 32826 /* GL_RESCALE_NORMAL_EXT */);
|
||||
GL11.glColor4f( 1.0F, 1.0F, 1.0F, 1.0F );
|
||||
|
||||
ResourceLocation loc = new ResourceLocation( "appliedenergistics2", "textures/models/skychest.png" );
|
||||
Minecraft.getMinecraft().getTextureManager().bindTexture( loc );
|
||||
|
||||
this.applyTESRRotation( x, y, z, skyChest.getForward(), skyChest.getUp() );
|
||||
|
||||
GL11.glScalef( 1.0F, -1F, -1F );
|
||||
GL11.glTranslatef( -0.0F, -1.0F, -1.0F );
|
||||
|
||||
long now = System.currentTimeMillis();
|
||||
long distnace = now - skyChest.lastEvent;
|
||||
|
||||
if ( skyChest.playerOpen > 0 )
|
||||
skyChest.lidAngle += distnace * 0.0001;
|
||||
else
|
||||
skyChest.lidAngle -= distnace * 0.0001;
|
||||
|
||||
if ( skyChest.lidAngle > 0.5f )
|
||||
skyChest.lidAngle = 0.5f;
|
||||
|
||||
if ( skyChest.lidAngle < 0.0f )
|
||||
skyChest.lidAngle = 0.0f;
|
||||
|
||||
float lidangle = skyChest.lidAngle;
|
||||
lidangle = 1.0F - lidangle;
|
||||
lidangle = 1.0F - lidangle * lidangle * lidangle;
|
||||
|
||||
model.chestLid.offsetY = -(0.9f / 16.0f);
|
||||
model.chestLid.rotateAngleX = -((lidangle * 3.141593F) / 2.0F);
|
||||
model.renderAll();
|
||||
|
||||
GL11.glDisable( 32826 /* GL_RESCALE_NORMAL_EXT */);
|
||||
GL11.glColor4f( 1.0F, 1.0F, 1.0F, 1.0F );
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,37 @@
|
||||
package appeng.container.implementations;
|
||||
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.entity.player.InventoryPlayer;
|
||||
import appeng.container.AEBaseContainer;
|
||||
import appeng.container.slot.SlotNormal;
|
||||
import appeng.tile.storage.TileSkyChest;
|
||||
|
||||
public class ContainerSkyChest extends AEBaseContainer
|
||||
{
|
||||
|
||||
TileSkyChest myte;
|
||||
|
||||
public ContainerSkyChest(InventoryPlayer ip, TileSkyChest te) {
|
||||
super( ip, te, null );
|
||||
myte = te;
|
||||
|
||||
for (int y = 0; y < 4; y++)
|
||||
{
|
||||
for (int x = 0; x < 9; x++)
|
||||
{
|
||||
addSlotToContainer( new SlotNormal( myte, y * 9 + x, 8 + 18 * x, 24 + 18 * y ) );
|
||||
}
|
||||
}
|
||||
|
||||
myte.openInventory();
|
||||
|
||||
bindPlayerInventory( ip, 0, 195 - /* height of playerinventory */82 );
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onContainerClosed(EntityPlayer par1EntityPlayer)
|
||||
{
|
||||
super.onContainerClosed( par1EntityPlayer );
|
||||
myte.closeInventory();
|
||||
}
|
||||
}
|
||||
@@ -54,6 +54,7 @@ import appeng.block.solids.BlockQuartzChiseled;
|
||||
import appeng.block.solids.BlockQuartzGlass;
|
||||
import appeng.block.solids.BlockQuartzLamp;
|
||||
import appeng.block.solids.BlockQuartzPillar;
|
||||
import appeng.block.solids.BlockSkyRock;
|
||||
import appeng.block.solids.OreQuartz;
|
||||
import appeng.block.solids.OreQuartzCharged;
|
||||
import appeng.block.spatial.BlockSpatialIOPort;
|
||||
@@ -61,6 +62,7 @@ import appeng.block.spatial.BlockSpatialPylon;
|
||||
import appeng.block.storage.BlockChest;
|
||||
import appeng.block.storage.BlockDrive;
|
||||
import appeng.block.storage.BlockIOPort;
|
||||
import appeng.block.storage.BlockSkyChest;
|
||||
import appeng.core.features.AEFeature;
|
||||
import appeng.core.features.AEFeatureHandler;
|
||||
import appeng.core.features.ColoredItemDefinition;
|
||||
@@ -245,6 +247,8 @@ public class Registration
|
||||
blocks.blockMatrixFrame = addFeature( BlockMatrixFrame.class );
|
||||
blocks.blockQuartz = addFeature( BlockQuartz.class );
|
||||
blocks.blockFluix = addFeature( BlockFluix.class );
|
||||
blocks.blockSkyRock = addFeature( BlockSkyRock.class );
|
||||
blocks.blockSkyChest = addFeature( BlockSkyChest.class );
|
||||
|
||||
blocks.blockQuartzGlass = addFeature( BlockQuartzGlass.class );
|
||||
blocks.blockQuartzVibrantGlass = addFeature( BlockQuartzLamp.class );
|
||||
|
||||
@@ -6,7 +6,7 @@ public enum GuiText
|
||||
{
|
||||
inventory("container"), // mc's default Inventory localization.
|
||||
|
||||
Chest, StoredEnergy, Of, Condenser, Drive, GrindStone,
|
||||
Chest, StoredEnergy, Of, Condenser, Drive, GrindStone, SkyChest,
|
||||
|
||||
VibrationChamber, SpatialIOPort, LevelEmitter, Terminal,
|
||||
|
||||
|
||||
@@ -45,6 +45,7 @@ import appeng.container.implementations.ContainerNetworkTool;
|
||||
import appeng.container.implementations.ContainerPriority;
|
||||
import appeng.container.implementations.ContainerQNB;
|
||||
import appeng.container.implementations.ContainerSecurity;
|
||||
import appeng.container.implementations.ContainerSkyChest;
|
||||
import appeng.container.implementations.ContainerStorageBus;
|
||||
import appeng.container.implementations.ContainerUpgradeable;
|
||||
import appeng.container.implementations.ContainerVibrationChamber;
|
||||
@@ -68,6 +69,7 @@ import appeng.tile.qnb.TileQuantumBridge;
|
||||
import appeng.tile.storage.TileChest;
|
||||
import appeng.tile.storage.TileDrive;
|
||||
import appeng.tile.storage.TileIOPort;
|
||||
import appeng.tile.storage.TileSkyChest;
|
||||
import appeng.util.Platform;
|
||||
import cpw.mods.fml.common.network.IGuiHandler;
|
||||
import cpw.mods.fml.relauncher.ReflectionHelper;
|
||||
@@ -80,6 +82,8 @@ public enum GuiBridge implements IGuiHandler
|
||||
|
||||
GUI_QNB(ContainerQNB.class, TileQuantumBridge.class, false, SecurityPermissions.BUILD),
|
||||
|
||||
GUI_SKYCHEST(ContainerSkyChest.class, TileSkyChest.class, false, null),
|
||||
|
||||
GUI_CHEST(ContainerChest.class, TileChest.class, false, SecurityPermissions.BUILD),
|
||||
|
||||
GUI_WIRELESS(ContainerWireless.class, TileWireless.class, false, SecurityPermissions.BUILD),
|
||||
|
||||
@@ -0,0 +1,114 @@
|
||||
package appeng.tile.storage;
|
||||
|
||||
import io.netty.buffer.ByteBuf;
|
||||
|
||||
import java.io.IOException;
|
||||
|
||||
import net.minecraft.inventory.IInventory;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import appeng.tile.AEBaseInvTile;
|
||||
import appeng.tile.events.AETileEventHandler;
|
||||
import appeng.tile.events.TileEventType;
|
||||
import appeng.tile.inventory.AppEngInternalInventory;
|
||||
import appeng.tile.inventory.InvOperation;
|
||||
import appeng.util.Platform;
|
||||
|
||||
public class TileSkyChest extends AEBaseInvTile
|
||||
{
|
||||
|
||||
final int sides[] = { 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35 };
|
||||
final AppEngInternalInventory inv = new AppEngInternalInventory( this, 9 * 4 );
|
||||
|
||||
class SkyChestHnadler extends AETileEventHandler
|
||||
{
|
||||
|
||||
public SkyChestHnadler() {
|
||||
super( TileEventType.NETWORK );
|
||||
}
|
||||
|
||||
@Override
|
||||
public void writeToStream(ByteBuf data) throws IOException
|
||||
{
|
||||
data.writeBoolean( playerOpen > 0 );
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean readFromStream(ByteBuf data) throws IOException
|
||||
{
|
||||
int wasOpen = playerOpen;
|
||||
playerOpen = data.readBoolean() ? 1 : 0;
|
||||
|
||||
if ( wasOpen != playerOpen )
|
||||
lastEvent = System.currentTimeMillis();
|
||||
|
||||
return false; // TESR yo!
|
||||
}
|
||||
|
||||
};
|
||||
|
||||
public TileSkyChest() {
|
||||
addNewHandler( new SkyChestHnadler() );
|
||||
}
|
||||
|
||||
// server
|
||||
public int playerOpen;
|
||||
|
||||
// client..
|
||||
public long lastEvent;
|
||||
public float lidAngle;
|
||||
|
||||
@Override
|
||||
public boolean requiresTESR()
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onChangeInventory(IInventory inv, int slot, InvOperation mc, ItemStack removed, ItemStack added)
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public IInventory getInternalInventory()
|
||||
{
|
||||
return inv;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int[] getAccessibleSlotsFromSide(int side)
|
||||
{
|
||||
return sides;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void openInventory()
|
||||
{
|
||||
if ( Platform.isClient() )
|
||||
return;
|
||||
|
||||
playerOpen++;
|
||||
|
||||
if ( playerOpen == 1 )
|
||||
{
|
||||
getWorldObj().playSoundEffect( xCoord + 0.5D, yCoord + 0.5D, zCoord + 0.5D, "random.chestopen", 0.5F, getWorldObj().rand.nextFloat() * 0.1F + 0.9F );
|
||||
markForUpdate();
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void closeInventory()
|
||||
{
|
||||
if ( Platform.isClient() )
|
||||
return;
|
||||
|
||||
playerOpen--;
|
||||
|
||||
if ( playerOpen < 0 )
|
||||
playerOpen = 0;
|
||||
|
||||
if ( playerOpen == 0 )
|
||||
markForUpdate();
|
||||
}
|
||||
|
||||
}
|
||||
Reference in New Issue
Block a user