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-03-02 09:35:11 +01:00
|
|
|
package appeng.parts;
|
|
|
|
|
|
|
|
import java.util.LinkedList;
|
|
|
|
import java.util.List;
|
|
|
|
|
|
|
|
import net.minecraft.block.Block;
|
|
|
|
import net.minecraft.block.Block.SoundType;
|
2014-05-03 09:51:56 +02:00
|
|
|
import net.minecraft.client.Minecraft;
|
2014-03-02 09:35:11 +01:00
|
|
|
import net.minecraft.entity.player.EntityPlayer;
|
|
|
|
import net.minecraft.item.ItemBlock;
|
|
|
|
import net.minecraft.item.ItemStack;
|
|
|
|
import net.minecraft.tileentity.TileEntity;
|
|
|
|
import net.minecraft.util.MovingObjectPosition;
|
2014-05-03 09:51:56 +02:00
|
|
|
import net.minecraft.util.Vec3;
|
2014-03-02 09:35:11 +01:00
|
|
|
import net.minecraft.world.World;
|
|
|
|
import net.minecraftforge.common.MinecraftForge;
|
|
|
|
import net.minecraftforge.common.util.ForgeDirection;
|
|
|
|
import net.minecraftforge.event.entity.player.PlayerDestroyItemEvent;
|
|
|
|
import net.minecraftforge.event.entity.player.PlayerInteractEvent;
|
|
|
|
import net.minecraftforge.event.entity.player.PlayerInteractEvent.Action;
|
|
|
|
import appeng.api.AEApi;
|
|
|
|
import appeng.api.parts.IFacadePart;
|
|
|
|
import appeng.api.parts.IPartHost;
|
|
|
|
import appeng.api.parts.IPartItem;
|
|
|
|
import appeng.api.parts.PartItemStack;
|
|
|
|
import appeng.api.parts.SelectedPart;
|
2014-08-29 04:37:08 +02:00
|
|
|
import appeng.api.util.DimensionalCoord;
|
2014-03-02 09:35:11 +01:00
|
|
|
import appeng.core.AppEng;
|
2014-08-03 06:53:34 +02:00
|
|
|
import appeng.core.CommonHelper;
|
2014-03-02 09:35:11 +01:00
|
|
|
import appeng.core.sync.network.NetworkHandler;
|
2014-05-26 01:32:16 +02:00
|
|
|
import appeng.core.sync.packets.PacketClick;
|
2014-03-02 09:35:11 +01:00
|
|
|
import appeng.core.sync.packets.PacketPartPlacement;
|
|
|
|
import appeng.facade.IFacadeItem;
|
2014-07-24 00:26:23 +02:00
|
|
|
import appeng.integration.IntegrationType;
|
2014-03-02 09:35:11 +01:00
|
|
|
import appeng.integration.abstraction.IBC;
|
|
|
|
import appeng.integration.abstraction.IFMP;
|
2014-08-08 08:40:17 +02:00
|
|
|
import appeng.integration.abstraction.IImmibisMicroblocks;
|
2014-03-02 09:35:11 +01:00
|
|
|
import appeng.util.LookDirection;
|
|
|
|
import appeng.util.Platform;
|
|
|
|
import cpw.mods.fml.common.eventhandler.SubscribeEvent;
|
2014-08-01 02:43:44 +02:00
|
|
|
import cpw.mods.fml.common.gameevent.TickEvent;
|
2014-03-02 09:35:11 +01:00
|
|
|
|
|
|
|
public class PartPlacement
|
|
|
|
{
|
|
|
|
|
2014-09-29 09:54:34 +02:00
|
|
|
private final ThreadLocal<Object> placing = new ThreadLocal<Object>();
|
2014-08-01 02:43:44 +02:00
|
|
|
private boolean wasCanceled = false;
|
|
|
|
|
|
|
|
@SubscribeEvent
|
|
|
|
public void playerInteract(TickEvent.ClientTickEvent event)
|
|
|
|
{
|
2014-12-29 15:13:47 +01:00
|
|
|
this.wasCanceled = false;
|
2014-08-01 02:43:44 +02:00
|
|
|
}
|
2014-03-02 09:35:11 +01:00
|
|
|
|
|
|
|
@SubscribeEvent
|
|
|
|
public void playerInteract(PlayerInteractEvent event)
|
|
|
|
{
|
2014-05-03 09:51:56 +02:00
|
|
|
if ( event.action == Action.RIGHT_CLICK_AIR && event.entityPlayer.worldObj.isRemote )
|
|
|
|
{
|
|
|
|
// re-check to see if this event was already channeled, cause these two events are really stupid...
|
|
|
|
MovingObjectPosition mop = Platform.rayTrace( event.entityPlayer, true, false );
|
|
|
|
Minecraft mc = Minecraft.getMinecraft();
|
|
|
|
|
|
|
|
float f = 1.0F;
|
2014-09-28 20:56:16 +02:00
|
|
|
double d0 = mc.playerController.getBlockReachDistance();
|
2014-05-03 09:51:56 +02:00
|
|
|
Vec3 vec3 = mc.renderViewEntity.getPosition( f );
|
|
|
|
|
|
|
|
if ( mop != null && mop.hitVec.distanceTo( vec3 ) < d0 )
|
|
|
|
{
|
|
|
|
World w = event.entity.worldObj;
|
|
|
|
TileEntity te = w.getTileEntity( mop.blockX, mop.blockY, mop.blockZ );
|
2014-12-29 15:13:47 +01:00
|
|
|
if ( te instanceof IPartHost && this.wasCanceled )
|
2014-05-03 09:51:56 +02:00
|
|
|
event.setCanceled( true );
|
|
|
|
}
|
2014-05-26 01:32:16 +02:00
|
|
|
else if ( event.entityPlayer != null )
|
|
|
|
{
|
|
|
|
ItemStack held = event.entityPlayer.getHeldItem();
|
2014-05-26 10:26:37 +02:00
|
|
|
boolean supportedItem = AEApi.instance().items().itemMemoryCard.sameAsStack( held )
|
|
|
|
|| AEApi.instance().items().itemColorApplicator.sameAsStack( held );
|
|
|
|
if ( event.entityPlayer.isSneaking() && held != null && supportedItem )
|
2014-05-26 01:32:16 +02:00
|
|
|
{
|
2014-10-04 08:08:28 +02:00
|
|
|
NetworkHandler.instance.sendToServer( new PacketClick( event.x, event.y, event.z, event.face, 0, 0, 0 ) );
|
2014-05-26 01:32:16 +02:00
|
|
|
}
|
|
|
|
}
|
2014-05-03 09:51:56 +02:00
|
|
|
}
|
|
|
|
else if ( event.action == Action.RIGHT_CLICK_BLOCK && event.entityPlayer.worldObj.isRemote )
|
2014-03-02 09:35:11 +01:00
|
|
|
{
|
2014-12-29 15:13:47 +01:00
|
|
|
if ( this.placing.get() != null )
|
2014-03-02 09:35:11 +01:00
|
|
|
return;
|
|
|
|
|
2014-12-29 15:13:47 +01:00
|
|
|
this.placing.set( event );
|
2014-03-02 09:35:11 +01:00
|
|
|
|
|
|
|
ItemStack held = event.entityPlayer.getHeldItem();
|
|
|
|
if ( place( held, event.x, event.y, event.z, event.face, event.entityPlayer, event.entityPlayer.worldObj, PlaceType.INTERACT_FIRST_PASS, 0 ) )
|
2014-08-01 02:43:44 +02:00
|
|
|
{
|
2014-03-02 09:35:11 +01:00
|
|
|
event.setCanceled( true );
|
2014-12-29 15:13:47 +01:00
|
|
|
this.wasCanceled = true;
|
2014-08-01 02:43:44 +02:00
|
|
|
}
|
2014-03-02 09:35:11 +01:00
|
|
|
|
2014-12-29 15:13:47 +01:00
|
|
|
this.placing.set( null );
|
2014-03-02 09:35:11 +01:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
public enum PlaceType
|
|
|
|
{
|
|
|
|
PLACE_ITEM, INTERACT_FIRST_PASS, INTERACT_SECOND_PASS
|
2014-09-28 00:50:06 +02:00
|
|
|
}
|
2014-03-02 09:35:11 +01:00
|
|
|
|
|
|
|
public static boolean place(ItemStack held, int x, int y, int z, int face, EntityPlayer player, World world, PlaceType pass, int depth)
|
|
|
|
{
|
|
|
|
if ( depth > 3 )
|
|
|
|
return false;
|
|
|
|
|
|
|
|
ForgeDirection side = ForgeDirection.getOrientation( face );
|
|
|
|
|
|
|
|
if ( held != null && Platform.isWrench( player, held, x, y, z ) && player.isSneaking() )
|
|
|
|
{
|
2014-08-29 04:37:08 +02:00
|
|
|
if ( !Platform.hasPermissions( new DimensionalCoord( world, x, y, z ), player ) )
|
|
|
|
return false;
|
|
|
|
|
2014-03-02 09:35:11 +01:00
|
|
|
Block block = world.getBlock( x, y, z );
|
|
|
|
TileEntity tile = world.getTileEntity( x, y, z );
|
|
|
|
IPartHost host = null;
|
|
|
|
|
|
|
|
if ( tile instanceof IPartHost )
|
|
|
|
host = (IPartHost) tile;
|
|
|
|
|
|
|
|
if ( host != null )
|
|
|
|
{
|
|
|
|
if ( !world.isRemote )
|
|
|
|
{
|
2014-08-29 04:37:08 +02:00
|
|
|
LookDirection dir = Platform.getPlayerRay( player, getEyeOffset( player ) );
|
2014-03-02 09:35:11 +01:00
|
|
|
MovingObjectPosition mop = block.collisionRayTrace( world, x, y, z, dir.a, dir.b );
|
|
|
|
if ( mop != null )
|
|
|
|
{
|
2014-09-28 22:20:14 +02:00
|
|
|
List<ItemStack> is = new LinkedList<ItemStack>();
|
2014-08-03 06:53:34 +02:00
|
|
|
SelectedPart sp = selectPart( player, host, mop.hitVec.addVector( -mop.blockX, -mop.blockY, -mop.blockZ ) );
|
2014-03-02 09:35:11 +01:00
|
|
|
|
|
|
|
if ( sp.part != null )
|
|
|
|
{
|
|
|
|
is.add( sp.part.getItemStack( PartItemStack.Wrench ) );
|
|
|
|
sp.part.getDrops( is, true );
|
|
|
|
host.removePart( sp.side, false );
|
|
|
|
}
|
|
|
|
|
|
|
|
if ( sp.facade != null )
|
|
|
|
{
|
|
|
|
is.add( sp.facade.getItemStack() );
|
|
|
|
host.getFacadeContainer().removeFacade( host, sp.side );
|
2014-07-08 06:54:28 +02:00
|
|
|
Platform.notifyBlocksOfNeighbors( world, x, y, z );
|
2014-03-02 09:35:11 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
if ( host.isEmpty() )
|
2014-04-10 22:01:04 +02:00
|
|
|
host.cleanup();
|
2014-03-02 09:35:11 +01:00
|
|
|
|
2014-09-28 19:41:51 +02:00
|
|
|
if ( !is.isEmpty() )
|
2014-03-02 09:35:11 +01:00
|
|
|
{
|
|
|
|
Platform.spawnDrops( world, x, y, z, is );
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
player.swingItem();
|
2014-10-04 08:08:28 +02:00
|
|
|
NetworkHandler.instance.sendToServer( new PacketPartPlacement( x, y, z, face, getEyeOffset( player ) ) );
|
2014-03-02 09:35:11 +01:00
|
|
|
}
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
|
|
|
TileEntity tile = world.getTileEntity( x, y, z );
|
|
|
|
IPartHost host = null;
|
|
|
|
|
|
|
|
if ( tile instanceof IPartHost )
|
|
|
|
host = (IPartHost) tile;
|
|
|
|
|
|
|
|
if ( held != null )
|
|
|
|
{
|
|
|
|
IFacadePart fp = isFacade( held, side );
|
|
|
|
if ( fp != null )
|
|
|
|
{
|
|
|
|
if ( host != null )
|
|
|
|
{
|
|
|
|
if ( !world.isRemote )
|
|
|
|
{
|
|
|
|
if ( host.getPart( ForgeDirection.UNKNOWN ) == null )
|
|
|
|
return false;
|
|
|
|
|
2014-04-20 06:35:48 +02:00
|
|
|
if ( host.canAddPart( held, side ) )
|
2014-03-02 09:35:11 +01:00
|
|
|
{
|
2014-04-20 06:35:48 +02:00
|
|
|
if ( host.getFacadeContainer().addFacade( fp ) )
|
2014-03-02 09:35:11 +01:00
|
|
|
{
|
2014-04-20 06:35:48 +02:00
|
|
|
host.markForUpdate();
|
|
|
|
if ( !player.capabilities.isCreativeMode )
|
2014-03-02 09:35:11 +01:00
|
|
|
{
|
2014-04-20 06:35:48 +02:00
|
|
|
held.stackSize--;
|
|
|
|
if ( held.stackSize == 0 )
|
|
|
|
{
|
|
|
|
player.inventory.mainInventory[player.inventory.currentItem] = null;
|
|
|
|
MinecraftForge.EVENT_BUS.post( new PlayerDestroyItemEvent( player, held ) );
|
|
|
|
}
|
2014-03-02 09:35:11 +01:00
|
|
|
}
|
2014-04-20 06:35:48 +02:00
|
|
|
return true;
|
2014-03-02 09:35:11 +01:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
player.swingItem();
|
2014-10-04 08:08:28 +02:00
|
|
|
NetworkHandler.instance.sendToServer( new PacketPartPlacement( x, y, z, face, getEyeOffset( player ) ) );
|
|
|
|
return true;
|
2014-03-02 09:35:11 +01:00
|
|
|
}
|
|
|
|
}
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2014-07-24 00:26:23 +02:00
|
|
|
if ( host == null && tile != null && AppEng.instance.isIntegrationEnabled( IntegrationType.FMP ) )
|
|
|
|
host = ((IFMP) AppEng.instance.getIntegration( IntegrationType.FMP )).getOrCreateHost( tile );
|
2014-03-02 09:35:11 +01:00
|
|
|
|
2014-08-08 08:40:17 +02:00
|
|
|
if ( host == null && tile != null && AppEng.instance.isIntegrationEnabled( IntegrationType.ImmibisMicroblocks ) )
|
|
|
|
host = ((IImmibisMicroblocks) AppEng.instance.getIntegration( IntegrationType.ImmibisMicroblocks )).getOrCreateHost( player, face, tile );
|
|
|
|
|
2014-03-02 09:35:11 +01:00
|
|
|
// if ( held == null )
|
|
|
|
{
|
|
|
|
Block block = world.getBlock( x, y, z );
|
|
|
|
if ( host != null && player.isSneaking() && block != null )
|
|
|
|
{
|
2014-08-29 04:37:08 +02:00
|
|
|
LookDirection dir = Platform.getPlayerRay( player, getEyeOffset( player ) );
|
2014-03-02 09:35:11 +01:00
|
|
|
MovingObjectPosition mop = block.collisionRayTrace( world, x, y, z, dir.a, dir.b );
|
|
|
|
if ( mop != null )
|
|
|
|
{
|
|
|
|
mop.hitVec = mop.hitVec.addVector( -mop.blockX, -mop.blockY, -mop.blockZ );
|
2014-08-03 06:53:34 +02:00
|
|
|
SelectedPart sPart = selectPart( player, host, mop.hitVec );
|
2014-03-02 09:35:11 +01:00
|
|
|
if ( sPart != null && sPart.part != null )
|
|
|
|
if ( sPart.part.onShiftActivate( player, mop.hitVec ) )
|
|
|
|
{
|
|
|
|
if ( world.isRemote )
|
|
|
|
{
|
2014-10-04 08:08:28 +02:00
|
|
|
NetworkHandler.instance.sendToServer( new PacketPartPlacement( x, y, z, face, getEyeOffset( player ) ) );
|
2014-03-02 09:35:11 +01:00
|
|
|
}
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
if ( held == null || !(held.getItem() instanceof IPartItem) )
|
|
|
|
return false;
|
|
|
|
|
|
|
|
int te_x = x;
|
|
|
|
int te_y = y;
|
|
|
|
int te_z = z;
|
|
|
|
|
|
|
|
if ( host == null && pass == PlaceType.PLACE_ITEM )
|
|
|
|
{
|
|
|
|
ItemStack is = AEApi.instance().blocks().blockMultiPart.stack( 1 );
|
|
|
|
ItemBlock ib = (ItemBlock) is.getItem();
|
|
|
|
ForgeDirection offset = ForgeDirection.UNKNOWN;
|
|
|
|
|
|
|
|
Block blkID = world.getBlock( x, y, z );
|
|
|
|
if ( blkID != null && !blkID.isReplaceable( world, x, y, z ) )
|
|
|
|
{
|
|
|
|
offset = side;
|
|
|
|
if ( Platform.isServer() )
|
|
|
|
side = side.getOpposite();
|
|
|
|
}
|
|
|
|
|
|
|
|
te_x = x + offset.offsetX;
|
|
|
|
te_y = y + offset.offsetY;
|
|
|
|
te_z = z + offset.offsetZ;
|
|
|
|
|
|
|
|
tile = world.getTileEntity( te_x, te_y, te_z );
|
|
|
|
if ( tile instanceof IPartHost )
|
|
|
|
host = (IPartHost) tile;
|
|
|
|
|
2014-07-24 00:26:23 +02:00
|
|
|
if ( host == null && tile != null && AppEng.instance.isIntegrationEnabled( IntegrationType.FMP ) )
|
|
|
|
host = ((IFMP) AppEng.instance.getIntegration( IntegrationType.FMP )).getOrCreateHost( tile );
|
2014-03-02 09:35:11 +01:00
|
|
|
|
2014-08-30 04:34:33 +02:00
|
|
|
if ( host == null && tile != null && AppEng.instance.isIntegrationEnabled( IntegrationType.ImmibisMicroblocks ) )
|
|
|
|
host = ((IImmibisMicroblocks) AppEng.instance.getIntegration( IntegrationType.ImmibisMicroblocks )).getOrCreateHost( player, face, tile );
|
|
|
|
|
2014-03-02 09:35:11 +01:00
|
|
|
if ( host == null && AEApi.instance().blocks().blockMultiPart.block().canPlaceBlockAt( world, te_x, te_y, te_z )
|
|
|
|
&& ib.placeBlockAt( is, player, world, te_x, te_y, te_z, side.ordinal(), 0.5f, 0.5f, 0.5f, 0 ) )
|
|
|
|
{
|
|
|
|
if ( !world.isRemote )
|
|
|
|
{
|
|
|
|
tile = world.getTileEntity( te_x, te_y, te_z );
|
|
|
|
|
|
|
|
if ( tile instanceof IPartHost )
|
|
|
|
host = (IPartHost) tile;
|
|
|
|
|
|
|
|
pass = PlaceType.INTERACT_SECOND_PASS;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
player.swingItem();
|
2014-10-04 08:08:28 +02:00
|
|
|
NetworkHandler.instance.sendToServer( new PacketPartPlacement( x, y, z, face, getEyeOffset( player ) ) );
|
2014-03-02 09:35:11 +01:00
|
|
|
return true;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else if ( host != null && !host.canAddPart( held, side ) )
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
|
|
|
if ( host == null )
|
|
|
|
return false;
|
|
|
|
|
|
|
|
if ( !host.canAddPart( held, side ) )
|
|
|
|
{
|
|
|
|
if ( pass == PlaceType.INTERACT_FIRST_PASS || pass == PlaceType.PLACE_ITEM )
|
|
|
|
{
|
2014-10-01 11:34:27 +02:00
|
|
|
te_x = x + side.offsetX;
|
|
|
|
te_y = y + side.offsetY;
|
|
|
|
te_z = z + side.offsetZ;
|
2014-03-02 09:35:11 +01:00
|
|
|
|
|
|
|
Block blkID = world.getBlock( te_x, te_y, te_z );
|
|
|
|
tile = world.getTileEntity( te_x, te_y, te_z );
|
|
|
|
|
2014-07-24 00:26:23 +02:00
|
|
|
if ( tile != null && AppEng.instance.isIntegrationEnabled( IntegrationType.FMP ) )
|
|
|
|
host = ((IFMP) AppEng.instance.getIntegration( IntegrationType.FMP )).getOrCreateHost( tile );
|
2014-03-02 09:35:11 +01:00
|
|
|
|
2014-10-01 11:34:27 +02:00
|
|
|
if ( (blkID == null || blkID.isReplaceable( world, te_x, te_y, te_z ) || host != null) && side != ForgeDirection.UNKNOWN )
|
2014-03-02 09:35:11 +01:00
|
|
|
return place( held, te_x, te_y, te_z, side.getOpposite().ordinal(), player, world,
|
|
|
|
pass == PlaceType.INTERACT_FIRST_PASS ? PlaceType.INTERACT_SECOND_PASS : PlaceType.PLACE_ITEM, depth + 1 );
|
|
|
|
}
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
|
|
|
if ( !world.isRemote )
|
|
|
|
{
|
2014-03-15 07:58:21 +01:00
|
|
|
Block block = world.getBlock( x, y, z );
|
2014-08-29 04:37:08 +02:00
|
|
|
LookDirection dir = Platform.getPlayerRay( player, getEyeOffset( player ) );
|
2014-03-15 07:58:21 +01:00
|
|
|
MovingObjectPosition mop = block.collisionRayTrace( world, x, y, z, dir.a, dir.b );
|
|
|
|
if ( mop != null )
|
|
|
|
{
|
2014-08-03 06:53:34 +02:00
|
|
|
SelectedPart sp = selectPart( player, host, mop.hitVec.addVector( -mop.blockX, -mop.blockY, -mop.blockZ ) );
|
2014-03-15 07:58:21 +01:00
|
|
|
|
|
|
|
if ( sp.part != null )
|
|
|
|
{
|
|
|
|
if ( !player.isSneaking() && sp.part.onActivate( player, mop.hitVec ) )
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2014-08-29 04:37:08 +02:00
|
|
|
DimensionalCoord dc = host.getLocation();
|
|
|
|
if ( !Platform.hasPermissions( dc, player ) )
|
|
|
|
return false;
|
|
|
|
|
2014-03-02 09:35:11 +01:00
|
|
|
ForgeDirection mySide = host.addPart( held, side, player );
|
|
|
|
if ( mySide != null )
|
|
|
|
{
|
|
|
|
SoundType ss = AEApi.instance().blocks().blockMultiPart.block().stepSound;
|
|
|
|
|
|
|
|
// ss.getPlaceSound()
|
|
|
|
world.playSoundEffect( 0.5 + x, 0.5 + y, 0.5 + z, ss.func_150496_b(), (ss.getVolume() + 1.0F) / 2.0F, ss.getPitch() * 0.8F );
|
|
|
|
|
|
|
|
if ( !player.capabilities.isCreativeMode )
|
|
|
|
{
|
|
|
|
held.stackSize--;
|
|
|
|
if ( held.stackSize == 0 )
|
|
|
|
{
|
|
|
|
player.inventory.mainInventory[player.inventory.currentItem] = null;
|
|
|
|
MinecraftForge.EVENT_BUS.post( new PlayerDestroyItemEvent( player, held ) );
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
player.swingItem();
|
2014-10-04 08:08:28 +02:00
|
|
|
NetworkHandler.instance.sendToServer( new PacketPartPlacement( x, y, z, face, getEyeOffset( player ) ) );
|
2014-03-02 09:35:11 +01:00
|
|
|
}
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
2014-08-18 23:12:45 +02:00
|
|
|
public static float eyeHeight = 0.0f;
|
2014-08-29 04:37:08 +02:00
|
|
|
|
|
|
|
private static float getEyeOffset(EntityPlayer p)
|
2014-08-18 23:12:45 +02:00
|
|
|
{
|
|
|
|
if ( p.worldObj.isRemote )
|
|
|
|
return Platform.getEyeOffset( p );
|
2014-08-29 04:37:08 +02:00
|
|
|
|
2014-08-18 23:12:45 +02:00
|
|
|
return eyeHeight;
|
|
|
|
}
|
|
|
|
|
2014-08-03 06:53:34 +02:00
|
|
|
private static SelectedPart selectPart(EntityPlayer player, IPartHost host, Vec3 pos)
|
|
|
|
{
|
|
|
|
CommonHelper.proxy.updateRenderMode( player );
|
|
|
|
SelectedPart sp = host.selectPart( pos );
|
|
|
|
CommonHelper.proxy.updateRenderMode( null );
|
|
|
|
|
|
|
|
return sp;
|
|
|
|
}
|
|
|
|
|
2014-05-04 21:54:07 +02:00
|
|
|
public static IFacadePart isFacade(ItemStack held, ForgeDirection side)
|
2014-03-02 09:35:11 +01:00
|
|
|
{
|
|
|
|
if ( held.getItem() instanceof IFacadeItem )
|
|
|
|
return ((IFacadeItem) held.getItem()).createPartFromItemStack( held, side );
|
2014-05-04 21:54:07 +02:00
|
|
|
|
2014-07-24 00:26:23 +02:00
|
|
|
if ( AppEng.instance.isIntegrationEnabled( IntegrationType.BC ) )
|
2014-03-02 09:35:11 +01:00
|
|
|
{
|
2014-07-24 00:26:23 +02:00
|
|
|
IBC bc = (IBC) AppEng.instance.getIntegration( IntegrationType.BC );
|
2014-03-02 09:35:11 +01:00
|
|
|
if ( bc.isFacade( held ) )
|
|
|
|
return bc.createFacadePart( held, side );
|
|
|
|
}
|
2014-05-04 21:54:07 +02:00
|
|
|
|
2014-03-02 09:35:11 +01:00
|
|
|
return null;
|
|
|
|
}
|
|
|
|
|
2013-12-27 23:59:59 +01:00
|
|
|
}
|