Lots of compile fixes

This commit is contained in:
Sebastian Hartte
2020-06-04 03:02:48 +02:00
parent 6eb2a9504a
commit 237463dd94
241 changed files with 3438 additions and 3474 deletions
@@ -8,7 +8,6 @@ import net.minecraftforge.api.distmarker.OnlyIn;
import appeng.bootstrap.IItemRendering;
import appeng.bootstrap.ItemRenderingCustomizer;
import appeng.client.render.model.BiometricCardModel;
import appeng.core.AppEng;
@@ -21,7 +20,7 @@ public class ToolBiometricCardRendering extends ItemRenderingCustomizer
@OnlyIn( Dist.CLIENT )
public void customize( IItemRendering rendering )
{
rendering.builtInModel( "models/item/builtin/biometric_card", new BiometricCardModel() );
// FIXME rendering.builtInModel( "models/item/builtin/biometric_card", new BiometricCardModel() );
rendering.model( new ModelResourceLocation( MODEL, "inventory" ) ).variants( MODEL );
}
}
@@ -33,6 +33,7 @@ import net.minecraft.util.Hand;
import net.minecraft.util.math.BlockPos;
import net.minecraft.util.text.ITextComponent;
import net.minecraft.util.text.TextFormatting;
import net.minecraft.util.text.TranslationTextComponent;
import net.minecraft.world.IWorldReader;
import net.minecraft.world.World;
import net.minecraftforge.api.distmarker.Dist;
@@ -70,12 +71,14 @@ public class ToolMemoryCard extends AEBaseItem implements IMemoryCard
@OnlyIn( Dist.CLIENT )
public void addInformation( final ItemStack stack, final World world, final List<ITextComponent> lines, final ITooltipFlag advancedTooltips )
{
lines.add( this.getLocalizedName( this.getSettingsName( stack ) + ".name", this.getSettingsName( stack ) ) );
String firstLineKey = this.getFirstValidTranslationKey( this.getSettingsName( stack ) + ".name", this.getSettingsName( stack ) );
lines.add( new TranslationTextComponent(firstLineKey));
final CompoundNBT data = this.getData( stack );
if( data.contains( "tooltip" ) )
{
lines.add( I18n.translateToLocal( this.getLocalizedName( data.getString( "tooltip" ) + ".name", data.getString( "tooltip" ) ) ) );
String tooltipKey = getFirstValidTranslationKey( data.getString( "tooltip" ) + ".name", data.getString( "tooltip" ) );
lines.add( new TranslationTextComponent(tooltipKey) );
}
if( data.contains( "freq" ) )
@@ -83,7 +86,7 @@ public class ToolMemoryCard extends AEBaseItem implements IMemoryCard
final short freq = data.getShort( "freq" );
final String freqTooltip = TextFormatting.BOLD + Platform.p2p().toHexString( freq );
lines.add( I18n.translateToLocalFormatted( "gui.tooltips.appliedenergistics2.P2PFrequency", freqTooltip ) );
lines.add( new TranslationTextComponent( "gui.tooltips.appliedenergistics2.P2PFrequency", freqTooltip ) );
}
}
@@ -94,14 +97,13 @@ public class ToolMemoryCard extends AEBaseItem implements IMemoryCard
*
* @return localized name
*/
private String getLocalizedName( final String... name )
private String getFirstValidTranslationKey( final String... name )
{
for( final String n : name )
{
final String l = I18n.translateToLocal( n );
if( !l.equals( n ) )
if( I18n.hasKey(n) )
{
return l;
return n;
}
}
@@ -126,7 +128,7 @@ public class ToolMemoryCard extends AEBaseItem implements IMemoryCard
{
final CompoundNBT c = is.getOrCreateTag();
final String name = c.getString( "Config" );
return name == null || name.isEmpty() ? GuiText.Blank.getUnlocalized() : name;
return name.isEmpty() ? GuiText.Blank.getTranslationKey() : name;
}
@Override
@@ -134,10 +136,6 @@ public class ToolMemoryCard extends AEBaseItem implements IMemoryCard
{
final CompoundNBT c = is.getOrCreateTag();
CompoundNBT o = c.getCompound( "Data" );
if( o == null )
{
o = new CompoundNBT();
}
return o.copy();
}
@@ -8,7 +8,6 @@ import net.minecraftforge.api.distmarker.OnlyIn;
import appeng.bootstrap.IItemRendering;
import appeng.bootstrap.ItemRenderingCustomizer;
import appeng.client.render.model.MemoryCardModel;
import appeng.core.AppEng;
@@ -21,7 +20,7 @@ public class ToolMemoryCardRendering extends ItemRenderingCustomizer
@OnlyIn( Dist.CLIENT )
public void customize( IItemRendering rendering )
{
rendering.builtInModel( "models/item/builtin/memory_card", new MemoryCardModel() );
// FIXME rendering.builtInModel( "models/item/builtin/memory_card", new MemoryCardModel() );
rendering.model( new ModelResourceLocation( MODEL, "inventory" ) ).variants( MODEL );
}
}
@@ -20,16 +20,15 @@ package appeng.items.tools;
import net.minecraft.block.Block;
import net.minecraft.block.BlockState;
import net.minecraft.entity.player.PlayerEntity;
import net.minecraft.item.Item;
import net.minecraft.item.ItemStack;
import net.minecraft.item.ItemUseContext;
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.*;
import net.minecraft.util.math.BlockPos;
import net.minecraft.util.math.BlockRayTraceResult;
import net.minecraft.util.math.RayTraceResult;
import net.minecraft.util.math.Vec3d;
import net.minecraft.world.IBlockReader;
@@ -48,7 +47,7 @@ import appeng.api.util.DimensionalCoord;
import appeng.api.util.INetworkToolAgent;
import appeng.container.AEBaseContainer;
import appeng.core.AppEng;
import appeng.core.sync.GuiBridge;
import appeng.core.sync.network.NetworkHandler;
import appeng.core.sync.packets.PacketClick;
import appeng.items.AEBaseItem;
@@ -90,12 +89,12 @@ public class ToolNetworkTool extends AEBaseItem implements IGuiItem, IAEWrench
@Override
public ActionResultType onItemUseFirst( ItemStack stack, ItemUseContext context )
{
final RayTraceResult mop = new RayTraceResult( new Vec3d( hitX, hitY, hitZ ), side, pos );
final BlockRayTraceResult mop = new BlockRayTraceResult( context.getHitVec(), context.getFace(), context.getPos(), context.isInside() );
final TileEntity te = context.getWorld().getTileEntity( context.getPos() );
if( te instanceof IPartHost )
{
final SelectedPart part = ( (IPartHost) te ).selectPart( mop.hitVec );
final SelectedPart part = ( (IPartHost) te ).selectPart( mop.getHitVec() );
if( part.part != null || part.facade != null )
{
@@ -116,7 +115,7 @@ public class ToolNetworkTool extends AEBaseItem implements IGuiItem, IAEWrench
if( Platform.isClient() )
{
NetworkHandler.instance().sendToServer( new PacketClick( pos, side, hitX, hitY, hitZ, hand ) );
NetworkHandler.instance().sendToServer( new PacketClick( context.getPos(), context.getFace(), context.getPos().getX(), context.getPos().getY(), context.getPos().getZ(), context.getHand() ) );
}
return ActionResultType.SUCCESS;
@@ -137,15 +136,15 @@ public class ToolNetworkTool extends AEBaseItem implements IGuiItem, IAEWrench
return false;
}
final Block b = w.getBlockState( pos ).getBlock();
final BlockState bs = w.getBlockState( pos );
if( !p.isCrouching() )
{
final TileEntity te = w.getTileEntity( pos );
if( !( te instanceof IGridHost ) )
{
if( b.rotateBlock( w, pos, side ) )
if( bs.rotate( w, pos, Rotation.CLOCKWISE_90 ) != bs )
{
b.neighborChanged( Platform.AIR_BLOCK.getDefaultState(), w, pos, Platform.AIR_BLOCK, null, false );
bs.neighborChanged( w, pos, Platform.AIR_BLOCK, pos, false );
p.swingArm( hand );
return !w.isRemote;
}
@@ -163,23 +162,24 @@ public class ToolNetworkTool extends AEBaseItem implements IGuiItem, IAEWrench
if( te instanceof IGridHost )
{
Platform.openGUI( p, te, AEPartLocation.fromFacing( side ), GuiBridge.GUI_NETWORK_STATUS );
// FIXME Platform.openGUI( p, te, AEPartLocation.fromFacing( side ), GuiBridge.GUI_NETWORK_STATUS );
}
else
{
Platform.openGUI( p, null, AEPartLocation.INTERNAL, GuiBridge.GUI_NETWORK_TOOL );
// FIXME Platform.openGUI( p, null, AEPartLocation.INTERNAL, GuiBridge.GUI_NETWORK_TOOL );
}
return true;
}
else
{
b.onBlockActivated( w, pos, w.getBlockState( pos ), p, hand, side, hitX, hitY, hitZ );
BlockRayTraceResult rtr = new BlockRayTraceResult(new Vec3d(hitX, hitY, hitZ), side, pos, false);
bs.onBlockActivated( w, p, hand, rtr );
}
}
else
{
Platform.openGUI( p, null, AEPartLocation.INTERNAL, GuiBridge.GUI_NETWORK_TOOL );
// FIXME Platform.openGUI( p, null, AEPartLocation.INTERNAL, GuiBridge.GUI_NETWORK_TOOL );
}
return false;
@@ -19,41 +19,6 @@
package appeng.items.tools.powered;
import java.util.Collections;
import java.util.HashMap;
import java.util.LinkedList;
import java.util.List;
import java.util.Map;
import java.util.Set;
import net.minecraft.item.SnowballItem;
import net.minecraft.util.ActionResultType;
import net.minecraft.util.text.ITextComponent;
import org.apache.commons.lang3.text.WordUtils;
import net.minecraft.block.Block;
import net.minecraft.block.BlockColored;
import net.minecraft.block.BlockStainedGlass;
import net.minecraft.block.BlockStainedGlassPane;
import net.minecraft.block.BlockState;
import net.minecraft.client.util.ITooltipFlag;
import net.minecraft.entity.player.PlayerEntity;
import net.minecraft.block.Blocks;
import net.minecraft.item.EnumDyeColor;
import net.minecraft.item.ItemSnowball;
import net.minecraft.item.ItemStack;
import net.minecraft.nbt.CompoundNBT;
import net.minecraft.tileentity.TileEntity;
import net.minecraft.util.EnumActionResult;
import net.minecraft.util.Direction;
import net.minecraft.util.Hand;
import net.minecraft.util.math.BlockPos;
import net.minecraft.world.World;
import net.minecraftforge.api.distmarker.Dist;
import net.minecraftforge.api.distmarker.OnlyIn;
import net.minecraftforge.items.IItemHandler;
import net.minecraftforge.oredict.OreDictionary;
import appeng.api.config.Actionable;
import appeng.api.config.FuzzyMode;
import appeng.api.implementations.items.IItemGroup;
@@ -82,6 +47,27 @@ import appeng.me.helpers.BaseActionSource;
import appeng.tile.misc.TilePaint;
import appeng.util.Platform;
import appeng.util.item.AEItemStack;
import net.minecraft.block.Block;
import net.minecraft.block.BlockState;
import net.minecraft.client.util.ITooltipFlag;
import net.minecraft.entity.player.PlayerEntity;
import net.minecraft.item.ItemStack;
import net.minecraft.item.SnowballItem;
import net.minecraft.nbt.CompoundNBT;
import net.minecraft.tileentity.TileEntity;
import net.minecraft.util.ActionResultType;
import net.minecraft.util.Direction;
import net.minecraft.util.Hand;
import net.minecraft.util.math.BlockPos;
import net.minecraft.util.text.ITextComponent;
import net.minecraft.util.text.TranslationTextComponent;
import net.minecraft.world.World;
import net.minecraftforge.api.distmarker.Dist;
import net.minecraftforge.api.distmarker.OnlyIn;
import net.minecraftforge.items.IItemHandler;
import org.apache.commons.lang3.text.WordUtils;
import java.util.*;
public class ToolColorApplicator extends AEBasePoweredItem implements IStorageCell<IAEItemStack>, IItemGroup, IBlockTool, IMouseWheelItem
@@ -95,9 +81,9 @@ public class ToolColorApplicator extends AEBasePoweredItem implements IStorageCe
{
final String dyeName = color.dye.getTranslationKey();
final String oreDictName = "dye" + WordUtils.capitalize( dyeName );
final int oreDictId = OreDictionary.getOreID( oreDictName );
// FIXME final int oreDictId = OreDictionary.getOreID( oreDictName );
ORE_TO_COLOR.put( oreDictId, color );
// FIXME ORE_TO_COLOR.put( oreDictId, color );
}
}
@@ -197,18 +183,18 @@ public class ToolColorApplicator extends AEBasePoweredItem implements IStorageCe
}
@Override
public String getItemStackDisplayName( final ItemStack par1ItemStack )
public ITextComponent getDisplayName( final ItemStack is )
{
String extra = GuiText.Empty.getLocal();
ITextComponent extra = GuiText.Empty.textComponent();
final AEColor selected = this.getActiveColor( par1ItemStack );
final AEColor selected = this.getActiveColor( is );
if( selected != null && Platform.isClient() )
{
extra = Platform.gui_localize( selected.translationKey);
extra = new TranslationTextComponent(selected.translationKey);
}
return super.getItemStackDisplayName( par1ItemStack ) + " - " + extra;
return super.getDisplayName( is ).appendText(" - ").appendSibling( extra );
}
public AEColor getActiveColor( final ItemStack tol )
@@ -235,15 +221,15 @@ public class ToolColorApplicator extends AEBasePoweredItem implements IStorageCe
}
else
{
final int[] id = OreDictionary.getOreIDs( paintBall );
for( final int oreID : id )
{
if( ORE_TO_COLOR.containsKey( oreID ) )
{
return ORE_TO_COLOR.get( oreID );
}
}
// FIXME final int[] id = OreDictionary.getOreIDs( paintBall );
// FIXME
// FIXME for( final int oreID : id )
// FIXME {
// FIXME if( ORE_TO_COLOR.containsKey( oreID ) )
// FIXME {
// FIXME return ORE_TO_COLOR.get( oreID );
// FIXME }
// FIXME }
}
return null;
@@ -353,63 +339,63 @@ public class ToolColorApplicator extends AEBasePoweredItem implements IStorageCe
{
final BlockState state = w.getBlockState( pos );
if( blk instanceof BlockColored )
{
final EnumDyeColor color = state.getValue( BlockColored.COLOR );
// FIXME if( blk instanceof BlockColored )
// FIXME {
// FIXME final DyeColor color = state.get( BlockColored.COLOR );
// FIXME
// FIXME if( newColor.dye == color )
// FIXME {
// FIXME return false;
// FIXME }
// FIXME
// FIXME return w.setBlockState( pos, state.with( BlockColored.COLOR, newColor.dye ) );
// FIXME }
if( newColor.dye == color )
{
return false;
}
// if( blk == Blocks.GLASS )
// {
// return w.setBlockState( pos, Blocks.STAINED_GLASS.getDefaultState().with( BlockStainedGlass.COLOR, newColor.dye ) );
// }
//
// if( blk == Blocks.STAINED_GLASS )
// {
// final DyeColor color = state.get( BlockStainedGlass.COLOR );
//
// if( newColor.dye == color )
// {
// return false;
// }
//
// return w.setBlockState( pos, state.with( BlockStainedGlass.COLOR, newColor.dye ) );
// }
return w.setBlockState( pos, state.with( BlockColored.COLOR, newColor.dye ) );
}
if( blk == Blocks.GLASS )
{
return w.setBlockState( pos, Blocks.STAINED_GLASS.getDefaultState().with( BlockStainedGlass.COLOR, newColor.dye ) );
}
if( blk == Blocks.STAINED_GLASS )
{
final EnumDyeColor color = state.getValue( BlockStainedGlass.COLOR );
if( newColor.dye == color )
{
return false;
}
return w.setBlockState( pos, state.with( BlockStainedGlass.COLOR, newColor.dye ) );
}
if( blk == Blocks.GLASS_PANE )
{
return w.setBlockState( pos, Blocks.STAINED_GLASS_PANE.getDefaultState().with( BlockStainedGlassPane.COLOR, newColor.dye ) );
}
if( blk == Blocks.STAINED_GLASS_PANE )
{
final EnumDyeColor color = state.getValue( BlockStainedGlassPane.COLOR );
if( newColor.dye == color )
{
return false;
}
return w.setBlockState( pos, state.with( BlockStainedGlassPane.COLOR, newColor.dye ) );
}
if( blk == Blocks.HARDENED_CLAY )
{
return w.setBlockState( pos, Blocks.STAINED_HARDENED_CLAY.getDefaultState().with( BlockColored.COLOR, newColor.dye ) );
}
// if( blk == Blocks.GLASS_PANE )
// {
// return w.setBlockState( pos, Blocks.STAINED_GLASS_PANE.getDefaultState().with( BlockStainedGlassPane.COLOR, newColor.dye ) );
// }
//
// if( blk == Blocks.STAINED_GLASS_PANE )
// {
// final DyeColor color = state.get( BlockStainedGlassPane.COLOR );
//
// if( newColor.dye == color )
// {
// return false;
// }
//
// return w.setBlockState( pos, state.with( BlockStainedGlassPane.COLOR, newColor.dye ) );
// }
//
// if( blk == Blocks.HARDENED_CLAY )
// {
// return w.setBlockState( pos, Blocks.STAINED_HARDENED_CLAY.getDefaultState().with( BlockColored.COLOR, newColor.dye ) );
// }
if( blk instanceof BlockCableBus )
{
return ( (BlockCableBus) blk ).recolorBlock( w, pos, side, newColor.dye, p );
}
return blk.recolorBlock( w, pos, side, newColor.dye );
return blk.recolorBlock( state, w, pos, side, newColor.dye );
}
public void cycleColors( final ItemStack is, final ItemStack paintBall, final int i )
@@ -460,25 +446,25 @@ public class ToolColorApplicator extends AEBasePoweredItem implements IStorageCe
@Override
public boolean isBlackListed( final ItemStack cellItem, final IAEItemStack requestedAddition )
{
if( requestedAddition != null )
{
final int[] id = OreDictionary.getOreIDs( requestedAddition.getDefinition() );
for( final int x : id )
{
if( ORE_TO_COLOR.containsKey( x ) )
{
return false;
}
}
if( requestedAddition.getItem() instanceof SnowballItem )
{
return false;
}
return !( requestedAddition.getItem() instanceof ItemPaintBall && requestedAddition.getItemDamage() < 20 );
}
// FIXME if( requestedAddition != null )
// FIXME {
// FIXME final int[] id = OreDictionary.getOreIDs( requestedAddition.getDefinition() );
// FIXME
// FIXME for( final int x : id )
// FIXME {
// FIXME if( ORE_TO_COLOR.containsKey( x ) )
// FIXME {
// FIXME return false;
// FIXME }
// FIXME }
// FIXME
// FIXME if( requestedAddition.getItem() instanceof SnowballItem )
// FIXME {
// FIXME return false;
// FIXME }
// FIXME
// FIXME return !( requestedAddition.getItem() instanceof ItemPaintBall && requestedAddition.getItemDamage() < 20 );
// FIXME }
return true;
}
@@ -509,7 +495,7 @@ public class ToolColorApplicator extends AEBasePoweredItem implements IStorageCe
@Override
public String getUnlocalizedGroupName( final Set<ItemStack> others, final ItemStack is )
{
return GuiText.StorageCells.getUnlocalized();
return GuiText.StorageCells.getTranslationKey();
}
@Override
@@ -10,7 +10,6 @@ import net.minecraftforge.api.distmarker.OnlyIn;
import appeng.api.util.AEColor;
import appeng.bootstrap.IItemRendering;
import appeng.bootstrap.ItemRenderingCustomizer;
import appeng.client.render.model.ColorApplicatorModel;
import appeng.core.AppEng;
@@ -24,10 +23,10 @@ public class ToolColorApplicatorRendering extends ItemRenderingCustomizer
@OnlyIn( Dist.CLIENT )
public void customize( IItemRendering rendering )
{
rendering.builtInModel( "models/item/builtin/color_applicator_colored", new ColorApplicatorModel() );
// FIXME rendering.builtInModel( "models/item/builtin/color_applicator_colored", new ColorApplicatorModel() );
rendering.variants( MODEL_COLORED, MODEL_UNCOLORED );
rendering.color( this::getColor );
rendering.meshDefinition( this::getMesh );
// FIXME rendering.meshDefinition( this::getMesh );
}
private ModelResourceLocation getMesh( ItemStack itemStack )
@@ -26,14 +26,13 @@ import java.util.Map;
import net.minecraft.block.Block;
import net.minecraft.block.BlockState;
import net.minecraft.block.BlockTNT;
import net.minecraft.block.Blocks;
import net.minecraft.block.TNTBlock;
import net.minecraft.block.material.Material;
import net.minecraft.entity.LivingEntity;
import net.minecraft.entity.player.PlayerEntity;
import net.minecraft.item.BlockItem;
import net.minecraft.item.ItemStack;
import net.minecraft.item.crafting.FurnaceRecipes;
import net.minecraft.item.Items;
import net.minecraft.util.ActionResult;
import net.minecraft.util.ActionResultType;
import net.minecraft.util.Direction;
@@ -41,6 +40,8 @@ import net.minecraft.util.Hand;
import net.minecraft.util.SoundCategory;
import net.minecraft.util.SoundEvents;
import net.minecraft.util.math.BlockPos;
import net.minecraft.util.math.BlockRayTraceResult;
import net.minecraft.util.math.RayTraceContext;
import net.minecraft.util.math.RayTraceResult;
import net.minecraft.world.World;
@@ -68,23 +69,23 @@ public class ToolEntropyManipulator extends AEBasePoweredItem implements IBlockT
this.coolDown.put( new InWorldToolOperationIngredient( Blocks.STONE.getDefaultState() ),
new InWorldToolOperationResult( Blocks.COBBLESTONE.getDefaultState() ) );
this.coolDown.put( new InWorldToolOperationIngredient( Blocks.STONEBRICK.getDefaultState() ),
new InWorldToolOperationResult( Blocks.STONEBRICK.getStateFromMeta( 2 ) ) );
// FIXME this.coolDown.put( new InWorldToolOperationIngredient( Blocks.STONE_BRICKS.getDefaultState() ),
// FIXME new InWorldToolOperationResult( Blocks.STONE_BRICKS.getStateFromMeta( 2 ) ) );
this.coolDown.put( new InWorldToolOperationIngredient( Blocks.LAVA, true ), new InWorldToolOperationResult( Blocks.OBSIDIAN.getDefaultState() ) );
this.coolDown.put( new InWorldToolOperationIngredient( Blocks.FLOWING_LAVA, true ),
new InWorldToolOperationResult( Blocks.OBSIDIAN.getDefaultState() ) );
// FIXME this.coolDown.put( new InWorldToolOperationIngredient( Blocks.FLOWING_LAVA, true ),
// FIXME new InWorldToolOperationResult( Blocks.OBSIDIAN.getDefaultState() ) );
this.coolDown.put( new InWorldToolOperationIngredient( Blocks.GRASS, true ), new InWorldToolOperationResult( Blocks.DIRT.getDefaultState() ) );
final List<ItemStack> snowBalls = new ArrayList<>();
snowBalls.add( new ItemStack( Items.SNOWBALL ) );
this.coolDown.put( new InWorldToolOperationIngredient( Blocks.FLOWING_WATER, true ), new InWorldToolOperationResult( null, snowBalls ) );
// FIXME this.coolDown.put( new InWorldToolOperationIngredient( Blocks.FLOWING_WATER, true ), new InWorldToolOperationResult( null, snowBalls ) );
this.coolDown.put( new InWorldToolOperationIngredient( Blocks.WATER, true ), new InWorldToolOperationResult( Blocks.ICE.getDefaultState() ) );
this.heatUp.put( new InWorldToolOperationIngredient( Blocks.ICE.getDefaultState() ), new InWorldToolOperationResult( Blocks.WATER.getDefaultState() ) );
this.heatUp.put( new InWorldToolOperationIngredient( Blocks.FLOWING_WATER, true ), new InWorldToolOperationResult() );
// FIXME this.heatUp.put( new InWorldToolOperationIngredient( Blocks.FLOWING_WATER, true ), new InWorldToolOperationResult() );
this.heatUp.put( new InWorldToolOperationIngredient( Blocks.WATER, true ), new InWorldToolOperationResult() );
this.heatUp.put( new InWorldToolOperationIngredient( Blocks.SNOW, true ),
new InWorldToolOperationResult( Blocks.FLOWING_WATER.getStateFromMeta( 7 ) ) );
// FIXME this.heatUp.put( new InWorldToolOperationIngredient( Blocks.SNOW, true ),
// FIXME new InWorldToolOperationResult( Blocks.FLOWING_WATER.getStateFromMeta( 7 ) ) );
}
private static class InWorldToolOperationIngredient
@@ -213,28 +214,26 @@ public class ToolEntropyManipulator extends AEBasePoweredItem implements IBlockT
@Override
public ActionResult<ItemStack> onItemRightClick( final World w, final PlayerEntity p, final Hand hand )
{
final RayTraceResult target = this.rayTrace( w, p, true );
final RayTraceResult target = this.rayTrace( w, p, RayTraceContext.FluidMode.ANY );
if( target == null )
if( target.getType() != RayTraceResult.Type.BLOCK )
{
return new ActionResult<>( ActionResultType.FAIL, p.getHeldItem( hand ) );
}
else
{
if( target.getType() == RayTraceResult.Type.BLOCK )
BlockPos pos = ((BlockRayTraceResult) target).getPos();
final BlockState state = w.getBlockState( pos );
if( state.getMaterial() == Material.LAVA || state.getMaterial() == Material.WATER )
{
final BlockState state = w.getBlockState( target.getBlockPos() );
if( state.getMaterial() == Material.LAVA || state.getMaterial() == Material.WATER )
if( Platform.hasPermissions( new DimensionalCoord( w, pos ), p ) )
{
if( Platform.hasPermissions( new DimensionalCoord( w, target.getBlockPos() ), p ) )
{
this.onItemUse( p, w, target.getBlockPos(), hand, Direction.UP, 0.0F, 0.0F, 0.0F );
}
this.onItemUse( p, w, pos, hand, Direction.UP, 0.0F, 0.0F, 0.0F );
}
}
}
return new ActionResult<>( EnumActionResult.SUCCESS, p.getHeldItem( hand ) );
return new ActionResult<>( ActionResultType.SUCCESS, p.getHeldItem( hand ) );
}
@Override
@@ -244,13 +243,13 @@ public class ToolEntropyManipulator extends AEBasePoweredItem implements IBlockT
}
@Override
public ActionResult onItemUse( ItemStack item, PlayerEntity p, World w, BlockPos pos, Hand hand, Direction side, float hitX, float hitY, float hitZ )
public ActionResultType onItemUse( ItemStack item, PlayerEntity p, World w, BlockPos pos, Hand hand, Direction side, float hitX, float hitY, float hitZ )
{
if( this.getAECurrentPower( item ) > 1600 )
{
if( !p.canPlayerEdit( pos, side, item ) )
{
return EnumActionResult.FAIL;
return ActionResultType.FAIL;
}
final BlockState state = w.getBlockState( pos );
@@ -262,30 +261,30 @@ public class ToolEntropyManipulator extends AEBasePoweredItem implements IBlockT
{
this.extractAEPower( item, 1600, Actionable.MODULATE );
this.cool( state, w, pos );
return EnumActionResult.SUCCESS;
return ActionResultType.SUCCESS;
}
}
else
{
if( blockID instanceof BlockTNT )
if( blockID instanceof TNTBlock)
{
w.removeBlock(pos, false);
( (BlockTNT) blockID ).explode( w, pos, state, p );
return EnumActionResult.SUCCESS;
( (TNTBlock) blockID ).explode( w, pos );
return ActionResultType.SUCCESS;
}
if( blockID instanceof BlockTinyTNT )
{
w.removeBlock(pos, false);
( (BlockTinyTNT) blockID ).startFuse( w, pos, p );
return EnumActionResult.SUCCESS;
return ActionResultType.SUCCESS;
}
if( this.canHeat( state ) )
{
this.extractAEPower( item, 1600, Actionable.MODULATE );
this.heat( state, w, pos );
return EnumActionResult.SUCCESS;
return ActionResultType.SUCCESS;
}
final ItemStack[] stack = Platform.getBlockDrops( w, pos );
@@ -295,26 +294,26 @@ public class ToolEntropyManipulator extends AEBasePoweredItem implements IBlockT
for( final ItemStack i : stack )
{
final ItemStack result = FurnaceRecipes.instance().getSmeltingResult( i );
if( !result.isEmpty() )
{
if( result.getItem() instanceof BlockItem )
{
if( Block.getBlockFromItem( result.getItem() ) == blockID && result.getItem().getDamage( result ) == blockID
.getMetaFromState( state ) )
{
canFurnaceable = false;
}
}
hasFurnaceable = true;
out.add( result );
}
else
{
canFurnaceable = false;
out.add( i );
}
// FIXME final ItemStack result = FurnaceRecipes.instance().getSmeltingResult( i );
// FIXME
// FIXME if( !result.isEmpty() )
// FIXME {
// FIXME if( result.getItem() instanceof BlockItem )
// FIXME {
// FIXME if( Block.getBlockFromItem( result.getItem() ) == blockID && result.getItem().getDamage( result ) == blockID
// FIXME .getMetaFromState( state ) )
// FIXME {
// FIXME canFurnaceable = false;
// FIXME }
// FIXME }
// FIXME hasFurnaceable = true;
// FIXME out.add( result );
// FIXME }
// FIXME else
// FIXME {
// FIXME canFurnaceable = false;
// FIXME out.add( i );
// FIXME }
}
if( hasFurnaceable && canFurnaceable )
@@ -322,7 +321,7 @@ public class ToolEntropyManipulator extends AEBasePoweredItem implements IBlockT
this.extractAEPower( item, 1600, Actionable.MODULATE );
final InWorldToolOperationResult or = InWorldToolOperationResult.getBlockOperationResult( out.toArray( new ItemStack[out.size()] ) );
w.playSound( p, pos.getX() + 0.5D, pos.getY() + 0.5D, pos.getZ() + 0.5D, SoundEvents.ITEM_FLINTANDSTEEL_USE, SoundCategory.PLAYERS, 1.0F,
itemRand.nextFloat() * 0.4F + 0.8F );
random.nextFloat() * 0.4F + 0.8F );
if( or.getBlockState() == null )
{
@@ -338,7 +337,7 @@ public class ToolEntropyManipulator extends AEBasePoweredItem implements IBlockT
Platform.spawnDrops( w, pos, or.getDrops() );
}
return EnumActionResult.SUCCESS;
return ActionResultType.SUCCESS;
}
else
{
@@ -346,22 +345,22 @@ public class ToolEntropyManipulator extends AEBasePoweredItem implements IBlockT
if( !p.canPlayerEdit( offsetPos, side, item ) )
{
return EnumActionResult.FAIL;
return ActionResultType.FAIL;
}
if( w.isAirBlock( offsetPos ) )
{
this.extractAEPower( item, 1600, Actionable.MODULATE );
w.playSound( p, offsetPos.getX() + 0.5D, offsetPos.getY() + 0.5D, offsetPos.getZ() + 0.5D, SoundEvents.ITEM_FLINTANDSTEEL_USE,
SoundCategory.PLAYERS, 1.0F, itemRand.nextFloat() * 0.4F + 0.8F );
SoundCategory.PLAYERS, 1.0F, random.nextFloat() * 0.4F + 0.8F );
w.setBlockState( offsetPos, Blocks.FIRE.getDefaultState() );
}
return EnumActionResult.SUCCESS;
return ActionResultType.SUCCESS;
}
}
}
return EnumActionResult.PASS;
return ActionResultType.PASS;
}
}
@@ -22,25 +22,17 @@ package appeng.items.tools.powered;
import java.util.List;
import javax.annotation.Nullable;
import net.minecraft.block.Block;
import net.minecraft.block.BlockState;
import net.minecraft.client.util.ITooltipFlag;
import net.minecraft.entity.Entity;
import net.minecraft.entity.LivingEntity;
import net.minecraft.entity.item.ItemEntity;
import net.minecraft.entity.passive.EntitySheep;
import net.minecraft.entity.passive.SheepEntity;
import net.minecraft.entity.player.PlayerEntity;
import net.minecraft.item.ItemStack;
import net.minecraft.tileentity.TileEntity;
import net.minecraft.util.ActionResult;
import net.minecraft.util.ActionResultType;
import net.minecraft.util.DamageSource;
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.RayTraceResult;
import net.minecraft.util.math.Vec3d;
import net.minecraft.util.*;
import net.minecraft.util.math.*;
import net.minecraft.util.text.ITextComponent;
import net.minecraft.world.World;
import net.minecraftforge.api.distmarker.Dist;
@@ -186,6 +178,7 @@ public class ToolMatterCannon extends AEBasePoweredItem implements IStorageCell<
final AxisAlignedBB bb = new AxisAlignedBB( Math.min( Vec3d.x, Vec3d1.x ), Math.min( Vec3d.y, Vec3d1.y ), Math.min( Vec3d.z, Vec3d1.z ), Math.max( Vec3d.x, Vec3d1.x ), Math.max( Vec3d.y, Vec3d1.y ), Math.max( Vec3d.z, Vec3d1.z ) ).grow( 16, 16, 16 );
Entity entity = null;
Vec3d entityIntersection = null;
final List list = w.getEntitiesWithinAABBExcludingEntity( p, bb );
double closest = 9999999.0D;
@@ -205,16 +198,17 @@ public class ToolMatterCannon extends AEBasePoweredItem implements IStorageCell<
final float f1 = 0.3F;
final AxisAlignedBB boundingBox = entity1.getEntityBoundingBox().grow( f1, f1, f1 );
final RayTraceResult RayTraceResult = boundingBox.calculateIntercept( Vec3d, Vec3d1 );
final AxisAlignedBB boundingBox = entity1.getBoundingBox().grow( f1, f1, f1 );
final Vec3d intersection = boundingBox.rayTrace( Vec3d, Vec3d1 ).orElse(null);
if( RayTraceResult != null )
if( intersection != null )
{
final double nd = Vec3d.squareDistanceTo( RayTraceResult.hitVec );
final double nd = Vec3d.squareDistanceTo( intersection );
if( nd < closest )
{
entity = entity1;
entityIntersection = intersection;
closest = nd;
}
}
@@ -222,61 +216,66 @@ public class ToolMatterCannon extends AEBasePoweredItem implements IStorageCell<
}
}
RayTraceResult pos = w.rayTraceBlocks( Vec3d, Vec3d1, false );
RayTraceContext rayTraceContext = new RayTraceContext(Vec3d, Vec3d1, RayTraceContext.BlockMode.COLLIDER, RayTraceContext.FluidMode.NONE, p);
RayTraceResult pos = w.rayTraceBlocks( rayTraceContext );
final Vec3d vec = new Vec3d( d0, d1, d2 );
if( entity != null && pos != null && pos.hitVec.squareDistanceTo( vec ) > closest )
if( entity != null && pos.getType() != RayTraceResult.Type.MISS && pos.getHitVec().squareDistanceTo( vec ) > closest )
{
pos = new RayTraceResult( entity );
pos = new EntityRayTraceResult( entity, entityIntersection );
}
else if( entity != null && pos == null )
else if( entity != null && pos.getType() == RayTraceResult.Type.MISS )
{
pos = new RayTraceResult( entity );
pos = new EntityRayTraceResult( entity, entityIntersection );
}
try
{
AppEng.proxy.sendToAllNearExcept( null, d0, d1, d2, 128, w, new PacketMatterCannon( d0, d1, d2, (float) direction.x, (float) direction.y, (float) direction.z, (byte) ( pos == null ? 32 : pos.hitVec.squareDistanceTo( vec ) + 1 ) ) );
AppEng.proxy.sendToAllNearExcept( null, d0, d1, d2, 128, w, new PacketMatterCannon( d0, d1, d2, (float) direction.x, (float) direction.y, (float) direction.z, (byte) ( pos.getType() == RayTraceResult.Type.MISS ? 32 : pos.getHitVec().squareDistanceTo( vec ) + 1 ) ) );
}
catch( final Exception err )
{
AELog.debug( err );
}
if( pos != null && type != null && type.getItem() instanceof ItemPaintBall )
if( pos.getType() != RayTraceResult.Type.MISS && type != null && type.getItem() instanceof ItemPaintBall )
{
final ItemPaintBall ipb = (ItemPaintBall) type.getItem();
final AEColor col = ipb.getColor( type );
// boolean lit = ipb.isLumen( type );
if( pos.getType() == RayTraceResult.Type.ENTITY )
if( pos instanceof EntityRayTraceResult )
{
final int id = pos.entityHit.getEntityId();
EntityRayTraceResult entityResult = (EntityRayTraceResult) pos;
Entity entityHit = entityResult.getEntity();
final int id = entityHit.getEntityId();
final PlayerColor marker = new PlayerColor( id, col, 20 * 30 );
TickHandler.INSTANCE.getPlayerColors().put( id, marker );
if( pos.entityHit instanceof EntitySheep )
if( entityHit instanceof SheepEntity)
{
final EntitySheep sh = (EntitySheep) pos.entityHit;
final SheepEntity sh = (SheepEntity) entityHit;
sh.setFleeceColor( col.dye );
}
pos.entityHit.attackEntityFrom( DamageSource.causePlayerDamage( p ), 0 );
entityHit.attackEntityFrom( DamageSource.causePlayerDamage( p ), 0 );
NetworkHandler.instance().sendToAll( marker.getPacket() );
}
else if( pos.typeOfHit == RayTraceResult.Type.BLOCK )
else if( pos instanceof BlockRayTraceResult )
{
final Direction side = pos.sideHit;
final BlockPos hitPos = pos.getBlockPos().offset( side );
BlockRayTraceResult blockResult = (BlockRayTraceResult) pos;
final Direction side = blockResult.getFace();
final BlockPos hitPos = blockResult.getPos().offset( side );
if( !Platform.hasPermissions( new DimensionalCoord( w, hitPos ), p ) )
{
return;
}
final Block whatsThere = w.getBlockState( hitPos ).getBlock();
if( whatsThere.isReplaceable( w, hitPos ) && w.isAirBlock( hitPos ) )
final BlockState whatsThere = w.getBlockState( hitPos );
if( whatsThere.getMaterial().isReplaceable() && w.isAirBlock( hitPos ) )
{
Api.INSTANCE.definitions().blocks().paint().maybeBlock().ifPresent( paintBlock -> {
w.setBlockState( hitPos, paintBlock.getDefaultState(), 3 );
@@ -286,7 +285,7 @@ public class ToolMatterCannon extends AEBasePoweredItem implements IStorageCell<
final TileEntity te = w.getTileEntity( hitPos );
if( te instanceof TilePaint )
{
final Vec3d hp = pos.hitVec.subtract( hitPos.getX(), hitPos.getY(), hitPos.getZ() );
final Vec3d hp = pos.getHitVec().subtract( hitPos.getX(), hitPos.getY(), hitPos.getZ() );
( (TilePaint) te ).addBlot( type, side.getOpposite(), hp );
}
}
@@ -303,6 +302,7 @@ public class ToolMatterCannon extends AEBasePoweredItem implements IStorageCell<
final AxisAlignedBB bb = new AxisAlignedBB( Math.min( Vec3d.x, Vec3d1.x ), Math.min( Vec3d.y, Vec3d1.y ), Math.min( Vec3d.z, Vec3d1.z ), Math.max( Vec3d.x, Vec3d1.x ), Math.max( Vec3d.y, Vec3d1.y ), Math.max( Vec3d.z, Vec3d1.z ) ).grow( 16, 16, 16 );
Entity entity = null;
Vec3d entityIntersection = null;
final List list = w.getEntitiesWithinAABBExcludingEntity( p, bb );
double closest = 9999999.0D;
@@ -310,7 +310,7 @@ public class ToolMatterCannon extends AEBasePoweredItem implements IStorageCell<
{
final Entity entity1 = (Entity) list.get( l );
if( !entity1.isDead && entity1 != p && !( entity1 instanceof EntityItem ) )
if( entity1.isAlive() && entity1 != p && !( entity1 instanceof ItemEntity ) )
{
if( entity1.isAlive() )
{
@@ -322,16 +322,17 @@ public class ToolMatterCannon extends AEBasePoweredItem implements IStorageCell<
final float f1 = 0.3F;
final AxisAlignedBB boundingBox = entity1.getEntityBoundingBox().grow( f1, f1, f1 );
final RayTraceResult RayTraceResult = boundingBox.calculateIntercept( Vec3d, Vec3d1 );
final AxisAlignedBB boundingBox = entity1.getBoundingBox().grow( f1, f1, f1 );
final Vec3d intersection = boundingBox.rayTrace( Vec3d, Vec3d1 ).orElse(null);
if( RayTraceResult != null )
if( intersection != null )
{
final double nd = Vec3d.squareDistanceTo( RayTraceResult.hitVec );
final double nd = Vec3d.squareDistanceTo( intersection );
if( nd < closest )
{
entity = entity1;
entityIntersection = intersection;
closest = nd;
}
}
@@ -339,37 +340,40 @@ public class ToolMatterCannon extends AEBasePoweredItem implements IStorageCell<
}
}
RayTraceContext rayTraceContext = new RayTraceContext(Vec3d, Vec3d1, RayTraceContext.BlockMode.COLLIDER, RayTraceContext.FluidMode.NONE, p);
final Vec3d vec = new Vec3d( d0, d1, d2 );
RayTraceResult pos = w.rayTraceBlocks( Vec3d, Vec3d1, true );
if( entity != null && pos != null && pos.hitVec.squareDistanceTo( vec ) > closest )
RayTraceResult pos = w.rayTraceBlocks( rayTraceContext );
if( entity != null && pos.getType() != RayTraceResult.Type.MISS && pos.getHitVec().squareDistanceTo( vec ) > closest )
{
pos = new RayTraceResult( entity );
pos = new EntityRayTraceResult( entity, entityIntersection );
}
else if( entity != null && pos == null )
else if( entity != null && pos.getType() == RayTraceResult.Type.MISS )
{
pos = new RayTraceResult( entity );
pos = new EntityRayTraceResult( entity, entityIntersection );
}
try
{
AppEng.proxy.sendToAllNearExcept( null, d0, d1, d2, 128, w, new PacketMatterCannon( d0, d1, d2, (float) direction.x, (float) direction.y, (float) direction.z, (byte) ( pos == null ? 32 : pos.hitVec.squareDistanceTo( vec ) + 1 ) ) );
AppEng.proxy.sendToAllNearExcept( null, d0, d1, d2, 128, w, new PacketMatterCannon( d0, d1, d2, (float) direction.x, (float) direction.y, (float) direction.z, (byte) ( pos.getType() == RayTraceResult.Type.MISS ? 32 : pos.getHitVec().squareDistanceTo( vec ) + 1 ) ) );
}
catch( final Exception err )
{
AELog.debug( err );
}
if( pos != null )
if( pos.getType() != RayTraceResult.Type.MISS )
{
final DamageSource dmgSrc = DamageSource.causePlayerDamage( p );
dmgSrc.damageType = "matter_cannon";
final DamageSource dmgSrc = new EntityDamageSource( "matter_cannon", p );
if( pos.typeOfHit == RayTraceResult.Type.ENTITY )
if( pos instanceof EntityRayTraceResult )
{
EntityRayTraceResult entityResult = (EntityRayTraceResult) pos;
Entity entityHit = entityResult.getEntity();
final int dmg = (int) Math.ceil( penetration / 20.0f );
if( pos.entityHit instanceof LivingEntity )
if( entityHit instanceof LivingEntity )
{
final LivingEntity el = (LivingEntity) pos.entityHit;
final LivingEntity el = (LivingEntity) entityHit;
penetration -= dmg;
el.knockBack( p, 0, -direction.x, -direction.z );
// el.knockBack( p, 0, Vec3d.x,
@@ -380,37 +384,38 @@ public class ToolMatterCannon extends AEBasePoweredItem implements IStorageCell<
hasDestroyed = true;
}
}
else if( pos.entityHit instanceof EntityItem )
else if( entityHit instanceof ItemEntity )
{
hasDestroyed = true;
pos.entityHit.setDead();
entityHit.remove();
}
else if( pos.entityHit.attackEntityFrom( dmgSrc, dmg ) )
else if( entityHit.attackEntityFrom( dmgSrc, dmg ) )
{
hasDestroyed = true;
}
}
else if( pos.typeOfHit == RayTraceResult.Type.BLOCK )
else if( pos instanceof BlockRayTraceResult )
{
BlockRayTraceResult blockResult = (BlockRayTraceResult) pos;
if( !AEConfig.instance().isFeatureEnabled( AEFeature.MASS_CANNON_BLOCK_DAMAGE ) )
{
penetration = 0;
}
else
{
final BlockState bs = w.getBlockState( pos.getBlockPos() );
// int meta = w.getBlockMetadata(
// pos.blockX, pos.blockY, pos.blockZ );
BlockPos blockPos = blockResult.getPos();
final BlockState bs = w.getBlockState(blockPos);
final float hardness = bs.getBlockHardness( w, pos.getBlockPos() ) * 9.0f;
final float hardness = bs.getBlockHardness( w, blockPos) * 9.0f;
if( hardness >= 0.0 )
{
if( penetration > hardness && Platform.hasPermissions( new DimensionalCoord( w, pos.getBlockPos() ), p ) )
if( penetration > hardness && Platform.hasPermissions( new DimensionalCoord( w, blockPos), p ) )
{
hasDestroyed = true;
penetration -= hardness;
penetration *= 0.60;
w.destroyBlock( pos.getBlockPos(), true );
w.destroyBlock(blockPos, true );
}
}
}
@@ -27,7 +27,7 @@ import net.minecraft.entity.player.PlayerEntity;
import net.minecraft.item.ItemStack;
import net.minecraft.util.ActionResult;
import net.minecraft.util.ActionResultType;
import net.minecraft.util.EnumActionResult;
import net.minecraft.util.ActionResultType;
import net.minecraft.util.Hand;
import net.minecraft.util.math.BlockPos;
import net.minecraft.util.text.ITextComponent;
@@ -50,7 +50,7 @@ import appeng.api.util.AEPartLocation;
import appeng.core.AEConfig;
import appeng.core.Api;
import appeng.core.localization.GuiText;
import appeng.core.sync.GuiBridge;
import appeng.items.contents.CellConfig;
import appeng.items.contents.CellUpgrades;
import appeng.items.contents.PortableCellViewer;
@@ -68,17 +68,10 @@ public class ToolPortableCell extends AEBasePoweredItem implements IStorageCell<
@Override
public ActionResult<ItemStack> onItemRightClick( final World w, final PlayerEntity player, final Hand hand )
{
Platform.openGUI( player, null, AEPartLocation.INTERNAL, GuiBridge.GUI_PORTABLE_CELL );
// FIXME Platform.openGUI( player, null, AEPartLocation.INTERNAL, GuiBridge.GUI_PORTABLE_CELL );
return new ActionResult<>( ActionResultType.SUCCESS, player.getHeldItem( hand ) );
}
@OnlyIn( Dist.CLIENT )
@Override
public boolean isFull3D()
{
return false;
}
@Override
@OnlyIn( Dist.CLIENT )
public void addInformation(final ItemStack stack, final World world, final List<ITextComponent> lines, final ITooltipFlag advancedTooltips )
@@ -145,7 +138,7 @@ public class ToolPortableCell extends AEBasePoweredItem implements IStorageCell<
@Override
public String getUnlocalizedGroupName( final Set<ItemStack> others, final ItemStack is )
{
return GuiText.StorageCells.getUnlocalized();
return GuiText.StorageCells.getTranslationKey();
}
@Override
@@ -30,6 +30,7 @@ import net.minecraft.util.ActionResult;
import net.minecraft.util.ActionResultType;
import net.minecraft.util.Hand;
import net.minecraft.util.text.ITextComponent;
import net.minecraft.util.text.TranslationTextComponent;
import net.minecraft.world.World;
import net.minecraftforge.api.distmarker.Dist;
import net.minecraftforge.api.distmarker.OnlyIn;
@@ -63,13 +64,6 @@ public class ToolWirelessTerminal extends AEBasePoweredItem implements IWireless
return new ActionResult<>( ActionResultType.SUCCESS, player.getHeldItem( hand ) );
}
@OnlyIn( Dist.CLIENT )
@Override
public boolean isFull3D()
{
return false;
}
@Override
@OnlyIn( Dist.CLIENT )
public void addInformation( final ItemStack stack, final World world, final List<ITextComponent> lines, final ITooltipFlag advancedTooltips )
@@ -85,17 +79,17 @@ public class ToolWirelessTerminal extends AEBasePoweredItem implements IWireless
if( encKey == null || encKey.isEmpty() )
{
lines.add( GuiText.Unlinked.getLocal() );
lines.add( GuiText.Unlinked.textComponent() );
}
else
{
lines.add( GuiText.Linked.getLocal() );
lines.add( GuiText.Linked.textComponent() );
}
}
}
else
{
lines.add( I18n.format( "AppEng.GuiITooltip.Unlinked" ) );
lines.add( new TranslationTextComponent( "AppEng.GuiITooltip.Unlinked" ) );
}
}
@@ -23,11 +23,12 @@ import java.text.MessageFormat;
import java.util.List;
import net.minecraft.client.util.ITooltipFlag;
import net.minecraft.creativetab.CreativeTabs;
import net.minecraft.item.ItemGroup;
import net.minecraft.item.ItemStack;
import net.minecraft.nbt.CompoundNBT;
import net.minecraft.util.NonNullList;
import net.minecraft.util.text.ITextComponent;
import net.minecraft.util.text.TranslationTextComponent;
import net.minecraft.world.World;
import net.minecraftforge.common.capabilities.ICapabilityProvider;
import net.minecraftforge.api.distmarker.Dist;
@@ -50,7 +51,7 @@ public abstract class AEBasePoweredItem extends AEBaseItem implements IAEItemPow
public AEBasePoweredItem( final double powerCapacity )
{
super(new Properties().maxStackSize( 1 ).maxDamage( 32 ));
super(new Properties().maxStackSize( 1 ).maxDamage( 32 ).setNoRepair());
//FIXME
// this.hasSubtypes = false;
// this.setFull3D();
@@ -73,8 +74,9 @@ public abstract class AEBasePoweredItem extends AEBaseItem implements IAEItemPow
final double percent = internalCurrentPower / internalMaxPower;
lines.add( GuiText.StoredEnergy.getLocal() + ':' + MessageFormat.format( " {0,number,#} ", internalCurrentPower ) + Platform
.gui_localize( PowerUnits.AE.unlocalizedName ) + " - " + MessageFormat.format( " {0,number,#.##%} ", percent ) );
lines.add( GuiText.StoredEnergy.textComponent().appendText( + ':' + MessageFormat.format( " {0,number,#} ", internalCurrentPower ) )
.appendSibling( new TranslationTextComponent( PowerUnits.AE.unlocalizedName ) )
.appendText( " - " + MessageFormat.format( " {0,number,#.##%} ", percent ) ) );
}
@Override
@@ -84,22 +86,15 @@ public abstract class AEBasePoweredItem extends AEBaseItem implements IAEItemPow
}
@Override
protected void getCheckedSubItems( final CreativeTabs creativeTab, final NonNullList<ItemStack> itemStacks )
{
super.getCheckedSubItems( creativeTab, itemStacks );
public void fillItemGroup(ItemGroup group, NonNullList<ItemStack> items) {
super.fillItemGroup(group, items);
final ItemStack charged = new ItemStack( this, 1 );
final CompoundNBT tag = charged.getOrCreateTag();
tag.putDouble(CURRENT_POWER_NBT_KEY, this.getAEMaxPower( charged ));
tag.putDouble(MAX_POWER_NBT_KEY, this.getAEMaxPower( charged ));
itemStacks.add( charged );
}
@Override
public boolean isRepairable()
{
return false;
items.add( charged );
}
@Override
@@ -21,12 +21,11 @@ package appeng.items.tools.powered.powersink;
import javax.annotation.Nullable;
import net.darkhax.tesla.api.ITeslaConsumer;
import net.darkhax.tesla.api.ITeslaHolder;
import net.minecraft.item.ItemStack;
import net.minecraft.util.Direction;
import net.minecraftforge.common.capabilities.Capability;
import net.minecraftforge.common.capabilities.ICapabilityProvider;
import net.minecraftforge.common.util.LazyOptional;
import net.minecraftforge.energy.IEnergyStorage;
import appeng.api.config.Actionable;
@@ -45,41 +44,21 @@ class PoweredItemCapabilities implements ICapabilityProvider, IEnergyStorage
private final IAEItemPowerStorage item;
private final Object teslaAdapter;
PoweredItemCapabilities( ItemStack is, IAEItemPowerStorage item )
{
this.is = is;
this.item = item;
if( Capabilities.TESLA_CONSUMER != null || Capabilities.TESLA_HOLDER != null )
{
this.teslaAdapter = new TeslaAdapter();
}
else
{
this.teslaAdapter = null;
}
}
@Override
public boolean hasCapability( Capability<?> capability, @Nullable Direction facing )
{
return capability == Capabilities.FORGE_ENERGY || capability == Capabilities.TESLA_CONSUMER || capability == Capabilities.TESLA_HOLDER;
}
@SuppressWarnings( "unchecked" )
@Override
public <T> T getCapability( Capability<T> capability, @Nullable Direction facing )
public <T> LazyOptional<T> getCapability(Capability<T> capability, @Nullable Direction facing )
{
if( capability == Capabilities.FORGE_ENERGY )
{
return (T) this;
return (LazyOptional<T>) LazyOptional.of(() -> this);
}
else if( capability == Capabilities.TESLA_CONSUMER || capability == Capabilities.TESLA_HOLDER )
{
return (T) this.teslaAdapter;
}
return null;
return LazyOptional.empty();
}
@Override
@@ -121,25 +100,4 @@ class PoweredItemCapabilities implements ICapabilityProvider, IEnergyStorage
return true;
}
private class TeslaAdapter implements ITeslaConsumer, ITeslaHolder
{
@Override
public long givePower( long power, boolean simulated )
{
return PoweredItemCapabilities.this.receiveEnergy( (int) power, simulated );
}
@Override
public long getStoredPower()
{
return PoweredItemCapabilities.this.getEnergyStored();
}
@Override
public long getCapacity()
{
return PoweredItemCapabilities.this.getMaxEnergyStored();
}
}
}