Lots of compile fixes
This commit is contained in:
@@ -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;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user