Lots of compile fixes
This commit is contained in:
@@ -26,6 +26,7 @@ import java.util.List;
|
||||
import java.util.Optional;
|
||||
import java.util.Random;
|
||||
|
||||
import appeng.core.Api;
|
||||
import com.google.common.base.Preconditions;
|
||||
|
||||
import net.minecraft.crash.CrashReportCategory;
|
||||
@@ -40,6 +41,7 @@ import net.minecraft.util.Direction;
|
||||
import net.minecraft.util.Hand;
|
||||
import net.minecraft.util.math.BlockPos;
|
||||
import net.minecraft.util.math.Vec3d;
|
||||
import net.minecraft.util.text.ITextComponent;
|
||||
import net.minecraft.world.IBlockReader;
|
||||
import net.minecraft.world.World;
|
||||
import net.minecraftforge.api.distmarker.Dist;
|
||||
@@ -185,7 +187,7 @@ public abstract class AEBasePart implements IPart, IGridProxyable, IActionHost,
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getCustomInventoryName()
|
||||
public ITextComponent getCustomInventoryName()
|
||||
{
|
||||
return this.getItemStack().getDisplayName();
|
||||
}
|
||||
@@ -198,7 +200,7 @@ public abstract class AEBasePart implements IPart, IGridProxyable, IActionHost,
|
||||
|
||||
public void addEntityCrashInfo( final CrashReportCategory crashreportcategory )
|
||||
{
|
||||
crashreportcategory.addCrashSection( "Part Side", this.getSide() );
|
||||
crashreportcategory.addDetail( "Part Side", this.getSide() );
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -207,7 +209,7 @@ public abstract class AEBasePart implements IPart, IGridProxyable, IActionHost,
|
||||
if( type == PartItemStack.NETWORK )
|
||||
{
|
||||
final ItemStack copy = this.is.copy();
|
||||
copy.setTagCompound( null );
|
||||
copy.setTag( null );
|
||||
return copy;
|
||||
}
|
||||
return this.is;
|
||||
@@ -282,7 +284,7 @@ public abstract class AEBasePart implements IPart, IGridProxyable, IActionHost,
|
||||
@Override
|
||||
public void removeFromWorld()
|
||||
{
|
||||
this.proxy.invalidate();
|
||||
this.proxy.remove();
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -368,7 +370,7 @@ public abstract class AEBasePart implements IPart, IGridProxyable, IActionHost,
|
||||
if( this instanceof IPriorityHost )
|
||||
{
|
||||
final IPriorityHost pHost = (IPriorityHost) this;
|
||||
pHost.setPriority( compound.getInteger( "priority" ) );
|
||||
pHost.setPriority( compound.getInt( "priority" ) );
|
||||
}
|
||||
|
||||
final IItemHandler inv = this.getInventoryByName( "config" );
|
||||
@@ -404,7 +406,7 @@ public abstract class AEBasePart implements IPart, IGridProxyable, IActionHost,
|
||||
if( this instanceof IPriorityHost )
|
||||
{
|
||||
final IPriorityHost pHost = (IPriorityHost) this;
|
||||
output.setInteger( "priority", pHost.getPriority() );
|
||||
output.putInt( "priority", pHost.getPriority() );
|
||||
}
|
||||
|
||||
final IItemHandler inv = this.getInventoryByName( "config" );
|
||||
|
||||
@@ -1285,9 +1285,10 @@ public class CableBusContainer extends CableBusStorage implements AEMultiTile, I
|
||||
final ItemStack textureItem = facade.getTextureItem();
|
||||
final BlockState blockState = facade.getBlockState();
|
||||
|
||||
if( blockState != null && textureItem != null )
|
||||
World world = getTile().getWorld();
|
||||
if( blockState != null && textureItem != null && world != null )
|
||||
{
|
||||
return new FacadeRenderState( blockState, !facade.getBlockState().isOpaqueCube() );
|
||||
return new FacadeRenderState( blockState, !facade.getBlockState().isOpaqueCube(world, getTile().getPos()) );
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -19,43 +19,12 @@
|
||||
package appeng.parts;
|
||||
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.Optional;
|
||||
|
||||
import net.minecraft.block.Block;
|
||||
import net.minecraft.block.BlockState;
|
||||
import net.minecraft.block.SoundType;
|
||||
import net.minecraft.client.Minecraft;
|
||||
import net.minecraft.entity.player.PlayerEntity;
|
||||
import net.minecraft.item.BlockItem;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.tileentity.TileEntity;
|
||||
import net.minecraft.util.ActionResult;
|
||||
import net.minecraft.util.ActionResultType;
|
||||
import net.minecraft.util.Direction;
|
||||
import net.minecraft.util.Hand;
|
||||
import net.minecraft.util.SoundCategory;
|
||||
import net.minecraft.util.math.BlockPos;
|
||||
import net.minecraft.util.math.RayTraceResult;
|
||||
import net.minecraft.util.math.Vec3d;
|
||||
import net.minecraft.world.World;
|
||||
import net.minecraftforge.common.MinecraftForge;
|
||||
import net.minecraftforge.event.TickEvent;
|
||||
import net.minecraftforge.event.entity.player.PlayerDestroyItemEvent;
|
||||
import net.minecraftforge.event.entity.player.PlayerInteractEvent;
|
||||
import net.minecraftforge.eventbus.api.SubscribeEvent;
|
||||
|
||||
import appeng.api.AEApi;
|
||||
import appeng.api.definitions.IBlockDefinition;
|
||||
import appeng.api.definitions.IItems;
|
||||
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;
|
||||
import appeng.api.parts.*;
|
||||
import appeng.api.util.AEPartLocation;
|
||||
import appeng.api.util.DimensionalCoord;
|
||||
import appeng.core.Api;
|
||||
import appeng.core.AppEng;
|
||||
import appeng.core.sync.network.NetworkHandler;
|
||||
import appeng.core.sync.packets.PacketClick;
|
||||
@@ -63,6 +32,25 @@ import appeng.core.sync.packets.PacketPartPlacement;
|
||||
import appeng.facade.IFacadeItem;
|
||||
import appeng.util.LookDirection;
|
||||
import appeng.util.Platform;
|
||||
import net.minecraft.block.Block;
|
||||
import net.minecraft.block.BlockState;
|
||||
import net.minecraft.block.SoundType;
|
||||
import net.minecraft.client.Minecraft;
|
||||
import net.minecraft.entity.player.PlayerEntity;
|
||||
import net.minecraft.item.*;
|
||||
import net.minecraft.tileentity.TileEntity;
|
||||
import net.minecraft.util.*;
|
||||
import net.minecraft.util.math.*;
|
||||
import net.minecraft.world.World;
|
||||
import net.minecraftforge.common.MinecraftForge;
|
||||
import net.minecraftforge.event.TickEvent;
|
||||
import net.minecraftforge.event.entity.player.PlayerDestroyItemEvent;
|
||||
import net.minecraftforge.event.entity.player.PlayerInteractEvent;
|
||||
import net.minecraftforge.eventbus.api.SubscribeEvent;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.Optional;
|
||||
|
||||
|
||||
public class PartPlacement
|
||||
@@ -79,6 +67,14 @@ public class PartPlacement
|
||||
return ActionResultType.FAIL;
|
||||
}
|
||||
|
||||
// FIXME: This was changed alot.
|
||||
final LookDirection dir = Platform.getPlayerRay( player );
|
||||
RayTraceContext rtc = new RayTraceContext(dir.getA(), dir.getB(), RayTraceContext.BlockMode.OUTLINE, RayTraceContext.FluidMode.NONE, player);
|
||||
final BlockRayTraceResult mop = world.rayTraceBlocks( rtc );
|
||||
BlockItemUseContext useContext = new BlockItemUseContext(new ItemUseContext(
|
||||
player, hand, mop
|
||||
));
|
||||
|
||||
if( !held.isEmpty() && Platform.isWrench( player, held, pos ) && player.isCrouching() )
|
||||
{
|
||||
if( !Platform.hasPermissions( new DimensionalCoord( world, pos ), player ) )
|
||||
@@ -86,7 +82,6 @@ public class PartPlacement
|
||||
return ActionResultType.FAIL;
|
||||
}
|
||||
|
||||
final Block block = world.getBlockState( pos ).getBlock();
|
||||
final TileEntity tile = world.getTileEntity( pos );
|
||||
IPartHost host = null;
|
||||
|
||||
@@ -99,14 +94,11 @@ public class PartPlacement
|
||||
{
|
||||
if( !world.isRemote )
|
||||
{
|
||||
final LookDirection dir = Platform.getPlayerRay( player );
|
||||
final RayTraceResult mop = block.getRayTraceResult( world.getBlockState( pos ), world, pos, dir.getA(), dir.getB(), mop );
|
||||
|
||||
if( mop != null )
|
||||
if( mop.getType() == RayTraceResult.Type.BLOCK )
|
||||
{
|
||||
final List<ItemStack> is = new ArrayList<>();
|
||||
final SelectedPart sp = selectPart( player, host,
|
||||
mop.getHitVec().addVector( -mop.getBlockPos().getX(), -mop.getBlockPos().getY(), -mop.getBlockPos().getZ() ) );
|
||||
mop.getHitVec().add( -mop.getPos().getX(), -mop.getPos().getY(), -mop.getPos().getZ() ) );
|
||||
|
||||
if( sp.part != null )
|
||||
{
|
||||
@@ -163,7 +155,7 @@ public class PartPlacement
|
||||
{
|
||||
if( host.getPart( AEPartLocation.INTERNAL ) == null )
|
||||
{
|
||||
return ActionResult.resultFail( null );
|
||||
return ActionResultType.FAIL;
|
||||
}
|
||||
|
||||
if( host.canAddPart( held, AEPartLocation.fromFacing( side ) ) )
|
||||
@@ -182,7 +174,7 @@ public class PartPlacement
|
||||
MinecraftForge.EVENT_BUS.post( new PlayerDestroyItemEvent( player, held, hand ) );
|
||||
}
|
||||
}
|
||||
return ActionResult.resultConsume( null );
|
||||
return ActionResultType.CONSUME;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -190,34 +182,30 @@ public class PartPlacement
|
||||
{
|
||||
player.swingArm( hand );
|
||||
NetworkHandler.instance().sendToServer( new PacketPartPlacement( pos, side, getEyeOffset( player ), hand ) );
|
||||
return ActionResult.resultSuccess( null );
|
||||
return ActionResultType.SUCCESS;
|
||||
}
|
||||
}
|
||||
return ActionResult.resultFail( null );
|
||||
return ActionResultType.FAIL;
|
||||
}
|
||||
}
|
||||
|
||||
if( held.isEmpty() )
|
||||
{
|
||||
final Block block = world.getBlockState( pos ).getBlock();
|
||||
if( host != null && player.isCrouching() && block != null )
|
||||
if( host != null && player.isCrouching() && world.isAirBlock(pos) )
|
||||
{
|
||||
final LookDirection dir = Platform.getPlayerRay( player, getEyeOffset( player ) );
|
||||
final RayTraceResult mop = block.getRayTraceResult( world.getBlockState( pos ), world, pos, dir.getA(), dir.getB(), mop );
|
||||
|
||||
if( mop != null )
|
||||
if( mop.getType() == RayTraceResult.Type.BLOCK )
|
||||
{
|
||||
mop.set = mop.hitVec.addVector( -mop.getBlockPos().getX(), -mop.getBlockPos().getY(), -mop.getBlockPos().getZ() );
|
||||
final SelectedPart sPart = selectPart( player, host, mop.hitVec );
|
||||
Vec3d hitVec = mop.getHitVec().add(-mop.getPos().getX(), -mop.getPos().getY(), -mop.getPos().getZ());
|
||||
final SelectedPart sPart = selectPart( player, host, hitVec );
|
||||
if( sPart != null && sPart.part != null )
|
||||
{
|
||||
if( sPart.part.onShiftActivate( player, hand, mop.hitVec ) )
|
||||
if( sPart.part.onShiftActivate( player, hand, hitVec ) )
|
||||
{
|
||||
if( world.isRemote )
|
||||
{
|
||||
NetworkHandler.instance().sendToServer( new PacketPartPlacement( pos, side, getEyeOffset( player ), hand ) );
|
||||
}
|
||||
return ActionResult.resultSuccess( null );
|
||||
return ActionResultType.SUCCESS;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -226,7 +214,7 @@ public class PartPlacement
|
||||
|
||||
if( held.isEmpty() || !( held.getItem() instanceof IPartItem ) )
|
||||
{
|
||||
return ActionResult.resultPass( null );
|
||||
return ActionResultType.PASS;
|
||||
}
|
||||
|
||||
BlockPos te_pos = pos;
|
||||
@@ -236,8 +224,9 @@ public class PartPlacement
|
||||
{
|
||||
Direction offset = null;
|
||||
|
||||
final Block blkID = world.getBlockState( pos ).getBlock();
|
||||
if( blkID != null && !blkID.isReplaceable( world, pos ) )
|
||||
BlockState blockState = world.getBlockState(pos);
|
||||
// FIXME isReplacable on the block state allows for more control, but requires an item use context
|
||||
if( !blockState.isAir(world, pos) && !blockState.isReplaceable(useContext) )
|
||||
{
|
||||
offset = side;
|
||||
if( Platform.isServer() )
|
||||
@@ -260,11 +249,15 @@ public class PartPlacement
|
||||
|
||||
final boolean hostIsNotPresent = host == null;
|
||||
final boolean multiPartPresent = maybeMultiPartBlock.isPresent() && maybeMultiPartStack.isPresent() && maybeMultiPartBlockItem.isPresent();
|
||||
final boolean canMultiPartBePlaced = maybeMultiPartBlock.get().canPlaceBlockAt( world, te_pos );
|
||||
BlockState multiPartBlockState = maybeMultiPartBlock.get().getDefaultState();
|
||||
final boolean canMultiPartBePlaced = multiPartBlockState.isValidPosition(world, te_pos);
|
||||
|
||||
// We cannot override the item stack of normal use context, so we use this hack
|
||||
BlockItemUseContext mpUseCtx = new BlockItemUseContext(new DirectionalPlaceContext(world, te_pos, side, maybeMultiPartStack.get(), side));
|
||||
|
||||
// FIXME: This is super-fishy and all needs to be re-checked. what does this even do???
|
||||
if( hostIsNotPresent && multiPartPresent && canMultiPartBePlaced && maybeMultiPartBlockItem.get()
|
||||
.placeBlockAt( maybeMultiPartStack.get(), player,
|
||||
world, te_pos, side, 0.5f, 0.5f, 0.5f, maybeMultiPartBlock.get().getDefaultState() ) )
|
||||
.tryPlace( mpUseCtx ) == ActionResultType.SUCCESS )
|
||||
{
|
||||
if( !world.isRemote )
|
||||
{
|
||||
@@ -281,18 +274,18 @@ public class PartPlacement
|
||||
{
|
||||
player.swingArm( hand );
|
||||
NetworkHandler.instance().sendToServer( new PacketPartPlacement( pos, side, getEyeOffset( player ), hand ) );
|
||||
return ActionResult.resultSuccess( null );
|
||||
return ActionResultType.SUCCESS;
|
||||
}
|
||||
}
|
||||
else if( host != null && !host.canAddPart( held, AEPartLocation.fromFacing( side ) ) )
|
||||
{
|
||||
return ActionResult.resultFail( null );
|
||||
return ActionResultType.FAIL;
|
||||
}
|
||||
}
|
||||
|
||||
if( host == null )
|
||||
{
|
||||
return ActionResult.resultPass( null );
|
||||
return ActionResultType.PASS;
|
||||
}
|
||||
|
||||
if( !host.canAddPart( held, AEPartLocation.fromFacing( side ) ) )
|
||||
@@ -301,33 +294,30 @@ public class PartPlacement
|
||||
{
|
||||
te_pos = pos.offset( side );
|
||||
|
||||
final Block blkID = world.getBlockState( te_pos ).getBlock();
|
||||
final BlockState blkState = world.getBlockState( te_pos );
|
||||
|
||||
if( blkID == null || blkID.isReplaceable( world, te_pos ) || host != null )
|
||||
// FIXME: this is always true (host was de-referenced above)
|
||||
if( blkState.isAir(world, te_pos) || blkState.isReplaceable( useContext ) || host != null )
|
||||
{
|
||||
return place( held, te_pos, side.getOpposite(), player, hand, world,
|
||||
pass == PlaceType.INTERACT_FIRST_PASS ? PlaceType.INTERACT_SECOND_PASS : PlaceType.PLACE_ITEM, depth + 1 );
|
||||
}
|
||||
}
|
||||
return ActionResult.resultPass( null );
|
||||
return ActionResultType.PASS;
|
||||
}
|
||||
|
||||
if( !world.isRemote )
|
||||
{
|
||||
final BlockState state = world.getBlockState( pos );
|
||||
final LookDirection dir = Platform.getPlayerRay( player, getEyeOffset( player ) );
|
||||
final RayTraceResult mop = state.getBlock().collisionRayTrace( state, world, pos, dir.getA(), dir.getB() );
|
||||
|
||||
if( mop != null )
|
||||
if( mop.getType() != RayTraceResult.Type.MISS )
|
||||
{
|
||||
final SelectedPart sp = selectPart( player, host,
|
||||
mop.hitVec.addVector( -mop.getBlockPos().getX(), -mop.getBlockPos().getY(), -mop.getBlockPos().getZ() ) );
|
||||
mop.getHitVec().add( -mop.getPos().getX(), -mop.getPos().getY(), -mop.getPos().getZ() ) );
|
||||
|
||||
if( sp.part != null )
|
||||
{
|
||||
if( !player.isCrouching() && sp.part.onActivate( player, hand, mop.hitVec ) )
|
||||
if( !player.isCrouching() && sp.part.onActivate( player, hand, mop.getHitVec() ) )
|
||||
{
|
||||
return ActionResult.resultFail( null );
|
||||
return ActionResultType.FAIL;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -335,7 +325,7 @@ public class PartPlacement
|
||||
final DimensionalCoord dc = host.getLocation();
|
||||
if( !Platform.hasPermissions( dc, player ) )
|
||||
{
|
||||
return ActionResult.resultFail( null );
|
||||
return ActionResultType.FAIL;
|
||||
}
|
||||
|
||||
final AEPartLocation mySide = host.addPart( held, AEPartLocation.fromFacing( side ), player, hand );
|
||||
@@ -343,7 +333,8 @@ public class PartPlacement
|
||||
{
|
||||
multiPart.maybeBlock().ifPresent( multiPartBlock ->
|
||||
{
|
||||
final SoundType ss = multiPartBlock.getSoundType( state, world, pos, player );
|
||||
BlockState blockState = world.getBlockState(pos);
|
||||
final SoundType ss = multiPartBlock.getSoundType( blockState, world, pos, player );
|
||||
|
||||
world.playSound( null, pos, ss.getPlaceSound(), SoundCategory.BLOCKS, ( ss.getVolume() + 1.0F ) / 2.0F, ss.getPitch() * 0.8F );
|
||||
} );
|
||||
@@ -363,7 +354,7 @@ public class PartPlacement
|
||||
{
|
||||
player.swingArm( hand );
|
||||
}
|
||||
return ActionResult.resultSuccess( null );
|
||||
return ActionResultType.SUCCESS;
|
||||
}
|
||||
|
||||
private static float getEyeOffset( final PlayerEntity p )
|
||||
@@ -420,10 +411,12 @@ public class PartPlacement
|
||||
final double d0 = mc.playerController.getBlockReachDistance();
|
||||
final Vec3d vec3 = mc.getRenderViewEntity().getEyePosition( f );
|
||||
|
||||
if( mop != null && mop.getHitVec().distanceTo( vec3 ) < d0 )
|
||||
if( mop instanceof BlockRayTraceResult && mop.getHitVec().distanceTo( vec3 ) < d0 )
|
||||
{
|
||||
BlockRayTraceResult brtr = (BlockRayTraceResult) mop;
|
||||
|
||||
final World w = event.getEntity().world;
|
||||
final TileEntity te = w.getTileEntity( mop.getBlockPos() );
|
||||
final TileEntity te = w.getTileEntity( brtr.getPos() );
|
||||
if( te instanceof IPartHost && this.wasCanceled )
|
||||
{
|
||||
event.setCanceled( true );
|
||||
@@ -454,7 +447,7 @@ public class PartPlacement
|
||||
|
||||
final ItemStack held = event.getPlayer().getHeldItem( event.getHand() );
|
||||
if( place( held, event.getPos(), event.getFace(), event.getPlayer(), event.getHand(), event.getPlayer().world,
|
||||
PlaceType.INTERACT_FIRST_PASS, 0 ) == ActionResult.resultSuccess( null ) )
|
||||
PlaceType.INTERACT_FIRST_PASS, 0 ) == ActionResultType.SUCCESS )
|
||||
{
|
||||
event.setCanceled( true );
|
||||
this.wasCanceled = true;
|
||||
|
||||
@@ -191,7 +191,7 @@ public abstract class PartAbstractFormationPlane<T extends IAEStack<T>> extends
|
||||
|
||||
final BlockPos tePos = te.getPos().offset( side.getFacing() );
|
||||
|
||||
this.blocked = !w.getBlockState( tePos ).getBlock().isReplaceable( w, tePos );
|
||||
this.blocked = !w.getBlockState( tePos ).getMaterial().isReplaceable();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -19,6 +19,7 @@
|
||||
package appeng.parts.automation;
|
||||
|
||||
|
||||
import java.util.Collections;
|
||||
import java.util.List;
|
||||
|
||||
import com.google.common.collect.Lists;
|
||||
@@ -29,6 +30,7 @@ import net.minecraft.block.material.Material;
|
||||
import net.minecraft.entity.Entity;
|
||||
import net.minecraft.entity.item.ItemEntity;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.item.Items;
|
||||
import net.minecraft.tileentity.TileEntity;
|
||||
import net.minecraft.util.Direction;
|
||||
import net.minecraft.util.math.AxisAlignedBB;
|
||||
@@ -69,6 +71,11 @@ import appeng.parts.PartBasicState;
|
||||
import appeng.util.IWorldCallable;
|
||||
import appeng.util.Platform;
|
||||
import appeng.util.item.AEItemStack;
|
||||
import net.minecraft.world.storage.loot.LootContext;
|
||||
import net.minecraft.world.storage.loot.LootParameters;
|
||||
import net.minecraftforge.common.ToolType;
|
||||
import net.minecraftforge.common.util.FakePlayer;
|
||||
import net.minecraftforge.common.util.FakePlayerFactory;
|
||||
|
||||
|
||||
public class PartAnnihilationPlane extends PartBasicState implements IGridTickable, IWorldCallable<TickRateModulation>
|
||||
@@ -478,8 +485,23 @@ public class PartAnnihilationPlane extends PartBasicState implements IGridTickab
|
||||
|
||||
protected List<ItemStack> obtainBlockDrops( final ServerWorld w, final BlockPos pos )
|
||||
{
|
||||
final ItemStack[] out = Platform.getBlockDrops( w, pos );
|
||||
return Lists.newArrayList( out );
|
||||
final FakePlayer fakePlayer = FakePlayerFactory.getMinecraft( w );
|
||||
final BlockState state = w.getBlockState( pos );
|
||||
ItemStack harvestTool = createHarvestTool(state);
|
||||
|
||||
// In case the block does NOT allow us to harvest it without a tool, or the proper tool,
|
||||
// do not return anything.
|
||||
if (harvestTool == null && !state.getMaterial().isToolNotRequired()) {
|
||||
return Collections.emptyList();
|
||||
}
|
||||
|
||||
LootContext.Builder lootContext = new LootContext.Builder(w)
|
||||
.withRandom(w.rand)
|
||||
.withParameter(LootParameters.POSITION, pos)
|
||||
.withNullableParameter(LootParameters.TOOL, harvestTool)
|
||||
.withNullableParameter(LootParameters.THIS_ENTITY, fakePlayer)
|
||||
.withNullableParameter(LootParameters.BLOCK_ENTITY, w.getTileEntity(pos));
|
||||
return state.getDrops(lootContext);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -569,4 +591,24 @@ public class PartAnnihilationPlane extends PartBasicState implements IGridTickab
|
||||
{
|
||||
return MODELS.getModel( this.getConnections(), this.isPowered(), this.isActive() );
|
||||
}
|
||||
|
||||
/**
|
||||
* Creates the fake (and temporary) tool that will be used to calculate the loot tables of
|
||||
* a block this plane wants to break.
|
||||
* @param state The state of the block about to be broken.
|
||||
*/
|
||||
protected ItemStack createHarvestTool(BlockState state) {
|
||||
// Try to use the right tool...
|
||||
ToolType harvestToolType = state.getBlock().getHarvestTool(state);
|
||||
if (harvestToolType == ToolType.AXE) {
|
||||
return new ItemStack(Items.DIAMOND_AXE, 1);
|
||||
} else if (harvestToolType == ToolType.SHOVEL) {
|
||||
return new ItemStack(Items.DIAMOND_SHOVEL, 1);
|
||||
} else if (harvestToolType == ToolType.PICKAXE) {
|
||||
return new ItemStack(Items.DIAMOND_PICKAXE, 1);
|
||||
} else {
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -57,7 +57,7 @@ import appeng.core.AELog;
|
||||
import appeng.core.Api;
|
||||
import appeng.core.AppEng;
|
||||
import appeng.core.settings.TickRates;
|
||||
import appeng.core.sync.GuiBridge;
|
||||
|
||||
import appeng.helpers.MultiCraftingTracker;
|
||||
import appeng.helpers.Reflected;
|
||||
import appeng.items.parts.PartModels;
|
||||
@@ -220,7 +220,7 @@ public class PartExportBus extends PartSharedItemBus implements ICraftingRequest
|
||||
{
|
||||
if( Platform.isServer() )
|
||||
{
|
||||
Platform.openGUI( player, this.getHost().getTile(), this.getSide(), GuiBridge.GUI_BUS );
|
||||
// FIXME Platform.openGUI( player, this.getHost().getTile(), this.getSide(), GuiBridge.GUI_BUS );
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
@@ -24,30 +24,23 @@ import java.util.Collections;
|
||||
import java.util.List;
|
||||
|
||||
import net.minecraft.entity.Entity;
|
||||
import net.minecraft.entity.item.EntityItem;
|
||||
import net.minecraft.entity.item.ItemEntity;
|
||||
import net.minecraft.entity.player.PlayerEntity;
|
||||
import net.minecraft.block.Blocks;
|
||||
import net.minecraft.item.Item;
|
||||
import net.minecraft.item.BlockItem;
|
||||
import net.minecraft.item.BlockItemSpecial;
|
||||
import net.minecraft.item.ItemFirework;
|
||||
import net.minecraft.item.ItemSkull;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.item.*;
|
||||
import net.minecraft.nbt.CompoundNBT;
|
||||
import net.minecraft.tileentity.TileEntity;
|
||||
import net.minecraft.util.EnumActionResult;
|
||||
import net.minecraft.util.ActionResultType;
|
||||
import net.minecraft.util.Direction;
|
||||
import net.minecraft.util.Hand;
|
||||
import net.minecraft.util.math.AxisAlignedBB;
|
||||
import net.minecraft.util.math.BlockPos;
|
||||
import net.minecraft.util.math.BlockRayTraceResult;
|
||||
import net.minecraft.util.math.Vec3d;
|
||||
import net.minecraft.world.World;
|
||||
import net.minecraft.world.WorldServer;
|
||||
import net.minecraft.world.server.ServerWorld;
|
||||
import net.minecraftforge.common.IPlantable;
|
||||
import net.minecraftforge.items.IItemHandler;
|
||||
|
||||
import appeng.api.AEApi;
|
||||
import appeng.api.config.AccessRestriction;
|
||||
import appeng.api.config.Actionable;
|
||||
import appeng.api.config.FuzzyMode;
|
||||
@@ -70,7 +63,7 @@ import appeng.api.storage.data.IItemList;
|
||||
import appeng.api.util.AEPartLocation;
|
||||
import appeng.core.AEConfig;
|
||||
import appeng.core.Api;
|
||||
import appeng.core.sync.GuiBridge;
|
||||
|
||||
import appeng.items.parts.PartModels;
|
||||
import appeng.me.GridAccessException;
|
||||
import appeng.me.storage.MEInventoryHandler;
|
||||
@@ -80,6 +73,8 @@ import appeng.util.inv.InvOperation;
|
||||
import appeng.util.prioritylist.FuzzyPriorityList;
|
||||
import appeng.util.prioritylist.PrecisePriorityList;
|
||||
|
||||
import javax.annotation.Nullable;
|
||||
|
||||
|
||||
public class PartFormationPlane extends PartAbstractFormationPlane<IAEItemStack>
|
||||
{
|
||||
@@ -200,7 +195,7 @@ public class PartFormationPlane extends PartAbstractFormationPlane<IAEItemStack>
|
||||
{
|
||||
if( Platform.isServer() )
|
||||
{
|
||||
Platform.openGUI( player, this.getHost().getTile(), this.getSide(), GuiBridge.GUI_FORMATION_PLANE );
|
||||
// FIXME Platform.openGUI( player, this.getHost().getTile(), this.getSide(), GuiBridge.GUI_FORMATION_PLANE );
|
||||
}
|
||||
return true;
|
||||
}
|
||||
@@ -237,14 +232,13 @@ public class PartFormationPlane extends PartAbstractFormationPlane<IAEItemStack>
|
||||
final World w = te.getWorld();
|
||||
final AEPartLocation side = this.getSide();
|
||||
|
||||
final BlockPos tePos = te.getPos().offset( side.getFacing() );
|
||||
final BlockPos placePos = te.getPos().offset( side.getFacing() );
|
||||
|
||||
if( w.getBlockState( tePos ).getBlock().isReplaceable( w, tePos ) )
|
||||
if( w.getBlockState( placePos ).getMaterial().isReplaceable() )
|
||||
{
|
||||
if( placeBlock == YesNo.YES && ( i instanceof BlockItem || i instanceof BlockItemSpecial || i instanceof IPlantable || i instanceof ItemSkull || i instanceof ItemFirework || i instanceof IPartItem || i == Item
|
||||
.getItemFromBlock( Blocks.REEDS ) ) )
|
||||
if( placeBlock == YesNo.YES && ( i instanceof BlockItem || i instanceof IPlantable || i instanceof FireworkStarItem || i instanceof FireworkRocketItem || i instanceof IPartItem ) )
|
||||
{
|
||||
final PlayerEntity player = Platform.getPlayer( (WorldServer) w );
|
||||
final PlayerEntity player = Platform.getPlayer( (ServerWorld) w );
|
||||
Platform.configurePlayer( player, side, this.getTile() );
|
||||
Hand hand = player.getActiveHand();
|
||||
player.setHeldItem( hand, is );
|
||||
@@ -253,38 +247,44 @@ public class PartFormationPlane extends PartAbstractFormationPlane<IAEItemStack>
|
||||
worked = true;
|
||||
if( type == Actionable.MODULATE )
|
||||
{
|
||||
if( i instanceof IPlantable || i instanceof ItemSkull || i == Item.getItemFromBlock( Blocks.REEDS ) )
|
||||
// The side the plane is attached to will be considered the look direction
|
||||
// in terms of placing an item
|
||||
Direction lookDirection = side.getFacing();
|
||||
|
||||
// FIXME No idea what any of this is _supposed_ to do, comment badly needed
|
||||
if ( i instanceof IPlantable || i instanceof WallOrFloorItem )
|
||||
{
|
||||
boolean Worked = false;
|
||||
|
||||
// Up or Down, Attempt 1??
|
||||
if( side.xOffset == 0 && side.zOffset == 0 )
|
||||
{
|
||||
Worked = i.onItemUse( player, w, tePos.offset( side.getFacing() ), hand, side.getFacing().getOpposite(), side.xOffset,
|
||||
side.yOffset, side.zOffset ) == EnumActionResult.SUCCESS;
|
||||
Worked = i.onItemUse( new DirectionalPlaceContext(w, placePos.offset( side.getFacing() ), lookDirection, is, side.getFacing()) ) == ActionResultType.SUCCESS;
|
||||
}
|
||||
|
||||
// Up or Down, Attempt 2??
|
||||
if( !Worked && side.xOffset == 0 && side.zOffset == 0 )
|
||||
{
|
||||
Worked = i.onItemUse( player, w, tePos.offset( side.getFacing().getOpposite() ), hand, side.getFacing(), side.xOffset,
|
||||
side.yOffset, side.zOffset ) == EnumActionResult.SUCCESS;
|
||||
Worked = i.onItemUse( new DirectionalPlaceContext(w, placePos.offset( side.getFacing().getOpposite() ), lookDirection, is, side.getFacing().getOpposite()) )
|
||||
== ActionResultType.SUCCESS;
|
||||
}
|
||||
|
||||
// Horizontal, attempt 1??
|
||||
if( !Worked && side.yOffset == 0 )
|
||||
{
|
||||
Worked = i.onItemUse( player, w, tePos.offset( Direction.DOWN ), hand, Direction.UP, side.xOffset, side.yOffset,
|
||||
side.zOffset ) == EnumActionResult.SUCCESS;
|
||||
Worked = i.onItemUse( new DirectionalPlaceContext(w, placePos.offset( Direction.DOWN ), lookDirection, is, Direction.DOWN) ) == ActionResultType.SUCCESS;
|
||||
}
|
||||
|
||||
if( !Worked )
|
||||
{
|
||||
i.onItemUse( player, w, tePos, hand, side.getFacing().getOpposite(), side.xOffset, side.yOffset, side.zOffset );
|
||||
i.onItemUse( new DirectionalPlaceContext(w, placePos, lookDirection, is, lookDirection.getOpposite()) );
|
||||
}
|
||||
|
||||
maxStorage -= is.getCount();
|
||||
}
|
||||
else
|
||||
{
|
||||
i.onItemUse( player, w, tePos, hand, side.getFacing().getOpposite(), side.xOffset, side.yOffset, side.zOffset );
|
||||
i.onItemUse( new DirectionalPlaceContext(w, placePos, lookDirection, is, lookDirection.getOpposite()) );
|
||||
maxStorage -= is.getCount();
|
||||
}
|
||||
}
|
||||
@@ -300,7 +300,7 @@ public class PartFormationPlane extends PartAbstractFormationPlane<IAEItemStack>
|
||||
{
|
||||
worked = true;
|
||||
|
||||
final int sum = this.countEntitesAround( w, tePos );
|
||||
final int sum = this.countEntitesAround( w, placePos );
|
||||
|
||||
if( sum < AEConfig.instance().getFormationPlaneEntityLimit() )
|
||||
{
|
||||
@@ -344,7 +344,7 @@ public class PartFormationPlane extends PartAbstractFormationPlane<IAEItemStack>
|
||||
}
|
||||
}
|
||||
|
||||
this.blocked = !w.getBlockState( tePos ).getBlock().isReplaceable( w, tePos );
|
||||
this.blocked = !w.getBlockState( placePos ).getMaterial().isReplaceable();
|
||||
|
||||
if( worked )
|
||||
{
|
||||
@@ -378,11 +378,11 @@ public class PartFormationPlane extends PartAbstractFormationPlane<IAEItemStack>
|
||||
return Api.INSTANCE.definitions().parts().formationPlane().maybeStack( 1 ).orElse( ItemStack.EMPTY );
|
||||
}
|
||||
|
||||
@Override
|
||||
public GuiBridge getGuiBridge()
|
||||
{
|
||||
return GuiBridge.GUI_FORMATION_PLANE;
|
||||
}
|
||||
// FIXME @Override
|
||||
// FIXME public GuiBridge getGuiBridge()
|
||||
// FIXME {
|
||||
// FIXME return GuiBridge.GUI_FORMATION_PLANE;
|
||||
// FIXME }
|
||||
|
||||
private int countEntitesAround( World world, BlockPos pos )
|
||||
{
|
||||
@@ -391,4 +391,11 @@ public class PartFormationPlane extends PartAbstractFormationPlane<IAEItemStack>
|
||||
|
||||
return list.size();
|
||||
}
|
||||
|
||||
private class ForcedItemUseContext extends ItemUseContext {
|
||||
protected ForcedItemUseContext(World worldIn, @Nullable PlayerEntity player, Hand handIn, ItemStack heldItem, BlockRayTraceResult rayTraceResultIn) {
|
||||
super(worldIn, player, handIn, heldItem, rayTraceResultIn);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -19,25 +19,21 @@
|
||||
package appeng.parts.automation;
|
||||
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
import net.minecraft.block.BlockState;
|
||||
import net.minecraft.item.Items;
|
||||
import net.minecraft.item.Item;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.tileentity.TileEntity;
|
||||
import net.minecraft.util.math.BlockPos;
|
||||
import net.minecraft.world.ServerWorld;
|
||||
import net.minecraft.world.server.ServerWorld;
|
||||
import net.minecraftforge.common.util.FakePlayer;
|
||||
import net.minecraftforge.common.util.FakePlayerFactory;
|
||||
|
||||
import appeng.api.parts.IPart;
|
||||
import appeng.api.parts.IPartHost;
|
||||
import appeng.api.parts.IPartModel;
|
||||
import appeng.api.util.AEPartLocation;
|
||||
import appeng.items.parts.PartModels;
|
||||
import com.google.common.collect.ImmutableMap;
|
||||
import net.minecraft.block.BlockState;
|
||||
import net.minecraft.enchantment.EnchantmentHelper;
|
||||
import net.minecraft.enchantment.Enchantments;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.tileentity.TileEntity;
|
||||
import net.minecraft.util.math.BlockPos;
|
||||
import net.minecraft.world.server.ServerWorld;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
|
||||
public class PartIdentityAnnihilationPlane extends PartAnnihilationPlane
|
||||
@@ -78,32 +74,17 @@ public class PartIdentityAnnihilationPlane extends PartAnnihilationPlane
|
||||
}
|
||||
|
||||
@Override
|
||||
protected List<ItemStack> obtainBlockDrops(final ServerWorld w, final BlockPos pos )
|
||||
{
|
||||
final FakePlayer fakePlayer = FakePlayerFactory.getMinecraft( w );
|
||||
final BlockState state = w.getBlockState( pos );
|
||||
protected ItemStack createHarvestTool(BlockState state) {
|
||||
ItemStack harvestTool = super.createHarvestTool(state);
|
||||
|
||||
if( state.getBlock().canSilkHarvest( w, pos, state, fakePlayer ) )
|
||||
{
|
||||
final List<ItemStack> out = new ArrayList<>( 1 );
|
||||
final Item item = Item.getItemFromBlock( state.getBlock() );
|
||||
// For silk touch purposes, enchant the fake tool
|
||||
if (harvestTool != null) {
|
||||
EnchantmentHelper.setEnchantments(ImmutableMap.of(
|
||||
Enchantments.SILK_TOUCH, 1
|
||||
), harvestTool);
|
||||
}
|
||||
|
||||
if( item != Items.AIR )
|
||||
{
|
||||
int meta = 0;
|
||||
if( item.getHasSubtypes() )
|
||||
{
|
||||
meta = state.getBlock().getMetaFromState( state );
|
||||
}
|
||||
final ItemStack itemstack = new ItemStack( item, 1, meta );
|
||||
out.add( itemstack );
|
||||
}
|
||||
return out;
|
||||
}
|
||||
else
|
||||
{
|
||||
return super.obtainBlockDrops( w, pos );
|
||||
}
|
||||
return harvestTool;
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -26,7 +26,6 @@ import net.minecraft.util.Hand;
|
||||
import net.minecraft.util.ResourceLocation;
|
||||
import net.minecraft.util.math.Vec3d;
|
||||
|
||||
import appeng.api.AEApi;
|
||||
import appeng.api.config.Actionable;
|
||||
import appeng.api.config.FuzzyMode;
|
||||
import appeng.api.config.RedstoneMode;
|
||||
@@ -47,7 +46,6 @@ import appeng.api.util.AECableType;
|
||||
import appeng.core.Api;
|
||||
import appeng.core.AppEng;
|
||||
import appeng.core.settings.TickRates;
|
||||
import appeng.core.sync.GuiBridge;
|
||||
import appeng.helpers.Reflected;
|
||||
import appeng.items.parts.PartModels;
|
||||
import appeng.me.GridAccessException;
|
||||
@@ -133,7 +131,7 @@ public class PartImportBus extends PartSharedItemBus implements IInventoryDestin
|
||||
{
|
||||
if( Platform.isServer() )
|
||||
{
|
||||
Platform.openGUI( player, this.getHost().getTile(), this.getSide(), GuiBridge.GUI_BUS );
|
||||
// FIXME Platform.openGUI( player, this.getHost().getTile(), this.getSide(), GuiBridge.GUI_BUS );
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
@@ -72,7 +72,7 @@ import appeng.api.util.AEPartLocation;
|
||||
import appeng.api.util.IConfigManager;
|
||||
import appeng.core.Api;
|
||||
import appeng.core.AppEng;
|
||||
import appeng.core.sync.GuiBridge;
|
||||
|
||||
import appeng.helpers.Reflected;
|
||||
import appeng.items.parts.PartModels;
|
||||
import appeng.me.GridAccessException;
|
||||
@@ -461,7 +461,7 @@ public class PartLevelEmitter extends PartUpgradeable implements IEnergyWatcherH
|
||||
{
|
||||
if( Platform.isServer() )
|
||||
{
|
||||
Platform.openGUI( player, this.getHost().getTile(), this.getSide(), GuiBridge.GUI_LEVEL_EMITTER );
|
||||
// FIXME Platform.openGUI( player, this.getHost().getTile(), this.getSide(), GuiBridge.GUI_LEVEL_EMITTER );
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
@@ -34,6 +34,7 @@ import net.minecraft.util.Hand;
|
||||
import net.minecraft.util.ResourceLocation;
|
||||
import net.minecraft.util.math.Vec3d;
|
||||
import net.minecraftforge.common.capabilities.Capability;
|
||||
import net.minecraftforge.common.util.LazyOptional;
|
||||
import net.minecraftforge.items.IItemHandler;
|
||||
|
||||
import appeng.api.config.Actionable;
|
||||
@@ -59,7 +60,7 @@ import appeng.api.util.AECableType;
|
||||
import appeng.api.util.IConfigManager;
|
||||
import appeng.core.Api;
|
||||
import appeng.core.AppEng;
|
||||
import appeng.core.sync.GuiBridge;
|
||||
|
||||
import appeng.helpers.DualityInterface;
|
||||
import appeng.helpers.IInterfaceHost;
|
||||
import appeng.helpers.IPriorityHost;
|
||||
@@ -176,7 +177,7 @@ public class PartInterface extends PartBasicState implements IGridTickable, ISto
|
||||
{
|
||||
if( Platform.isServer() )
|
||||
{
|
||||
Platform.openGUI( p, this.getTileEntity(), this.getSide(), GuiBridge.GUI_INTERFACE );
|
||||
// FIXME Platform.openGUI( p, this.getTileEntity(), this.getSide(), GuiBridge.GUI_INTERFACE );
|
||||
}
|
||||
return true;
|
||||
}
|
||||
@@ -295,13 +296,7 @@ public class PartInterface extends PartBasicState implements IGridTickable, ISto
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean hasCapability( Capability<?> capabilityClass )
|
||||
{
|
||||
return this.duality.hasCapability( capabilityClass, this.getSide().getFacing() );
|
||||
}
|
||||
|
||||
@Override
|
||||
public <T> T getCapability( Capability<T> capabilityClass )
|
||||
public <T> LazyOptional<T> getCapability(Capability<T> capabilityClass )
|
||||
{
|
||||
return this.duality.getCapability( capabilityClass, this.getSide().getFacing() );
|
||||
}
|
||||
@@ -312,9 +307,9 @@ public class PartInterface extends PartBasicState implements IGridTickable, ISto
|
||||
return Api.INSTANCE.definitions().parts().iface().maybeStack( 1 ).orElse( ItemStack.EMPTY );
|
||||
}
|
||||
|
||||
@Override
|
||||
public GuiBridge getGuiBridge()
|
||||
{
|
||||
return GuiBridge.GUI_INTERFACE;
|
||||
}
|
||||
// FIXME @Override
|
||||
// FIXME public GuiBridge getGuiBridge()
|
||||
// FIXME {
|
||||
// FIXME return GuiBridge.GUI_INTERFACE;
|
||||
// FIXME }
|
||||
}
|
||||
|
||||
@@ -76,7 +76,7 @@ import appeng.capabilities.Capabilities;
|
||||
import appeng.core.Api;
|
||||
import appeng.core.AppEng;
|
||||
import appeng.core.settings.TickRates;
|
||||
import appeng.core.sync.GuiBridge;
|
||||
|
||||
import appeng.helpers.IInterfaceHost;
|
||||
import appeng.helpers.IPriorityHost;
|
||||
import appeng.helpers.Reflected;
|
||||
@@ -316,7 +316,7 @@ public class PartStorageBus extends PartUpgradeable implements IGridTickable, IC
|
||||
{
|
||||
if( Platform.isServer() )
|
||||
{
|
||||
Platform.openGUI( player, this.getHost().getTile(), this.getSide(), GuiBridge.GUI_STORAGEBUS );
|
||||
// FIXME Platform.openGUI( player, this.getHost().getTile(), this.getSide(), GuiBridge.GUI_STORAGEBUS );
|
||||
}
|
||||
return true;
|
||||
}
|
||||
@@ -646,9 +646,9 @@ public class PartStorageBus extends PartUpgradeable implements IGridTickable, IC
|
||||
return Api.INSTANCE.definitions().parts().storageBus().maybeStack( 1 ).orElse( ItemStack.EMPTY );
|
||||
}
|
||||
|
||||
@Override
|
||||
public GuiBridge getGuiBridge()
|
||||
{
|
||||
return GuiBridge.GUI_STORAGEBUS;
|
||||
}
|
||||
// FIXME @Override
|
||||
// FIXME public GuiBridge getGuiBridge()
|
||||
// FIXME {
|
||||
// FIXME return GuiBridge.GUI_STORAGEBUS;
|
||||
// FIXME }
|
||||
}
|
||||
|
||||
@@ -30,7 +30,6 @@ import net.minecraft.util.ResourceLocation;
|
||||
import net.minecraft.util.math.BlockPos;
|
||||
import net.minecraft.world.IBlockReader;
|
||||
|
||||
import appeng.api.AEApi;
|
||||
import appeng.api.exceptions.FailedConnectionException;
|
||||
import appeng.api.networking.IGridConnection;
|
||||
import appeng.api.networking.IGridNode;
|
||||
@@ -140,7 +139,7 @@ public class PartToggleBus extends PartBasicState
|
||||
public void removeFromWorld()
|
||||
{
|
||||
super.removeFromWorld();
|
||||
this.getOuterProxy().invalidate();
|
||||
this.getOuterProxy().remove();
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -95,7 +95,7 @@ public class PartQuartzFiber extends AEBasePart implements IEnergyGridProvider
|
||||
public void removeFromWorld()
|
||||
{
|
||||
super.removeFromWorld();
|
||||
this.outerProxy.invalidate();
|
||||
this.outerProxy.remove();
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -82,27 +82,18 @@ public class PartP2PFEPower extends PartP2PTunnel<PartP2PFEPower>
|
||||
return energyStorageOpt.orElse( NULL_ENERGY_STORAGE );
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean hasCapability( @Nonnull Capability<?> capability )
|
||||
{
|
||||
if( capability == Capabilities.FORGE_ENERGY )
|
||||
{
|
||||
return true;
|
||||
}
|
||||
return super.hasCapability( capability );
|
||||
}
|
||||
|
||||
@SuppressWarnings("unchecked")
|
||||
@Nullable
|
||||
@Override
|
||||
public <T> T getCapability( @Nonnull Capability<T> capability )
|
||||
public <T> LazyOptional<T> getCapability( @Nonnull Capability<T> capability )
|
||||
{
|
||||
if( capability == Capabilities.FORGE_ENERGY )
|
||||
{
|
||||
if( this.isOutput() )
|
||||
{
|
||||
return (T) this.outputHandler;
|
||||
return (LazyOptional<T>) LazyOptional.of(() -> this.outputHandler);
|
||||
}
|
||||
return (T) this.inputHandler;
|
||||
return (LazyOptional<T>) LazyOptional.of(() ->this.inputHandler);
|
||||
}
|
||||
return super.getCapability( capability );
|
||||
}
|
||||
|
||||
@@ -31,6 +31,7 @@ import net.minecraft.tileentity.TileEntity;
|
||||
import net.minecraft.util.math.BlockPos;
|
||||
import net.minecraft.world.IBlockReader;
|
||||
import net.minecraftforge.common.capabilities.Capability;
|
||||
import net.minecraftforge.common.util.LazyOptional;
|
||||
import net.minecraftforge.fluids.FluidStack;
|
||||
import net.minecraftforge.fluids.capability.CapabilityFluidHandler;
|
||||
import net.minecraftforge.fluids.capability.FluidTankProperties;
|
||||
@@ -91,23 +92,13 @@ public class PartP2PFluids extends PartP2PTunnel<PartP2PFluids> implements IFlui
|
||||
}
|
||||
}
|
||||
|
||||
@SuppressWarnings("unchecked")
|
||||
@Override
|
||||
public boolean hasCapability( Capability<?> capabilityClass )
|
||||
public <T> LazyOptional<T> getCapability(Capability<T> capabilityClass )
|
||||
{
|
||||
if( capabilityClass == CapabilityFluidHandler.FLUID_HANDLER_CAPABILITY )
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
return super.hasCapability( capabilityClass );
|
||||
}
|
||||
|
||||
@Override
|
||||
public <T> T getCapability( Capability<T> capabilityClass )
|
||||
{
|
||||
if( capabilityClass == CapabilityFluidHandler.FLUID_HANDLER_CAPABILITY )
|
||||
{
|
||||
return (T) this;
|
||||
return (LazyOptional<T>) LazyOptional.of(() ->this);
|
||||
}
|
||||
|
||||
return super.getCapability( capabilityClass );
|
||||
|
||||
@@ -28,6 +28,7 @@ import net.minecraft.util.Direction;
|
||||
import net.minecraft.util.math.BlockPos;
|
||||
import net.minecraft.world.IBlockReader;
|
||||
import net.minecraftforge.common.capabilities.Capability;
|
||||
import net.minecraftforge.common.util.LazyOptional;
|
||||
import net.minecraftforge.items.CapabilityItemHandler;
|
||||
import net.minecraftforge.items.IItemHandler;
|
||||
import net.minecraftforge.items.wrapper.EmptyHandler;
|
||||
@@ -230,24 +231,13 @@ public class PartP2PItems extends PartP2PTunnel<PartP2PItems> implements IItemHa
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean hasCapability( Capability<?> capabilityClass )
|
||||
{
|
||||
if( capabilityClass == CapabilityItemHandler.ITEM_HANDLER_CAPABILITY )
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
return super.hasCapability( capabilityClass );
|
||||
}
|
||||
|
||||
@SuppressWarnings( "unchecked" )
|
||||
@Override
|
||||
public <T> T getCapability( Capability<T> capabilityClass )
|
||||
public <T> LazyOptional<T> getCapability(Capability<T> capabilityClass )
|
||||
{
|
||||
if( capabilityClass == CapabilityItemHandler.ITEM_HANDLER_CAPABILITY )
|
||||
{
|
||||
return (T) this;
|
||||
return (LazyOptional<T>) LazyOptional.of(() ->this);
|
||||
}
|
||||
|
||||
return super.getCapability( capabilityClass );
|
||||
|
||||
@@ -30,7 +30,6 @@ import net.minecraft.nbt.CompoundNBT;
|
||||
import net.minecraft.tileentity.TileEntity;
|
||||
import net.minecraft.util.Hand;
|
||||
|
||||
import appeng.api.AEApi;
|
||||
import appeng.api.exceptions.FailedConnectionException;
|
||||
import appeng.api.networking.GridFlags;
|
||||
import appeng.api.networking.IGridNode;
|
||||
@@ -114,7 +113,7 @@ public class PartP2PTunnelME extends PartP2PTunnel<PartP2PTunnelME> implements I
|
||||
public void removeFromWorld()
|
||||
{
|
||||
super.removeFromWorld();
|
||||
this.outerProxy.invalidate();
|
||||
this.outerProxy.remove();
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -21,6 +21,8 @@ package appeng.parts.reporting;
|
||||
|
||||
import java.io.IOException;
|
||||
|
||||
import com.mojang.blaze3d.matrix.MatrixStack;
|
||||
import net.minecraft.client.renderer.IRenderTypeBuffer;
|
||||
import net.minecraft.entity.player.PlayerEntity;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.nbt.CompoundNBT;
|
||||
@@ -250,7 +252,7 @@ public abstract class AbstractPartMonitor extends AbstractPartDisplay implements
|
||||
|
||||
@Override
|
||||
@OnlyIn( Dist.CLIENT )
|
||||
public void renderDynamic( double x, double y, double z, float partialTicks, int destroyStage )
|
||||
public void renderDynamic(float partialTicks, MatrixStack matrixStack, IRenderTypeBuffer buffers, int combinedLightIn, int combinedOverlayIn)
|
||||
{
|
||||
|
||||
if( ( this.getClientFlags() & ( PartPanel.POWERED_FLAG | PartPanel.CHANNEL_FLAG ) ) != ( PartPanel.POWERED_FLAG | PartPanel.CHANNEL_FLAG ) )
|
||||
@@ -265,16 +267,16 @@ public abstract class AbstractPartMonitor extends AbstractPartDisplay implements
|
||||
return;
|
||||
}
|
||||
|
||||
GlStateManager.pushMatrix();
|
||||
GlStateManager.translate( x + 0.5, y + 0.5, z + 0.5 );
|
||||
matrixStack.push();
|
||||
matrixStack.translate( 0.5, 0.5, 0.5 );
|
||||
|
||||
Direction facing = this.getSide().getFacing();
|
||||
|
||||
TesrRenderHelper.moveToFace( facing );
|
||||
TesrRenderHelper.rotateToFace( facing, this.getSpin() );
|
||||
TesrRenderHelper.renderItem2dWithAmount( ais, 0.8f, 0.17f );
|
||||
TesrRenderHelper.moveToFace( matrixStack, facing );
|
||||
TesrRenderHelper.rotateToFace( matrixStack, facing, this.getSpin() );
|
||||
TesrRenderHelper.renderItem2dWithAmount(matrixStack, buffers, ais, 0.8f, 0.17f );
|
||||
|
||||
GlStateManager.popMatrix();
|
||||
matrixStack.pop();
|
||||
|
||||
}
|
||||
|
||||
|
||||
@@ -44,6 +44,7 @@ import appeng.api.util.AEPartLocation;
|
||||
import appeng.me.GridAccessException;
|
||||
import appeng.parts.AEBasePart;
|
||||
import appeng.util.Platform;
|
||||
import net.minecraft.world.World;
|
||||
|
||||
|
||||
/**
|
||||
@@ -134,7 +135,7 @@ public abstract class AbstractPartReporting extends AEBasePart implements IPartM
|
||||
public void writeToNBT( final CompoundNBT data )
|
||||
{
|
||||
super.writeToNBT( data );
|
||||
data.setByte( "spin", this.getSpin() );
|
||||
data.putByte( "spin", this.getSpin() );
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -255,7 +256,9 @@ public abstract class AbstractPartReporting extends AEBasePart implements IPartM
|
||||
if( this.opacity < 0 )
|
||||
{
|
||||
final TileEntity te = this.getTile();
|
||||
this.opacity = 255 - te.getWorld().getBlockLightOpacity( te.getPos().offset( this.getSide().getFacing() ) );
|
||||
World world = te.getWorld();
|
||||
BlockPos pos = te.getPos().offset(this.getSide().getFacing());
|
||||
this.opacity = 255 - world.getBlockState(pos).getOpacity(world, pos);
|
||||
}
|
||||
|
||||
return (int) ( emit * ( this.opacity / 255.0f ) );
|
||||
|
||||
@@ -38,7 +38,7 @@ import appeng.api.storage.IStorageChannel;
|
||||
import appeng.api.storage.ITerminalHost;
|
||||
import appeng.api.storage.data.IAEStack;
|
||||
import appeng.api.util.IConfigManager;
|
||||
import appeng.core.sync.GuiBridge;
|
||||
|
||||
import appeng.me.GridAccessException;
|
||||
import appeng.tile.inventory.AppEngInternalInventory;
|
||||
import appeng.util.ConfigManager;
|
||||
@@ -117,16 +117,16 @@ public abstract class AbstractPartTerminal extends AbstractPartDisplay implement
|
||||
{
|
||||
if( Platform.isServer() )
|
||||
{
|
||||
Platform.openGUI( player, this.getHost().getTile(), this.getSide(), this.getGui( player ) );
|
||||
// FIXME Platform.openGUI( player, this.getHost().getTile(), this.getSide(), this.getGui( player ) );
|
||||
}
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
public GuiBridge getGui( final PlayerEntity player )
|
||||
{
|
||||
return GuiBridge.GUI_ME;
|
||||
}
|
||||
// FIXME public GuiBridge getGui( final PlayerEntity player )
|
||||
// FIXME {
|
||||
// FIXME return GuiBridge.GUI_ME;
|
||||
// FIXME }
|
||||
|
||||
@Override
|
||||
public <T extends IAEStack<T>> IMEMonitor<T> getInventory( IStorageChannel<T> channel )
|
||||
|
||||
@@ -22,6 +22,7 @@ package appeng.parts.reporting;
|
||||
import java.util.Collections;
|
||||
import java.util.List;
|
||||
|
||||
import appeng.core.Api;
|
||||
import net.minecraft.entity.player.PlayerEntity;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.tileentity.TileEntity;
|
||||
|
||||
@@ -29,7 +29,7 @@ import net.minecraftforge.items.IItemHandler;
|
||||
|
||||
import appeng.api.parts.IPartModel;
|
||||
import appeng.core.AppEng;
|
||||
import appeng.core.sync.GuiBridge;
|
||||
|
||||
import appeng.helpers.Reflected;
|
||||
import appeng.items.parts.PartModels;
|
||||
import appeng.parts.PartModel;
|
||||
@@ -84,25 +84,25 @@ public class PartCraftingTerminal extends AbstractPartTerminal
|
||||
this.craftingGrid.writeToNBT( data, "craftingGrid" );
|
||||
}
|
||||
|
||||
@Override
|
||||
public GuiBridge getGui( final PlayerEntity p )
|
||||
{
|
||||
int x = (int) p.getPosX();
|
||||
int y = (int) p.getPosY();
|
||||
int z = (int) p.getPosZ();
|
||||
if( this.getHost().getTile() != null )
|
||||
{
|
||||
x = this.getTile().getPos().getX();
|
||||
y = this.getTile().getPos().getY();
|
||||
z = this.getTile().getPos().getZ();
|
||||
}
|
||||
|
||||
if( GuiBridge.GUI_CRAFTING_TERMINAL.hasPermissions( this.getHost().getTile(), x, y, z, this.getSide(), p ) )
|
||||
{
|
||||
return GuiBridge.GUI_CRAFTING_TERMINAL;
|
||||
}
|
||||
return GuiBridge.GUI_ME;
|
||||
}
|
||||
// FIXME @Override
|
||||
// FIXME public GuiBridge getGui( final PlayerEntity p )
|
||||
// FIXME {
|
||||
// FIXME int x = (int) p.getPosX();
|
||||
// FIXME int y = (int) p.getPosY();
|
||||
// FIXME int z = (int) p.getPosZ();
|
||||
// FIXME if( this.getHost().getTile() != null )
|
||||
// FIXME {
|
||||
// FIXME x = this.getTile().getPos().getX();
|
||||
// FIXME y = this.getTile().getPos().getY();
|
||||
// FIXME z = this.getTile().getPos().getZ();
|
||||
// FIXME }
|
||||
// FIXME
|
||||
// FIXME if( GuiBridge.GUI_CRAFTING_TERMINAL.hasPermissions( this.getHost().getTile(), x, y, z, this.getSide(), p ) )
|
||||
// FIXME {
|
||||
// FIXME return GuiBridge.GUI_CRAFTING_TERMINAL;
|
||||
// FIXME }
|
||||
// FIXME return GuiBridge.GUI_ME;
|
||||
// FIXME }
|
||||
|
||||
@Override
|
||||
public IItemHandler getInventoryByName( final String name )
|
||||
|
||||
@@ -27,7 +27,7 @@ import net.minecraft.util.math.Vec3d;
|
||||
|
||||
import appeng.api.parts.IPartModel;
|
||||
import appeng.core.AppEng;
|
||||
import appeng.core.sync.GuiBridge;
|
||||
|
||||
import appeng.items.parts.PartModels;
|
||||
import appeng.parts.PartModel;
|
||||
import appeng.util.Platform;
|
||||
@@ -57,7 +57,7 @@ public class PartInterfaceTerminal extends AbstractPartDisplay
|
||||
{
|
||||
if( Platform.isServer() )
|
||||
{
|
||||
Platform.openGUI( player, this.getHost().getTile(), this.getSide(), GuiBridge.GUI_INTERFACE_TERMINAL );
|
||||
// FIXME Platform.openGUI( player, this.getHost().getTile(), this.getSide(), GuiBridge.GUI_INTERFACE_TERMINAL );
|
||||
}
|
||||
}
|
||||
return true;
|
||||
|
||||
@@ -32,7 +32,7 @@ import appeng.api.networking.crafting.ICraftingPatternDetails;
|
||||
import appeng.api.parts.IPartModel;
|
||||
import appeng.api.storage.data.IAEItemStack;
|
||||
import appeng.core.AppEng;
|
||||
import appeng.core.sync.GuiBridge;
|
||||
|
||||
import appeng.helpers.Reflected;
|
||||
import appeng.items.parts.PartModels;
|
||||
import appeng.parts.PartModel;
|
||||
@@ -99,25 +99,25 @@ public class PartPatternTerminal extends AbstractPartTerminal
|
||||
this.crafting.writeToNBT( data, "craftingGrid" );
|
||||
}
|
||||
|
||||
@Override
|
||||
public GuiBridge getGui( final PlayerEntity p )
|
||||
{
|
||||
int x = (int) p.getPosX();
|
||||
int y = (int) p.getPosY();
|
||||
int z = (int) p.getPosZ();
|
||||
if( this.getHost().getTile() != null )
|
||||
{
|
||||
x = this.getTile().getPos().getX();
|
||||
y = this.getTile().getPos().getY();
|
||||
z = this.getTile().getPos().getZ();
|
||||
}
|
||||
|
||||
if( GuiBridge.GUI_PATTERN_TERMINAL.hasPermissions( this.getHost().getTile(), x, y, z, this.getSide(), p ) )
|
||||
{
|
||||
return GuiBridge.GUI_PATTERN_TERMINAL;
|
||||
}
|
||||
return GuiBridge.GUI_ME;
|
||||
}
|
||||
// FIXME @Override
|
||||
// FIXME public GuiBridge getGui( final PlayerEntity p )
|
||||
// FIXME {
|
||||
// FIXME int x = (int) p.getPosX();
|
||||
// FIXME int y = (int) p.getPosY();
|
||||
// FIXME int z = (int) p.getPosZ();
|
||||
// FIXME if( this.getHost().getTile() != null )
|
||||
// FIXME {
|
||||
// FIXME x = this.getTile().getPos().getX();
|
||||
// FIXME y = this.getTile().getPos().getY();
|
||||
// FIXME z = this.getTile().getPos().getZ();
|
||||
// FIXME }
|
||||
// FIXME
|
||||
// FIXME if( GuiBridge.GUI_PATTERN_TERMINAL.hasPermissions( this.getHost().getTile(), x, y, z, this.getSide(), p ) )
|
||||
// FIXME {
|
||||
// FIXME return GuiBridge.GUI_PATTERN_TERMINAL;
|
||||
// FIXME }
|
||||
// FIXME return GuiBridge.GUI_ME;
|
||||
// FIXME }
|
||||
|
||||
@Override
|
||||
public void onChangeInventory( final IItemHandler inv, final int slot, final InvOperation mc, final ItemStack removedStack, final ItemStack newStack )
|
||||
|
||||
Reference in New Issue
Block a user