More compile things
This commit is contained in:
@@ -25,18 +25,15 @@ import net.minecraft.client.resources.I18n;
|
||||
import net.minecraft.client.util.ITooltipFlag;
|
||||
import net.minecraft.entity.player.PlayerEntity;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.item.ItemUseContext;
|
||||
import net.minecraft.nbt.CompoundNBT;
|
||||
import net.minecraft.util.ActionResult;
|
||||
import net.minecraft.util.EnumActionResult;
|
||||
import net.minecraft.util.Direction;
|
||||
import net.minecraft.util.ActionResultType;
|
||||
import net.minecraft.util.Hand;
|
||||
import net.minecraft.util.math.BlockPos;
|
||||
import net.minecraft.util.text.ITextComponent;
|
||||
import net.minecraft.util.text.TextComponent;
|
||||
import net.minecraft.util.text.TextComponentUtils;
|
||||
import net.minecraft.util.text.TextFormatting;
|
||||
import net.minecraft.util.text.translation.I18n;
|
||||
import net.minecraft.world.IBlockReader;
|
||||
import net.minecraft.world.IWorldReader;
|
||||
import net.minecraft.world.World;
|
||||
import net.minecraftforge.api.distmarker.Dist;
|
||||
import net.minecraftforge.api.distmarker.OnlyIn;
|
||||
@@ -54,18 +51,24 @@ public class ToolMemoryCard extends AEBaseItem implements IMemoryCard
|
||||
{
|
||||
|
||||
private static final AEColor[] DEFAULT_COLOR_CODE = new AEColor[] {
|
||||
AEColor.TRANSPARENT, AEColor.TRANSPARENT, AEColor.TRANSPARENT, AEColor.TRANSPARENT,
|
||||
AEColor.TRANSPARENT, AEColor.TRANSPARENT, AEColor.TRANSPARENT, AEColor.TRANSPARENT,
|
||||
};
|
||||
AEColor.TRANSPARENT,
|
||||
AEColor.TRANSPARENT,
|
||||
AEColor.TRANSPARENT,
|
||||
AEColor.TRANSPARENT,
|
||||
AEColor.TRANSPARENT,
|
||||
AEColor.TRANSPARENT,
|
||||
AEColor.TRANSPARENT,
|
||||
AEColor.TRANSPARENT,
|
||||
};
|
||||
|
||||
public ToolMemoryCard()
|
||||
{
|
||||
this.setMaxStackSize( 1 );
|
||||
super( new Properties().maxStackSize( 1 ) );
|
||||
}
|
||||
|
||||
@Override
|
||||
@OnlyIn( Dist.CLIENT )
|
||||
public void addInformation(final ItemStack stack, final World world, final List<ITextComponent> lines, final ITooltipFlag advancedTooltips )
|
||||
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 ) ) );
|
||||
|
||||
@@ -113,15 +116,15 @@ public class ToolMemoryCard extends AEBaseItem implements IMemoryCard
|
||||
@Override
|
||||
public void setMemoryCardContents( final ItemStack is, final String settingsName, final CompoundNBT data )
|
||||
{
|
||||
final CompoundNBT c = Platform.openNbtData( is );
|
||||
c.setString( "Config", settingsName );
|
||||
c.setTag( "Data", data );
|
||||
final CompoundNBT c = is.getOrCreateTag();
|
||||
c.putString( "Config", settingsName );
|
||||
c.put( "Data", data );
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getSettingsName( final ItemStack is )
|
||||
{
|
||||
final CompoundNBT c = Platform.openNbtData( is );
|
||||
final CompoundNBT c = is.getOrCreateTag();
|
||||
final String name = c.getString( "Config" );
|
||||
return name == null || name.isEmpty() ? GuiText.Blank.getUnlocalized() : name;
|
||||
}
|
||||
@@ -129,8 +132,8 @@ public class ToolMemoryCard extends AEBaseItem implements IMemoryCard
|
||||
@Override
|
||||
public CompoundNBT getData( final ItemStack is )
|
||||
{
|
||||
final CompoundNBT c = Platform.openNbtData( is );
|
||||
CompoundNBT o = c.getCompoundTag( "Data" );
|
||||
final CompoundNBT c = is.getOrCreateTag();
|
||||
CompoundNBT o = c.getCompound( "Data" );
|
||||
if( o == null )
|
||||
{
|
||||
o = new CompoundNBT();
|
||||
@@ -143,15 +146,21 @@ public class ToolMemoryCard extends AEBaseItem implements IMemoryCard
|
||||
{
|
||||
final CompoundNBT tag = this.getData( is );
|
||||
|
||||
if( tag.hasKey( "colorCode" ) )
|
||||
if( tag.contains( "colorCode" ) )
|
||||
{
|
||||
final int[] frequency = tag.getIntArray( "colorCode" );
|
||||
final AEColor[] colorArray = AEColor.values();
|
||||
|
||||
return new AEColor[] {
|
||||
colorArray[frequency[0]], colorArray[frequency[1]], colorArray[frequency[2]], colorArray[frequency[3]],
|
||||
colorArray[frequency[4]], colorArray[frequency[5]], colorArray[frequency[6]], colorArray[frequency[7]],
|
||||
};
|
||||
colorArray[frequency[0]],
|
||||
colorArray[frequency[1]],
|
||||
colorArray[frequency[2]],
|
||||
colorArray[frequency[3]],
|
||||
colorArray[frequency[4]],
|
||||
colorArray[frequency[5]],
|
||||
colorArray[frequency[6]],
|
||||
colorArray[frequency[7]],
|
||||
};
|
||||
}
|
||||
|
||||
return DEFAULT_COLOR_CODE;
|
||||
@@ -187,19 +196,19 @@ public class ToolMemoryCard extends AEBaseItem implements IMemoryCard
|
||||
}
|
||||
|
||||
@Override
|
||||
public EnumActionResult onItemUse( final PlayerEntity player, final World w, final BlockPos pos, final Hand hand, final Direction side, final float hx, final float hy, final float hz )
|
||||
public ActionResultType onItemUse( ItemUseContext context )
|
||||
{
|
||||
if( player.isShiftKeyDown() )
|
||||
if( context.getPlayer().isShiftKeyDown() )
|
||||
{
|
||||
if( !w.isRemote )
|
||||
if( !context.getPlayer().world.isRemote )
|
||||
{
|
||||
this.clearCard( player, w, hand );
|
||||
this.clearCard( context.getPlayer(), context.getWorld(), context.getHand() );
|
||||
}
|
||||
return EnumActionResult.SUCCESS;
|
||||
return ActionResultType.SUCCESS;
|
||||
}
|
||||
else
|
||||
{
|
||||
return super.onItemUse( player, w, pos, hand, side, hx, hy, hz );
|
||||
return super.onItemUse( context );
|
||||
}
|
||||
}
|
||||
|
||||
@@ -215,11 +224,10 @@ public class ToolMemoryCard extends AEBaseItem implements IMemoryCard
|
||||
}
|
||||
|
||||
return super.onItemRightClick( w, player, hand );
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean doesSneakBypassUse( final ItemStack itemstack, final IBlockReader world, final BlockPos pos, final PlayerEntity player )
|
||||
public boolean doesSneakBypassUse( ItemStack stack, IWorldReader world, BlockPos pos, PlayerEntity player )
|
||||
{
|
||||
return true;
|
||||
}
|
||||
@@ -228,6 +236,6 @@ public class ToolMemoryCard extends AEBaseItem implements IMemoryCard
|
||||
{
|
||||
final IMemoryCard mem = (IMemoryCard) player.getHeldItem( hand ).getItem();
|
||||
mem.notifyUser( player, MemoryCardMessages.SETTINGS_CLEARED );
|
||||
player.getHeldItem( hand ).setTagCompound( null );
|
||||
player.getHeldItem( hand ).setTag( null );
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user