reformatted all src files (#141)
This commit is contained in:
@@ -19,11 +19,14 @@
|
||||
package appeng.items.tools;
|
||||
|
||||
|
||||
import java.util.EnumSet;
|
||||
import java.util.List;
|
||||
|
||||
import appeng.api.config.SecurityPermissions;
|
||||
import appeng.api.features.IPlayerRegistry;
|
||||
import appeng.api.implementations.items.IBiometricCard;
|
||||
import appeng.api.networking.security.ISecurityRegistry;
|
||||
import appeng.core.localization.GuiText;
|
||||
import appeng.items.AEBaseItem;
|
||||
import appeng.util.Platform;
|
||||
import com.mojang.authlib.GameProfile;
|
||||
|
||||
import net.minecraft.client.util.ITooltipFlag;
|
||||
import net.minecraft.entity.EntityLivingBase;
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
@@ -37,172 +40,133 @@ import net.minecraft.world.World;
|
||||
import net.minecraftforge.fml.relauncher.Side;
|
||||
import net.minecraftforge.fml.relauncher.SideOnly;
|
||||
|
||||
import appeng.api.config.SecurityPermissions;
|
||||
import appeng.api.features.IPlayerRegistry;
|
||||
import appeng.api.implementations.items.IBiometricCard;
|
||||
import appeng.api.networking.security.ISecurityRegistry;
|
||||
import appeng.core.localization.GuiText;
|
||||
import appeng.items.AEBaseItem;
|
||||
import appeng.util.Platform;
|
||||
import java.util.EnumSet;
|
||||
import java.util.List;
|
||||
|
||||
|
||||
public class ToolBiometricCard extends AEBaseItem implements IBiometricCard
|
||||
{
|
||||
public ToolBiometricCard()
|
||||
{
|
||||
this.setMaxStackSize( 1 );
|
||||
}
|
||||
public class ToolBiometricCard extends AEBaseItem implements IBiometricCard {
|
||||
public ToolBiometricCard() {
|
||||
this.setMaxStackSize(1);
|
||||
}
|
||||
|
||||
@Override
|
||||
public ActionResult<ItemStack> onItemRightClick( final World w, final EntityPlayer p, final EnumHand hand )
|
||||
{
|
||||
if( p.isSneaking() )
|
||||
{
|
||||
this.encode( p.getHeldItem( hand ), p );
|
||||
p.swingArm( hand );
|
||||
return new ActionResult<>( EnumActionResult.SUCCESS, p.getHeldItem( hand ) );
|
||||
}
|
||||
@Override
|
||||
public ActionResult<ItemStack> onItemRightClick(final World w, final EntityPlayer p, final EnumHand hand) {
|
||||
if (p.isSneaking()) {
|
||||
this.encode(p.getHeldItem(hand), p);
|
||||
p.swingArm(hand);
|
||||
return new ActionResult<>(EnumActionResult.SUCCESS, p.getHeldItem(hand));
|
||||
}
|
||||
|
||||
return new ActionResult<>( EnumActionResult.PASS, p.getHeldItem( hand ) );
|
||||
}
|
||||
return new ActionResult<>(EnumActionResult.PASS, p.getHeldItem(hand));
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean itemInteractionForEntity( ItemStack is, final EntityPlayer player, final EntityLivingBase target, final EnumHand hand )
|
||||
{
|
||||
if( target instanceof EntityPlayer && !player.isSneaking() )
|
||||
{
|
||||
if( player.capabilities.isCreativeMode )
|
||||
{
|
||||
is = player.getHeldItem( hand );
|
||||
}
|
||||
this.encode( is, (EntityPlayer) target );
|
||||
player.swingArm( hand );
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
@Override
|
||||
public boolean itemInteractionForEntity(ItemStack is, final EntityPlayer player, final EntityLivingBase target, final EnumHand hand) {
|
||||
if (target instanceof EntityPlayer && !player.isSneaking()) {
|
||||
if (player.capabilities.isCreativeMode) {
|
||||
is = player.getHeldItem(hand);
|
||||
}
|
||||
this.encode(is, (EntityPlayer) target);
|
||||
player.swingArm(hand);
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getItemStackDisplayName( final ItemStack is )
|
||||
{
|
||||
final GameProfile username = this.getProfile( is );
|
||||
return username != null ? super.getItemStackDisplayName( is ) + " - " + username.getName() : super.getItemStackDisplayName( is );
|
||||
}
|
||||
@Override
|
||||
public String getItemStackDisplayName(final ItemStack is) {
|
||||
final GameProfile username = this.getProfile(is);
|
||||
return username != null ? super.getItemStackDisplayName(is) + " - " + username.getName() : super.getItemStackDisplayName(is);
|
||||
}
|
||||
|
||||
private void encode( final ItemStack is, final EntityPlayer p )
|
||||
{
|
||||
final GameProfile username = this.getProfile( is );
|
||||
private void encode(final ItemStack is, final EntityPlayer p) {
|
||||
final GameProfile username = this.getProfile(is);
|
||||
|
||||
if( username != null && username.equals( p.getGameProfile() ) )
|
||||
{
|
||||
this.setProfile( is, null );
|
||||
}
|
||||
else
|
||||
{
|
||||
this.setProfile( is, p.getGameProfile() );
|
||||
}
|
||||
}
|
||||
if (username != null && username.equals(p.getGameProfile())) {
|
||||
this.setProfile(is, null);
|
||||
} else {
|
||||
this.setProfile(is, p.getGameProfile());
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setProfile( final ItemStack itemStack, final GameProfile profile )
|
||||
{
|
||||
final NBTTagCompound tag = Platform.openNbtData( itemStack );
|
||||
@Override
|
||||
public void setProfile(final ItemStack itemStack, final GameProfile profile) {
|
||||
final NBTTagCompound tag = Platform.openNbtData(itemStack);
|
||||
|
||||
if( profile != null )
|
||||
{
|
||||
final NBTTagCompound pNBT = new NBTTagCompound();
|
||||
NBTUtil.writeGameProfile( pNBT, profile );
|
||||
tag.setTag( "profile", pNBT );
|
||||
}
|
||||
else
|
||||
{
|
||||
tag.removeTag( "profile" );
|
||||
}
|
||||
}
|
||||
if (profile != null) {
|
||||
final NBTTagCompound pNBT = new NBTTagCompound();
|
||||
NBTUtil.writeGameProfile(pNBT, profile);
|
||||
tag.setTag("profile", pNBT);
|
||||
} else {
|
||||
tag.removeTag("profile");
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public GameProfile getProfile( final ItemStack is )
|
||||
{
|
||||
final NBTTagCompound tag = Platform.openNbtData( is );
|
||||
if( tag.hasKey( "profile" ) )
|
||||
{
|
||||
return NBTUtil.readGameProfileFromNBT( tag.getCompoundTag( "profile" ) );
|
||||
}
|
||||
return null;
|
||||
}
|
||||
@Override
|
||||
public GameProfile getProfile(final ItemStack is) {
|
||||
final NBTTagCompound tag = Platform.openNbtData(is);
|
||||
if (tag.hasKey("profile")) {
|
||||
return NBTUtil.readGameProfileFromNBT(tag.getCompoundTag("profile"));
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public EnumSet<SecurityPermissions> getPermissions( final ItemStack is )
|
||||
{
|
||||
final NBTTagCompound tag = Platform.openNbtData( is );
|
||||
final EnumSet<SecurityPermissions> result = EnumSet.noneOf( SecurityPermissions.class );
|
||||
@Override
|
||||
public EnumSet<SecurityPermissions> getPermissions(final ItemStack is) {
|
||||
final NBTTagCompound tag = Platform.openNbtData(is);
|
||||
final EnumSet<SecurityPermissions> result = EnumSet.noneOf(SecurityPermissions.class);
|
||||
|
||||
for( final SecurityPermissions sp : SecurityPermissions.values() )
|
||||
{
|
||||
if( tag.getBoolean( sp.name() ) )
|
||||
{
|
||||
result.add( sp );
|
||||
}
|
||||
}
|
||||
for (final SecurityPermissions sp : SecurityPermissions.values()) {
|
||||
if (tag.getBoolean(sp.name())) {
|
||||
result.add(sp);
|
||||
}
|
||||
}
|
||||
|
||||
return result;
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean hasPermission( final ItemStack is, final SecurityPermissions permission )
|
||||
{
|
||||
final NBTTagCompound tag = Platform.openNbtData( is );
|
||||
return tag.getBoolean( permission.name() );
|
||||
}
|
||||
@Override
|
||||
public boolean hasPermission(final ItemStack is, final SecurityPermissions permission) {
|
||||
final NBTTagCompound tag = Platform.openNbtData(is);
|
||||
return tag.getBoolean(permission.name());
|
||||
}
|
||||
|
||||
@Override
|
||||
public void removePermission( final ItemStack itemStack, final SecurityPermissions permission )
|
||||
{
|
||||
final NBTTagCompound tag = Platform.openNbtData( itemStack );
|
||||
if( tag.hasKey( permission.name() ) )
|
||||
{
|
||||
tag.removeTag( permission.name() );
|
||||
}
|
||||
}
|
||||
@Override
|
||||
public void removePermission(final ItemStack itemStack, final SecurityPermissions permission) {
|
||||
final NBTTagCompound tag = Platform.openNbtData(itemStack);
|
||||
if (tag.hasKey(permission.name())) {
|
||||
tag.removeTag(permission.name());
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void addPermission( final ItemStack itemStack, final SecurityPermissions permission )
|
||||
{
|
||||
final NBTTagCompound tag = Platform.openNbtData( itemStack );
|
||||
tag.setBoolean( permission.name(), true );
|
||||
}
|
||||
@Override
|
||||
public void addPermission(final ItemStack itemStack, final SecurityPermissions permission) {
|
||||
final NBTTagCompound tag = Platform.openNbtData(itemStack);
|
||||
tag.setBoolean(permission.name(), true);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void registerPermissions( final ISecurityRegistry register, final IPlayerRegistry pr, final ItemStack is )
|
||||
{
|
||||
register.addPlayer( pr.getID( this.getProfile( is ) ), this.getPermissions( is ) );
|
||||
}
|
||||
@Override
|
||||
public void registerPermissions(final ISecurityRegistry register, final IPlayerRegistry pr, final ItemStack is) {
|
||||
register.addPlayer(pr.getID(this.getProfile(is)), this.getPermissions(is));
|
||||
}
|
||||
|
||||
@Override
|
||||
@SideOnly( Side.CLIENT )
|
||||
public void addCheckedInformation( final ItemStack stack, final World world, final List<String> lines, final ITooltipFlag advancedTooltips )
|
||||
{
|
||||
final EnumSet<SecurityPermissions> perms = this.getPermissions( stack );
|
||||
if( perms.isEmpty() )
|
||||
{
|
||||
lines.add( GuiText.NoPermissions.getLocal() );
|
||||
}
|
||||
else
|
||||
{
|
||||
String msg = null;
|
||||
@Override
|
||||
@SideOnly(Side.CLIENT)
|
||||
public void addCheckedInformation(final ItemStack stack, final World world, final List<String> lines, final ITooltipFlag advancedTooltips) {
|
||||
final EnumSet<SecurityPermissions> perms = this.getPermissions(stack);
|
||||
if (perms.isEmpty()) {
|
||||
lines.add(GuiText.NoPermissions.getLocal());
|
||||
} else {
|
||||
String msg = null;
|
||||
|
||||
for( final SecurityPermissions sp : perms )
|
||||
{
|
||||
if( msg == null )
|
||||
{
|
||||
msg = Platform.gui_localize( sp.getUnlocalizedName() );
|
||||
}
|
||||
else
|
||||
{
|
||||
msg = msg + ", " + Platform.gui_localize( sp.getUnlocalizedName() );
|
||||
}
|
||||
}
|
||||
lines.add( msg );
|
||||
}
|
||||
}
|
||||
for (final SecurityPermissions sp : perms) {
|
||||
if (msg == null) {
|
||||
msg = Platform.gui_localize(sp.getUnlocalizedName());
|
||||
} else {
|
||||
msg = msg + ", " + Platform.gui_localize(sp.getUnlocalizedName());
|
||||
}
|
||||
}
|
||||
lines.add(msg);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,28 +1,24 @@
|
||||
|
||||
package appeng.items.tools;
|
||||
|
||||
|
||||
import net.minecraft.client.renderer.block.model.ModelResourceLocation;
|
||||
import net.minecraft.util.ResourceLocation;
|
||||
import net.minecraftforge.fml.relauncher.Side;
|
||||
import net.minecraftforge.fml.relauncher.SideOnly;
|
||||
|
||||
import appeng.bootstrap.IItemRendering;
|
||||
import appeng.bootstrap.ItemRenderingCustomizer;
|
||||
import appeng.client.render.model.BiometricCardModel;
|
||||
import appeng.core.AppEng;
|
||||
import net.minecraft.client.renderer.block.model.ModelResourceLocation;
|
||||
import net.minecraft.util.ResourceLocation;
|
||||
import net.minecraftforge.fml.relauncher.Side;
|
||||
import net.minecraftforge.fml.relauncher.SideOnly;
|
||||
|
||||
|
||||
public class ToolBiometricCardRendering extends ItemRenderingCustomizer
|
||||
{
|
||||
public class ToolBiometricCardRendering extends ItemRenderingCustomizer {
|
||||
|
||||
private static final ResourceLocation MODEL = new ResourceLocation( AppEng.MOD_ID, "builtin/biometric_card" );
|
||||
private static final ResourceLocation MODEL = new ResourceLocation(AppEng.MOD_ID, "builtin/biometric_card");
|
||||
|
||||
@Override
|
||||
@SideOnly( Side.CLIENT )
|
||||
public void customize( IItemRendering rendering )
|
||||
{
|
||||
rendering.builtInModel( "models/item/builtin/biometric_card", new BiometricCardModel() );
|
||||
rendering.model( new ModelResourceLocation( MODEL, "inventory" ) ).variants( MODEL );
|
||||
}
|
||||
@Override
|
||||
@SideOnly(Side.CLIENT)
|
||||
public void customize(IItemRendering rendering) {
|
||||
rendering.builtInModel("models/item/builtin/biometric_card", new BiometricCardModel());
|
||||
rendering.model(new ModelResourceLocation(MODEL, "inventory")).variants(MODEL);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -19,8 +19,13 @@
|
||||
package appeng.items.tools;
|
||||
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import appeng.api.implementations.items.IMemoryCard;
|
||||
import appeng.api.implementations.items.MemoryCardMessages;
|
||||
import appeng.api.util.AEColor;
|
||||
import appeng.core.localization.GuiText;
|
||||
import appeng.core.localization.PlayerMessages;
|
||||
import appeng.items.AEBaseItem;
|
||||
import appeng.util.Platform;
|
||||
import net.minecraft.client.util.ITooltipFlag;
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.item.ItemStack;
|
||||
@@ -37,193 +42,158 @@ import net.minecraft.world.World;
|
||||
import net.minecraftforge.fml.relauncher.Side;
|
||||
import net.minecraftforge.fml.relauncher.SideOnly;
|
||||
|
||||
import appeng.api.implementations.items.IMemoryCard;
|
||||
import appeng.api.implementations.items.MemoryCardMessages;
|
||||
import appeng.api.util.AEColor;
|
||||
import appeng.core.localization.GuiText;
|
||||
import appeng.core.localization.PlayerMessages;
|
||||
import appeng.items.AEBaseItem;
|
||||
import appeng.util.Platform;
|
||||
import java.util.List;
|
||||
|
||||
|
||||
public class ToolMemoryCard extends AEBaseItem implements IMemoryCard
|
||||
{
|
||||
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,
|
||||
};
|
||||
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,
|
||||
};
|
||||
|
||||
public ToolMemoryCard()
|
||||
{
|
||||
this.setMaxStackSize( 1 );
|
||||
}
|
||||
public ToolMemoryCard() {
|
||||
this.setMaxStackSize(1);
|
||||
}
|
||||
|
||||
@Override
|
||||
@SideOnly( Side.CLIENT )
|
||||
public void addCheckedInformation( final ItemStack stack, final World world, final List<String> lines, final ITooltipFlag advancedTooltips )
|
||||
{
|
||||
lines.add( this.getLocalizedName( this.getSettingsName( stack ) + ".name", this.getSettingsName( stack ) ) );
|
||||
@Override
|
||||
@SideOnly(Side.CLIENT)
|
||||
public void addCheckedInformation(final ItemStack stack, final World world, final List<String> lines, final ITooltipFlag advancedTooltips) {
|
||||
lines.add(this.getLocalizedName(this.getSettingsName(stack) + ".name", this.getSettingsName(stack)));
|
||||
|
||||
final NBTTagCompound data = this.getData( stack );
|
||||
if( data.hasKey( "tooltip" ) )
|
||||
{
|
||||
lines.add( I18n.translateToLocal( this.getLocalizedName( data.getString( "tooltip" ) + ".name", data.getString( "tooltip" ) ) ) );
|
||||
}
|
||||
final NBTTagCompound data = this.getData(stack);
|
||||
if (data.hasKey("tooltip")) {
|
||||
lines.add(I18n.translateToLocal(this.getLocalizedName(data.getString("tooltip") + ".name", data.getString("tooltip"))));
|
||||
}
|
||||
|
||||
if( data.hasKey( "freq" ) )
|
||||
{
|
||||
final short freq = data.getShort( "freq" );
|
||||
final String freqTooltip = TextFormatting.BOLD + Platform.p2p().toHexString( freq );
|
||||
if (data.hasKey("freq")) {
|
||||
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(I18n.translateToLocalFormatted("gui.tooltips.appliedenergistics2.P2PFrequency", freqTooltip));
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Find the localized string...
|
||||
*
|
||||
* @param name possible names for the localized string
|
||||
*
|
||||
* @return localized name
|
||||
*/
|
||||
private String getLocalizedName( final String... name )
|
||||
{
|
||||
for( final String n : name )
|
||||
{
|
||||
final String l = I18n.translateToLocal( n );
|
||||
if( !l.equals( n ) )
|
||||
{
|
||||
return l;
|
||||
}
|
||||
}
|
||||
/**
|
||||
* Find the localized string...
|
||||
*
|
||||
* @param name possible names for the localized string
|
||||
* @return localized name
|
||||
*/
|
||||
private String getLocalizedName(final String... name) {
|
||||
for (final String n : name) {
|
||||
final String l = I18n.translateToLocal(n);
|
||||
if (!l.equals(n)) {
|
||||
return l;
|
||||
}
|
||||
}
|
||||
|
||||
for( final String n : name )
|
||||
{
|
||||
return n;
|
||||
}
|
||||
for (final String n : name) {
|
||||
return n;
|
||||
}
|
||||
|
||||
return "";
|
||||
}
|
||||
return "";
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setMemoryCardContents( final ItemStack is, final String settingsName, final NBTTagCompound data )
|
||||
{
|
||||
final NBTTagCompound c = Platform.openNbtData( is );
|
||||
c.setString( "Config", settingsName );
|
||||
c.setTag( "Data", data );
|
||||
}
|
||||
@Override
|
||||
public void setMemoryCardContents(final ItemStack is, final String settingsName, final NBTTagCompound data) {
|
||||
final NBTTagCompound c = Platform.openNbtData(is);
|
||||
c.setString("Config", settingsName);
|
||||
c.setTag("Data", data);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getSettingsName( final ItemStack is )
|
||||
{
|
||||
final NBTTagCompound c = Platform.openNbtData( is );
|
||||
final String name = c.getString( "Config" );
|
||||
return name == null || name.isEmpty() ? GuiText.Blank.getUnlocalized() : name;
|
||||
}
|
||||
@Override
|
||||
public String getSettingsName(final ItemStack is) {
|
||||
final NBTTagCompound c = Platform.openNbtData(is);
|
||||
final String name = c.getString("Config");
|
||||
return name == null || name.isEmpty() ? GuiText.Blank.getUnlocalized() : name;
|
||||
}
|
||||
|
||||
@Override
|
||||
public NBTTagCompound getData( final ItemStack is )
|
||||
{
|
||||
final NBTTagCompound c = Platform.openNbtData( is );
|
||||
NBTTagCompound o = c.getCompoundTag( "Data" );
|
||||
if( o == null )
|
||||
{
|
||||
o = new NBTTagCompound();
|
||||
}
|
||||
return o.copy();
|
||||
}
|
||||
@Override
|
||||
public NBTTagCompound getData(final ItemStack is) {
|
||||
final NBTTagCompound c = Platform.openNbtData(is);
|
||||
NBTTagCompound o = c.getCompoundTag("Data");
|
||||
if (o == null) {
|
||||
o = new NBTTagCompound();
|
||||
}
|
||||
return o.copy();
|
||||
}
|
||||
|
||||
@Override
|
||||
public AEColor[] getColorCode( ItemStack is )
|
||||
{
|
||||
final NBTTagCompound tag = this.getData( is );
|
||||
@Override
|
||||
public AEColor[] getColorCode(ItemStack is) {
|
||||
final NBTTagCompound tag = this.getData(is);
|
||||
|
||||
if( tag.hasKey( "colorCode" ) )
|
||||
{
|
||||
final int[] frequency = tag.getIntArray( "colorCode" );
|
||||
final AEColor[] colorArray = AEColor.values();
|
||||
if (tag.hasKey("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]],
|
||||
};
|
||||
}
|
||||
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]],
|
||||
};
|
||||
}
|
||||
|
||||
return DEFAULT_COLOR_CODE;
|
||||
}
|
||||
return DEFAULT_COLOR_CODE;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void notifyUser( final EntityPlayer player, final MemoryCardMessages msg )
|
||||
{
|
||||
if( Platform.isClient() )
|
||||
{
|
||||
return;
|
||||
}
|
||||
@Override
|
||||
public void notifyUser(final EntityPlayer player, final MemoryCardMessages msg) {
|
||||
if (Platform.isClient()) {
|
||||
return;
|
||||
}
|
||||
|
||||
switch( msg )
|
||||
{
|
||||
case SETTINGS_CLEARED:
|
||||
player.sendMessage( PlayerMessages.SettingCleared.get() );
|
||||
break;
|
||||
case INVALID_MACHINE:
|
||||
player.sendMessage( PlayerMessages.InvalidMachine.get() );
|
||||
break;
|
||||
case SETTINGS_LOADED:
|
||||
player.sendMessage( PlayerMessages.LoadedSettings.get() );
|
||||
break;
|
||||
case SETTINGS_SAVED:
|
||||
player.sendMessage( PlayerMessages.SavedSettings.get() );
|
||||
break;
|
||||
case SETTINGS_RESET:
|
||||
player.sendMessage( PlayerMessages.ResetSettings.get() );
|
||||
break;
|
||||
default:
|
||||
}
|
||||
}
|
||||
switch (msg) {
|
||||
case SETTINGS_CLEARED:
|
||||
player.sendMessage(PlayerMessages.SettingCleared.get());
|
||||
break;
|
||||
case INVALID_MACHINE:
|
||||
player.sendMessage(PlayerMessages.InvalidMachine.get());
|
||||
break;
|
||||
case SETTINGS_LOADED:
|
||||
player.sendMessage(PlayerMessages.LoadedSettings.get());
|
||||
break;
|
||||
case SETTINGS_SAVED:
|
||||
player.sendMessage(PlayerMessages.SavedSettings.get());
|
||||
break;
|
||||
case SETTINGS_RESET:
|
||||
player.sendMessage(PlayerMessages.ResetSettings.get());
|
||||
break;
|
||||
default:
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public EnumActionResult onItemUse( final EntityPlayer player, final World w, final BlockPos pos, final EnumHand hand, final EnumFacing side, final float hx, final float hy, final float hz )
|
||||
{
|
||||
if( player.isSneaking() )
|
||||
{
|
||||
if( !w.isRemote )
|
||||
{
|
||||
this.clearCard( player, w, hand );
|
||||
}
|
||||
return EnumActionResult.SUCCESS;
|
||||
}
|
||||
else
|
||||
{
|
||||
return super.onItemUse( player, w, pos, hand, side, hx, hy, hz );
|
||||
}
|
||||
}
|
||||
@Override
|
||||
public EnumActionResult onItemUse(final EntityPlayer player, final World w, final BlockPos pos, final EnumHand hand, final EnumFacing side, final float hx, final float hy, final float hz) {
|
||||
if (player.isSneaking()) {
|
||||
if (!w.isRemote) {
|
||||
this.clearCard(player, w, hand);
|
||||
}
|
||||
return EnumActionResult.SUCCESS;
|
||||
} else {
|
||||
return super.onItemUse(player, w, pos, hand, side, hx, hy, hz);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public ActionResult<ItemStack> onItemRightClick( World w, EntityPlayer player, EnumHand hand )
|
||||
{
|
||||
if( player.isSneaking() )
|
||||
{
|
||||
if( !w.isRemote )
|
||||
{
|
||||
this.clearCard( player, w, hand );
|
||||
}
|
||||
}
|
||||
@Override
|
||||
public ActionResult<ItemStack> onItemRightClick(World w, EntityPlayer player, EnumHand hand) {
|
||||
if (player.isSneaking()) {
|
||||
if (!w.isRemote) {
|
||||
this.clearCard(player, w, hand);
|
||||
}
|
||||
}
|
||||
|
||||
return super.onItemRightClick( w, player, hand );
|
||||
return super.onItemRightClick(w, player, hand);
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean doesSneakBypassUse( final ItemStack itemstack, final IBlockAccess world, final BlockPos pos, final EntityPlayer player )
|
||||
{
|
||||
return true;
|
||||
}
|
||||
@Override
|
||||
public boolean doesSneakBypassUse(final ItemStack itemstack, final IBlockAccess world, final BlockPos pos, final EntityPlayer player) {
|
||||
return true;
|
||||
}
|
||||
|
||||
private void clearCard( final EntityPlayer player, final World w, final EnumHand hand )
|
||||
{
|
||||
final IMemoryCard mem = (IMemoryCard) player.getHeldItem( hand ).getItem();
|
||||
mem.notifyUser( player, MemoryCardMessages.SETTINGS_CLEARED );
|
||||
player.getHeldItem( hand ).setTagCompound( null );
|
||||
}
|
||||
private void clearCard(final EntityPlayer player, final World w, final EnumHand hand) {
|
||||
final IMemoryCard mem = (IMemoryCard) player.getHeldItem(hand).getItem();
|
||||
mem.notifyUser(player, MemoryCardMessages.SETTINGS_CLEARED);
|
||||
player.getHeldItem(hand).setTagCompound(null);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,28 +1,24 @@
|
||||
|
||||
package appeng.items.tools;
|
||||
|
||||
|
||||
import net.minecraft.client.renderer.block.model.ModelResourceLocation;
|
||||
import net.minecraft.util.ResourceLocation;
|
||||
import net.minecraftforge.fml.relauncher.Side;
|
||||
import net.minecraftforge.fml.relauncher.SideOnly;
|
||||
|
||||
import appeng.bootstrap.IItemRendering;
|
||||
import appeng.bootstrap.ItemRenderingCustomizer;
|
||||
import appeng.client.render.model.MemoryCardModel;
|
||||
import appeng.core.AppEng;
|
||||
import net.minecraft.client.renderer.block.model.ModelResourceLocation;
|
||||
import net.minecraft.util.ResourceLocation;
|
||||
import net.minecraftforge.fml.relauncher.Side;
|
||||
import net.minecraftforge.fml.relauncher.SideOnly;
|
||||
|
||||
|
||||
public class ToolMemoryCardRendering extends ItemRenderingCustomizer
|
||||
{
|
||||
public class ToolMemoryCardRendering extends ItemRenderingCustomizer {
|
||||
|
||||
private static final ResourceLocation MODEL = new ResourceLocation( AppEng.MOD_ID, "builtin/memory_card" );
|
||||
private static final ResourceLocation MODEL = new ResourceLocation(AppEng.MOD_ID, "builtin/memory_card");
|
||||
|
||||
@Override
|
||||
@SideOnly( Side.CLIENT )
|
||||
public void customize( IItemRendering rendering )
|
||||
{
|
||||
rendering.builtInModel( "models/item/builtin/memory_card", new MemoryCardModel() );
|
||||
rendering.model( new ModelResourceLocation( MODEL, "inventory" ) ).variants( MODEL );
|
||||
}
|
||||
@Override
|
||||
@SideOnly(Side.CLIENT)
|
||||
public void customize(IItemRendering rendering) {
|
||||
rendering.builtInModel("models/item/builtin/memory_card", new MemoryCardModel());
|
||||
rendering.model(new ModelResourceLocation(MODEL, "inventory")).variants(MODEL);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -19,25 +19,6 @@
|
||||
package appeng.items.tools;
|
||||
|
||||
|
||||
import net.minecraft.block.Block;
|
||||
import net.minecraft.entity.Entity;
|
||||
import net.minecraft.entity.EntityLivingBase;
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.tileentity.TileEntity;
|
||||
import net.minecraft.util.ActionResult;
|
||||
import net.minecraft.util.EnumActionResult;
|
||||
import net.minecraft.util.EnumFacing;
|
||||
import net.minecraft.util.EnumHand;
|
||||
import net.minecraft.util.math.BlockPos;
|
||||
import net.minecraft.util.math.RayTraceResult;
|
||||
import net.minecraft.util.math.Vec3d;
|
||||
import net.minecraft.world.IBlockAccess;
|
||||
import net.minecraft.world.World;
|
||||
import net.minecraftforge.fml.common.Optional.Interface;
|
||||
|
||||
import cofh.api.item.IToolHammer;
|
||||
|
||||
import appeng.api.implementations.guiobjects.IGuiItem;
|
||||
import appeng.api.implementations.guiobjects.IGuiItemObject;
|
||||
import appeng.api.implementations.items.IAEWrench;
|
||||
@@ -55,171 +36,152 @@ import appeng.core.sync.packets.PacketClick;
|
||||
import appeng.items.AEBaseItem;
|
||||
import appeng.items.contents.NetworkToolViewer;
|
||||
import appeng.util.Platform;
|
||||
import cofh.api.item.IToolHammer;
|
||||
import net.minecraft.block.Block;
|
||||
import net.minecraft.entity.Entity;
|
||||
import net.minecraft.entity.EntityLivingBase;
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.tileentity.TileEntity;
|
||||
import net.minecraft.util.ActionResult;
|
||||
import net.minecraft.util.EnumActionResult;
|
||||
import net.minecraft.util.EnumFacing;
|
||||
import net.minecraft.util.EnumHand;
|
||||
import net.minecraft.util.math.BlockPos;
|
||||
import net.minecraft.util.math.RayTraceResult;
|
||||
import net.minecraft.util.math.Vec3d;
|
||||
import net.minecraft.world.IBlockAccess;
|
||||
import net.minecraft.world.World;
|
||||
import net.minecraftforge.fml.common.Optional.Interface;
|
||||
|
||||
|
||||
// TODO BC Integration
|
||||
//@Interface( iface = "buildcraft.api.tools.IToolWrench", iname = IntegrationType.BuildCraftCore )
|
||||
@Interface( iface = "cofh.api.item.IToolHammer", modid = "cofhcore" )
|
||||
public class ToolNetworkTool extends AEBaseItem implements IGuiItem, IAEWrench, IToolHammer /* , IToolWrench */
|
||||
{
|
||||
@Interface(iface = "cofh.api.item.IToolHammer", modid = "cofhcore")
|
||||
public class ToolNetworkTool extends AEBaseItem implements IGuiItem, IAEWrench, IToolHammer /* , IToolWrench */ {
|
||||
|
||||
public ToolNetworkTool()
|
||||
{
|
||||
this.setMaxStackSize( 1 );
|
||||
this.setHarvestLevel( "wrench", 0 );
|
||||
}
|
||||
public ToolNetworkTool() {
|
||||
this.setMaxStackSize(1);
|
||||
this.setHarvestLevel("wrench", 0);
|
||||
}
|
||||
|
||||
@Override
|
||||
public IGuiItemObject getGuiObject( final ItemStack is, final World world, final BlockPos pos )
|
||||
{
|
||||
final TileEntity te = world.getTileEntity( pos );
|
||||
return new NetworkToolViewer( is, (IGridHost) ( te instanceof IGridHost ? te : null ) );
|
||||
}
|
||||
@Override
|
||||
public IGuiItemObject getGuiObject(final ItemStack is, final World world, final BlockPos pos) {
|
||||
final TileEntity te = world.getTileEntity(pos);
|
||||
return new NetworkToolViewer(is, (IGridHost) (te instanceof IGridHost ? te : null));
|
||||
}
|
||||
|
||||
@Override
|
||||
public ActionResult<ItemStack> onItemRightClick( final World w, final EntityPlayer p, final EnumHand hand )
|
||||
{
|
||||
if( Platform.isClient() )
|
||||
{
|
||||
final RayTraceResult mop = AppEng.proxy.getRTR();
|
||||
@Override
|
||||
public ActionResult<ItemStack> onItemRightClick(final World w, final EntityPlayer p, final EnumHand hand) {
|
||||
if (Platform.isClient()) {
|
||||
final RayTraceResult mop = AppEng.proxy.getRTR();
|
||||
|
||||
if( mop == null || mop.typeOfHit == RayTraceResult.Type.MISS )
|
||||
{
|
||||
NetworkHandler.instance().sendToServer( new PacketClick( BlockPos.ORIGIN, null, 0, 0, 0, hand ) );
|
||||
}
|
||||
}
|
||||
if (mop == null || mop.typeOfHit == RayTraceResult.Type.MISS) {
|
||||
NetworkHandler.instance().sendToServer(new PacketClick(BlockPos.ORIGIN, null, 0, 0, 0, hand));
|
||||
}
|
||||
}
|
||||
|
||||
return new ActionResult<>( EnumActionResult.SUCCESS, p.getHeldItem( hand ) );
|
||||
}
|
||||
return new ActionResult<>(EnumActionResult.SUCCESS, p.getHeldItem(hand));
|
||||
}
|
||||
|
||||
@Override
|
||||
public EnumActionResult onItemUseFirst( final EntityPlayer player, final World world, final BlockPos pos, final EnumFacing side, final float hitX, final float hitY, final float hitZ, final EnumHand hand )
|
||||
{
|
||||
final RayTraceResult mop = new RayTraceResult( new Vec3d( hitX, hitY, hitZ ), side, pos );
|
||||
final TileEntity te = world.getTileEntity( pos );
|
||||
@Override
|
||||
public EnumActionResult onItemUseFirst(final EntityPlayer player, final World world, final BlockPos pos, final EnumFacing side, final float hitX, final float hitY, final float hitZ, final EnumHand hand) {
|
||||
final RayTraceResult mop = new RayTraceResult(new Vec3d(hitX, hitY, hitZ), side, pos);
|
||||
final TileEntity te = world.getTileEntity(pos);
|
||||
|
||||
if( te instanceof IPartHost )
|
||||
{
|
||||
final SelectedPart part = ( (IPartHost) te ).selectPart( mop.hitVec );
|
||||
if (te instanceof IPartHost) {
|
||||
final SelectedPart part = ((IPartHost) te).selectPart(mop.hitVec);
|
||||
|
||||
if( part.part != null || part.facade != null )
|
||||
{
|
||||
if( part.part instanceof INetworkToolAgent && !( (INetworkToolAgent) part.part ).showNetworkInfo( mop ) )
|
||||
{
|
||||
return EnumActionResult.FAIL;
|
||||
}
|
||||
else if( player.isSneaking() )
|
||||
{
|
||||
return EnumActionResult.PASS;
|
||||
}
|
||||
}
|
||||
}
|
||||
else if( te instanceof INetworkToolAgent && !( (INetworkToolAgent) te ).showNetworkInfo( mop ) )
|
||||
{
|
||||
return EnumActionResult.FAIL;
|
||||
}
|
||||
if (part.part != null || part.facade != null) {
|
||||
if (part.part instanceof INetworkToolAgent && !((INetworkToolAgent) part.part).showNetworkInfo(mop)) {
|
||||
return EnumActionResult.FAIL;
|
||||
} else if (player.isSneaking()) {
|
||||
return EnumActionResult.PASS;
|
||||
}
|
||||
}
|
||||
} else if (te instanceof INetworkToolAgent && !((INetworkToolAgent) te).showNetworkInfo(mop)) {
|
||||
return EnumActionResult.FAIL;
|
||||
}
|
||||
|
||||
if( Platform.isClient() )
|
||||
{
|
||||
NetworkHandler.instance().sendToServer( new PacketClick( pos, side, hitX, hitY, hitZ, hand ) );
|
||||
}
|
||||
if (Platform.isClient()) {
|
||||
NetworkHandler.instance().sendToServer(new PacketClick(pos, side, hitX, hitY, hitZ, hand));
|
||||
}
|
||||
|
||||
return EnumActionResult.SUCCESS;
|
||||
}
|
||||
return EnumActionResult.SUCCESS;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean doesSneakBypassUse( final ItemStack itemstack, final IBlockAccess world, final BlockPos pos, final EntityPlayer player )
|
||||
{
|
||||
return true;
|
||||
}
|
||||
@Override
|
||||
public boolean doesSneakBypassUse(final ItemStack itemstack, final IBlockAccess world, final BlockPos pos, final EntityPlayer player) {
|
||||
return true;
|
||||
}
|
||||
|
||||
public boolean serverSideToolLogic( final ItemStack is, final EntityPlayer p, final EnumHand hand, final World w, final BlockPos pos, final EnumFacing side, final float hitX, final float hitY, final float hitZ )
|
||||
{
|
||||
if( side != null )
|
||||
{
|
||||
if( !Platform.hasPermissions( new DimensionalCoord( w, pos ), p ) )
|
||||
{
|
||||
return false;
|
||||
}
|
||||
public boolean serverSideToolLogic(final ItemStack is, final EntityPlayer p, final EnumHand hand, final World w, final BlockPos pos, final EnumFacing side, final float hitX, final float hitY, final float hitZ) {
|
||||
if (side != null) {
|
||||
if (!Platform.hasPermissions(new DimensionalCoord(w, pos), p)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
final Block b = w.getBlockState( pos ).getBlock();
|
||||
if( !p.isSneaking() )
|
||||
{
|
||||
final TileEntity te = w.getTileEntity( pos );
|
||||
if( !( te instanceof IGridHost ) )
|
||||
{
|
||||
if( b.rotateBlock( w, pos, side ) )
|
||||
{
|
||||
b.neighborChanged( Platform.AIR_BLOCK.getDefaultState(), w, pos, Platform.AIR_BLOCK, null );
|
||||
p.swingArm( hand );
|
||||
return !w.isRemote;
|
||||
}
|
||||
}
|
||||
}
|
||||
final Block b = w.getBlockState(pos).getBlock();
|
||||
if (!p.isSneaking()) {
|
||||
final TileEntity te = w.getTileEntity(pos);
|
||||
if (!(te instanceof IGridHost)) {
|
||||
if (b.rotateBlock(w, pos, side)) {
|
||||
b.neighborChanged(Platform.AIR_BLOCK.getDefaultState(), w, pos, Platform.AIR_BLOCK, null);
|
||||
p.swingArm(hand);
|
||||
return !w.isRemote;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if( !p.isSneaking() )
|
||||
{
|
||||
if( p.openContainer instanceof AEBaseContainer )
|
||||
{
|
||||
return true;
|
||||
}
|
||||
if (!p.isSneaking()) {
|
||||
if (p.openContainer instanceof AEBaseContainer) {
|
||||
return true;
|
||||
}
|
||||
|
||||
final TileEntity te = w.getTileEntity( pos );
|
||||
final TileEntity te = w.getTileEntity(pos);
|
||||
|
||||
if( te instanceof IGridHost )
|
||||
{
|
||||
Platform.openGUI( p, te, AEPartLocation.fromFacing( side ), GuiBridge.GUI_NETWORK_STATUS );
|
||||
}
|
||||
else
|
||||
{
|
||||
Platform.openGUI( p, null, AEPartLocation.INTERNAL, GuiBridge.GUI_NETWORK_TOOL );
|
||||
}
|
||||
if (te instanceof IGridHost) {
|
||||
Platform.openGUI(p, te, AEPartLocation.fromFacing(side), GuiBridge.GUI_NETWORK_STATUS);
|
||||
} else {
|
||||
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 );
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
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);
|
||||
}
|
||||
} else {
|
||||
Platform.openGUI(p, null, AEPartLocation.INTERNAL, GuiBridge.GUI_NETWORK_TOOL);
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean canWrench( final ItemStack wrench, final EntityPlayer player, final BlockPos pos )
|
||||
{
|
||||
return true;
|
||||
}
|
||||
@Override
|
||||
public boolean canWrench(final ItemStack wrench, final EntityPlayer player, final BlockPos pos) {
|
||||
return true;
|
||||
}
|
||||
|
||||
// IToolHammer - start
|
||||
@Override
|
||||
public boolean isUsable( ItemStack item, EntityLivingBase user, BlockPos pos )
|
||||
{
|
||||
return true;
|
||||
}
|
||||
// IToolHammer - start
|
||||
@Override
|
||||
public boolean isUsable(ItemStack item, EntityLivingBase user, BlockPos pos) {
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isUsable( ItemStack item, EntityLivingBase user, Entity entity )
|
||||
{
|
||||
return true;
|
||||
}
|
||||
@Override
|
||||
public boolean isUsable(ItemStack item, EntityLivingBase user, Entity entity) {
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void toolUsed( ItemStack item, EntityLivingBase user, BlockPos pos )
|
||||
{
|
||||
}
|
||||
@Override
|
||||
public void toolUsed(ItemStack item, EntityLivingBase user, BlockPos pos) {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void toolUsed( ItemStack item, EntityLivingBase user, Entity entity )
|
||||
{
|
||||
}
|
||||
// IToolHammer - end
|
||||
@Override
|
||||
public void toolUsed(ItemStack item, EntityLivingBase user, Entity entity) {
|
||||
}
|
||||
// IToolHammer - end
|
||||
|
||||
// TODO: BC WRENCH INTEGRATION
|
||||
// TODO: BC WRENCH INTEGRATION
|
||||
|
||||
}
|
||||
|
||||
@@ -19,48 +19,41 @@
|
||||
package appeng.items.tools.powered;
|
||||
|
||||
|
||||
import net.minecraft.entity.EntityLivingBase;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.util.DamageSource;
|
||||
import net.minecraft.util.math.AxisAlignedBB;
|
||||
|
||||
import appeng.api.config.Actionable;
|
||||
import appeng.core.AEConfig;
|
||||
import appeng.core.AppEng;
|
||||
import appeng.core.sync.packets.PacketLightning;
|
||||
import appeng.items.tools.powered.powersink.AEBasePoweredItem;
|
||||
import appeng.util.Platform;
|
||||
import net.minecraft.entity.EntityLivingBase;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.util.DamageSource;
|
||||
import net.minecraft.util.math.AxisAlignedBB;
|
||||
|
||||
|
||||
public class ToolChargedStaff extends AEBasePoweredItem
|
||||
{
|
||||
public class ToolChargedStaff extends AEBasePoweredItem {
|
||||
|
||||
public ToolChargedStaff()
|
||||
{
|
||||
super( AEConfig.instance().getChargedStaffBattery() );
|
||||
}
|
||||
public ToolChargedStaff() {
|
||||
super(AEConfig.instance().getChargedStaffBattery());
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean hitEntity( final ItemStack item, final EntityLivingBase target, final EntityLivingBase hitter )
|
||||
{
|
||||
if( this.getAECurrentPower( item ) > 300 )
|
||||
{
|
||||
this.extractAEPower( item, 300, Actionable.MODULATE );
|
||||
if( Platform.isServer() )
|
||||
{
|
||||
for( int x = 0; x < 2; x++ )
|
||||
{
|
||||
final AxisAlignedBB entityBoundingBox = target.getEntityBoundingBox();
|
||||
final float dx = (float) ( Platform.getRandomFloat() * target.width + entityBoundingBox.minX );
|
||||
final float dy = (float) ( Platform.getRandomFloat() * target.height + entityBoundingBox.minY );
|
||||
final float dz = (float) ( Platform.getRandomFloat() * target.width + entityBoundingBox.minZ );
|
||||
AppEng.proxy.sendToAllNearExcept( null, dx, dy, dz, 32.0, target.world, new PacketLightning( dx, dy, dz ) );
|
||||
}
|
||||
}
|
||||
target.attackEntityFrom( DamageSource.MAGIC, 6 );
|
||||
return true;
|
||||
}
|
||||
@Override
|
||||
public boolean hitEntity(final ItemStack item, final EntityLivingBase target, final EntityLivingBase hitter) {
|
||||
if (this.getAECurrentPower(item) > 300) {
|
||||
this.extractAEPower(item, 300, Actionable.MODULATE);
|
||||
if (Platform.isServer()) {
|
||||
for (int x = 0; x < 2; x++) {
|
||||
final AxisAlignedBB entityBoundingBox = target.getEntityBoundingBox();
|
||||
final float dx = (float) (Platform.getRandomFloat() * target.width + entityBoundingBox.minX);
|
||||
final float dy = (float) (Platform.getRandomFloat() * target.height + entityBoundingBox.minY);
|
||||
final float dz = (float) (Platform.getRandomFloat() * target.width + entityBoundingBox.minZ);
|
||||
AppEng.proxy.sendToAllNearExcept(null, dx, dy, dz, 32.0, target.world, new PacketLightning(dx, dy, dz));
|
||||
}
|
||||
}
|
||||
target.attackEntityFrom(DamageSource.MAGIC, 6);
|
||||
return true;
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -19,38 +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 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.state.IBlockState;
|
||||
import net.minecraft.client.util.ITooltipFlag;
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.init.Blocks;
|
||||
import net.minecraft.item.EnumDyeColor;
|
||||
import net.minecraft.item.ItemSnowball;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.nbt.NBTTagCompound;
|
||||
import net.minecraft.tileentity.TileEntity;
|
||||
import net.minecraft.util.EnumActionResult;
|
||||
import net.minecraft.util.EnumFacing;
|
||||
import net.minecraft.util.EnumHand;
|
||||
import net.minecraft.util.math.BlockPos;
|
||||
import net.minecraft.world.World;
|
||||
import net.minecraftforge.fml.relauncher.Side;
|
||||
import net.minecraftforge.fml.relauncher.SideOnly;
|
||||
import net.minecraftforge.items.IItemHandler;
|
||||
import net.minecraftforge.oredict.OreDictionary;
|
||||
|
||||
import appeng.api.AEApi;
|
||||
import appeng.api.config.Actionable;
|
||||
import appeng.api.config.FuzzyMode;
|
||||
@@ -79,477 +47,413 @@ import appeng.me.helpers.BaseActionSource;
|
||||
import appeng.tile.misc.TilePaint;
|
||||
import appeng.util.Platform;
|
||||
import appeng.util.item.AEItemStack;
|
||||
|
||||
|
||||
public class ToolColorApplicator extends AEBasePoweredItem implements IStorageCell<IAEItemStack>, IItemGroup, IBlockTool, IMouseWheelItem
|
||||
{
|
||||
|
||||
private static final Map<Integer, AEColor> ORE_TO_COLOR = new HashMap<>();
|
||||
|
||||
static
|
||||
{
|
||||
for( final AEColor color : AEColor.VALID_COLORS )
|
||||
{
|
||||
final String dyeName = color.dye.getUnlocalizedName();
|
||||
final String oreDictName = "dye" + WordUtils.capitalize( dyeName );
|
||||
final int oreDictId = OreDictionary.getOreID( oreDictName );
|
||||
|
||||
ORE_TO_COLOR.put( oreDictId, color );
|
||||
}
|
||||
}
|
||||
|
||||
public ToolColorApplicator()
|
||||
{
|
||||
super( AEConfig.instance().getColorApplicatorBattery() );
|
||||
}
|
||||
|
||||
@Override
|
||||
public EnumActionResult onItemUse( EntityPlayer p, World w, BlockPos pos, EnumHand hand, EnumFacing side, float hitX, float hitY, float hitZ )
|
||||
{
|
||||
return this.onItemUse( p.getHeldItem( hand ), p, w, pos, hand, side, hitX, hitY, hitZ );
|
||||
}
|
||||
|
||||
@Override
|
||||
public EnumActionResult onItemUse( ItemStack is, EntityPlayer p, World w, BlockPos pos, EnumHand hand, EnumFacing side, float hitX, float hitY, float hitZ )
|
||||
{
|
||||
final Block blk = w.getBlockState( pos ).getBlock();
|
||||
|
||||
ItemStack paintBall = this.getColor( is );
|
||||
|
||||
final IMEInventory<IAEItemStack> inv = AEApi.instance()
|
||||
.registries()
|
||||
.cell()
|
||||
.getCellInventory( is, null,
|
||||
AEApi.instance().storage().getStorageChannel( IItemStorageChannel.class ) );
|
||||
if( inv != null )
|
||||
{
|
||||
final IAEItemStack option = inv.extractItems( AEItemStack.fromItemStack( paintBall ), Actionable.SIMULATE, new BaseActionSource() );
|
||||
|
||||
if( option != null )
|
||||
{
|
||||
paintBall = option.createItemStack();
|
||||
paintBall.setCount( 1 );
|
||||
}
|
||||
else
|
||||
{
|
||||
paintBall = ItemStack.EMPTY;
|
||||
}
|
||||
|
||||
if( !Platform.hasPermissions( new DimensionalCoord( w, pos ), p ) )
|
||||
{
|
||||
return EnumActionResult.FAIL;
|
||||
}
|
||||
|
||||
final double powerPerUse = 100;
|
||||
if( !paintBall.isEmpty() && paintBall.getItem() instanceof ItemSnowball )
|
||||
{
|
||||
final TileEntity te = w.getTileEntity( pos );
|
||||
// clean cables.
|
||||
if( te instanceof IColorableTile )
|
||||
{
|
||||
if( this.getAECurrentPower( is ) > powerPerUse && ( (IColorableTile) te ).getColor() != AEColor.TRANSPARENT )
|
||||
{
|
||||
if( ( (IColorableTile) te ).recolourBlock( side, AEColor.TRANSPARENT, p ) )
|
||||
{
|
||||
inv.extractItems( AEItemStack.fromItemStack( paintBall ), Actionable.MODULATE, new BaseActionSource() );
|
||||
this.extractAEPower( is, powerPerUse, Actionable.MODULATE );
|
||||
return EnumActionResult.SUCCESS;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// clean paint balls..
|
||||
final Block testBlk = w.getBlockState( pos.offset( side ) ).getBlock();
|
||||
final TileEntity painted = w.getTileEntity( pos.offset( side ) );
|
||||
if( this.getAECurrentPower( is ) > powerPerUse && testBlk instanceof BlockPaint && painted instanceof TilePaint )
|
||||
{
|
||||
inv.extractItems( AEItemStack.fromItemStack( paintBall ), Actionable.MODULATE, new BaseActionSource() );
|
||||
this.extractAEPower( is, powerPerUse, Actionable.MODULATE );
|
||||
( (TilePaint) painted ).cleanSide( side.getOpposite() );
|
||||
return EnumActionResult.SUCCESS;
|
||||
}
|
||||
}
|
||||
else if( !paintBall.isEmpty() )
|
||||
{
|
||||
final AEColor color = this.getColorFromItem( paintBall );
|
||||
|
||||
if( color != null && this.getAECurrentPower( is ) > powerPerUse )
|
||||
{
|
||||
if( color != AEColor.TRANSPARENT && this.recolourBlock( blk, side, w, pos, side, color, p ) )
|
||||
{
|
||||
inv.extractItems( AEItemStack.fromItemStack( paintBall ), Actionable.MODULATE, new BaseActionSource() );
|
||||
this.extractAEPower( is, powerPerUse, Actionable.MODULATE );
|
||||
return EnumActionResult.SUCCESS;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if( p.isSneaking() )
|
||||
{
|
||||
this.cycleColors( is, paintBall, 1 );
|
||||
}
|
||||
|
||||
return EnumActionResult.FAIL;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getItemStackDisplayName( final ItemStack par1ItemStack )
|
||||
{
|
||||
String extra = GuiText.Empty.getLocal();
|
||||
|
||||
final AEColor selected = this.getActiveColor( par1ItemStack );
|
||||
|
||||
if( selected != null && Platform.isClient() )
|
||||
{
|
||||
extra = Platform.gui_localize( selected.unlocalizedName );
|
||||
}
|
||||
|
||||
return super.getItemStackDisplayName( par1ItemStack ) + " - " + extra;
|
||||
}
|
||||
|
||||
public AEColor getActiveColor( final ItemStack tol )
|
||||
{
|
||||
return this.getColorFromItem( this.getColor( tol ) );
|
||||
}
|
||||
|
||||
private AEColor getColorFromItem( final ItemStack paintBall )
|
||||
{
|
||||
if( paintBall.isEmpty() )
|
||||
{
|
||||
return null;
|
||||
}
|
||||
|
||||
if( paintBall.getItem() instanceof ItemSnowball )
|
||||
{
|
||||
return AEColor.TRANSPARENT;
|
||||
}
|
||||
|
||||
if( paintBall.getItem() instanceof ItemPaintBall )
|
||||
{
|
||||
final ItemPaintBall ipb = (ItemPaintBall) paintBall.getItem();
|
||||
return ipb.getColor( paintBall );
|
||||
}
|
||||
else
|
||||
{
|
||||
final int[] id = OreDictionary.getOreIDs( paintBall );
|
||||
|
||||
for( final int oreID : id )
|
||||
{
|
||||
if( ORE_TO_COLOR.containsKey( oreID ) )
|
||||
{
|
||||
return ORE_TO_COLOR.get( oreID );
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
public ItemStack getColor( final ItemStack is )
|
||||
{
|
||||
final NBTTagCompound c = is.getTagCompound();
|
||||
if( c != null && c.hasKey( "color" ) )
|
||||
{
|
||||
final NBTTagCompound color = c.getCompoundTag( "color" );
|
||||
final ItemStack oldColor = new ItemStack( color );
|
||||
if( !oldColor.isEmpty() )
|
||||
{
|
||||
return oldColor;
|
||||
}
|
||||
}
|
||||
|
||||
return this.findNextColor( is, ItemStack.EMPTY, 0 );
|
||||
}
|
||||
|
||||
private ItemStack findNextColor( final ItemStack is, final ItemStack anchor, final int scrollOffset )
|
||||
{
|
||||
ItemStack newColor = ItemStack.EMPTY;
|
||||
|
||||
final IMEInventory<IAEItemStack> inv = AEApi.instance()
|
||||
.registries()
|
||||
.cell()
|
||||
.getCellInventory( is, null,
|
||||
AEApi.instance().storage().getStorageChannel( IItemStorageChannel.class ) );
|
||||
if( inv != null )
|
||||
{
|
||||
final IItemList<IAEItemStack> itemList = inv
|
||||
.getAvailableItems( AEApi.instance().storage().getStorageChannel( IItemStorageChannel.class ).createList() );
|
||||
if( anchor.isEmpty() )
|
||||
{
|
||||
final IAEItemStack firstItem = itemList.getFirstItem();
|
||||
if( firstItem != null )
|
||||
{
|
||||
newColor = firstItem.asItemStackRepresentation();
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
final LinkedList<IAEItemStack> list = new LinkedList<>();
|
||||
|
||||
for( final IAEItemStack i : itemList )
|
||||
{
|
||||
list.add( i );
|
||||
}
|
||||
|
||||
Collections.sort( list, ( a, b ) -> Integer.compare( a.getItemDamage(), b.getItemDamage() ) );
|
||||
|
||||
if( list.size() <= 0 )
|
||||
{
|
||||
return ItemStack.EMPTY;
|
||||
}
|
||||
|
||||
IAEItemStack where = list.getFirst();
|
||||
int cycles = 1 + list.size();
|
||||
|
||||
while( cycles > 0 && !where.equals( anchor ) )
|
||||
{
|
||||
list.addLast( list.removeFirst() );
|
||||
cycles--;
|
||||
where = list.getFirst();
|
||||
}
|
||||
|
||||
if( scrollOffset > 0 )
|
||||
{
|
||||
list.addLast( list.removeFirst() );
|
||||
}
|
||||
|
||||
if( scrollOffset < 0 )
|
||||
{
|
||||
list.addFirst( list.removeLast() );
|
||||
}
|
||||
|
||||
return list.get( 0 ).asItemStackRepresentation();
|
||||
}
|
||||
}
|
||||
|
||||
if( !newColor.isEmpty() )
|
||||
{
|
||||
this.setColor( is, newColor );
|
||||
}
|
||||
|
||||
return newColor;
|
||||
}
|
||||
|
||||
private void setColor( final ItemStack is, final ItemStack newColor )
|
||||
{
|
||||
final NBTTagCompound data = Platform.openNbtData( is );
|
||||
if( newColor.isEmpty() )
|
||||
{
|
||||
data.removeTag( "color" );
|
||||
}
|
||||
else
|
||||
{
|
||||
final NBTTagCompound color = new NBTTagCompound();
|
||||
newColor.writeToNBT( color );
|
||||
data.setTag( "color", color );
|
||||
}
|
||||
}
|
||||
|
||||
private boolean recolourBlock( final Block blk, final EnumFacing side, final World w, final BlockPos pos, final EnumFacing orientation, final AEColor newColor, final EntityPlayer p )
|
||||
{
|
||||
final IBlockState state = w.getBlockState( pos );
|
||||
|
||||
if( blk instanceof BlockColored )
|
||||
{
|
||||
final EnumDyeColor color = state.getValue( BlockColored.COLOR );
|
||||
|
||||
if( newColor.dye == color )
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
return w.setBlockState( pos, state.withProperty( BlockColored.COLOR, newColor.dye ) );
|
||||
}
|
||||
|
||||
if( blk == Blocks.GLASS )
|
||||
{
|
||||
return w.setBlockState( pos, Blocks.STAINED_GLASS.getDefaultState().withProperty( 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.withProperty( BlockStainedGlass.COLOR, newColor.dye ) );
|
||||
}
|
||||
|
||||
if( blk == Blocks.GLASS_PANE )
|
||||
{
|
||||
return w.setBlockState( pos, Blocks.STAINED_GLASS_PANE.getDefaultState().withProperty( 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.withProperty( BlockStainedGlassPane.COLOR, newColor.dye ) );
|
||||
}
|
||||
|
||||
if( blk == Blocks.HARDENED_CLAY )
|
||||
{
|
||||
return w.setBlockState( pos, Blocks.STAINED_HARDENED_CLAY.getDefaultState().withProperty( 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 );
|
||||
}
|
||||
|
||||
public void cycleColors( final ItemStack is, final ItemStack paintBall, final int i )
|
||||
{
|
||||
if( paintBall.isEmpty() )
|
||||
{
|
||||
this.setColor( is, this.getColor( is ) );
|
||||
}
|
||||
else
|
||||
{
|
||||
this.setColor( is, this.findNextColor( is, paintBall, i ) );
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
@SideOnly( Side.CLIENT )
|
||||
public void addCheckedInformation( final ItemStack stack, final World world, final List<String> lines, final ITooltipFlag advancedTooltips )
|
||||
{
|
||||
super.addCheckedInformation( stack, world, lines, advancedTooltips );
|
||||
|
||||
final ICellInventoryHandler<IAEItemStack> cdi = AEApi.instance()
|
||||
.registries()
|
||||
.cell()
|
||||
.getCellInventory( stack, null,
|
||||
AEApi.instance().storage().getStorageChannel( IItemStorageChannel.class ) );
|
||||
|
||||
AEApi.instance().client().addCellInformation( cdi, lines );
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getBytes( final ItemStack cellItem )
|
||||
{
|
||||
return 512;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getBytesPerType( final ItemStack cellItem )
|
||||
{
|
||||
return 8;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getTotalTypes( final ItemStack cellItem )
|
||||
{
|
||||
return 27;
|
||||
}
|
||||
|
||||
@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 ItemSnowball )
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
return !( requestedAddition.getItem() instanceof ItemPaintBall && requestedAddition.getItemDamage() < 20 );
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean storableInStorageCell()
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isStorageCell( final ItemStack i )
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public double getIdleDrain()
|
||||
{
|
||||
return 0.5;
|
||||
}
|
||||
|
||||
@Override
|
||||
public IStorageChannel<IAEItemStack> getChannel()
|
||||
{
|
||||
return AEApi.instance().storage().getStorageChannel( IItemStorageChannel.class );
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getUnlocalizedGroupName( final Set<ItemStack> others, final ItemStack is )
|
||||
{
|
||||
return GuiText.StorageCells.getUnlocalized();
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isEditable( final ItemStack is )
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public IItemHandler getUpgradesInventory( final ItemStack is )
|
||||
{
|
||||
return new CellUpgrades( is, 2 );
|
||||
}
|
||||
|
||||
@Override
|
||||
public IItemHandler getConfigInventory( final ItemStack is )
|
||||
{
|
||||
return new CellConfig( is );
|
||||
}
|
||||
|
||||
@Override
|
||||
public FuzzyMode getFuzzyMode( final ItemStack is )
|
||||
{
|
||||
final String fz = Platform.openNbtData( is ).getString( "FuzzyMode" );
|
||||
try
|
||||
{
|
||||
return FuzzyMode.valueOf( fz );
|
||||
}
|
||||
catch( final Throwable t )
|
||||
{
|
||||
return FuzzyMode.IGNORE_ALL;
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setFuzzyMode( final ItemStack is, final FuzzyMode fzMode )
|
||||
{
|
||||
Platform.openNbtData( is ).setString( "FuzzyMode", fzMode.name() );
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onWheel( final ItemStack is, final boolean up )
|
||||
{
|
||||
this.cycleColors( is, this.getColor( is ), up ? 1 : -1 );
|
||||
}
|
||||
import net.minecraft.block.Block;
|
||||
import net.minecraft.block.BlockColored;
|
||||
import net.minecraft.block.BlockStainedGlass;
|
||||
import net.minecraft.block.BlockStainedGlassPane;
|
||||
import net.minecraft.block.state.IBlockState;
|
||||
import net.minecraft.client.util.ITooltipFlag;
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.init.Blocks;
|
||||
import net.minecraft.item.EnumDyeColor;
|
||||
import net.minecraft.item.ItemSnowball;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.nbt.NBTTagCompound;
|
||||
import net.minecraft.tileentity.TileEntity;
|
||||
import net.minecraft.util.EnumActionResult;
|
||||
import net.minecraft.util.EnumFacing;
|
||||
import net.minecraft.util.EnumHand;
|
||||
import net.minecraft.util.math.BlockPos;
|
||||
import net.minecraft.world.World;
|
||||
import net.minecraftforge.fml.relauncher.Side;
|
||||
import net.minecraftforge.fml.relauncher.SideOnly;
|
||||
import net.minecraftforge.items.IItemHandler;
|
||||
import net.minecraftforge.oredict.OreDictionary;
|
||||
import org.apache.commons.lang3.text.WordUtils;
|
||||
|
||||
import java.util.*;
|
||||
|
||||
|
||||
public class ToolColorApplicator extends AEBasePoweredItem implements IStorageCell<IAEItemStack>, IItemGroup, IBlockTool, IMouseWheelItem {
|
||||
|
||||
private static final Map<Integer, AEColor> ORE_TO_COLOR = new HashMap<>();
|
||||
|
||||
static {
|
||||
for (final AEColor color : AEColor.VALID_COLORS) {
|
||||
final String dyeName = color.dye.getUnlocalizedName();
|
||||
final String oreDictName = "dye" + WordUtils.capitalize(dyeName);
|
||||
final int oreDictId = OreDictionary.getOreID(oreDictName);
|
||||
|
||||
ORE_TO_COLOR.put(oreDictId, color);
|
||||
}
|
||||
}
|
||||
|
||||
public ToolColorApplicator() {
|
||||
super(AEConfig.instance().getColorApplicatorBattery());
|
||||
}
|
||||
|
||||
@Override
|
||||
public EnumActionResult onItemUse(EntityPlayer p, World w, BlockPos pos, EnumHand hand, EnumFacing side, float hitX, float hitY, float hitZ) {
|
||||
return this.onItemUse(p.getHeldItem(hand), p, w, pos, hand, side, hitX, hitY, hitZ);
|
||||
}
|
||||
|
||||
@Override
|
||||
public EnumActionResult onItemUse(ItemStack is, EntityPlayer p, World w, BlockPos pos, EnumHand hand, EnumFacing side, float hitX, float hitY, float hitZ) {
|
||||
final Block blk = w.getBlockState(pos).getBlock();
|
||||
|
||||
ItemStack paintBall = this.getColor(is);
|
||||
|
||||
final IMEInventory<IAEItemStack> inv = AEApi.instance()
|
||||
.registries()
|
||||
.cell()
|
||||
.getCellInventory(is, null,
|
||||
AEApi.instance().storage().getStorageChannel(IItemStorageChannel.class));
|
||||
if (inv != null) {
|
||||
final IAEItemStack option = inv.extractItems(AEItemStack.fromItemStack(paintBall), Actionable.SIMULATE, new BaseActionSource());
|
||||
|
||||
if (option != null) {
|
||||
paintBall = option.createItemStack();
|
||||
paintBall.setCount(1);
|
||||
} else {
|
||||
paintBall = ItemStack.EMPTY;
|
||||
}
|
||||
|
||||
if (!Platform.hasPermissions(new DimensionalCoord(w, pos), p)) {
|
||||
return EnumActionResult.FAIL;
|
||||
}
|
||||
|
||||
final double powerPerUse = 100;
|
||||
if (!paintBall.isEmpty() && paintBall.getItem() instanceof ItemSnowball) {
|
||||
final TileEntity te = w.getTileEntity(pos);
|
||||
// clean cables.
|
||||
if (te instanceof IColorableTile) {
|
||||
if (this.getAECurrentPower(is) > powerPerUse && ((IColorableTile) te).getColor() != AEColor.TRANSPARENT) {
|
||||
if (((IColorableTile) te).recolourBlock(side, AEColor.TRANSPARENT, p)) {
|
||||
inv.extractItems(AEItemStack.fromItemStack(paintBall), Actionable.MODULATE, new BaseActionSource());
|
||||
this.extractAEPower(is, powerPerUse, Actionable.MODULATE);
|
||||
return EnumActionResult.SUCCESS;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// clean paint balls..
|
||||
final Block testBlk = w.getBlockState(pos.offset(side)).getBlock();
|
||||
final TileEntity painted = w.getTileEntity(pos.offset(side));
|
||||
if (this.getAECurrentPower(is) > powerPerUse && testBlk instanceof BlockPaint && painted instanceof TilePaint) {
|
||||
inv.extractItems(AEItemStack.fromItemStack(paintBall), Actionable.MODULATE, new BaseActionSource());
|
||||
this.extractAEPower(is, powerPerUse, Actionable.MODULATE);
|
||||
((TilePaint) painted).cleanSide(side.getOpposite());
|
||||
return EnumActionResult.SUCCESS;
|
||||
}
|
||||
} else if (!paintBall.isEmpty()) {
|
||||
final AEColor color = this.getColorFromItem(paintBall);
|
||||
|
||||
if (color != null && this.getAECurrentPower(is) > powerPerUse) {
|
||||
if (color != AEColor.TRANSPARENT && this.recolourBlock(blk, side, w, pos, side, color, p)) {
|
||||
inv.extractItems(AEItemStack.fromItemStack(paintBall), Actionable.MODULATE, new BaseActionSource());
|
||||
this.extractAEPower(is, powerPerUse, Actionable.MODULATE);
|
||||
return EnumActionResult.SUCCESS;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (p.isSneaking()) {
|
||||
this.cycleColors(is, paintBall, 1);
|
||||
}
|
||||
|
||||
return EnumActionResult.FAIL;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getItemStackDisplayName(final ItemStack par1ItemStack) {
|
||||
String extra = GuiText.Empty.getLocal();
|
||||
|
||||
final AEColor selected = this.getActiveColor(par1ItemStack);
|
||||
|
||||
if (selected != null && Platform.isClient()) {
|
||||
extra = Platform.gui_localize(selected.unlocalizedName);
|
||||
}
|
||||
|
||||
return super.getItemStackDisplayName(par1ItemStack) + " - " + extra;
|
||||
}
|
||||
|
||||
public AEColor getActiveColor(final ItemStack tol) {
|
||||
return this.getColorFromItem(this.getColor(tol));
|
||||
}
|
||||
|
||||
private AEColor getColorFromItem(final ItemStack paintBall) {
|
||||
if (paintBall.isEmpty()) {
|
||||
return null;
|
||||
}
|
||||
|
||||
if (paintBall.getItem() instanceof ItemSnowball) {
|
||||
return AEColor.TRANSPARENT;
|
||||
}
|
||||
|
||||
if (paintBall.getItem() instanceof ItemPaintBall) {
|
||||
final ItemPaintBall ipb = (ItemPaintBall) paintBall.getItem();
|
||||
return ipb.getColor(paintBall);
|
||||
} else {
|
||||
final int[] id = OreDictionary.getOreIDs(paintBall);
|
||||
|
||||
for (final int oreID : id) {
|
||||
if (ORE_TO_COLOR.containsKey(oreID)) {
|
||||
return ORE_TO_COLOR.get(oreID);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
public ItemStack getColor(final ItemStack is) {
|
||||
final NBTTagCompound c = is.getTagCompound();
|
||||
if (c != null && c.hasKey("color")) {
|
||||
final NBTTagCompound color = c.getCompoundTag("color");
|
||||
final ItemStack oldColor = new ItemStack(color);
|
||||
if (!oldColor.isEmpty()) {
|
||||
return oldColor;
|
||||
}
|
||||
}
|
||||
|
||||
return this.findNextColor(is, ItemStack.EMPTY, 0);
|
||||
}
|
||||
|
||||
private ItemStack findNextColor(final ItemStack is, final ItemStack anchor, final int scrollOffset) {
|
||||
ItemStack newColor = ItemStack.EMPTY;
|
||||
|
||||
final IMEInventory<IAEItemStack> inv = AEApi.instance()
|
||||
.registries()
|
||||
.cell()
|
||||
.getCellInventory(is, null,
|
||||
AEApi.instance().storage().getStorageChannel(IItemStorageChannel.class));
|
||||
if (inv != null) {
|
||||
final IItemList<IAEItemStack> itemList = inv
|
||||
.getAvailableItems(AEApi.instance().storage().getStorageChannel(IItemStorageChannel.class).createList());
|
||||
if (anchor.isEmpty()) {
|
||||
final IAEItemStack firstItem = itemList.getFirstItem();
|
||||
if (firstItem != null) {
|
||||
newColor = firstItem.asItemStackRepresentation();
|
||||
}
|
||||
} else {
|
||||
final LinkedList<IAEItemStack> list = new LinkedList<>();
|
||||
|
||||
for (final IAEItemStack i : itemList) {
|
||||
list.add(i);
|
||||
}
|
||||
|
||||
Collections.sort(list, (a, b) -> Integer.compare(a.getItemDamage(), b.getItemDamage()));
|
||||
|
||||
if (list.size() <= 0) {
|
||||
return ItemStack.EMPTY;
|
||||
}
|
||||
|
||||
IAEItemStack where = list.getFirst();
|
||||
int cycles = 1 + list.size();
|
||||
|
||||
while (cycles > 0 && !where.equals(anchor)) {
|
||||
list.addLast(list.removeFirst());
|
||||
cycles--;
|
||||
where = list.getFirst();
|
||||
}
|
||||
|
||||
if (scrollOffset > 0) {
|
||||
list.addLast(list.removeFirst());
|
||||
}
|
||||
|
||||
if (scrollOffset < 0) {
|
||||
list.addFirst(list.removeLast());
|
||||
}
|
||||
|
||||
return list.get(0).asItemStackRepresentation();
|
||||
}
|
||||
}
|
||||
|
||||
if (!newColor.isEmpty()) {
|
||||
this.setColor(is, newColor);
|
||||
}
|
||||
|
||||
return newColor;
|
||||
}
|
||||
|
||||
private void setColor(final ItemStack is, final ItemStack newColor) {
|
||||
final NBTTagCompound data = Platform.openNbtData(is);
|
||||
if (newColor.isEmpty()) {
|
||||
data.removeTag("color");
|
||||
} else {
|
||||
final NBTTagCompound color = new NBTTagCompound();
|
||||
newColor.writeToNBT(color);
|
||||
data.setTag("color", color);
|
||||
}
|
||||
}
|
||||
|
||||
private boolean recolourBlock(final Block blk, final EnumFacing side, final World w, final BlockPos pos, final EnumFacing orientation, final AEColor newColor, final EntityPlayer p) {
|
||||
final IBlockState state = w.getBlockState(pos);
|
||||
|
||||
if (blk instanceof BlockColored) {
|
||||
final EnumDyeColor color = state.getValue(BlockColored.COLOR);
|
||||
|
||||
if (newColor.dye == color) {
|
||||
return false;
|
||||
}
|
||||
|
||||
return w.setBlockState(pos, state.withProperty(BlockColored.COLOR, newColor.dye));
|
||||
}
|
||||
|
||||
if (blk == Blocks.GLASS) {
|
||||
return w.setBlockState(pos, Blocks.STAINED_GLASS.getDefaultState().withProperty(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.withProperty(BlockStainedGlass.COLOR, newColor.dye));
|
||||
}
|
||||
|
||||
if (blk == Blocks.GLASS_PANE) {
|
||||
return w.setBlockState(pos, Blocks.STAINED_GLASS_PANE.getDefaultState().withProperty(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.withProperty(BlockStainedGlassPane.COLOR, newColor.dye));
|
||||
}
|
||||
|
||||
if (blk == Blocks.HARDENED_CLAY) {
|
||||
return w.setBlockState(pos, Blocks.STAINED_HARDENED_CLAY.getDefaultState().withProperty(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);
|
||||
}
|
||||
|
||||
public void cycleColors(final ItemStack is, final ItemStack paintBall, final int i) {
|
||||
if (paintBall.isEmpty()) {
|
||||
this.setColor(is, this.getColor(is));
|
||||
} else {
|
||||
this.setColor(is, this.findNextColor(is, paintBall, i));
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
@SideOnly(Side.CLIENT)
|
||||
public void addCheckedInformation(final ItemStack stack, final World world, final List<String> lines, final ITooltipFlag advancedTooltips) {
|
||||
super.addCheckedInformation(stack, world, lines, advancedTooltips);
|
||||
|
||||
final ICellInventoryHandler<IAEItemStack> cdi = AEApi.instance()
|
||||
.registries()
|
||||
.cell()
|
||||
.getCellInventory(stack, null,
|
||||
AEApi.instance().storage().getStorageChannel(IItemStorageChannel.class));
|
||||
|
||||
AEApi.instance().client().addCellInformation(cdi, lines);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getBytes(final ItemStack cellItem) {
|
||||
return 512;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getBytesPerType(final ItemStack cellItem) {
|
||||
return 8;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getTotalTypes(final ItemStack cellItem) {
|
||||
return 27;
|
||||
}
|
||||
|
||||
@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 ItemSnowball) {
|
||||
return false;
|
||||
}
|
||||
|
||||
return !(requestedAddition.getItem() instanceof ItemPaintBall && requestedAddition.getItemDamage() < 20);
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean storableInStorageCell() {
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isStorageCell(final ItemStack i) {
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public double getIdleDrain() {
|
||||
return 0.5;
|
||||
}
|
||||
|
||||
@Override
|
||||
public IStorageChannel<IAEItemStack> getChannel() {
|
||||
return AEApi.instance().storage().getStorageChannel(IItemStorageChannel.class);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getUnlocalizedGroupName(final Set<ItemStack> others, final ItemStack is) {
|
||||
return GuiText.StorageCells.getUnlocalized();
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isEditable(final ItemStack is) {
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public IItemHandler getUpgradesInventory(final ItemStack is) {
|
||||
return new CellUpgrades(is, 2);
|
||||
}
|
||||
|
||||
@Override
|
||||
public IItemHandler getConfigInventory(final ItemStack is) {
|
||||
return new CellConfig(is);
|
||||
}
|
||||
|
||||
@Override
|
||||
public FuzzyMode getFuzzyMode(final ItemStack is) {
|
||||
final String fz = Platform.openNbtData(is).getString("FuzzyMode");
|
||||
try {
|
||||
return FuzzyMode.valueOf(fz);
|
||||
} catch (final Throwable t) {
|
||||
return FuzzyMode.IGNORE_ALL;
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setFuzzyMode(final ItemStack is, final FuzzyMode fzMode) {
|
||||
Platform.openNbtData(is).setString("FuzzyMode", fzMode.name());
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onWheel(final ItemStack is, final boolean up) {
|
||||
this.cycleColors(is, this.getColor(is), up ? 1 : -1);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,69 +1,60 @@
|
||||
|
||||
package appeng.items.tools.powered;
|
||||
|
||||
|
||||
import net.minecraft.client.renderer.block.model.ModelResourceLocation;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.util.ResourceLocation;
|
||||
import net.minecraftforge.fml.relauncher.Side;
|
||||
import net.minecraftforge.fml.relauncher.SideOnly;
|
||||
|
||||
import appeng.api.util.AEColor;
|
||||
import appeng.bootstrap.IItemRendering;
|
||||
import appeng.bootstrap.ItemRenderingCustomizer;
|
||||
import appeng.client.render.model.ColorApplicatorModel;
|
||||
import appeng.core.AppEng;
|
||||
import net.minecraft.client.renderer.block.model.ModelResourceLocation;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.util.ResourceLocation;
|
||||
import net.minecraftforge.fml.relauncher.Side;
|
||||
import net.minecraftforge.fml.relauncher.SideOnly;
|
||||
|
||||
|
||||
public class ToolColorApplicatorRendering extends ItemRenderingCustomizer
|
||||
{
|
||||
public class ToolColorApplicatorRendering extends ItemRenderingCustomizer {
|
||||
|
||||
private static final ModelResourceLocation MODEL_COLORED = new ModelResourceLocation( new ResourceLocation( AppEng.MOD_ID, "builtin/color_applicator_colored" ), "inventory" );
|
||||
private static final ModelResourceLocation MODEL_UNCOLORED = new ModelResourceLocation( new ResourceLocation( AppEng.MOD_ID, "color_applicator_uncolored" ), "inventory" );
|
||||
private static final ModelResourceLocation MODEL_COLORED = new ModelResourceLocation(new ResourceLocation(AppEng.MOD_ID, "builtin/color_applicator_colored"), "inventory");
|
||||
private static final ModelResourceLocation MODEL_UNCOLORED = new ModelResourceLocation(new ResourceLocation(AppEng.MOD_ID, "color_applicator_uncolored"), "inventory");
|
||||
|
||||
@Override
|
||||
@SideOnly( Side.CLIENT )
|
||||
public void customize( IItemRendering rendering )
|
||||
{
|
||||
rendering.builtInModel( "models/item/builtin/color_applicator_colored", new ColorApplicatorModel() );
|
||||
rendering.variants( MODEL_COLORED, MODEL_UNCOLORED );
|
||||
rendering.color( this::getColor );
|
||||
rendering.meshDefinition( this::getMesh );
|
||||
}
|
||||
@Override
|
||||
@SideOnly(Side.CLIENT)
|
||||
public void customize(IItemRendering rendering) {
|
||||
rendering.builtInModel("models/item/builtin/color_applicator_colored", new ColorApplicatorModel());
|
||||
rendering.variants(MODEL_COLORED, MODEL_UNCOLORED);
|
||||
rendering.color(this::getColor);
|
||||
rendering.meshDefinition(this::getMesh);
|
||||
}
|
||||
|
||||
private ModelResourceLocation getMesh( ItemStack itemStack )
|
||||
{
|
||||
// If the stack has no color, don't use the colored model since the impact of calling getColor for every quad is
|
||||
// extremely high,
|
||||
// if the stack tries to re-search its inventory for a new paintball everytime
|
||||
AEColor col = ( (ToolColorApplicator) itemStack.getItem() ).getActiveColor( itemStack );
|
||||
return ( col != null ) ? MODEL_COLORED : MODEL_UNCOLORED;
|
||||
}
|
||||
private ModelResourceLocation getMesh(ItemStack itemStack) {
|
||||
// If the stack has no color, don't use the colored model since the impact of calling getColor for every quad is
|
||||
// extremely high,
|
||||
// if the stack tries to re-search its inventory for a new paintball everytime
|
||||
AEColor col = ((ToolColorApplicator) itemStack.getItem()).getActiveColor(itemStack);
|
||||
return (col != null) ? MODEL_COLORED : MODEL_UNCOLORED;
|
||||
}
|
||||
|
||||
private int getColor( ItemStack itemStack, int idx )
|
||||
{
|
||||
if( idx == 0 )
|
||||
{
|
||||
return -1;
|
||||
}
|
||||
private int getColor(ItemStack itemStack, int idx) {
|
||||
if (idx == 0) {
|
||||
return -1;
|
||||
}
|
||||
|
||||
final AEColor col = ( (ToolColorApplicator) itemStack.getItem() ).getActiveColor( itemStack );
|
||||
final AEColor col = ((ToolColorApplicator) itemStack.getItem()).getActiveColor(itemStack);
|
||||
|
||||
if( col == null )
|
||||
{
|
||||
return -1;
|
||||
}
|
||||
if (col == null) {
|
||||
return -1;
|
||||
}
|
||||
|
||||
switch( idx )
|
||||
{
|
||||
case 1:
|
||||
return col.blackVariant;
|
||||
case 2:
|
||||
return col.mediumVariant;
|
||||
case 3:
|
||||
return col.whiteVariant;
|
||||
default:
|
||||
return -1;
|
||||
}
|
||||
}
|
||||
switch (idx) {
|
||||
case 1:
|
||||
return col.blackVariant;
|
||||
case 2:
|
||||
return col.mediumVariant;
|
||||
case 3:
|
||||
return col.whiteVariant;
|
||||
default:
|
||||
return -1;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -19,11 +19,14 @@
|
||||
package appeng.items.tools.powered;
|
||||
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
import appeng.api.config.Actionable;
|
||||
import appeng.api.util.DimensionalCoord;
|
||||
import appeng.block.misc.BlockTinyTNT;
|
||||
import appeng.core.AEConfig;
|
||||
import appeng.hooks.IBlockTool;
|
||||
import appeng.items.tools.powered.powersink.AEBasePoweredItem;
|
||||
import appeng.util.InWorldToolOperationResult;
|
||||
import appeng.util.Platform;
|
||||
import net.minecraft.block.Block;
|
||||
import net.minecraft.block.BlockTNT;
|
||||
import net.minecraft.block.material.Material;
|
||||
@@ -36,333 +39,265 @@ import net.minecraft.init.SoundEvents;
|
||||
import net.minecraft.item.ItemBlock;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.item.crafting.FurnaceRecipes;
|
||||
import net.minecraft.util.ActionResult;
|
||||
import net.minecraft.util.EnumActionResult;
|
||||
import net.minecraft.util.EnumFacing;
|
||||
import net.minecraft.util.EnumHand;
|
||||
import net.minecraft.util.SoundCategory;
|
||||
import net.minecraft.util.*;
|
||||
import net.minecraft.util.math.BlockPos;
|
||||
import net.minecraft.util.math.RayTraceResult;
|
||||
import net.minecraft.world.World;
|
||||
|
||||
import appeng.api.config.Actionable;
|
||||
import appeng.api.util.DimensionalCoord;
|
||||
import appeng.block.misc.BlockTinyTNT;
|
||||
import appeng.core.AEConfig;
|
||||
import appeng.hooks.IBlockTool;
|
||||
import appeng.items.tools.powered.powersink.AEBasePoweredItem;
|
||||
import appeng.util.InWorldToolOperationResult;
|
||||
import appeng.util.Platform;
|
||||
import java.util.ArrayList;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
|
||||
public class ToolEntropyManipulator extends AEBasePoweredItem implements IBlockTool
|
||||
{
|
||||
private final Map<InWorldToolOperationIngredient, InWorldToolOperationResult> heatUp;
|
||||
private final Map<InWorldToolOperationIngredient, InWorldToolOperationResult> coolDown;
|
||||
public class ToolEntropyManipulator extends AEBasePoweredItem implements IBlockTool {
|
||||
private final Map<InWorldToolOperationIngredient, InWorldToolOperationResult> heatUp;
|
||||
private final Map<InWorldToolOperationIngredient, InWorldToolOperationResult> coolDown;
|
||||
|
||||
public ToolEntropyManipulator()
|
||||
{
|
||||
super( AEConfig.instance().getEntropyManipulatorBattery() );
|
||||
public ToolEntropyManipulator() {
|
||||
super(AEConfig.instance().getEntropyManipulatorBattery());
|
||||
|
||||
this.heatUp = new HashMap<>();
|
||||
this.coolDown = new HashMap<>();
|
||||
this.heatUp = new HashMap<>();
|
||||
this.coolDown = new HashMap<>();
|
||||
|
||||
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 ) ) );
|
||||
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() ) );
|
||||
this.coolDown.put( new InWorldToolOperationIngredient( Blocks.GRASS, true ), new InWorldToolOperationResult( Blocks.DIRT.getDefaultState() ) );
|
||||
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)));
|
||||
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()));
|
||||
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 ) );
|
||||
this.coolDown.put( new InWorldToolOperationIngredient( Blocks.WATER, true ), new InWorldToolOperationResult( Blocks.ICE.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));
|
||||
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() );
|
||||
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 ) ) );
|
||||
}
|
||||
this.heatUp.put(new InWorldToolOperationIngredient(Blocks.ICE.getDefaultState()), new InWorldToolOperationResult(Blocks.WATER.getDefaultState()));
|
||||
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)));
|
||||
}
|
||||
|
||||
private static class InWorldToolOperationIngredient
|
||||
{
|
||||
private final IBlockState state;
|
||||
private final boolean blockOnly;
|
||||
private static class InWorldToolOperationIngredient {
|
||||
private final IBlockState state;
|
||||
private final boolean blockOnly;
|
||||
|
||||
public InWorldToolOperationIngredient( final IBlockState state )
|
||||
{
|
||||
this.state = state;
|
||||
this.blockOnly = false;
|
||||
}
|
||||
public InWorldToolOperationIngredient(final IBlockState state) {
|
||||
this.state = state;
|
||||
this.blockOnly = false;
|
||||
}
|
||||
|
||||
public InWorldToolOperationIngredient( final Block blk, final boolean b )
|
||||
{
|
||||
this.state = blk.getDefaultState();
|
||||
this.blockOnly = b;
|
||||
}
|
||||
public InWorldToolOperationIngredient(final Block blk, final boolean b) {
|
||||
this.state = blk.getDefaultState();
|
||||
this.blockOnly = b;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int hashCode()
|
||||
{
|
||||
return this.state.getBlock().hashCode();
|
||||
}
|
||||
@Override
|
||||
public int hashCode() {
|
||||
return this.state.getBlock().hashCode();
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean equals( final Object obj )
|
||||
{
|
||||
if( obj == null )
|
||||
{
|
||||
return false;
|
||||
}
|
||||
if( this.getClass() != obj.getClass() )
|
||||
{
|
||||
return false;
|
||||
}
|
||||
final InWorldToolOperationIngredient other = (InWorldToolOperationIngredient) obj;
|
||||
return this.state == other.state && ( this.blockOnly && this.state.getBlock() == other.state.getBlock() );
|
||||
}
|
||||
}
|
||||
@Override
|
||||
public boolean equals(final Object obj) {
|
||||
if (obj == null) {
|
||||
return false;
|
||||
}
|
||||
if (this.getClass() != obj.getClass()) {
|
||||
return false;
|
||||
}
|
||||
final InWorldToolOperationIngredient other = (InWorldToolOperationIngredient) obj;
|
||||
return this.state == other.state && (this.blockOnly && this.state.getBlock() == other.state.getBlock());
|
||||
}
|
||||
}
|
||||
|
||||
private void heat( final IBlockState state, final World w, final BlockPos pos )
|
||||
{
|
||||
InWorldToolOperationResult r = this.heatUp.get( new InWorldToolOperationIngredient( state ) );
|
||||
private void heat(final IBlockState state, final World w, final BlockPos pos) {
|
||||
InWorldToolOperationResult r = this.heatUp.get(new InWorldToolOperationIngredient(state));
|
||||
|
||||
if( r == null )
|
||||
{
|
||||
r = this.heatUp.get( new InWorldToolOperationIngredient( state.getBlock(), true ) );
|
||||
}
|
||||
if (r == null) {
|
||||
r = this.heatUp.get(new InWorldToolOperationIngredient(state.getBlock(), true));
|
||||
}
|
||||
|
||||
if( r.getBlockState() != null )
|
||||
{
|
||||
w.setBlockState( pos, r.getBlockState(), 3 );
|
||||
}
|
||||
else
|
||||
{
|
||||
w.setBlockToAir( pos );
|
||||
}
|
||||
if (r.getBlockState() != null) {
|
||||
w.setBlockState(pos, r.getBlockState(), 3);
|
||||
} else {
|
||||
w.setBlockToAir(pos);
|
||||
}
|
||||
|
||||
if( r.getDrops() != null )
|
||||
{
|
||||
Platform.spawnDrops( w, pos, r.getDrops() );
|
||||
}
|
||||
}
|
||||
if (r.getDrops() != null) {
|
||||
Platform.spawnDrops(w, pos, r.getDrops());
|
||||
}
|
||||
}
|
||||
|
||||
private boolean canHeat( final IBlockState state )
|
||||
{
|
||||
InWorldToolOperationResult r = this.heatUp.get( new InWorldToolOperationIngredient( state ) );
|
||||
private boolean canHeat(final IBlockState state) {
|
||||
InWorldToolOperationResult r = this.heatUp.get(new InWorldToolOperationIngredient(state));
|
||||
|
||||
if( r == null )
|
||||
{
|
||||
r = this.heatUp.get( new InWorldToolOperationIngredient( state.getBlock(), true ) );
|
||||
}
|
||||
if (r == null) {
|
||||
r = this.heatUp.get(new InWorldToolOperationIngredient(state.getBlock(), true));
|
||||
}
|
||||
|
||||
return r != null;
|
||||
}
|
||||
return r != null;
|
||||
}
|
||||
|
||||
private void cool( final IBlockState state, final World w, final BlockPos pos )
|
||||
{
|
||||
InWorldToolOperationResult r = this.coolDown.get( new InWorldToolOperationIngredient( state ) );
|
||||
private void cool(final IBlockState state, final World w, final BlockPos pos) {
|
||||
InWorldToolOperationResult r = this.coolDown.get(new InWorldToolOperationIngredient(state));
|
||||
|
||||
if( r == null )
|
||||
{
|
||||
r = this.coolDown.get( new InWorldToolOperationIngredient( state.getBlock(), true ) );
|
||||
}
|
||||
if (r == null) {
|
||||
r = this.coolDown.get(new InWorldToolOperationIngredient(state.getBlock(), true));
|
||||
}
|
||||
|
||||
if( r.getBlockState() != null )
|
||||
{
|
||||
w.setBlockState( pos, r.getBlockState(), 3 );
|
||||
}
|
||||
else
|
||||
{
|
||||
w.setBlockToAir( pos );
|
||||
}
|
||||
if (r.getBlockState() != null) {
|
||||
w.setBlockState(pos, r.getBlockState(), 3);
|
||||
} else {
|
||||
w.setBlockToAir(pos);
|
||||
}
|
||||
|
||||
if( r.getDrops() != null )
|
||||
{
|
||||
Platform.spawnDrops( w, pos, r.getDrops() );
|
||||
}
|
||||
}
|
||||
if (r.getDrops() != null) {
|
||||
Platform.spawnDrops(w, pos, r.getDrops());
|
||||
}
|
||||
}
|
||||
|
||||
private boolean canCool( final IBlockState state )
|
||||
{
|
||||
InWorldToolOperationResult r = this.coolDown.get( new InWorldToolOperationIngredient( state ) );
|
||||
private boolean canCool(final IBlockState state) {
|
||||
InWorldToolOperationResult r = this.coolDown.get(new InWorldToolOperationIngredient(state));
|
||||
|
||||
if( r == null )
|
||||
{
|
||||
r = this.coolDown.get( new InWorldToolOperationIngredient( state.getBlock(), true ) );
|
||||
}
|
||||
if (r == null) {
|
||||
r = this.coolDown.get(new InWorldToolOperationIngredient(state.getBlock(), true));
|
||||
}
|
||||
|
||||
return r != null;
|
||||
}
|
||||
return r != null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean hitEntity( final ItemStack item, final EntityLivingBase target, final EntityLivingBase hitter )
|
||||
{
|
||||
if( this.getAECurrentPower( item ) > 1600 )
|
||||
{
|
||||
this.extractAEPower( item, 1600, Actionable.MODULATE );
|
||||
target.setFire( 8 );
|
||||
}
|
||||
@Override
|
||||
public boolean hitEntity(final ItemStack item, final EntityLivingBase target, final EntityLivingBase hitter) {
|
||||
if (this.getAECurrentPower(item) > 1600) {
|
||||
this.extractAEPower(item, 1600, Actionable.MODULATE);
|
||||
target.setFire(8);
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public ActionResult<ItemStack> onItemRightClick( final World w, final EntityPlayer p, final EnumHand hand )
|
||||
{
|
||||
final RayTraceResult target = this.rayTrace( w, p, true );
|
||||
@Override
|
||||
public ActionResult<ItemStack> onItemRightClick(final World w, final EntityPlayer p, final EnumHand hand) {
|
||||
final RayTraceResult target = this.rayTrace(w, p, true);
|
||||
|
||||
if( target == null )
|
||||
{
|
||||
return new ActionResult<>( EnumActionResult.FAIL, p.getHeldItem( hand ) );
|
||||
}
|
||||
else
|
||||
{
|
||||
if( target.typeOfHit == RayTraceResult.Type.BLOCK )
|
||||
{
|
||||
final IBlockState state = w.getBlockState( target.getBlockPos() );
|
||||
if( state.getMaterial() == Material.LAVA || state.getMaterial() == Material.WATER )
|
||||
{
|
||||
if( Platform.hasPermissions( new DimensionalCoord( w, target.getBlockPos() ), p ) )
|
||||
{
|
||||
this.onItemUse( p, w, target.getBlockPos(), hand, EnumFacing.UP, 0.0F, 0.0F, 0.0F );
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
if (target == null) {
|
||||
return new ActionResult<>(EnumActionResult.FAIL, p.getHeldItem(hand));
|
||||
} else {
|
||||
if (target.typeOfHit == RayTraceResult.Type.BLOCK) {
|
||||
final IBlockState state = w.getBlockState(target.getBlockPos());
|
||||
if (state.getMaterial() == Material.LAVA || state.getMaterial() == Material.WATER) {
|
||||
if (Platform.hasPermissions(new DimensionalCoord(w, target.getBlockPos()), p)) {
|
||||
this.onItemUse(p, w, target.getBlockPos(), hand, EnumFacing.UP, 0.0F, 0.0F, 0.0F);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return new ActionResult<>( EnumActionResult.SUCCESS, p.getHeldItem( hand ) );
|
||||
}
|
||||
return new ActionResult<>(EnumActionResult.SUCCESS, p.getHeldItem(hand));
|
||||
}
|
||||
|
||||
@Override
|
||||
public EnumActionResult onItemUse( EntityPlayer p, World w, BlockPos pos, EnumHand hand, EnumFacing side, float hitX, float hitY, float hitZ )
|
||||
{
|
||||
return this.onItemUse( p.getHeldItem( hand ), p, w, pos, hand, side, hitX, hitY, hitZ );
|
||||
}
|
||||
@Override
|
||||
public EnumActionResult onItemUse(EntityPlayer p, World w, BlockPos pos, EnumHand hand, EnumFacing side, float hitX, float hitY, float hitZ) {
|
||||
return this.onItemUse(p.getHeldItem(hand), p, w, pos, hand, side, hitX, hitY, hitZ);
|
||||
}
|
||||
|
||||
@Override
|
||||
public EnumActionResult onItemUse( ItemStack item, EntityPlayer p, World w, BlockPos pos, EnumHand hand, EnumFacing side, float hitX, float hitY, float hitZ )
|
||||
{
|
||||
if( this.getAECurrentPower( item ) > 1600 )
|
||||
{
|
||||
if( !p.canPlayerEdit( pos, side, item ) )
|
||||
{
|
||||
return EnumActionResult.FAIL;
|
||||
}
|
||||
@Override
|
||||
public EnumActionResult onItemUse(ItemStack item, EntityPlayer p, World w, BlockPos pos, EnumHand hand, EnumFacing side, float hitX, float hitY, float hitZ) {
|
||||
if (this.getAECurrentPower(item) > 1600) {
|
||||
if (!p.canPlayerEdit(pos, side, item)) {
|
||||
return EnumActionResult.FAIL;
|
||||
}
|
||||
|
||||
final IBlockState state = w.getBlockState( pos );
|
||||
final Block blockID = state.getBlock();
|
||||
final IBlockState state = w.getBlockState(pos);
|
||||
final Block blockID = state.getBlock();
|
||||
|
||||
if( p.isSneaking() )
|
||||
{
|
||||
if( this.canCool( state ) )
|
||||
{
|
||||
this.extractAEPower( item, 1600, Actionable.MODULATE );
|
||||
this.cool( state, w, pos );
|
||||
return EnumActionResult.SUCCESS;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
if( blockID instanceof BlockTNT )
|
||||
{
|
||||
w.setBlockToAir( pos );
|
||||
( (BlockTNT) blockID ).explode( w, pos, state, p );
|
||||
return EnumActionResult.SUCCESS;
|
||||
}
|
||||
if (p.isSneaking()) {
|
||||
if (this.canCool(state)) {
|
||||
this.extractAEPower(item, 1600, Actionable.MODULATE);
|
||||
this.cool(state, w, pos);
|
||||
return EnumActionResult.SUCCESS;
|
||||
}
|
||||
} else {
|
||||
if (blockID instanceof BlockTNT) {
|
||||
w.setBlockToAir(pos);
|
||||
((BlockTNT) blockID).explode(w, pos, state, p);
|
||||
return EnumActionResult.SUCCESS;
|
||||
}
|
||||
|
||||
if( blockID instanceof BlockTinyTNT )
|
||||
{
|
||||
w.setBlockToAir( pos );
|
||||
( (BlockTinyTNT) blockID ).startFuse( w, pos, p );
|
||||
return EnumActionResult.SUCCESS;
|
||||
}
|
||||
if (blockID instanceof BlockTinyTNT) {
|
||||
w.setBlockToAir(pos);
|
||||
((BlockTinyTNT) blockID).startFuse(w, pos, p);
|
||||
return EnumActionResult.SUCCESS;
|
||||
}
|
||||
|
||||
if( this.canHeat( state ) )
|
||||
{
|
||||
this.extractAEPower( item, 1600, Actionable.MODULATE );
|
||||
this.heat( state, w, pos );
|
||||
return EnumActionResult.SUCCESS;
|
||||
}
|
||||
if (this.canHeat(state)) {
|
||||
this.extractAEPower(item, 1600, Actionable.MODULATE);
|
||||
this.heat(state, w, pos);
|
||||
return EnumActionResult.SUCCESS;
|
||||
}
|
||||
|
||||
final ItemStack[] stack = Platform.getBlockDrops( w, pos );
|
||||
final List<ItemStack> out = new ArrayList<>();
|
||||
boolean hasFurnaceable = false;
|
||||
boolean canFurnaceable = true;
|
||||
final ItemStack[] stack = Platform.getBlockDrops(w, pos);
|
||||
final List<ItemStack> out = new ArrayList<>();
|
||||
boolean hasFurnaceable = false;
|
||||
boolean canFurnaceable = true;
|
||||
|
||||
for( final ItemStack i : stack )
|
||||
{
|
||||
final ItemStack result = FurnaceRecipes.instance().getSmeltingResult( i );
|
||||
for (final ItemStack i : stack) {
|
||||
final ItemStack result = FurnaceRecipes.instance().getSmeltingResult(i);
|
||||
|
||||
if( !result.isEmpty() )
|
||||
{
|
||||
if( result.getItem() instanceof ItemBlock )
|
||||
{
|
||||
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 );
|
||||
}
|
||||
}
|
||||
if (!result.isEmpty()) {
|
||||
if (result.getItem() instanceof ItemBlock) {
|
||||
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);
|
||||
}
|
||||
}
|
||||
|
||||
if( hasFurnaceable && canFurnaceable )
|
||||
{
|
||||
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 );
|
||||
if (hasFurnaceable && canFurnaceable) {
|
||||
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);
|
||||
|
||||
if( or.getBlockState() == null )
|
||||
{
|
||||
w.setBlockState( pos, Platform.AIR_BLOCK.getDefaultState(), 3 );
|
||||
}
|
||||
else
|
||||
{
|
||||
w.setBlockState( pos, or.getBlockState(), 3 );
|
||||
}
|
||||
if (or.getBlockState() == null) {
|
||||
w.setBlockState(pos, Platform.AIR_BLOCK.getDefaultState(), 3);
|
||||
} else {
|
||||
w.setBlockState(pos, or.getBlockState(), 3);
|
||||
}
|
||||
|
||||
if( or.getDrops() != null )
|
||||
{
|
||||
Platform.spawnDrops( w, pos, or.getDrops() );
|
||||
}
|
||||
if (or.getDrops() != null) {
|
||||
Platform.spawnDrops(w, pos, or.getDrops());
|
||||
}
|
||||
|
||||
return EnumActionResult.SUCCESS;
|
||||
}
|
||||
else
|
||||
{
|
||||
final BlockPos offsetPos = pos.offset( side );
|
||||
return EnumActionResult.SUCCESS;
|
||||
} else {
|
||||
final BlockPos offsetPos = pos.offset(side);
|
||||
|
||||
if( !p.canPlayerEdit( offsetPos, side, item ) )
|
||||
{
|
||||
return EnumActionResult.FAIL;
|
||||
}
|
||||
if (!p.canPlayerEdit(offsetPos, side, item)) {
|
||||
return EnumActionResult.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 );
|
||||
w.setBlockState( offsetPos, Blocks.FIRE.getDefaultState() );
|
||||
}
|
||||
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);
|
||||
w.setBlockState(offsetPos, Blocks.FIRE.getDefaultState());
|
||||
}
|
||||
|
||||
return EnumActionResult.SUCCESS;
|
||||
}
|
||||
}
|
||||
}
|
||||
return EnumActionResult.SUCCESS;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return EnumActionResult.PASS;
|
||||
}
|
||||
return EnumActionResult.PASS;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -19,34 +19,6 @@
|
||||
package appeng.items.tools.powered;
|
||||
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import javax.annotation.Nullable;
|
||||
|
||||
import net.minecraft.block.Block;
|
||||
import net.minecraft.block.state.IBlockState;
|
||||
import net.minecraft.client.util.ITooltipFlag;
|
||||
import net.minecraft.entity.Entity;
|
||||
import net.minecraft.entity.EntityLivingBase;
|
||||
import net.minecraft.entity.item.EntityItem;
|
||||
import net.minecraft.entity.passive.EntitySheep;
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.tileentity.TileEntity;
|
||||
import net.minecraft.util.ActionResult;
|
||||
import net.minecraft.util.DamageSource;
|
||||
import net.minecraft.util.EnumActionResult;
|
||||
import net.minecraft.util.EnumFacing;
|
||||
import net.minecraft.util.EnumHand;
|
||||
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.world.World;
|
||||
import net.minecraftforge.fml.relauncher.Side;
|
||||
import net.minecraftforge.fml.relauncher.SideOnly;
|
||||
import net.minecraftforge.items.IItemHandler;
|
||||
|
||||
import appeng.api.AEApi;
|
||||
import appeng.api.config.Actionable;
|
||||
import appeng.api.config.FuzzyMode;
|
||||
@@ -76,459 +48,390 @@ import appeng.me.helpers.PlayerSource;
|
||||
import appeng.tile.misc.TilePaint;
|
||||
import appeng.util.LookDirection;
|
||||
import appeng.util.Platform;
|
||||
import net.minecraft.block.Block;
|
||||
import net.minecraft.block.state.IBlockState;
|
||||
import net.minecraft.client.util.ITooltipFlag;
|
||||
import net.minecraft.entity.Entity;
|
||||
import net.minecraft.entity.EntityLivingBase;
|
||||
import net.minecraft.entity.item.EntityItem;
|
||||
import net.minecraft.entity.passive.EntitySheep;
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.tileentity.TileEntity;
|
||||
import net.minecraft.util.*;
|
||||
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.world.World;
|
||||
import net.minecraftforge.fml.relauncher.Side;
|
||||
import net.minecraftforge.fml.relauncher.SideOnly;
|
||||
import net.minecraftforge.items.IItemHandler;
|
||||
|
||||
import javax.annotation.Nullable;
|
||||
import java.util.List;
|
||||
|
||||
|
||||
public class ToolMatterCannon extends AEBasePoweredItem implements IStorageCell<IAEItemStack>
|
||||
{
|
||||
public class ToolMatterCannon extends AEBasePoweredItem implements IStorageCell<IAEItemStack> {
|
||||
|
||||
public ToolMatterCannon()
|
||||
{
|
||||
super( AEConfig.instance().getMatterCannonBattery() );
|
||||
}
|
||||
public ToolMatterCannon() {
|
||||
super(AEConfig.instance().getMatterCannonBattery());
|
||||
}
|
||||
|
||||
@SideOnly( Side.CLIENT )
|
||||
@Override
|
||||
public void addCheckedInformation( final ItemStack stack, final World world, final List<String> lines, final ITooltipFlag advancedTooltips )
|
||||
{
|
||||
super.addCheckedInformation( stack, world, lines, advancedTooltips );
|
||||
@SideOnly(Side.CLIENT)
|
||||
@Override
|
||||
public void addCheckedInformation(final ItemStack stack, final World world, final List<String> lines, final ITooltipFlag advancedTooltips) {
|
||||
super.addCheckedInformation(stack, world, lines, advancedTooltips);
|
||||
|
||||
final ICellInventoryHandler<IAEItemStack> cdi = AEApi.instance()
|
||||
.registries()
|
||||
.cell()
|
||||
.getCellInventory( stack, null,
|
||||
AEApi.instance().storage().getStorageChannel( IItemStorageChannel.class ) );
|
||||
final ICellInventoryHandler<IAEItemStack> cdi = AEApi.instance()
|
||||
.registries()
|
||||
.cell()
|
||||
.getCellInventory(stack, null,
|
||||
AEApi.instance().storage().getStorageChannel(IItemStorageChannel.class));
|
||||
|
||||
AEApi.instance().client().addCellInformation( cdi, lines );
|
||||
}
|
||||
AEApi.instance().client().addCellInformation(cdi, lines);
|
||||
}
|
||||
|
||||
@Override
|
||||
public ActionResult<ItemStack> onItemRightClick( final World w, final EntityPlayer p, final @Nullable EnumHand hand )
|
||||
{
|
||||
if( this.getAECurrentPower( p.getHeldItem( hand ) ) > 1600 )
|
||||
{
|
||||
int shots = 1;
|
||||
@Override
|
||||
public ActionResult<ItemStack> onItemRightClick(final World w, final EntityPlayer p, final @Nullable EnumHand hand) {
|
||||
if (this.getAECurrentPower(p.getHeldItem(hand)) > 1600) {
|
||||
int shots = 1;
|
||||
|
||||
final CellUpgrades cu = (CellUpgrades) this.getUpgradesInventory( p.getHeldItem( hand ) );
|
||||
if( cu != null )
|
||||
{
|
||||
shots += cu.getInstalledUpgrades( Upgrades.SPEED );
|
||||
}
|
||||
final CellUpgrades cu = (CellUpgrades) this.getUpgradesInventory(p.getHeldItem(hand));
|
||||
if (cu != null) {
|
||||
shots += cu.getInstalledUpgrades(Upgrades.SPEED);
|
||||
}
|
||||
|
||||
final ICellInventoryHandler<IAEItemStack> inv = AEApi.instance()
|
||||
.registries()
|
||||
.cell()
|
||||
.getCellInventory( p.getHeldItem( hand ), null,
|
||||
AEApi.instance().storage().getStorageChannel( IItemStorageChannel.class ) );
|
||||
if( inv != null )
|
||||
{
|
||||
final IItemList<IAEItemStack> itemList = inv
|
||||
.getAvailableItems( AEApi.instance().storage().getStorageChannel( IItemStorageChannel.class ).createList() );
|
||||
IAEItemStack req = itemList.getFirstItem();
|
||||
if( req instanceof IAEItemStack )
|
||||
{
|
||||
shots = Math.min( shots, (int) req.getStackSize() );
|
||||
for( int sh = 0; sh < shots; sh++ )
|
||||
{
|
||||
IAEItemStack aeAmmo = req.copy();
|
||||
this.extractAEPower( p.getHeldItem( hand ), 1600, Actionable.MODULATE );
|
||||
final ICellInventoryHandler<IAEItemStack> inv = AEApi.instance()
|
||||
.registries()
|
||||
.cell()
|
||||
.getCellInventory(p.getHeldItem(hand), null,
|
||||
AEApi.instance().storage().getStorageChannel(IItemStorageChannel.class));
|
||||
if (inv != null) {
|
||||
final IItemList<IAEItemStack> itemList = inv
|
||||
.getAvailableItems(AEApi.instance().storage().getStorageChannel(IItemStorageChannel.class).createList());
|
||||
IAEItemStack req = itemList.getFirstItem();
|
||||
if (req instanceof IAEItemStack) {
|
||||
shots = Math.min(shots, (int) req.getStackSize());
|
||||
for (int sh = 0; sh < shots; sh++) {
|
||||
IAEItemStack aeAmmo = req.copy();
|
||||
this.extractAEPower(p.getHeldItem(hand), 1600, Actionable.MODULATE);
|
||||
|
||||
if( Platform.isClient() )
|
||||
{
|
||||
return new ActionResult<>( EnumActionResult.SUCCESS, p.getHeldItem( hand ) );
|
||||
}
|
||||
if (Platform.isClient()) {
|
||||
return new ActionResult<>(EnumActionResult.SUCCESS, p.getHeldItem(hand));
|
||||
}
|
||||
|
||||
aeAmmo.setStackSize( 1 );
|
||||
final ItemStack ammo = aeAmmo.createItemStack();
|
||||
if( ammo == null )
|
||||
{
|
||||
return new ActionResult<>( EnumActionResult.SUCCESS, p.getHeldItem( hand ) );
|
||||
}
|
||||
aeAmmo.setStackSize(1);
|
||||
final ItemStack ammo = aeAmmo.createItemStack();
|
||||
if (ammo == null) {
|
||||
return new ActionResult<>(EnumActionResult.SUCCESS, p.getHeldItem(hand));
|
||||
}
|
||||
|
||||
aeAmmo = inv.extractItems( aeAmmo, Actionable.MODULATE, new PlayerSource( p, null ) );
|
||||
if( aeAmmo == null )
|
||||
{
|
||||
return new ActionResult<>( EnumActionResult.SUCCESS, p.getHeldItem( hand ) );
|
||||
}
|
||||
aeAmmo = inv.extractItems(aeAmmo, Actionable.MODULATE, new PlayerSource(p, null));
|
||||
if (aeAmmo == null) {
|
||||
return new ActionResult<>(EnumActionResult.SUCCESS, p.getHeldItem(hand));
|
||||
}
|
||||
|
||||
final LookDirection dir = Platform.getPlayerRay( p, p.getEyeHeight() );
|
||||
final LookDirection dir = Platform.getPlayerRay(p, p.getEyeHeight());
|
||||
|
||||
final Vec3d Vec3d = dir.getA();
|
||||
final Vec3d Vec3d1 = dir.getB();
|
||||
final Vec3d direction = Vec3d1.subtract( Vec3d );
|
||||
direction.normalize();
|
||||
final Vec3d Vec3d = dir.getA();
|
||||
final Vec3d Vec3d1 = dir.getB();
|
||||
final Vec3d direction = Vec3d1.subtract(Vec3d);
|
||||
direction.normalize();
|
||||
|
||||
final double d0 = Vec3d.x;
|
||||
final double d1 = Vec3d.y;
|
||||
final double d2 = Vec3d.z;
|
||||
final double d0 = Vec3d.x;
|
||||
final double d1 = Vec3d.y;
|
||||
final double d2 = Vec3d.z;
|
||||
|
||||
final float penetration = AEApi.instance().registries().matterCannon().getPenetration( ammo ); // 196.96655f;
|
||||
if( penetration <= 0 )
|
||||
{
|
||||
final ItemStack type = aeAmmo.asItemStackRepresentation();
|
||||
if( type.getItem() instanceof ItemPaintBall )
|
||||
{
|
||||
this.shootPaintBalls( type, w, p, Vec3d, Vec3d1, direction, d0, d1, d2 );
|
||||
}
|
||||
return new ActionResult<>( EnumActionResult.SUCCESS, p.getHeldItem( hand ) );
|
||||
}
|
||||
else
|
||||
{
|
||||
this.standardAmmo( penetration, w, p, Vec3d, Vec3d1, direction, d0, d1, d2 );
|
||||
}
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
if( Platform.isServer() )
|
||||
{
|
||||
p.sendMessage( PlayerMessages.AmmoDepleted.get() );
|
||||
}
|
||||
return new ActionResult<>( EnumActionResult.SUCCESS, p.getHeldItem( hand ) );
|
||||
}
|
||||
}
|
||||
}
|
||||
return new ActionResult<>( EnumActionResult.FAIL, p.getHeldItem( hand ) );
|
||||
}
|
||||
final float penetration = AEApi.instance().registries().matterCannon().getPenetration(ammo); // 196.96655f;
|
||||
if (penetration <= 0) {
|
||||
final ItemStack type = aeAmmo.asItemStackRepresentation();
|
||||
if (type.getItem() instanceof ItemPaintBall) {
|
||||
this.shootPaintBalls(type, w, p, Vec3d, Vec3d1, direction, d0, d1, d2);
|
||||
}
|
||||
return new ActionResult<>(EnumActionResult.SUCCESS, p.getHeldItem(hand));
|
||||
} else {
|
||||
this.standardAmmo(penetration, w, p, Vec3d, Vec3d1, direction, d0, d1, d2);
|
||||
}
|
||||
}
|
||||
} else {
|
||||
if (Platform.isServer()) {
|
||||
p.sendMessage(PlayerMessages.AmmoDepleted.get());
|
||||
}
|
||||
return new ActionResult<>(EnumActionResult.SUCCESS, p.getHeldItem(hand));
|
||||
}
|
||||
}
|
||||
}
|
||||
return new ActionResult<>(EnumActionResult.FAIL, p.getHeldItem(hand));
|
||||
}
|
||||
|
||||
private void shootPaintBalls( final ItemStack type, final World w, final EntityPlayer p, final Vec3d Vec3d, final Vec3d Vec3d1, final Vec3d direction, final double d0, final double d1, final double d2 )
|
||||
{
|
||||
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 );
|
||||
private void shootPaintBalls(final ItemStack type, final World w, final EntityPlayer p, final Vec3d Vec3d, final Vec3d Vec3d1, final Vec3d direction, final double d0, final double d1, final double d2) {
|
||||
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;
|
||||
final List list = w.getEntitiesWithinAABBExcludingEntity( p, bb );
|
||||
double closest = 9999999.0D;
|
||||
Entity entity = null;
|
||||
final List list = w.getEntitiesWithinAABBExcludingEntity(p, bb);
|
||||
double closest = 9999999.0D;
|
||||
|
||||
for( int l = 0; l < list.size(); ++l )
|
||||
{
|
||||
final Entity entity1 = (Entity) list.get( l );
|
||||
for (int l = 0; l < list.size(); ++l) {
|
||||
final Entity entity1 = (Entity) list.get(l);
|
||||
|
||||
if( !entity1.isDead && entity1 != p && !( entity1 instanceof EntityItem ) )
|
||||
{
|
||||
if( entity1.isEntityAlive() )
|
||||
{
|
||||
// prevent killing / flying of mounts.
|
||||
if( entity1.isRidingOrBeingRiddenBy( p ) )
|
||||
{
|
||||
continue;
|
||||
}
|
||||
if (!entity1.isDead && entity1 != p && !(entity1 instanceof EntityItem)) {
|
||||
if (entity1.isEntityAlive()) {
|
||||
// prevent killing / flying of mounts.
|
||||
if (entity1.isRidingOrBeingRiddenBy(p)) {
|
||||
continue;
|
||||
}
|
||||
|
||||
final float f1 = 0.3F;
|
||||
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.getEntityBoundingBox().grow(f1, f1, f1);
|
||||
final RayTraceResult RayTraceResult = boundingBox.calculateIntercept(Vec3d, Vec3d1);
|
||||
|
||||
if( RayTraceResult != null )
|
||||
{
|
||||
final double nd = Vec3d.squareDistanceTo( RayTraceResult.hitVec );
|
||||
if (RayTraceResult != null) {
|
||||
final double nd = Vec3d.squareDistanceTo(RayTraceResult.hitVec);
|
||||
|
||||
if( nd < closest )
|
||||
{
|
||||
entity = entity1;
|
||||
closest = nd;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
if (nd < closest) {
|
||||
entity = entity1;
|
||||
closest = nd;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
RayTraceResult pos = w.rayTraceBlocks( Vec3d, Vec3d1, false );
|
||||
RayTraceResult pos = w.rayTraceBlocks(Vec3d, Vec3d1, false);
|
||||
|
||||
final Vec3d vec = new Vec3d( d0, d1, d2 );
|
||||
if( entity != null && pos != null && pos.hitVec.squareDistanceTo( vec ) > closest )
|
||||
{
|
||||
pos = new RayTraceResult( entity );
|
||||
}
|
||||
else if( entity != null && pos == null )
|
||||
{
|
||||
pos = new RayTraceResult( entity );
|
||||
}
|
||||
final Vec3d vec = new Vec3d(d0, d1, d2);
|
||||
if (entity != null && pos != null && pos.hitVec.squareDistanceTo(vec) > closest) {
|
||||
pos = new RayTraceResult(entity);
|
||||
} else if (entity != null && pos == null) {
|
||||
pos = new RayTraceResult(entity);
|
||||
}
|
||||
|
||||
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 ) ) );
|
||||
}
|
||||
catch( final Exception err )
|
||||
{
|
||||
AELog.debug( err );
|
||||
}
|
||||
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)));
|
||||
} catch (final Exception err) {
|
||||
AELog.debug(err);
|
||||
}
|
||||
|
||||
if( pos != null && type != null && type.getItem() instanceof ItemPaintBall )
|
||||
{
|
||||
final ItemPaintBall ipb = (ItemPaintBall) type.getItem();
|
||||
if (pos != null && type != null && type.getItem() instanceof ItemPaintBall) {
|
||||
final ItemPaintBall ipb = (ItemPaintBall) type.getItem();
|
||||
|
||||
final AEColor col = ipb.getColor( type );
|
||||
// boolean lit = ipb.isLumen( type );
|
||||
final AEColor col = ipb.getColor(type);
|
||||
// boolean lit = ipb.isLumen( type );
|
||||
|
||||
if( pos.typeOfHit == RayTraceResult.Type.ENTITY )
|
||||
{
|
||||
final int id = pos.entityHit.getEntityId();
|
||||
final PlayerColor marker = new PlayerColor( id, col, 20 * 30 );
|
||||
TickHandler.INSTANCE.getPlayerColors().put( id, marker );
|
||||
if (pos.typeOfHit == RayTraceResult.Type.ENTITY) {
|
||||
final int id = pos.entityHit.getEntityId();
|
||||
final PlayerColor marker = new PlayerColor(id, col, 20 * 30);
|
||||
TickHandler.INSTANCE.getPlayerColors().put(id, marker);
|
||||
|
||||
if( pos.entityHit instanceof EntitySheep )
|
||||
{
|
||||
final EntitySheep sh = (EntitySheep) pos.entityHit;
|
||||
sh.setFleeceColor( col.dye );
|
||||
}
|
||||
if (pos.entityHit instanceof EntitySheep) {
|
||||
final EntitySheep sh = (EntitySheep) pos.entityHit;
|
||||
sh.setFleeceColor(col.dye);
|
||||
}
|
||||
|
||||
pos.entityHit.attackEntityFrom( DamageSource.causePlayerDamage( p ), 0 );
|
||||
NetworkHandler.instance().sendToAll( marker.getPacket() );
|
||||
}
|
||||
else if( pos.typeOfHit == RayTraceResult.Type.BLOCK )
|
||||
{
|
||||
final EnumFacing side = pos.sideHit;
|
||||
final BlockPos hitPos = pos.getBlockPos().offset( side );
|
||||
pos.entityHit.attackEntityFrom(DamageSource.causePlayerDamage(p), 0);
|
||||
NetworkHandler.instance().sendToAll(marker.getPacket());
|
||||
} else if (pos.typeOfHit == RayTraceResult.Type.BLOCK) {
|
||||
final EnumFacing side = pos.sideHit;
|
||||
final BlockPos hitPos = pos.getBlockPos().offset(side);
|
||||
|
||||
if( !Platform.hasPermissions( new DimensionalCoord( w, hitPos ), p ) )
|
||||
{
|
||||
return;
|
||||
}
|
||||
if (!Platform.hasPermissions(new DimensionalCoord(w, hitPos), p)) {
|
||||
return;
|
||||
}
|
||||
|
||||
final Block whatsThere = w.getBlockState( hitPos ).getBlock();
|
||||
if( whatsThere.isReplaceable( w, hitPos ) && w.isAirBlock( hitPos ) )
|
||||
{
|
||||
AEApi.instance().definitions().blocks().paint().maybeBlock().ifPresent( paintBlock ->
|
||||
{
|
||||
w.setBlockState( hitPos, paintBlock.getDefaultState(), 3 );
|
||||
} );
|
||||
}
|
||||
final Block whatsThere = w.getBlockState(hitPos).getBlock();
|
||||
if (whatsThere.isReplaceable(w, hitPos) && w.isAirBlock(hitPos)) {
|
||||
AEApi.instance().definitions().blocks().paint().maybeBlock().ifPresent(paintBlock ->
|
||||
{
|
||||
w.setBlockState(hitPos, paintBlock.getDefaultState(), 3);
|
||||
});
|
||||
}
|
||||
|
||||
final TileEntity te = w.getTileEntity( hitPos );
|
||||
if( te instanceof TilePaint )
|
||||
{
|
||||
final Vec3d hp = pos.hitVec.subtract( hitPos.getX(), hitPos.getY(), hitPos.getZ() );
|
||||
( (TilePaint) te ).addBlot( type, side.getOpposite(), hp );
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
final TileEntity te = w.getTileEntity(hitPos);
|
||||
if (te instanceof TilePaint) {
|
||||
final Vec3d hp = pos.hitVec.subtract(hitPos.getX(), hitPos.getY(), hitPos.getZ());
|
||||
((TilePaint) te).addBlot(type, side.getOpposite(), hp);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private void standardAmmo( float penetration, final World w, final EntityPlayer p, final Vec3d Vec3d, final Vec3d Vec3d1, final Vec3d direction, final double d0, final double d1, final double d2 )
|
||||
{
|
||||
boolean hasDestroyed = true;
|
||||
while( penetration > 0 && hasDestroyed )
|
||||
{
|
||||
hasDestroyed = false;
|
||||
private void standardAmmo(float penetration, final World w, final EntityPlayer p, final Vec3d Vec3d, final Vec3d Vec3d1, final Vec3d direction, final double d0, final double d1, final double d2) {
|
||||
boolean hasDestroyed = true;
|
||||
while (penetration > 0 && hasDestroyed) {
|
||||
hasDestroyed = false;
|
||||
|
||||
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 );
|
||||
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;
|
||||
final List list = w.getEntitiesWithinAABBExcludingEntity( p, bb );
|
||||
double closest = 9999999.0D;
|
||||
Entity entity = null;
|
||||
final List list = w.getEntitiesWithinAABBExcludingEntity(p, bb);
|
||||
double closest = 9999999.0D;
|
||||
|
||||
for( int l = 0; l < list.size(); ++l )
|
||||
{
|
||||
final Entity entity1 = (Entity) list.get( l );
|
||||
for (int l = 0; l < list.size(); ++l) {
|
||||
final Entity entity1 = (Entity) list.get(l);
|
||||
|
||||
if( !entity1.isDead && entity1 != p && !( entity1 instanceof EntityItem ) )
|
||||
{
|
||||
if( entity1.isEntityAlive() )
|
||||
{
|
||||
// prevent killing / flying of mounts.
|
||||
if( entity1.isRidingOrBeingRiddenBy( p ) )
|
||||
{
|
||||
continue;
|
||||
}
|
||||
if (!entity1.isDead && entity1 != p && !(entity1 instanceof EntityItem)) {
|
||||
if (entity1.isEntityAlive()) {
|
||||
// prevent killing / flying of mounts.
|
||||
if (entity1.isRidingOrBeingRiddenBy(p)) {
|
||||
continue;
|
||||
}
|
||||
|
||||
final float f1 = 0.3F;
|
||||
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.getEntityBoundingBox().grow(f1, f1, f1);
|
||||
final RayTraceResult RayTraceResult = boundingBox.calculateIntercept(Vec3d, Vec3d1);
|
||||
|
||||
if( RayTraceResult != null )
|
||||
{
|
||||
final double nd = Vec3d.squareDistanceTo( RayTraceResult.hitVec );
|
||||
if (RayTraceResult != null) {
|
||||
final double nd = Vec3d.squareDistanceTo(RayTraceResult.hitVec);
|
||||
|
||||
if( nd < closest )
|
||||
{
|
||||
entity = entity1;
|
||||
closest = nd;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
if (nd < closest) {
|
||||
entity = entity1;
|
||||
closest = nd;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
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 )
|
||||
{
|
||||
pos = new RayTraceResult( entity );
|
||||
}
|
||||
else if( entity != null && pos == null )
|
||||
{
|
||||
pos = new RayTraceResult( entity );
|
||||
}
|
||||
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) {
|
||||
pos = new RayTraceResult(entity);
|
||||
} else if (entity != null && pos == null) {
|
||||
pos = new RayTraceResult(entity);
|
||||
}
|
||||
|
||||
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 ) ) );
|
||||
}
|
||||
catch( final Exception err )
|
||||
{
|
||||
AELog.debug( err );
|
||||
}
|
||||
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)));
|
||||
} catch (final Exception err) {
|
||||
AELog.debug(err);
|
||||
}
|
||||
|
||||
if( pos != null )
|
||||
{
|
||||
final DamageSource dmgSrc = DamageSource.causePlayerDamage( p );
|
||||
dmgSrc.damageType = "matter_cannon";
|
||||
if (pos != null) {
|
||||
final DamageSource dmgSrc = DamageSource.causePlayerDamage(p);
|
||||
dmgSrc.damageType = "matter_cannon";
|
||||
|
||||
if( pos.typeOfHit == RayTraceResult.Type.ENTITY )
|
||||
{
|
||||
final int dmg = (int) Math.ceil( penetration / 20.0f );
|
||||
if( pos.entityHit instanceof EntityLivingBase )
|
||||
{
|
||||
final EntityLivingBase el = (EntityLivingBase) pos.entityHit;
|
||||
penetration -= dmg;
|
||||
el.knockBack( p, 0, -direction.x, -direction.z );
|
||||
// el.knockBack( p, 0, Vec3d.x,
|
||||
// Vec3d.z );
|
||||
el.attackEntityFrom( dmgSrc, dmg );
|
||||
if( !el.isEntityAlive() )
|
||||
{
|
||||
hasDestroyed = true;
|
||||
}
|
||||
}
|
||||
else if( pos.entityHit instanceof EntityItem )
|
||||
{
|
||||
hasDestroyed = true;
|
||||
pos.entityHit.setDead();
|
||||
}
|
||||
else if( pos.entityHit.attackEntityFrom( dmgSrc, dmg ) )
|
||||
{
|
||||
hasDestroyed = pos.entityHit.isEntityAlive();
|
||||
}
|
||||
}
|
||||
else if( pos.typeOfHit == RayTraceResult.Type.BLOCK )
|
||||
{
|
||||
if( !AEConfig.instance().isFeatureEnabled( AEFeature.MASS_CANNON_BLOCK_DAMAGE ) )
|
||||
{
|
||||
penetration = 0;
|
||||
}
|
||||
else
|
||||
{
|
||||
final IBlockState bs = w.getBlockState( pos.getBlockPos() );
|
||||
// int meta = w.getBlockMetadata(
|
||||
// pos.blockX, pos.blockY, pos.blockZ );
|
||||
if (pos.typeOfHit == RayTraceResult.Type.ENTITY) {
|
||||
final int dmg = (int) Math.ceil(penetration / 20.0f);
|
||||
if (pos.entityHit instanceof EntityLivingBase) {
|
||||
final EntityLivingBase el = (EntityLivingBase) pos.entityHit;
|
||||
penetration -= dmg;
|
||||
el.knockBack(p, 0, -direction.x, -direction.z);
|
||||
// el.knockBack( p, 0, Vec3d.x,
|
||||
// Vec3d.z );
|
||||
el.attackEntityFrom(dmgSrc, dmg);
|
||||
if (!el.isEntityAlive()) {
|
||||
hasDestroyed = true;
|
||||
}
|
||||
} else if (pos.entityHit instanceof EntityItem) {
|
||||
hasDestroyed = true;
|
||||
pos.entityHit.setDead();
|
||||
} else if (pos.entityHit.attackEntityFrom(dmgSrc, dmg)) {
|
||||
hasDestroyed = pos.entityHit.isEntityAlive();
|
||||
}
|
||||
} else if (pos.typeOfHit == RayTraceResult.Type.BLOCK) {
|
||||
if (!AEConfig.instance().isFeatureEnabled(AEFeature.MASS_CANNON_BLOCK_DAMAGE)) {
|
||||
penetration = 0;
|
||||
} else {
|
||||
final IBlockState bs = w.getBlockState(pos.getBlockPos());
|
||||
// int meta = w.getBlockMetadata(
|
||||
// pos.blockX, pos.blockY, pos.blockZ );
|
||||
|
||||
final float hardness = bs.getBlockHardness( w, pos.getBlockPos() ) * 9.0f;
|
||||
if( hardness >= 0.0 )
|
||||
{
|
||||
if( penetration > hardness && Platform.hasPermissions( new DimensionalCoord( w, pos.getBlockPos() ), p ) )
|
||||
{
|
||||
hasDestroyed = true;
|
||||
penetration -= hardness;
|
||||
penetration *= 0.60;
|
||||
w.destroyBlock( pos.getBlockPos(), true );
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
final float hardness = bs.getBlockHardness(w, pos.getBlockPos()) * 9.0f;
|
||||
if (hardness >= 0.0) {
|
||||
if (penetration > hardness && Platform.hasPermissions(new DimensionalCoord(w, pos.getBlockPos()), p)) {
|
||||
hasDestroyed = true;
|
||||
penetration -= hardness;
|
||||
penetration *= 0.60;
|
||||
w.destroyBlock(pos.getBlockPos(), true);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isEditable( final ItemStack is )
|
||||
{
|
||||
return true;
|
||||
}
|
||||
@Override
|
||||
public boolean isEditable(final ItemStack is) {
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public IItemHandler getUpgradesInventory( final ItemStack is )
|
||||
{
|
||||
return new CellUpgrades( is, 4 );
|
||||
}
|
||||
@Override
|
||||
public IItemHandler getUpgradesInventory(final ItemStack is) {
|
||||
return new CellUpgrades(is, 4);
|
||||
}
|
||||
|
||||
@Override
|
||||
public IItemHandler getConfigInventory( final ItemStack is )
|
||||
{
|
||||
return new CellConfig( is );
|
||||
}
|
||||
@Override
|
||||
public IItemHandler getConfigInventory(final ItemStack is) {
|
||||
return new CellConfig(is);
|
||||
}
|
||||
|
||||
@Override
|
||||
public FuzzyMode getFuzzyMode( final ItemStack is )
|
||||
{
|
||||
final String fz = Platform.openNbtData( is ).getString( "FuzzyMode" );
|
||||
try
|
||||
{
|
||||
return FuzzyMode.valueOf( fz );
|
||||
}
|
||||
catch( final Throwable t )
|
||||
{
|
||||
return FuzzyMode.IGNORE_ALL;
|
||||
}
|
||||
}
|
||||
@Override
|
||||
public FuzzyMode getFuzzyMode(final ItemStack is) {
|
||||
final String fz = Platform.openNbtData(is).getString("FuzzyMode");
|
||||
try {
|
||||
return FuzzyMode.valueOf(fz);
|
||||
} catch (final Throwable t) {
|
||||
return FuzzyMode.IGNORE_ALL;
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setFuzzyMode( final ItemStack is, final FuzzyMode fzMode )
|
||||
{
|
||||
Platform.openNbtData( is ).setString( "FuzzyMode", fzMode.name() );
|
||||
}
|
||||
@Override
|
||||
public void setFuzzyMode(final ItemStack is, final FuzzyMode fzMode) {
|
||||
Platform.openNbtData(is).setString("FuzzyMode", fzMode.name());
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getBytes( final ItemStack cellItem )
|
||||
{
|
||||
return 512;
|
||||
}
|
||||
@Override
|
||||
public int getBytes(final ItemStack cellItem) {
|
||||
return 512;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getBytesPerType( final ItemStack cellItem )
|
||||
{
|
||||
return 8;
|
||||
}
|
||||
@Override
|
||||
public int getBytesPerType(final ItemStack cellItem) {
|
||||
return 8;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getTotalTypes( final ItemStack cellItem )
|
||||
{
|
||||
return 1;
|
||||
}
|
||||
@Override
|
||||
public int getTotalTypes(final ItemStack cellItem) {
|
||||
return 1;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isBlackListed( final ItemStack cellItem, final IAEItemStack requestedAddition )
|
||||
{
|
||||
final float pen = AEApi.instance().registries().matterCannon().getPenetration( requestedAddition.createItemStack() );
|
||||
if( pen > 0 )
|
||||
{
|
||||
return false;
|
||||
}
|
||||
@Override
|
||||
public boolean isBlackListed(final ItemStack cellItem, final IAEItemStack requestedAddition) {
|
||||
final float pen = AEApi.instance().registries().matterCannon().getPenetration(requestedAddition.createItemStack());
|
||||
if (pen > 0) {
|
||||
return false;
|
||||
}
|
||||
|
||||
if( requestedAddition.getItem() instanceof ItemPaintBall )
|
||||
{
|
||||
return false;
|
||||
}
|
||||
return !(requestedAddition.getItem() instanceof ItemPaintBall);
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
@Override
|
||||
public boolean storableInStorageCell() {
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean storableInStorageCell()
|
||||
{
|
||||
return true;
|
||||
}
|
||||
@Override
|
||||
public boolean isStorageCell(final ItemStack i) {
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isStorageCell( final ItemStack i )
|
||||
{
|
||||
return true;
|
||||
}
|
||||
@Override
|
||||
public double getIdleDrain() {
|
||||
return 0.5;
|
||||
}
|
||||
|
||||
@Override
|
||||
public double getIdleDrain()
|
||||
{
|
||||
return 0.5;
|
||||
}
|
||||
|
||||
@Override
|
||||
public IStorageChannel<IAEItemStack> getChannel()
|
||||
{
|
||||
return AEApi.instance().storage().getStorageChannel( IItemStorageChannel.class );
|
||||
}
|
||||
@Override
|
||||
public IStorageChannel<IAEItemStack> getChannel() {
|
||||
return AEApi.instance().storage().getStorageChannel(IItemStorageChannel.class);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -19,21 +19,6 @@
|
||||
package appeng.items.tools.powered;
|
||||
|
||||
|
||||
import java.util.List;
|
||||
import java.util.Set;
|
||||
|
||||
import net.minecraft.client.util.ITooltipFlag;
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.util.ActionResult;
|
||||
import net.minecraft.util.EnumActionResult;
|
||||
import net.minecraft.util.EnumHand;
|
||||
import net.minecraft.util.math.BlockPos;
|
||||
import net.minecraft.world.World;
|
||||
import net.minecraftforge.fml.relauncher.Side;
|
||||
import net.minecraftforge.fml.relauncher.SideOnly;
|
||||
import net.minecraftforge.items.IItemHandler;
|
||||
|
||||
import appeng.api.AEApi;
|
||||
import appeng.api.config.FuzzyMode;
|
||||
import appeng.api.implementations.guiobjects.IGuiItem;
|
||||
@@ -53,145 +38,135 @@ import appeng.items.contents.CellUpgrades;
|
||||
import appeng.items.contents.PortableCellViewer;
|
||||
import appeng.items.tools.powered.powersink.AEBasePoweredItem;
|
||||
import appeng.util.Platform;
|
||||
import net.minecraft.client.util.ITooltipFlag;
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.util.ActionResult;
|
||||
import net.minecraft.util.EnumActionResult;
|
||||
import net.minecraft.util.EnumHand;
|
||||
import net.minecraft.util.math.BlockPos;
|
||||
import net.minecraft.world.World;
|
||||
import net.minecraftforge.fml.relauncher.Side;
|
||||
import net.minecraftforge.fml.relauncher.SideOnly;
|
||||
import net.minecraftforge.items.IItemHandler;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.Set;
|
||||
|
||||
|
||||
public class ToolPortableCell extends AEBasePoweredItem implements IStorageCell<IAEItemStack>, IGuiItem, IItemGroup
|
||||
{
|
||||
public ToolPortableCell()
|
||||
{
|
||||
super( AEConfig.instance().getPortableCellBattery() );
|
||||
}
|
||||
public class ToolPortableCell extends AEBasePoweredItem implements IStorageCell<IAEItemStack>, IGuiItem, IItemGroup {
|
||||
public ToolPortableCell() {
|
||||
super(AEConfig.instance().getPortableCellBattery());
|
||||
}
|
||||
|
||||
@Override
|
||||
public ActionResult<ItemStack> onItemRightClick( final World w, final EntityPlayer player, final EnumHand hand )
|
||||
{
|
||||
Platform.openGUI( player, null, AEPartLocation.INTERNAL, GuiBridge.GUI_PORTABLE_CELL );
|
||||
return new ActionResult<>( EnumActionResult.SUCCESS, player.getHeldItem( hand ) );
|
||||
}
|
||||
@Override
|
||||
public ActionResult<ItemStack> onItemRightClick(final World w, final EntityPlayer player, final EnumHand hand) {
|
||||
Platform.openGUI(player, null, AEPartLocation.INTERNAL, GuiBridge.GUI_PORTABLE_CELL);
|
||||
return new ActionResult<>(EnumActionResult.SUCCESS, player.getHeldItem(hand));
|
||||
}
|
||||
|
||||
@SideOnly( Side.CLIENT )
|
||||
@Override
|
||||
public boolean isFull3D()
|
||||
{
|
||||
return false;
|
||||
}
|
||||
@SideOnly(Side.CLIENT)
|
||||
@Override
|
||||
public boolean isFull3D() {
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
@SideOnly( Side.CLIENT )
|
||||
public void addCheckedInformation( final ItemStack stack, final World world, final List<String> lines, final ITooltipFlag advancedTooltips )
|
||||
{
|
||||
super.addCheckedInformation( stack, world, lines, advancedTooltips );
|
||||
@Override
|
||||
@SideOnly(Side.CLIENT)
|
||||
public void addCheckedInformation(final ItemStack stack, final World world, final List<String> lines, final ITooltipFlag advancedTooltips) {
|
||||
super.addCheckedInformation(stack, world, lines, advancedTooltips);
|
||||
|
||||
final ICellInventoryHandler<IAEItemStack> cdi = AEApi.instance()
|
||||
.registries()
|
||||
.cell()
|
||||
.getCellInventory( stack, null,
|
||||
AEApi.instance().storage().getStorageChannel( IItemStorageChannel.class ) );
|
||||
final ICellInventoryHandler<IAEItemStack> cdi = AEApi.instance()
|
||||
.registries()
|
||||
.cell()
|
||||
.getCellInventory(stack, null,
|
||||
AEApi.instance().storage().getStorageChannel(IItemStorageChannel.class));
|
||||
|
||||
AEApi.instance().client().addCellInformation( cdi, lines );
|
||||
}
|
||||
AEApi.instance().client().addCellInformation(cdi, lines);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getBytes( final ItemStack cellItem )
|
||||
{
|
||||
return 512;
|
||||
}
|
||||
@Override
|
||||
public int getBytes(final ItemStack cellItem) {
|
||||
return 512;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getBytesPerType( final ItemStack cellItem )
|
||||
{
|
||||
return 8;
|
||||
}
|
||||
@Override
|
||||
public int getBytesPerType(final ItemStack cellItem) {
|
||||
return 8;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getTotalTypes( final ItemStack cellItem )
|
||||
{
|
||||
return 27;
|
||||
}
|
||||
@Override
|
||||
public int getTotalTypes(final ItemStack cellItem) {
|
||||
return 27;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isBlackListed( final ItemStack cellItem, final IAEItemStack requestedAddition )
|
||||
{
|
||||
return false;
|
||||
}
|
||||
@Override
|
||||
public boolean isBlackListed(final ItemStack cellItem, final IAEItemStack requestedAddition) {
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean storableInStorageCell()
|
||||
{
|
||||
return false;
|
||||
}
|
||||
@Override
|
||||
public boolean storableInStorageCell() {
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isStorageCell( final ItemStack i )
|
||||
{
|
||||
return true;
|
||||
}
|
||||
@Override
|
||||
public boolean isStorageCell(final ItemStack i) {
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public double getIdleDrain()
|
||||
{
|
||||
return 0.5;
|
||||
}
|
||||
@Override
|
||||
public double getIdleDrain() {
|
||||
return 0.5;
|
||||
}
|
||||
|
||||
@Override
|
||||
public IStorageChannel<IAEItemStack> getChannel()
|
||||
{
|
||||
return AEApi.instance().storage().getStorageChannel( IItemStorageChannel.class );
|
||||
}
|
||||
@Override
|
||||
public IStorageChannel<IAEItemStack> getChannel() {
|
||||
return AEApi.instance().storage().getStorageChannel(IItemStorageChannel.class);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getUnlocalizedGroupName( final Set<ItemStack> others, final ItemStack is )
|
||||
{
|
||||
return GuiText.StorageCells.getUnlocalized();
|
||||
}
|
||||
@Override
|
||||
public String getUnlocalizedGroupName(final Set<ItemStack> others, final ItemStack is) {
|
||||
return GuiText.StorageCells.getUnlocalized();
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isEditable( final ItemStack is )
|
||||
{
|
||||
return true;
|
||||
}
|
||||
@Override
|
||||
public boolean isEditable(final ItemStack is) {
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public IItemHandler getUpgradesInventory( final ItemStack is )
|
||||
{
|
||||
return new CellUpgrades( is, 2 );
|
||||
}
|
||||
@Override
|
||||
public IItemHandler getUpgradesInventory(final ItemStack is) {
|
||||
return new CellUpgrades(is, 2);
|
||||
}
|
||||
|
||||
@Override
|
||||
public IItemHandler getConfigInventory( final ItemStack is )
|
||||
{
|
||||
return new CellConfig( is );
|
||||
}
|
||||
@Override
|
||||
public IItemHandler getConfigInventory(final ItemStack is) {
|
||||
return new CellConfig(is);
|
||||
}
|
||||
|
||||
@Override
|
||||
public FuzzyMode getFuzzyMode( final ItemStack is )
|
||||
{
|
||||
final String fz = Platform.openNbtData( is ).getString( "FuzzyMode" );
|
||||
try
|
||||
{
|
||||
return FuzzyMode.valueOf( fz );
|
||||
}
|
||||
catch( final Throwable t )
|
||||
{
|
||||
return FuzzyMode.IGNORE_ALL;
|
||||
}
|
||||
}
|
||||
@Override
|
||||
public FuzzyMode getFuzzyMode(final ItemStack is) {
|
||||
final String fz = Platform.openNbtData(is).getString("FuzzyMode");
|
||||
try {
|
||||
return FuzzyMode.valueOf(fz);
|
||||
} catch (final Throwable t) {
|
||||
return FuzzyMode.IGNORE_ALL;
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setFuzzyMode( final ItemStack is, final FuzzyMode fzMode )
|
||||
{
|
||||
Platform.openNbtData( is ).setString( "FuzzyMode", fzMode.name() );
|
||||
}
|
||||
@Override
|
||||
public void setFuzzyMode(final ItemStack is, final FuzzyMode fzMode) {
|
||||
Platform.openNbtData(is).setString("FuzzyMode", fzMode.name());
|
||||
}
|
||||
|
||||
@Override
|
||||
public IGuiItemObject getGuiObject( final ItemStack is, final World w, final BlockPos pos )
|
||||
{
|
||||
return new PortableCellViewer( is, pos.getX() );
|
||||
}
|
||||
@Override
|
||||
public IGuiItemObject getGuiObject(final ItemStack is, final World w, final BlockPos pos) {
|
||||
return new PortableCellViewer(is, pos.getX());
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean shouldCauseReequipAnimation( ItemStack oldStack, ItemStack newStack, boolean slotChanged )
|
||||
{
|
||||
return slotChanged;
|
||||
}
|
||||
@Override
|
||||
public boolean shouldCauseReequipAnimation(ItemStack oldStack, ItemStack newStack, boolean slotChanged) {
|
||||
return slotChanged;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -19,8 +19,15 @@
|
||||
package appeng.items.tools.powered;
|
||||
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import appeng.api.AEApi;
|
||||
import appeng.api.config.*;
|
||||
import appeng.api.features.IWirelessTermHandler;
|
||||
import appeng.api.util.IConfigManager;
|
||||
import appeng.core.AEConfig;
|
||||
import appeng.core.localization.GuiText;
|
||||
import appeng.items.tools.powered.powersink.AEBasePoweredItem;
|
||||
import appeng.util.ConfigManager;
|
||||
import appeng.util.Platform;
|
||||
import net.minecraft.client.util.ITooltipFlag;
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.item.ItemStack;
|
||||
@@ -33,125 +40,94 @@ import net.minecraft.world.World;
|
||||
import net.minecraftforge.fml.relauncher.Side;
|
||||
import net.minecraftforge.fml.relauncher.SideOnly;
|
||||
|
||||
import appeng.api.AEApi;
|
||||
import appeng.api.config.Actionable;
|
||||
import appeng.api.config.Settings;
|
||||
import appeng.api.config.SortDir;
|
||||
import appeng.api.config.SortOrder;
|
||||
import appeng.api.config.ViewItems;
|
||||
import appeng.api.features.IWirelessTermHandler;
|
||||
import appeng.api.util.IConfigManager;
|
||||
import appeng.core.AEConfig;
|
||||
import appeng.core.localization.GuiText;
|
||||
import appeng.items.tools.powered.powersink.AEBasePoweredItem;
|
||||
import appeng.util.ConfigManager;
|
||||
import appeng.util.Platform;
|
||||
import java.util.List;
|
||||
|
||||
|
||||
public class ToolWirelessTerminal extends AEBasePoweredItem implements IWirelessTermHandler
|
||||
{
|
||||
public class ToolWirelessTerminal extends AEBasePoweredItem implements IWirelessTermHandler {
|
||||
|
||||
public ToolWirelessTerminal()
|
||||
{
|
||||
super( AEConfig.instance().getWirelessTerminalBattery() );
|
||||
}
|
||||
public ToolWirelessTerminal() {
|
||||
super(AEConfig.instance().getWirelessTerminalBattery());
|
||||
}
|
||||
|
||||
@Override
|
||||
public ActionResult<ItemStack> onItemRightClick( final World w, final EntityPlayer player, final EnumHand hand )
|
||||
{
|
||||
AEApi.instance().registries().wireless().openWirelessTerminalGui( player.getHeldItem( hand ), w, player );
|
||||
return new ActionResult<>( EnumActionResult.SUCCESS, player.getHeldItem( hand ) );
|
||||
}
|
||||
@Override
|
||||
public ActionResult<ItemStack> onItemRightClick(final World w, final EntityPlayer player, final EnumHand hand) {
|
||||
AEApi.instance().registries().wireless().openWirelessTerminalGui(player.getHeldItem(hand), w, player);
|
||||
return new ActionResult<>(EnumActionResult.SUCCESS, player.getHeldItem(hand));
|
||||
}
|
||||
|
||||
@SideOnly( Side.CLIENT )
|
||||
@Override
|
||||
public boolean isFull3D()
|
||||
{
|
||||
return false;
|
||||
}
|
||||
@SideOnly(Side.CLIENT)
|
||||
@Override
|
||||
public boolean isFull3D() {
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
@SideOnly( Side.CLIENT )
|
||||
public void addCheckedInformation( final ItemStack stack, final World world, final List<String> lines, final ITooltipFlag advancedTooltips )
|
||||
{
|
||||
super.addCheckedInformation( stack, world, lines, advancedTooltips );
|
||||
@Override
|
||||
@SideOnly(Side.CLIENT)
|
||||
public void addCheckedInformation(final ItemStack stack, final World world, final List<String> lines, final ITooltipFlag advancedTooltips) {
|
||||
super.addCheckedInformation(stack, world, lines, advancedTooltips);
|
||||
|
||||
if( stack.hasTagCompound() )
|
||||
{
|
||||
final NBTTagCompound tag = Platform.openNbtData( stack );
|
||||
if( tag != null )
|
||||
{
|
||||
final String encKey = tag.getString( "encryptionKey" );
|
||||
if (stack.hasTagCompound()) {
|
||||
final NBTTagCompound tag = Platform.openNbtData(stack);
|
||||
if (tag != null) {
|
||||
final String encKey = tag.getString("encryptionKey");
|
||||
|
||||
if( encKey == null || encKey.isEmpty() )
|
||||
{
|
||||
lines.add( GuiText.Unlinked.getLocal() );
|
||||
}
|
||||
else
|
||||
{
|
||||
lines.add( GuiText.Linked.getLocal() );
|
||||
}
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
lines.add( I18n.translateToLocal( "AppEng.GuiITooltip.Unlinked" ) );
|
||||
}
|
||||
}
|
||||
if (encKey == null || encKey.isEmpty()) {
|
||||
lines.add(GuiText.Unlinked.getLocal());
|
||||
} else {
|
||||
lines.add(GuiText.Linked.getLocal());
|
||||
}
|
||||
}
|
||||
} else {
|
||||
lines.add(I18n.translateToLocal("AppEng.GuiITooltip.Unlinked"));
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean canHandle( final ItemStack is )
|
||||
{
|
||||
return AEApi.instance().definitions().items().wirelessTerminal().isSameAs( is );
|
||||
}
|
||||
@Override
|
||||
public boolean canHandle(final ItemStack is) {
|
||||
return AEApi.instance().definitions().items().wirelessTerminal().isSameAs(is);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean usePower( final EntityPlayer player, final double amount, final ItemStack is )
|
||||
{
|
||||
return this.extractAEPower( is, amount, Actionable.MODULATE ) >= amount - 0.5;
|
||||
}
|
||||
@Override
|
||||
public boolean usePower(final EntityPlayer player, final double amount, final ItemStack is) {
|
||||
return this.extractAEPower(is, amount, Actionable.MODULATE) >= amount - 0.5;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean hasPower( final EntityPlayer player, final double amt, final ItemStack is )
|
||||
{
|
||||
return this.getAECurrentPower( is ) >= amt;
|
||||
}
|
||||
@Override
|
||||
public boolean hasPower(final EntityPlayer player, final double amt, final ItemStack is) {
|
||||
return this.getAECurrentPower(is) >= amt;
|
||||
}
|
||||
|
||||
@Override
|
||||
public IConfigManager getConfigManager( final ItemStack target )
|
||||
{
|
||||
final ConfigManager out = new ConfigManager( ( manager, settingName, newValue ) ->
|
||||
{
|
||||
final NBTTagCompound data = Platform.openNbtData( target );
|
||||
manager.writeToNBT( data );
|
||||
} );
|
||||
@Override
|
||||
public IConfigManager getConfigManager(final ItemStack target) {
|
||||
final ConfigManager out = new ConfigManager((manager, settingName, newValue) ->
|
||||
{
|
||||
final NBTTagCompound data = Platform.openNbtData(target);
|
||||
manager.writeToNBT(data);
|
||||
});
|
||||
|
||||
out.registerSetting( Settings.SORT_BY, SortOrder.NAME );
|
||||
out.registerSetting( Settings.VIEW_MODE, ViewItems.ALL );
|
||||
out.registerSetting( Settings.SORT_DIRECTION, SortDir.ASCENDING );
|
||||
out.registerSetting(Settings.SORT_BY, SortOrder.NAME);
|
||||
out.registerSetting(Settings.VIEW_MODE, ViewItems.ALL);
|
||||
out.registerSetting(Settings.SORT_DIRECTION, SortDir.ASCENDING);
|
||||
|
||||
out.readFromNBT( Platform.openNbtData( target ).copy() );
|
||||
return out;
|
||||
}
|
||||
out.readFromNBT(Platform.openNbtData(target).copy());
|
||||
return out;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getEncryptionKey( final ItemStack item )
|
||||
{
|
||||
final NBTTagCompound tag = Platform.openNbtData( item );
|
||||
return tag.getString( "encryptionKey" );
|
||||
}
|
||||
@Override
|
||||
public String getEncryptionKey(final ItemStack item) {
|
||||
final NBTTagCompound tag = Platform.openNbtData(item);
|
||||
return tag.getString("encryptionKey");
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setEncryptionKey( final ItemStack item, final String encKey, final String name )
|
||||
{
|
||||
final NBTTagCompound tag = Platform.openNbtData( item );
|
||||
tag.setString( "encryptionKey", encKey );
|
||||
tag.setString( "name", name );
|
||||
}
|
||||
@Override
|
||||
public void setEncryptionKey(final ItemStack item, final String encKey, final String name) {
|
||||
final NBTTagCompound tag = Platform.openNbtData(item);
|
||||
tag.setString("encryptionKey", encKey);
|
||||
tag.setString("name", name);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean shouldCauseReequipAnimation( ItemStack oldStack, ItemStack newStack, boolean slotChanged )
|
||||
{
|
||||
return slotChanged;
|
||||
}
|
||||
@Override
|
||||
public boolean shouldCauseReequipAnimation(ItemStack oldStack, ItemStack newStack, boolean slotChanged) {
|
||||
return slotChanged;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -19,9 +19,13 @@
|
||||
package appeng.items.tools.powered.powersink;
|
||||
|
||||
|
||||
import java.text.MessageFormat;
|
||||
import java.util.List;
|
||||
|
||||
import appeng.api.config.AccessRestriction;
|
||||
import appeng.api.config.Actionable;
|
||||
import appeng.api.config.PowerUnits;
|
||||
import appeng.api.implementations.items.IAEItemPowerStorage;
|
||||
import appeng.core.localization.GuiText;
|
||||
import appeng.items.AEBaseItem;
|
||||
import appeng.util.Platform;
|
||||
import net.minecraft.client.util.ITooltipFlag;
|
||||
import net.minecraft.creativetab.CreativeTabs;
|
||||
import net.minecraft.item.ItemStack;
|
||||
@@ -32,151 +36,128 @@ import net.minecraftforge.common.capabilities.ICapabilityProvider;
|
||||
import net.minecraftforge.fml.relauncher.Side;
|
||||
import net.minecraftforge.fml.relauncher.SideOnly;
|
||||
|
||||
import appeng.api.config.AccessRestriction;
|
||||
import appeng.api.config.Actionable;
|
||||
import appeng.api.config.PowerUnits;
|
||||
import appeng.api.implementations.items.IAEItemPowerStorage;
|
||||
import appeng.core.localization.GuiText;
|
||||
import appeng.items.AEBaseItem;
|
||||
import appeng.util.Platform;
|
||||
import java.text.MessageFormat;
|
||||
import java.util.List;
|
||||
|
||||
|
||||
public abstract class AEBasePoweredItem extends AEBaseItem implements IAEItemPowerStorage
|
||||
{
|
||||
private static final String CURRENT_POWER_NBT_KEY = "internalCurrentPower";
|
||||
private static final String MAX_POWER_NBT_KEY = "internalMaxPower";
|
||||
private final double powerCapacity;
|
||||
public abstract class AEBasePoweredItem extends AEBaseItem implements IAEItemPowerStorage {
|
||||
private static final String CURRENT_POWER_NBT_KEY = "internalCurrentPower";
|
||||
private static final String MAX_POWER_NBT_KEY = "internalMaxPower";
|
||||
private final double powerCapacity;
|
||||
|
||||
public AEBasePoweredItem( final double powerCapacity )
|
||||
{
|
||||
this.setMaxStackSize( 1 );
|
||||
this.setMaxDamage( 32 );
|
||||
this.hasSubtypes = false;
|
||||
this.setFull3D();
|
||||
public AEBasePoweredItem(final double powerCapacity) {
|
||||
this.setMaxStackSize(1);
|
||||
this.setMaxDamage(32);
|
||||
this.hasSubtypes = false;
|
||||
this.setFull3D();
|
||||
|
||||
this.powerCapacity = powerCapacity;
|
||||
}
|
||||
this.powerCapacity = powerCapacity;
|
||||
}
|
||||
|
||||
@SideOnly( Side.CLIENT )
|
||||
@Override
|
||||
public void addCheckedInformation( final ItemStack stack, final World world, final List<String> lines, final ITooltipFlag advancedTooltips )
|
||||
{
|
||||
final NBTTagCompound tag = stack.getTagCompound();
|
||||
double internalCurrentPower = 0;
|
||||
final double internalMaxPower = this.getAEMaxPower( stack );
|
||||
@SideOnly(Side.CLIENT)
|
||||
@Override
|
||||
public void addCheckedInformation(final ItemStack stack, final World world, final List<String> lines, final ITooltipFlag advancedTooltips) {
|
||||
final NBTTagCompound tag = stack.getTagCompound();
|
||||
double internalCurrentPower = 0;
|
||||
final double internalMaxPower = this.getAEMaxPower(stack);
|
||||
|
||||
if( tag != null )
|
||||
{
|
||||
internalCurrentPower = tag.getDouble( CURRENT_POWER_NBT_KEY );
|
||||
}
|
||||
if (tag != null) {
|
||||
internalCurrentPower = tag.getDouble(CURRENT_POWER_NBT_KEY);
|
||||
}
|
||||
|
||||
final double percent = internalCurrentPower / internalMaxPower;
|
||||
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.getLocal() + ':' + MessageFormat.format(" {0,number,#} ", internalCurrentPower) + Platform
|
||||
.gui_localize(PowerUnits.AE.unlocalizedName) + " - " + MessageFormat.format(" {0,number,#.##%} ", percent));
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isDamageable()
|
||||
{
|
||||
return true;
|
||||
}
|
||||
@Override
|
||||
public boolean isDamageable() {
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void getCheckedSubItems( final CreativeTabs creativeTab, final NonNullList<ItemStack> itemStacks )
|
||||
{
|
||||
super.getCheckedSubItems( creativeTab, itemStacks );
|
||||
@Override
|
||||
protected void getCheckedSubItems(final CreativeTabs creativeTab, final NonNullList<ItemStack> itemStacks) {
|
||||
super.getCheckedSubItems(creativeTab, itemStacks);
|
||||
|
||||
final ItemStack charged = new ItemStack( this, 1 );
|
||||
final NBTTagCompound tag = Platform.openNbtData( charged );
|
||||
tag.setDouble( CURRENT_POWER_NBT_KEY, this.getAEMaxPower( charged ) );
|
||||
tag.setDouble( MAX_POWER_NBT_KEY, this.getAEMaxPower( charged ) );
|
||||
final ItemStack charged = new ItemStack(this, 1);
|
||||
final NBTTagCompound tag = Platform.openNbtData(charged);
|
||||
tag.setDouble(CURRENT_POWER_NBT_KEY, this.getAEMaxPower(charged));
|
||||
tag.setDouble(MAX_POWER_NBT_KEY, this.getAEMaxPower(charged));
|
||||
|
||||
itemStacks.add( charged );
|
||||
}
|
||||
itemStacks.add(charged);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isRepairable()
|
||||
{
|
||||
return false;
|
||||
}
|
||||
@Override
|
||||
public boolean isRepairable() {
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public double getDurabilityForDisplay( final ItemStack is )
|
||||
{
|
||||
return 1 - this.getAECurrentPower( is ) / this.getAEMaxPower( is );
|
||||
}
|
||||
@Override
|
||||
public double getDurabilityForDisplay(final ItemStack is) {
|
||||
return 1 - this.getAECurrentPower(is) / this.getAEMaxPower(is);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isDamaged( final ItemStack stack )
|
||||
{
|
||||
return true;
|
||||
}
|
||||
@Override
|
||||
public boolean isDamaged(final ItemStack stack) {
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setDamage( final ItemStack stack, final int damage )
|
||||
{
|
||||
@Override
|
||||
public void setDamage(final ItemStack stack, final int damage) {
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public double injectAEPower( final ItemStack is, final double amount, Actionable mode )
|
||||
{
|
||||
final double maxStorage = this.getAEMaxPower( is );
|
||||
final double currentStorage = this.getAECurrentPower( is );
|
||||
final double required = maxStorage - currentStorage;
|
||||
final double overflow = amount - required;
|
||||
@Override
|
||||
public double injectAEPower(final ItemStack is, final double amount, Actionable mode) {
|
||||
final double maxStorage = this.getAEMaxPower(is);
|
||||
final double currentStorage = this.getAECurrentPower(is);
|
||||
final double required = maxStorage - currentStorage;
|
||||
final double overflow = amount - required;
|
||||
|
||||
if( mode == Actionable.MODULATE )
|
||||
{
|
||||
final NBTTagCompound data = Platform.openNbtData( is );
|
||||
final double toAdd = Math.min( amount, required );
|
||||
if (mode == Actionable.MODULATE) {
|
||||
final NBTTagCompound data = Platform.openNbtData(is);
|
||||
final double toAdd = Math.min(amount, required);
|
||||
|
||||
data.setDouble( CURRENT_POWER_NBT_KEY, currentStorage + toAdd );
|
||||
}
|
||||
data.setDouble(CURRENT_POWER_NBT_KEY, currentStorage + toAdd);
|
||||
}
|
||||
|
||||
return Math.max( 0, overflow );
|
||||
}
|
||||
return Math.max(0, overflow);
|
||||
}
|
||||
|
||||
@Override
|
||||
public double extractAEPower( final ItemStack is, final double amount, Actionable mode )
|
||||
{
|
||||
final double currentStorage = this.getAECurrentPower( is );
|
||||
final double fulfillable = Math.min( amount, currentStorage );
|
||||
@Override
|
||||
public double extractAEPower(final ItemStack is, final double amount, Actionable mode) {
|
||||
final double currentStorage = this.getAECurrentPower(is);
|
||||
final double fulfillable = Math.min(amount, currentStorage);
|
||||
|
||||
if( mode == Actionable.MODULATE )
|
||||
{
|
||||
final NBTTagCompound data = Platform.openNbtData( is );
|
||||
if (mode == Actionable.MODULATE) {
|
||||
final NBTTagCompound data = Platform.openNbtData(is);
|
||||
|
||||
data.setDouble( CURRENT_POWER_NBT_KEY, currentStorage - fulfillable );
|
||||
}
|
||||
data.setDouble(CURRENT_POWER_NBT_KEY, currentStorage - fulfillable);
|
||||
}
|
||||
|
||||
return fulfillable;
|
||||
}
|
||||
return fulfillable;
|
||||
}
|
||||
|
||||
@Override
|
||||
public double getAEMaxPower( final ItemStack is )
|
||||
{
|
||||
return this.powerCapacity;
|
||||
}
|
||||
@Override
|
||||
public double getAEMaxPower(final ItemStack is) {
|
||||
return this.powerCapacity;
|
||||
}
|
||||
|
||||
@Override
|
||||
public double getAECurrentPower( final ItemStack is )
|
||||
{
|
||||
final NBTTagCompound data = Platform.openNbtData( is );
|
||||
@Override
|
||||
public double getAECurrentPower(final ItemStack is) {
|
||||
final NBTTagCompound data = Platform.openNbtData(is);
|
||||
|
||||
return data.getDouble( CURRENT_POWER_NBT_KEY );
|
||||
}
|
||||
return data.getDouble(CURRENT_POWER_NBT_KEY);
|
||||
}
|
||||
|
||||
@Override
|
||||
public AccessRestriction getPowerFlow( final ItemStack is )
|
||||
{
|
||||
return AccessRestriction.WRITE;
|
||||
}
|
||||
@Override
|
||||
public AccessRestriction getPowerFlow(final ItemStack is) {
|
||||
return AccessRestriction.WRITE;
|
||||
}
|
||||
|
||||
@Override
|
||||
public ICapabilityProvider initCapabilities( ItemStack stack, NBTTagCompound nbt )
|
||||
{
|
||||
return new PoweredItemCapabilities( stack, this );
|
||||
}
|
||||
@Override
|
||||
public ICapabilityProvider initCapabilities(ItemStack stack, NBTTagCompound nbt) {
|
||||
return new PoweredItemCapabilities(stack, this);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -19,8 +19,10 @@
|
||||
package appeng.items.tools.powered.powersink;
|
||||
|
||||
|
||||
import javax.annotation.Nullable;
|
||||
|
||||
import appeng.api.config.Actionable;
|
||||
import appeng.api.config.PowerUnits;
|
||||
import appeng.api.implementations.items.IAEItemPowerStorage;
|
||||
import appeng.capabilities.Capabilities;
|
||||
import net.darkhax.tesla.api.ITeslaConsumer;
|
||||
import net.darkhax.tesla.api.ITeslaHolder;
|
||||
import net.minecraft.item.ItemStack;
|
||||
@@ -29,117 +31,94 @@ import net.minecraftforge.common.capabilities.Capability;
|
||||
import net.minecraftforge.common.capabilities.ICapabilityProvider;
|
||||
import net.minecraftforge.energy.IEnergyStorage;
|
||||
|
||||
import appeng.api.config.Actionable;
|
||||
import appeng.api.config.PowerUnits;
|
||||
import appeng.api.implementations.items.IAEItemPowerStorage;
|
||||
import appeng.capabilities.Capabilities;
|
||||
import javax.annotation.Nullable;
|
||||
|
||||
|
||||
/**
|
||||
* The capability provider to expose chargable items to other mods.
|
||||
*/
|
||||
class PoweredItemCapabilities implements ICapabilityProvider, IEnergyStorage
|
||||
{
|
||||
class PoweredItemCapabilities implements ICapabilityProvider, IEnergyStorage {
|
||||
|
||||
private final ItemStack is;
|
||||
private final ItemStack is;
|
||||
|
||||
private final IAEItemPowerStorage item;
|
||||
private final IAEItemPowerStorage item;
|
||||
|
||||
private final Object teslaAdapter;
|
||||
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;
|
||||
}
|
||||
}
|
||||
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 EnumFacing facing )
|
||||
{
|
||||
return capability == Capabilities.FORGE_ENERGY || capability == Capabilities.TESLA_CONSUMER || capability == Capabilities.TESLA_HOLDER;
|
||||
}
|
||||
@Override
|
||||
public boolean hasCapability(Capability<?> capability, @Nullable EnumFacing 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 EnumFacing facing )
|
||||
{
|
||||
if( capability == Capabilities.FORGE_ENERGY )
|
||||
{
|
||||
return (T) this;
|
||||
}
|
||||
else if( capability == Capabilities.TESLA_CONSUMER || capability == Capabilities.TESLA_HOLDER )
|
||||
{
|
||||
return (T) this.teslaAdapter;
|
||||
}
|
||||
return null;
|
||||
}
|
||||
@SuppressWarnings("unchecked")
|
||||
@Override
|
||||
public <T> T getCapability(Capability<T> capability, @Nullable EnumFacing facing) {
|
||||
if (capability == Capabilities.FORGE_ENERGY) {
|
||||
return (T) this;
|
||||
} else if (capability == Capabilities.TESLA_CONSUMER || capability == Capabilities.TESLA_HOLDER) {
|
||||
return (T) this.teslaAdapter;
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int receiveEnergy( int maxReceive, boolean simulate )
|
||||
{
|
||||
final double convertedOffer = PowerUnits.RF.convertTo( PowerUnits.AE, maxReceive );
|
||||
final double overflow = this.item.injectAEPower( this.is, convertedOffer, simulate ? Actionable.SIMULATE : Actionable.MODULATE );
|
||||
@Override
|
||||
public int receiveEnergy(int maxReceive, boolean simulate) {
|
||||
final double convertedOffer = PowerUnits.RF.convertTo(PowerUnits.AE, maxReceive);
|
||||
final double overflow = this.item.injectAEPower(this.is, convertedOffer, simulate ? Actionable.SIMULATE : Actionable.MODULATE);
|
||||
|
||||
return maxReceive - (int) PowerUnits.AE.convertTo( PowerUnits.RF, overflow );
|
||||
}
|
||||
return maxReceive - (int) PowerUnits.AE.convertTo(PowerUnits.RF, overflow);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int extractEnergy( int maxExtract, boolean simulate )
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
@Override
|
||||
public int extractEnergy(int maxExtract, boolean simulate) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getEnergyStored()
|
||||
{
|
||||
return (int) PowerUnits.AE.convertTo( PowerUnits.RF, this.item.getAECurrentPower( this.is ) );
|
||||
}
|
||||
@Override
|
||||
public int getEnergyStored() {
|
||||
return (int) PowerUnits.AE.convertTo(PowerUnits.RF, this.item.getAECurrentPower(this.is));
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getMaxEnergyStored()
|
||||
{
|
||||
return (int) PowerUnits.AE.convertTo( PowerUnits.RF, this.item.getAEMaxPower( this.is ) );
|
||||
}
|
||||
@Override
|
||||
public int getMaxEnergyStored() {
|
||||
return (int) PowerUnits.AE.convertTo(PowerUnits.RF, this.item.getAEMaxPower(this.is));
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean canExtract()
|
||||
{
|
||||
return false;
|
||||
}
|
||||
@Override
|
||||
public boolean canExtract() {
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean canReceive()
|
||||
{
|
||||
return true;
|
||||
}
|
||||
@Override
|
||||
public boolean canReceive() {
|
||||
return true;
|
||||
}
|
||||
|
||||
private class TeslaAdapter implements ITeslaConsumer, ITeslaHolder
|
||||
{
|
||||
private class TeslaAdapter implements ITeslaConsumer, ITeslaHolder {
|
||||
|
||||
@Override
|
||||
public long givePower( long power, boolean simulated )
|
||||
{
|
||||
return PoweredItemCapabilities.this.receiveEnergy( (int) power, simulated );
|
||||
}
|
||||
@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 getStoredPower() {
|
||||
return PoweredItemCapabilities.this.getEnergyStored();
|
||||
}
|
||||
|
||||
@Override
|
||||
public long getCapacity()
|
||||
{
|
||||
return PoweredItemCapabilities.this.getMaxEnergyStored();
|
||||
}
|
||||
}
|
||||
@Override
|
||||
public long getCapacity() {
|
||||
return PoweredItemCapabilities.this.getMaxEnergyStored();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -19,26 +19,22 @@
|
||||
package appeng.items.tools.quartz;
|
||||
|
||||
|
||||
import appeng.core.features.AEFeature;
|
||||
import appeng.util.Platform;
|
||||
import net.minecraft.item.ItemAxe;
|
||||
import net.minecraft.item.ItemStack;
|
||||
|
||||
import appeng.core.features.AEFeature;
|
||||
import appeng.util.Platform;
|
||||
|
||||
public class ToolQuartzAxe extends ItemAxe {
|
||||
private final AEFeature type;
|
||||
|
||||
public class ToolQuartzAxe extends ItemAxe
|
||||
{
|
||||
private final AEFeature type;
|
||||
public ToolQuartzAxe(final AEFeature type) {
|
||||
super(ToolMaterial.IRON);
|
||||
this.type = type;
|
||||
}
|
||||
|
||||
public ToolQuartzAxe( final AEFeature type )
|
||||
{
|
||||
super( ToolMaterial.IRON );
|
||||
this.type = type;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean getIsRepairable( final ItemStack a, final ItemStack b )
|
||||
{
|
||||
return Platform.canRepair( this.type, a, b );
|
||||
}
|
||||
@Override
|
||||
public boolean getIsRepairable(final ItemStack a, final ItemStack b) {
|
||||
return Platform.canRepair(this.type, a, b);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -19,6 +19,14 @@
|
||||
package appeng.items.tools.quartz;
|
||||
|
||||
|
||||
import appeng.api.implementations.guiobjects.IGuiItem;
|
||||
import appeng.api.implementations.guiobjects.IGuiItemObject;
|
||||
import appeng.api.util.AEPartLocation;
|
||||
import appeng.core.features.AEFeature;
|
||||
import appeng.core.sync.GuiBridge;
|
||||
import appeng.items.AEBaseItem;
|
||||
import appeng.items.contents.QuartzKnifeObj;
|
||||
import appeng.util.Platform;
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.util.ActionResult;
|
||||
@@ -28,78 +36,58 @@ import net.minecraft.util.EnumHand;
|
||||
import net.minecraft.util.math.BlockPos;
|
||||
import net.minecraft.world.World;
|
||||
|
||||
import appeng.api.implementations.guiobjects.IGuiItem;
|
||||
import appeng.api.implementations.guiobjects.IGuiItemObject;
|
||||
import appeng.api.util.AEPartLocation;
|
||||
import appeng.core.features.AEFeature;
|
||||
import appeng.core.sync.GuiBridge;
|
||||
import appeng.items.AEBaseItem;
|
||||
import appeng.items.contents.QuartzKnifeObj;
|
||||
import appeng.util.Platform;
|
||||
|
||||
public class ToolQuartzCuttingKnife extends AEBaseItem implements IGuiItem {
|
||||
private final AEFeature type;
|
||||
|
||||
public class ToolQuartzCuttingKnife extends AEBaseItem implements IGuiItem
|
||||
{
|
||||
private final AEFeature type;
|
||||
public ToolQuartzCuttingKnife(final AEFeature type) {
|
||||
this.type = type;
|
||||
this.setMaxDamage(50);
|
||||
this.setMaxStackSize(1);
|
||||
}
|
||||
|
||||
public ToolQuartzCuttingKnife( final AEFeature type )
|
||||
{
|
||||
this.type = type;
|
||||
this.setMaxDamage( 50 );
|
||||
this.setMaxStackSize( 1 );
|
||||
}
|
||||
@Override
|
||||
public EnumActionResult onItemUse(final EntityPlayer p, final World worldIn, final BlockPos pos, final EnumHand hand, final EnumFacing side, final float hitX, final float hitY, final float hitZ) {
|
||||
if (Platform.isServer()) {
|
||||
Platform.openGUI(p, null, AEPartLocation.INTERNAL, GuiBridge.GUI_QUARTZ_KNIFE);
|
||||
}
|
||||
return EnumActionResult.SUCCESS;
|
||||
}
|
||||
|
||||
@Override
|
||||
public EnumActionResult onItemUse( final EntityPlayer p, final World worldIn, final BlockPos pos, final EnumHand hand, final EnumFacing side, final float hitX, final float hitY, final float hitZ )
|
||||
{
|
||||
if( Platform.isServer() )
|
||||
{
|
||||
Platform.openGUI( p, null, AEPartLocation.INTERNAL, GuiBridge.GUI_QUARTZ_KNIFE );
|
||||
}
|
||||
return EnumActionResult.SUCCESS;
|
||||
}
|
||||
@Override
|
||||
public ActionResult<ItemStack> onItemRightClick(final World w, final EntityPlayer p, final EnumHand hand) {
|
||||
if (Platform.isServer()) {
|
||||
Platform.openGUI(p, null, AEPartLocation.INTERNAL, GuiBridge.GUI_QUARTZ_KNIFE);
|
||||
}
|
||||
p.swingArm(hand);
|
||||
return new ActionResult<>(EnumActionResult.SUCCESS, p.getHeldItem(hand));
|
||||
}
|
||||
|
||||
@Override
|
||||
public ActionResult<ItemStack> onItemRightClick( final World w, final EntityPlayer p, final EnumHand hand )
|
||||
{
|
||||
if( Platform.isServer() )
|
||||
{
|
||||
Platform.openGUI( p, null, AEPartLocation.INTERNAL, GuiBridge.GUI_QUARTZ_KNIFE );
|
||||
}
|
||||
p.swingArm( hand );
|
||||
return new ActionResult<>( EnumActionResult.SUCCESS, p.getHeldItem( hand ) );
|
||||
}
|
||||
@Override
|
||||
public boolean getIsRepairable(final ItemStack a, final ItemStack b) {
|
||||
return Platform.canRepair(this.type, a, b);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean getIsRepairable( final ItemStack a, final ItemStack b )
|
||||
{
|
||||
return Platform.canRepair( this.type, a, b );
|
||||
}
|
||||
@Override
|
||||
public boolean isRepairable() {
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isRepairable()
|
||||
{
|
||||
return false;
|
||||
}
|
||||
@Override
|
||||
public ItemStack getContainerItem(final ItemStack itemStack) {
|
||||
ItemStack copy = itemStack.copy();
|
||||
copy.setItemDamage(itemStack.getItemDamage() + 1);
|
||||
|
||||
@Override
|
||||
public ItemStack getContainerItem( final ItemStack itemStack )
|
||||
{
|
||||
ItemStack copy = itemStack.copy();
|
||||
copy.setItemDamage( itemStack.getItemDamage() + 1 );
|
||||
return copy;
|
||||
}
|
||||
|
||||
return copy;
|
||||
}
|
||||
@Override
|
||||
public boolean hasContainerItem(final ItemStack stack) {
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean hasContainerItem( final ItemStack stack )
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public IGuiItemObject getGuiObject( final ItemStack is, final World world, final BlockPos pos )
|
||||
{
|
||||
return new QuartzKnifeObj( is );
|
||||
}
|
||||
@Override
|
||||
public IGuiItemObject getGuiObject(final ItemStack is, final World world, final BlockPos pos) {
|
||||
return new QuartzKnifeObj(is);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -19,27 +19,23 @@
|
||||
package appeng.items.tools.quartz;
|
||||
|
||||
|
||||
import appeng.core.features.AEFeature;
|
||||
import appeng.util.Platform;
|
||||
import net.minecraft.item.ItemHoe;
|
||||
import net.minecraft.item.ItemStack;
|
||||
|
||||
import appeng.core.features.AEFeature;
|
||||
import appeng.util.Platform;
|
||||
|
||||
public class ToolQuartzHoe extends ItemHoe {
|
||||
private final AEFeature type;
|
||||
|
||||
public class ToolQuartzHoe extends ItemHoe
|
||||
{
|
||||
private final AEFeature type;
|
||||
public ToolQuartzHoe(final AEFeature type) {
|
||||
super(ToolMaterial.IRON);
|
||||
this.type = type;
|
||||
}
|
||||
|
||||
public ToolQuartzHoe( final AEFeature type )
|
||||
{
|
||||
super( ToolMaterial.IRON );
|
||||
this.type = type;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean getIsRepairable( final ItemStack a, final ItemStack b )
|
||||
{
|
||||
return Platform.canRepair( this.type, a, b );
|
||||
}
|
||||
@Override
|
||||
public boolean getIsRepairable(final ItemStack a, final ItemStack b) {
|
||||
return Platform.canRepair(this.type, a, b);
|
||||
}
|
||||
|
||||
}
|
||||
@@ -19,26 +19,22 @@
|
||||
package appeng.items.tools.quartz;
|
||||
|
||||
|
||||
import appeng.core.features.AEFeature;
|
||||
import appeng.util.Platform;
|
||||
import net.minecraft.item.ItemPickaxe;
|
||||
import net.minecraft.item.ItemStack;
|
||||
|
||||
import appeng.core.features.AEFeature;
|
||||
import appeng.util.Platform;
|
||||
|
||||
public class ToolQuartzPickaxe extends ItemPickaxe {
|
||||
private final AEFeature type;
|
||||
|
||||
public class ToolQuartzPickaxe extends ItemPickaxe
|
||||
{
|
||||
private final AEFeature type;
|
||||
public ToolQuartzPickaxe(final AEFeature type) {
|
||||
super(ToolMaterial.IRON);
|
||||
this.type = type;
|
||||
}
|
||||
|
||||
public ToolQuartzPickaxe( final AEFeature type )
|
||||
{
|
||||
super( ToolMaterial.IRON );
|
||||
this.type = type;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean getIsRepairable( final ItemStack a, final ItemStack b )
|
||||
{
|
||||
return Platform.canRepair( this.type, a, b );
|
||||
}
|
||||
@Override
|
||||
public boolean getIsRepairable(final ItemStack a, final ItemStack b) {
|
||||
return Platform.canRepair(this.type, a, b);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -19,26 +19,22 @@
|
||||
package appeng.items.tools.quartz;
|
||||
|
||||
|
||||
import appeng.core.features.AEFeature;
|
||||
import appeng.util.Platform;
|
||||
import net.minecraft.item.ItemSpade;
|
||||
import net.minecraft.item.ItemStack;
|
||||
|
||||
import appeng.core.features.AEFeature;
|
||||
import appeng.util.Platform;
|
||||
|
||||
public class ToolQuartzSpade extends ItemSpade {
|
||||
private final AEFeature type;
|
||||
|
||||
public class ToolQuartzSpade extends ItemSpade
|
||||
{
|
||||
private final AEFeature type;
|
||||
public ToolQuartzSpade(final AEFeature type) {
|
||||
super(ToolMaterial.IRON);
|
||||
this.type = type;
|
||||
}
|
||||
|
||||
public ToolQuartzSpade( final AEFeature type )
|
||||
{
|
||||
super( ToolMaterial.IRON );
|
||||
this.type = type;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean getIsRepairable( final ItemStack a, final ItemStack b )
|
||||
{
|
||||
return Platform.canRepair( this.type, a, b );
|
||||
}
|
||||
@Override
|
||||
public boolean getIsRepairable(final ItemStack a, final ItemStack b) {
|
||||
return Platform.canRepair(this.type, a, b);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -19,26 +19,22 @@
|
||||
package appeng.items.tools.quartz;
|
||||
|
||||
|
||||
import appeng.core.features.AEFeature;
|
||||
import appeng.util.Platform;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.item.ItemSword;
|
||||
|
||||
import appeng.core.features.AEFeature;
|
||||
import appeng.util.Platform;
|
||||
|
||||
public class ToolQuartzSword extends ItemSword {
|
||||
private final AEFeature type;
|
||||
|
||||
public class ToolQuartzSword extends ItemSword
|
||||
{
|
||||
private final AEFeature type;
|
||||
public ToolQuartzSword(AEFeature type) {
|
||||
super(ToolMaterial.IRON);
|
||||
this.type = type;
|
||||
}
|
||||
|
||||
public ToolQuartzSword( AEFeature type )
|
||||
{
|
||||
super( ToolMaterial.IRON );
|
||||
this.type = type;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean getIsRepairable( final ItemStack a, final ItemStack b )
|
||||
{
|
||||
return Platform.canRepair( this.type, a, b );
|
||||
}
|
||||
@Override
|
||||
public boolean getIsRepairable(final ItemStack a, final ItemStack b) {
|
||||
return Platform.canRepair(this.type, a, b);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -19,6 +19,11 @@
|
||||
package appeng.items.tools.quartz;
|
||||
|
||||
|
||||
import appeng.api.implementations.items.IAEWrench;
|
||||
import appeng.api.util.DimensionalCoord;
|
||||
import appeng.items.AEBaseItem;
|
||||
import appeng.util.Platform;
|
||||
import cofh.api.item.IToolHammer;
|
||||
import net.minecraft.block.Block;
|
||||
import net.minecraft.entity.Entity;
|
||||
import net.minecraft.entity.EntityLivingBase;
|
||||
@@ -32,96 +37,77 @@ import net.minecraft.world.IBlockAccess;
|
||||
import net.minecraft.world.World;
|
||||
import net.minecraftforge.fml.common.Optional.Interface;
|
||||
|
||||
import cofh.api.item.IToolHammer;
|
||||
|
||||
import appeng.api.implementations.items.IAEWrench;
|
||||
import appeng.api.util.DimensionalCoord;
|
||||
import appeng.items.AEBaseItem;
|
||||
import appeng.util.Platform;
|
||||
|
||||
|
||||
// TODO BC Integration
|
||||
//@Interface( iface = "buildcraft.api.tools.IToolWrench", iname = IntegrationType.BuildCraftCore )
|
||||
@Interface( iface = "cofh.api.item.IToolHammer", modid = "cofhcore" )
|
||||
public class ToolQuartzWrench extends AEBaseItem implements IAEWrench, IToolHammer /* , IToolWrench */
|
||||
{
|
||||
@Interface(iface = "cofh.api.item.IToolHammer", modid = "cofhcore")
|
||||
public class ToolQuartzWrench extends AEBaseItem implements IAEWrench, IToolHammer /* , IToolWrench */ {
|
||||
|
||||
public ToolQuartzWrench()
|
||||
{
|
||||
this.setMaxStackSize( 1 );
|
||||
this.setHarvestLevel( "wrench", 0 );
|
||||
}
|
||||
public ToolQuartzWrench() {
|
||||
this.setMaxStackSize(1);
|
||||
this.setHarvestLevel("wrench", 0);
|
||||
}
|
||||
|
||||
@Override
|
||||
public EnumActionResult onItemUseFirst( final EntityPlayer player, final World world, final BlockPos pos, final EnumFacing side, final float hitX, final float hitY, final float hitZ, final EnumHand hand )
|
||||
{
|
||||
final Block b = world.getBlockState( pos ).getBlock();
|
||||
if( b != null && !player.isSneaking() && Platform.hasPermissions( new DimensionalCoord( world, pos ), player ) )
|
||||
{
|
||||
if( Platform.isClient() )
|
||||
{
|
||||
// TODO 1.10-R - if we return FAIL on client, action will not be sent to server. Fix that in all
|
||||
// Block#onItemUseFirst overrides.
|
||||
return !world.isRemote ? EnumActionResult.SUCCESS : EnumActionResult.PASS;
|
||||
}
|
||||
@Override
|
||||
public EnumActionResult onItemUseFirst(final EntityPlayer player, final World world, final BlockPos pos, final EnumFacing side, final float hitX, final float hitY, final float hitZ, final EnumHand hand) {
|
||||
final Block b = world.getBlockState(pos).getBlock();
|
||||
if (b != null && !player.isSneaking() && Platform.hasPermissions(new DimensionalCoord(world, pos), player)) {
|
||||
if (Platform.isClient()) {
|
||||
// TODO 1.10-R - if we return FAIL on client, action will not be sent to server. Fix that in all
|
||||
// Block#onItemUseFirst overrides.
|
||||
return !world.isRemote ? EnumActionResult.SUCCESS : EnumActionResult.PASS;
|
||||
}
|
||||
|
||||
if( b.rotateBlock( world, pos, side ) )
|
||||
{
|
||||
player.swingArm( hand );
|
||||
return !world.isRemote ? EnumActionResult.SUCCESS : EnumActionResult.FAIL;
|
||||
}
|
||||
}
|
||||
return EnumActionResult.PASS;
|
||||
}
|
||||
if (b.rotateBlock(world, pos, side)) {
|
||||
player.swingArm(hand);
|
||||
return !world.isRemote ? EnumActionResult.SUCCESS : EnumActionResult.FAIL;
|
||||
}
|
||||
}
|
||||
return EnumActionResult.PASS;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean doesSneakBypassUse( final ItemStack itemstack, final IBlockAccess world, final BlockPos pos, final EntityPlayer player )
|
||||
{
|
||||
return true;
|
||||
}
|
||||
@Override
|
||||
public boolean doesSneakBypassUse(final ItemStack itemstack, final IBlockAccess world, final BlockPos pos, final EntityPlayer player) {
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean canWrench( final ItemStack wrench, final EntityPlayer player, final BlockPos pos )
|
||||
{
|
||||
return true;
|
||||
}
|
||||
@Override
|
||||
public boolean canWrench(final ItemStack wrench, final EntityPlayer player, final BlockPos pos) {
|
||||
return true;
|
||||
}
|
||||
|
||||
// IToolHammer - start
|
||||
@Override
|
||||
public boolean isUsable( ItemStack item, EntityLivingBase user, BlockPos pos )
|
||||
{
|
||||
return true;
|
||||
}
|
||||
// IToolHammer - start
|
||||
@Override
|
||||
public boolean isUsable(ItemStack item, EntityLivingBase user, BlockPos pos) {
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isUsable( ItemStack item, EntityLivingBase user, Entity entity )
|
||||
{
|
||||
return true;
|
||||
}
|
||||
@Override
|
||||
public boolean isUsable(ItemStack item, EntityLivingBase user, Entity entity) {
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void toolUsed( ItemStack item, EntityLivingBase user, BlockPos pos )
|
||||
{
|
||||
}
|
||||
@Override
|
||||
public void toolUsed(ItemStack item, EntityLivingBase user, BlockPos pos) {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void toolUsed( ItemStack item, EntityLivingBase user, Entity entity )
|
||||
{
|
||||
}
|
||||
@Override
|
||||
public void toolUsed(ItemStack item, EntityLivingBase user, Entity entity) {
|
||||
}
|
||||
|
||||
// IToolHammer - end
|
||||
// IToolHammer - end
|
||||
|
||||
// TODO: BC Wrench Integration
|
||||
/*
|
||||
* @Override
|
||||
* public boolean canWrench( EntityPlayer player, int x, int y, int z )
|
||||
* {
|
||||
* return true;
|
||||
* }
|
||||
* @Override
|
||||
* public void wrenchUsed( EntityPlayer player, int x, int y, int z )
|
||||
* {
|
||||
* player.swingItem();
|
||||
* }
|
||||
*/
|
||||
// TODO: BC Wrench Integration
|
||||
/*
|
||||
* @Override
|
||||
* public boolean canWrench( EntityPlayer player, int x, int y, int z )
|
||||
* {
|
||||
* return true;
|
||||
* }
|
||||
* @Override
|
||||
* public void wrenchUsed( EntityPlayer player, int x, int y, int z )
|
||||
* {
|
||||
* player.swingItem();
|
||||
* }
|
||||
*/
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user