2014-11-14 12:02:52 +01:00
|
|
|
/*
|
|
|
|
* This file is part of Applied Energistics 2.
|
|
|
|
* Copyright (c) 2013 - 2014, AlgorithmX2, All rights reserved.
|
|
|
|
*
|
|
|
|
* Applied Energistics 2 is free software: you can redistribute it and/or modify
|
|
|
|
* it under the terms of the GNU Lesser General Public License as published by
|
|
|
|
* the Free Software Foundation, either version 3 of the License, or
|
|
|
|
* (at your option) any later version.
|
|
|
|
*
|
|
|
|
* Applied Energistics 2 is distributed in the hope that it will be useful,
|
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
* GNU Lesser General Public License for more details.
|
|
|
|
*
|
|
|
|
* You should have received a copy of the GNU Lesser General Public License
|
|
|
|
* along with Applied Energistics 2. If not, see <http://www.gnu.org/licenses/lgpl>.
|
|
|
|
*/
|
|
|
|
|
2014-02-28 09:12:00 +01:00
|
|
|
package appeng.block.storage;
|
|
|
|
|
2014-11-28 04:36:46 +01:00
|
|
|
|
|
|
|
import java.util.Collections;
|
2014-02-28 09:12:00 +01:00
|
|
|
import java.util.List;
|
2016-06-19 14:43:27 +02:00
|
|
|
import javax.annotation.Nullable;
|
|
|
|
|
2014-02-28 09:12:00 +01:00
|
|
|
import net.minecraft.block.material.Material;
|
2016-07-11 15:38:54 +02:00
|
|
|
import net.minecraft.block.state.IBlockState;
|
2014-02-28 09:12:00 +01:00
|
|
|
import net.minecraft.entity.Entity;
|
|
|
|
import net.minecraft.entity.player.EntityPlayer;
|
2016-06-19 14:43:27 +02:00
|
|
|
import net.minecraft.item.ItemStack;
|
2016-07-11 15:38:54 +02:00
|
|
|
import net.minecraft.util.EnumBlockRenderType;
|
2015-06-16 02:44:59 +02:00
|
|
|
import net.minecraft.util.EnumFacing;
|
2016-06-19 14:43:27 +02:00
|
|
|
import net.minecraft.util.EnumHand;
|
|
|
|
import net.minecraft.util.math.AxisAlignedBB;
|
|
|
|
import net.minecraft.util.math.BlockPos;
|
2014-02-28 09:12:00 +01:00
|
|
|
import net.minecraft.world.World;
|
2015-09-30 14:22:21 +02:00
|
|
|
|
2015-06-16 02:44:59 +02:00
|
|
|
import appeng.api.util.AEPartLocation;
|
2015-05-09 12:18:43 +02:00
|
|
|
import appeng.block.AEBaseTileBlock;
|
2014-02-28 09:12:00 +01:00
|
|
|
import appeng.core.sync.GuiBridge;
|
|
|
|
import appeng.helpers.ICustomCollision;
|
|
|
|
import appeng.tile.storage.TileSkyChest;
|
|
|
|
import appeng.util.Platform;
|
|
|
|
|
2015-04-03 08:54:31 +02:00
|
|
|
|
2016-08-22 14:25:10 +02:00
|
|
|
public class BlockSkyChest extends AEBaseTileBlock implements ICustomCollision
|
2014-02-28 09:12:00 +01:00
|
|
|
{
|
2015-12-24 02:03:16 +01:00
|
|
|
|
2016-08-22 14:25:10 +02:00
|
|
|
public enum SkyChestType
|
2015-06-16 02:44:59 +02:00
|
|
|
{
|
|
|
|
STONE, BLOCK
|
|
|
|
};
|
2014-02-28 09:12:00 +01:00
|
|
|
|
2015-06-16 02:44:59 +02:00
|
|
|
public final SkyChestType type;
|
2015-12-24 02:03:16 +01:00
|
|
|
|
2015-09-30 14:24:40 +02:00
|
|
|
public BlockSkyChest( final SkyChestType type )
|
2015-04-03 08:54:31 +02:00
|
|
|
{
|
2016-08-22 14:25:10 +02:00
|
|
|
super( Material.ROCK );
|
2014-12-29 15:13:47 +01:00
|
|
|
this.setTileEntity( TileSkyChest.class );
|
2015-10-08 15:42:42 +02:00
|
|
|
this.setOpaque( this.setFullSize( false ) );
|
2014-12-29 15:13:47 +01:00
|
|
|
this.lightOpacity = 0;
|
2015-12-24 02:05:39 +01:00
|
|
|
this.setHasSubtypes( true );
|
2014-12-29 15:13:47 +01:00
|
|
|
this.setHardness( 50 );
|
|
|
|
this.blockResistance = 150.0f;
|
2015-06-16 02:44:59 +02:00
|
|
|
this.type = type;
|
2014-02-28 09:12:00 +01:00
|
|
|
}
|
|
|
|
|
2016-07-11 15:38:54 +02:00
|
|
|
@Override
|
|
|
|
public EnumBlockRenderType getRenderType( IBlockState state )
|
|
|
|
{
|
|
|
|
return EnumBlockRenderType.ENTITYBLOCK_ANIMATED;
|
|
|
|
}
|
|
|
|
|
2016-08-22 14:25:10 +02:00
|
|
|
|
2014-03-01 04:45:30 +01:00
|
|
|
@Override
|
2016-06-19 14:43:27 +02:00
|
|
|
public boolean onActivated( final World w, final BlockPos pos, final EntityPlayer player, final EnumHand hand, final @Nullable ItemStack heldItem, final EnumFacing side, final float hitX, final float hitY, final float hitZ )
|
2014-03-01 04:45:30 +01:00
|
|
|
{
|
2015-04-03 08:54:31 +02:00
|
|
|
if( Platform.isServer() )
|
2015-04-29 02:30:53 +02:00
|
|
|
{
|
2015-06-16 02:44:59 +02:00
|
|
|
Platform.openGUI( player, this.getTileEntity( w, pos ), AEPartLocation.fromFacing( side ), GuiBridge.GUI_SKYCHEST );
|
2015-04-29 02:30:53 +02:00
|
|
|
}
|
2015-03-21 16:03:26 +01:00
|
|
|
|
2015-04-03 08:54:31 +02:00
|
|
|
return true;
|
2014-03-01 04:45:30 +01:00
|
|
|
}
|
2015-12-24 02:03:16 +01:00
|
|
|
|
2014-02-28 09:12:00 +01:00
|
|
|
@Override
|
2016-01-01 02:02:05 +01:00
|
|
|
public Iterable<AxisAlignedBB> getSelectedBoundingBoxesFromPool( final World w, final BlockPos pos, final Entity thePlayer, final boolean b )
|
2014-02-28 09:12:00 +01:00
|
|
|
{
|
2015-09-30 14:24:40 +02:00
|
|
|
final TileSkyChest sk = this.getTileEntity( w, pos );
|
2015-06-16 02:44:59 +02:00
|
|
|
EnumFacing o = EnumFacing.UP;
|
2014-03-27 04:57:38 +01:00
|
|
|
|
2015-04-03 08:54:31 +02:00
|
|
|
if( sk != null )
|
2015-04-29 02:30:53 +02:00
|
|
|
{
|
2014-03-27 04:57:38 +01:00
|
|
|
o = sk.getUp();
|
2015-04-29 02:30:53 +02:00
|
|
|
}
|
2014-03-27 04:57:38 +01:00
|
|
|
|
2015-09-30 14:24:40 +02:00
|
|
|
final double offsetX = o.getFrontOffsetX() == 0 ? 0.06 : 0.0;
|
|
|
|
final double offsetY = o.getFrontOffsetY() == 0 ? 0.06 : 0.0;
|
|
|
|
final double offsetZ = o.getFrontOffsetZ() == 0 ? 0.06 : 0.0;
|
2014-03-27 04:57:38 +01:00
|
|
|
|
2015-09-30 14:24:40 +02:00
|
|
|
final double sc = 0.06;
|
2016-06-19 14:43:27 +02:00
|
|
|
return Collections.singletonList( new AxisAlignedBB( Math.max( 0.0, offsetX - o.getFrontOffsetX() * sc ), Math.max( 0.0, offsetY - o.getFrontOffsetY() * sc ), Math.max( 0.0, offsetZ - o.getFrontOffsetZ() * sc ), Math.min( 1.0, ( 1.0 - offsetX ) - o.getFrontOffsetX() * sc ), Math.min( 1.0, ( 1.0 - offsetY ) - o.getFrontOffsetY() * sc ), Math.min( 1.0, ( 1.0 - offsetZ ) - o.getFrontOffsetZ() * sc ) ) );
|
2014-02-28 09:12:00 +01:00
|
|
|
}
|
2015-12-24 02:03:16 +01:00
|
|
|
|
2014-02-28 09:12:00 +01:00
|
|
|
@Override
|
2016-01-01 02:02:05 +01:00
|
|
|
public void addCollidingBlockToList( final World w, final BlockPos pos, final AxisAlignedBB bb, final List<AxisAlignedBB> out, final Entity e )
|
2014-02-28 09:12:00 +01:00
|
|
|
{
|
2016-06-19 14:43:27 +02:00
|
|
|
out.add( new AxisAlignedBB( 0.05, 0.05, 0.05, 0.95, 0.95, 0.95 ) );
|
2014-02-28 09:12:00 +01:00
|
|
|
}
|
|
|
|
}
|