pick 97420a31d The big reformat of 2020
This commit is contained in:
@@ -18,30 +18,24 @@
|
||||
|
||||
package appeng.items;
|
||||
|
||||
|
||||
import net.minecraft.item.Item;
|
||||
import net.minecraft.item.ItemStack;
|
||||
|
||||
public abstract class AEBaseItem extends Item {
|
||||
|
||||
public abstract class AEBaseItem extends Item
|
||||
{
|
||||
public AEBaseItem(Item.Properties properties) {
|
||||
super(properties.setNoRepair());
|
||||
}
|
||||
|
||||
public AEBaseItem( Item.Properties properties )
|
||||
{
|
||||
super( properties.setNoRepair() );
|
||||
}
|
||||
@Override
|
||||
public String toString() {
|
||||
String regName = this.getRegistryName() != null ? this.getRegistryName().getPath() : "unregistered";
|
||||
return this.getClass().getSimpleName() + "[" + regName + "]";
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString()
|
||||
{
|
||||
String regName = this.getRegistryName() != null ? this.getRegistryName().getPath() : "unregistered";
|
||||
return this.getClass().getSimpleName() + "[" + regName + "]";
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isBookEnchantable( final ItemStack itemstack1, final ItemStack itemstack2 )
|
||||
{
|
||||
return false;
|
||||
}
|
||||
@Override
|
||||
public boolean isBookEnchantable(final ItemStack itemstack1, final ItemStack itemstack2) {
|
||||
return false;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -18,27 +18,22 @@
|
||||
|
||||
package appeng.items.contents;
|
||||
|
||||
|
||||
import net.minecraft.item.ItemStack;
|
||||
|
||||
import appeng.tile.inventory.AppEngInternalInventory;
|
||||
|
||||
public class CellConfig extends AppEngInternalInventory {
|
||||
|
||||
public class CellConfig extends AppEngInternalInventory
|
||||
{
|
||||
private final ItemStack is;
|
||||
|
||||
private final ItemStack is;
|
||||
public CellConfig(final ItemStack is) {
|
||||
super(null, 63);
|
||||
this.is = is;
|
||||
this.readFromNBT(is.getOrCreateTag(), "list");
|
||||
}
|
||||
|
||||
public CellConfig( final ItemStack is )
|
||||
{
|
||||
super( null, 63 );
|
||||
this.is = is;
|
||||
this.readFromNBT(is.getOrCreateTag(), "list" );
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void onContentsChanged( int slot )
|
||||
{
|
||||
this.writeToNBT(this.is.getOrCreateTag(), "list" );
|
||||
}
|
||||
@Override
|
||||
protected void onContentsChanged(int slot) {
|
||||
this.writeToNBT(this.is.getOrCreateTag(), "list");
|
||||
}
|
||||
}
|
||||
@@ -18,26 +18,21 @@
|
||||
|
||||
package appeng.items.contents;
|
||||
|
||||
|
||||
import net.minecraft.item.ItemStack;
|
||||
|
||||
import appeng.parts.automation.StackUpgradeInventory;
|
||||
|
||||
public final class CellUpgrades extends StackUpgradeInventory {
|
||||
private final ItemStack is;
|
||||
|
||||
public final class CellUpgrades extends StackUpgradeInventory
|
||||
{
|
||||
private final ItemStack is;
|
||||
public CellUpgrades(final ItemStack is, final int upgrades) {
|
||||
super(is, null, upgrades);
|
||||
this.is = is;
|
||||
this.readFromNBT(is.getOrCreateTag(), "upgrades");
|
||||
}
|
||||
|
||||
public CellUpgrades( final ItemStack is, final int upgrades )
|
||||
{
|
||||
super( is, null, upgrades );
|
||||
this.is = is;
|
||||
this.readFromNBT(is.getOrCreateTag(), "upgrades" );
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void onContentsChanged( int slot )
|
||||
{
|
||||
this.writeToNBT(this.is.getOrCreateTag(), "upgrades" );
|
||||
}
|
||||
@Override
|
||||
protected void onContentsChanged(int slot) {
|
||||
this.writeToNBT(this.is.getOrCreateTag(), "upgrades");
|
||||
}
|
||||
}
|
||||
@@ -18,7 +18,6 @@
|
||||
|
||||
package appeng.items.contents;
|
||||
|
||||
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraftforge.items.IItemHandler;
|
||||
|
||||
@@ -30,72 +29,62 @@ import appeng.util.inv.IAEAppEngInventory;
|
||||
import appeng.util.inv.InvOperation;
|
||||
import appeng.util.inv.filter.IAEItemFilter;
|
||||
|
||||
public class NetworkToolViewer implements INetworkTool, IAEAppEngInventory {
|
||||
|
||||
public class NetworkToolViewer implements INetworkTool, IAEAppEngInventory
|
||||
{
|
||||
private final AppEngInternalInventory inv;
|
||||
private final ItemStack is;
|
||||
private final IGridHost gh;
|
||||
|
||||
private final AppEngInternalInventory inv;
|
||||
private final ItemStack is;
|
||||
private final IGridHost gh;
|
||||
public NetworkToolViewer(final ItemStack is, final IGridHost gHost) {
|
||||
this.is = is;
|
||||
this.gh = gHost;
|
||||
this.inv = new AppEngInternalInventory(this, 9);
|
||||
this.inv.setFilter(new NetworkToolInventoryFilter());
|
||||
if (is.hasTag()) // prevent crash when opening network status screen.
|
||||
{
|
||||
this.inv.readFromNBT(is.getOrCreateTag(), "inv");
|
||||
}
|
||||
}
|
||||
|
||||
public NetworkToolViewer( final ItemStack is, final IGridHost gHost )
|
||||
{
|
||||
this.is = is;
|
||||
this.gh = gHost;
|
||||
this.inv = new AppEngInternalInventory( this, 9 );
|
||||
this.inv.setFilter( new NetworkToolInventoryFilter() );
|
||||
if( is.hasTag() ) // prevent crash when opening network status screen.
|
||||
{
|
||||
this.inv.readFromNBT(is.getOrCreateTag(), "inv" );
|
||||
}
|
||||
}
|
||||
@Override
|
||||
public void saveChanges() {
|
||||
this.inv.writeToNBT(this.is.getOrCreateTag(), "inv");
|
||||
}
|
||||
|
||||
@Override
|
||||
public void saveChanges()
|
||||
{
|
||||
this.inv.writeToNBT(this.is.getOrCreateTag(), "inv" );
|
||||
}
|
||||
@Override
|
||||
public void onChangeInventory(IItemHandler inv, int slot, InvOperation mc, ItemStack removedStack,
|
||||
ItemStack newStack) {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onChangeInventory( IItemHandler inv, int slot, InvOperation mc, ItemStack removedStack, ItemStack newStack )
|
||||
{
|
||||
}
|
||||
@Override
|
||||
public ItemStack getItemStack() {
|
||||
return this.is;
|
||||
}
|
||||
|
||||
@Override
|
||||
public ItemStack getItemStack()
|
||||
{
|
||||
return this.is;
|
||||
}
|
||||
@Override
|
||||
public IGridHost getGridHost() {
|
||||
return this.gh;
|
||||
}
|
||||
|
||||
@Override
|
||||
public IGridHost getGridHost()
|
||||
{
|
||||
return this.gh;
|
||||
}
|
||||
private static class NetworkToolInventoryFilter implements IAEItemFilter {
|
||||
@Override
|
||||
public boolean allowExtract(IItemHandler inv, int slot, int amount) {
|
||||
return true;
|
||||
}
|
||||
|
||||
private static class NetworkToolInventoryFilter implements IAEItemFilter
|
||||
{
|
||||
@Override
|
||||
public boolean allowExtract( IItemHandler inv, int slot, int amount )
|
||||
{
|
||||
return true;
|
||||
}
|
||||
@Override
|
||||
public boolean allowInsert(IItemHandler inv, int slot, ItemStack stack) {
|
||||
return stack.getItem() instanceof IUpgradeModule
|
||||
&& ((IUpgradeModule) stack.getItem()).getType(stack) != null;
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean allowInsert( IItemHandler inv, int slot, ItemStack stack )
|
||||
{
|
||||
return stack.getItem() instanceof IUpgradeModule && ( (IUpgradeModule) stack.getItem() ).getType( stack ) != null;
|
||||
}
|
||||
}
|
||||
public IItemHandler getInternalInventory() {
|
||||
return this.inv;
|
||||
}
|
||||
|
||||
public IItemHandler getInternalInventory()
|
||||
{
|
||||
return this.inv;
|
||||
}
|
||||
|
||||
@Override
|
||||
public IItemHandler getInventory()
|
||||
{
|
||||
return this.inv;
|
||||
}
|
||||
@Override
|
||||
public IItemHandler getInventory() {
|
||||
return this.inv;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -18,7 +18,6 @@
|
||||
|
||||
package appeng.items.contents;
|
||||
|
||||
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.nbt.CompoundNBT;
|
||||
|
||||
@@ -41,71 +40,61 @@ import appeng.container.interfaces.IInventorySlotAware;
|
||||
import appeng.me.helpers.MEMonitorHandler;
|
||||
import appeng.util.ConfigManager;
|
||||
|
||||
public class PortableCellViewer extends MEMonitorHandler<IAEItemStack> implements IPortableCell, IInventorySlotAware {
|
||||
|
||||
public class PortableCellViewer extends MEMonitorHandler<IAEItemStack> implements IPortableCell, IInventorySlotAware
|
||||
{
|
||||
private final ItemStack target;
|
||||
private final IAEItemPowerStorage ips;
|
||||
private final int inventorySlot;
|
||||
|
||||
private final ItemStack target;
|
||||
private final IAEItemPowerStorage ips;
|
||||
private final int inventorySlot;
|
||||
public PortableCellViewer(final ItemStack is, final int slot) {
|
||||
super(AEApi.instance().registries().cell().getCellInventory(is, null,
|
||||
AEApi.instance().storage().getStorageChannel(IItemStorageChannel.class)));
|
||||
this.ips = (IAEItemPowerStorage) is.getItem();
|
||||
this.target = is;
|
||||
this.inventorySlot = slot;
|
||||
}
|
||||
|
||||
public PortableCellViewer( final ItemStack is, final int slot )
|
||||
{
|
||||
super( AEApi.instance().registries().cell().getCellInventory( is, null, AEApi.instance().storage().getStorageChannel( IItemStorageChannel.class ) ) );
|
||||
this.ips = (IAEItemPowerStorage) is.getItem();
|
||||
this.target = is;
|
||||
this.inventorySlot = slot;
|
||||
}
|
||||
@Override
|
||||
public int getInventorySlot() {
|
||||
return this.inventorySlot;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getInventorySlot()
|
||||
{
|
||||
return this.inventorySlot;
|
||||
}
|
||||
@Override
|
||||
public ItemStack getItemStack() {
|
||||
return this.target;
|
||||
}
|
||||
|
||||
@Override
|
||||
public ItemStack getItemStack()
|
||||
{
|
||||
return this.target;
|
||||
}
|
||||
@Override
|
||||
public double extractAEPower(double amt, final Actionable mode, final PowerMultiplier usePowerMultiplier) {
|
||||
amt = usePowerMultiplier.multiply(amt);
|
||||
|
||||
@Override
|
||||
public double extractAEPower( double amt, final Actionable mode, final PowerMultiplier usePowerMultiplier )
|
||||
{
|
||||
amt = usePowerMultiplier.multiply( amt );
|
||||
if (mode == Actionable.SIMULATE) {
|
||||
return usePowerMultiplier.divide(Math.min(amt, this.ips.getAECurrentPower(this.target)));
|
||||
}
|
||||
|
||||
if( mode == Actionable.SIMULATE )
|
||||
{
|
||||
return usePowerMultiplier.divide( Math.min( amt, this.ips.getAECurrentPower( this.target ) ) );
|
||||
}
|
||||
return usePowerMultiplier.divide(this.ips.extractAEPower(this.target, amt, Actionable.MODULATE));
|
||||
}
|
||||
|
||||
return usePowerMultiplier.divide( this.ips.extractAEPower( this.target, amt, Actionable.MODULATE ) );
|
||||
}
|
||||
@Override
|
||||
public <T extends IAEStack<T>> IMEMonitor<T> getInventory(IStorageChannel<T> channel) {
|
||||
if (channel == AEApi.instance().storage().getStorageChannel(IItemStorageChannel.class)) {
|
||||
return (IMEMonitor<T>) this;
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public <T extends IAEStack<T>> IMEMonitor<T> getInventory( IStorageChannel<T> channel )
|
||||
{
|
||||
if( channel == AEApi.instance().storage().getStorageChannel( IItemStorageChannel.class ) )
|
||||
{
|
||||
return (IMEMonitor<T>) this;
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public IConfigManager getConfigManager()
|
||||
{
|
||||
final ConfigManager out = new ConfigManager( ( manager, settingName, newValue ) ->
|
||||
{
|
||||
@Override
|
||||
public IConfigManager getConfigManager() {
|
||||
final ConfigManager out = new ConfigManager((manager, settingName, newValue) -> {
|
||||
final CompoundNBT data = this.target.getOrCreateTag();
|
||||
manager.writeToNBT( data );
|
||||
} );
|
||||
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( this.target.getOrCreateTag().copy() );
|
||||
return out;
|
||||
}
|
||||
out.readFromNBT(this.target.getOrCreateTag().copy());
|
||||
return out;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -18,25 +18,20 @@
|
||||
|
||||
package appeng.items.contents;
|
||||
|
||||
|
||||
import net.minecraft.item.ItemStack;
|
||||
|
||||
import appeng.api.implementations.guiobjects.IGuiItemObject;
|
||||
|
||||
public class QuartzKnifeObj implements IGuiItemObject {
|
||||
|
||||
public class QuartzKnifeObj implements IGuiItemObject
|
||||
{
|
||||
private final ItemStack is;
|
||||
|
||||
private final ItemStack is;
|
||||
public QuartzKnifeObj(final ItemStack o) {
|
||||
this.is = o;
|
||||
}
|
||||
|
||||
public QuartzKnifeObj( final ItemStack o )
|
||||
{
|
||||
this.is = o;
|
||||
}
|
||||
|
||||
@Override
|
||||
public ItemStack getItemStack()
|
||||
{
|
||||
return this.is;
|
||||
}
|
||||
@Override
|
||||
public ItemStack getItemStack() {
|
||||
return this.is;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -18,7 +18,6 @@
|
||||
|
||||
package appeng.items.materials;
|
||||
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Arrays;
|
||||
import java.util.Collections;
|
||||
@@ -30,7 +29,6 @@ import java.util.Map.Entry;
|
||||
import java.util.regex.Matcher;
|
||||
import java.util.regex.Pattern;
|
||||
|
||||
import appeng.entity.EntitySingularity;
|
||||
import com.google.common.base.Preconditions;
|
||||
|
||||
import net.minecraft.client.util.ITooltipFlag;
|
||||
@@ -54,6 +52,7 @@ import net.minecraftforge.api.distmarker.OnlyIn;
|
||||
import net.minecraftforge.items.IItemHandler;
|
||||
|
||||
import appeng.api.config.Upgrades;
|
||||
import appeng.api.features.AEFeature;
|
||||
import appeng.api.implementations.IUpgradeableHost;
|
||||
import appeng.api.implementations.items.IItemGroup;
|
||||
import appeng.api.implementations.items.IStorageComponent;
|
||||
@@ -62,239 +61,204 @@ import appeng.api.implementations.tiles.ISegmentedInventory;
|
||||
import appeng.api.parts.IPartHost;
|
||||
import appeng.api.parts.SelectedPart;
|
||||
import appeng.core.AEConfig;
|
||||
import appeng.api.features.AEFeature;
|
||||
import appeng.core.features.IStackSrc;
|
||||
import appeng.core.features.MaterialStackSrc;
|
||||
import appeng.entity.EntitySingularity;
|
||||
import appeng.items.AEBaseItem;
|
||||
import appeng.util.InventoryAdaptor;
|
||||
import appeng.util.Platform;
|
||||
import appeng.util.inv.AdaptorItemHandler;
|
||||
|
||||
public final class ItemMaterial extends AEBaseItem implements IStorageComponent, IUpgradeModule {
|
||||
|
||||
public final class ItemMaterial extends AEBaseItem implements IStorageComponent, IUpgradeModule
|
||||
{
|
||||
private static final int KILO_SCALAR = 1024;
|
||||
|
||||
private static final int KILO_SCALAR = 1024;
|
||||
private final MaterialType materialType;
|
||||
|
||||
private final MaterialType materialType;
|
||||
public ItemMaterial(Properties properties, MaterialType materialType) {
|
||||
super(properties);
|
||||
this.materialType = materialType;
|
||||
}
|
||||
|
||||
public ItemMaterial(Properties properties, MaterialType materialType) {
|
||||
super(properties);
|
||||
this.materialType = materialType;
|
||||
}
|
||||
@OnlyIn(Dist.CLIENT)
|
||||
@Override
|
||||
public void addInformation(final ItemStack stack, final World world, final List<ITextComponent> lines,
|
||||
final ITooltipFlag advancedTooltips) {
|
||||
super.addInformation(stack, world, lines, advancedTooltips);
|
||||
|
||||
@OnlyIn( Dist.CLIENT )
|
||||
@Override
|
||||
public void addInformation( final ItemStack stack, final World world, final List<ITextComponent> lines, final ITooltipFlag advancedTooltips )
|
||||
{
|
||||
super.addInformation( stack, world, lines, advancedTooltips );
|
||||
if (materialType == MaterialType.NAME_PRESS) {
|
||||
final CompoundNBT c = stack.getOrCreateTag();
|
||||
if (c.contains("InscriberName")) {
|
||||
lines.add(new StringTextComponent(c.getString("InscribeName")));
|
||||
}
|
||||
}
|
||||
|
||||
if( materialType == MaterialType.NAME_PRESS )
|
||||
{
|
||||
final CompoundNBT c = stack.getOrCreateTag();
|
||||
if (c.contains("InscriberName")) {
|
||||
lines.add(new StringTextComponent(c.getString("InscribeName")));
|
||||
}
|
||||
}
|
||||
final Upgrades u = this.getType(stack);
|
||||
if (u != null) {
|
||||
final List<ITextComponent> textList = new ArrayList<>();
|
||||
for (final Entry<ItemStack, Integer> j : u.getSupported().entrySet()) {
|
||||
ITextComponent name = null;
|
||||
|
||||
final Upgrades u = this.getType( stack );
|
||||
if( u != null )
|
||||
{
|
||||
final List<ITextComponent> textList = new ArrayList<>();
|
||||
for( final Entry<ItemStack, Integer> j : u.getSupported().entrySet() )
|
||||
{
|
||||
ITextComponent name = null;
|
||||
final int limit = j.getValue();
|
||||
|
||||
final int limit = j.getValue();
|
||||
if (j.getKey().getItem() instanceof IItemGroup) {
|
||||
final IItemGroup ig = (IItemGroup) j.getKey().getItem();
|
||||
final String str = ig.getUnlocalizedGroupName(u.getSupported().keySet(), j.getKey());
|
||||
if (str != null) {
|
||||
name = new TranslationTextComponent(str).appendText(limit > 1 ? " (" + limit + ')' : "");
|
||||
}
|
||||
}
|
||||
|
||||
if( j.getKey().getItem() instanceof IItemGroup )
|
||||
{
|
||||
final IItemGroup ig = (IItemGroup) j.getKey().getItem();
|
||||
final String str = ig.getUnlocalizedGroupName( u.getSupported().keySet(), j.getKey() );
|
||||
if( str != null )
|
||||
{
|
||||
name = new TranslationTextComponent( str ).appendText( limit > 1 ? " (" + limit + ')' : "" );
|
||||
}
|
||||
}
|
||||
if (name == null) {
|
||||
name = j.getKey().getDisplayName().appendText((limit > 1 ? " (" + limit + ')' : ""));
|
||||
}
|
||||
|
||||
if( name == null )
|
||||
{
|
||||
name = j.getKey().getDisplayName().appendText( ( limit > 1 ? " (" + limit + ')' : "" ) );
|
||||
}
|
||||
if (!textList.contains(name)) {
|
||||
textList.add(name);
|
||||
}
|
||||
}
|
||||
|
||||
if( !textList.contains( name ) )
|
||||
{
|
||||
textList.add( name );
|
||||
}
|
||||
}
|
||||
final Pattern p = Pattern.compile("(\\d+)[^\\d]");
|
||||
// FIXME This comparison is not great...
|
||||
final SlightlyBetterSort s = new SlightlyBetterSort(p);
|
||||
textList.sort(s);
|
||||
lines.addAll(textList);
|
||||
}
|
||||
}
|
||||
|
||||
final Pattern p = Pattern.compile( "(\\d+)[^\\d]" );
|
||||
// FIXME This comparison is not great...
|
||||
final SlightlyBetterSort s = new SlightlyBetterSort( p );
|
||||
textList.sort(s);
|
||||
lines.addAll( textList );
|
||||
}
|
||||
}
|
||||
@Override
|
||||
public Upgrades getType(final ItemStack itemstack) {
|
||||
switch (materialType) {
|
||||
case CARD_CAPACITY:
|
||||
return Upgrades.CAPACITY;
|
||||
case CARD_FUZZY:
|
||||
return Upgrades.FUZZY;
|
||||
case CARD_REDSTONE:
|
||||
return Upgrades.REDSTONE;
|
||||
case CARD_SPEED:
|
||||
return Upgrades.SPEED;
|
||||
case CARD_INVERTER:
|
||||
return Upgrades.INVERTER;
|
||||
case CARD_CRAFTING:
|
||||
return Upgrades.CRAFTING;
|
||||
default:
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public Upgrades getType( final ItemStack itemstack )
|
||||
{
|
||||
switch( materialType )
|
||||
{
|
||||
case CARD_CAPACITY:
|
||||
return Upgrades.CAPACITY;
|
||||
case CARD_FUZZY:
|
||||
return Upgrades.FUZZY;
|
||||
case CARD_REDSTONE:
|
||||
return Upgrades.REDSTONE;
|
||||
case CARD_SPEED:
|
||||
return Upgrades.SPEED;
|
||||
case CARD_INVERTER:
|
||||
return Upgrades.INVERTER;
|
||||
case CARD_CRAFTING:
|
||||
return Upgrades.CRAFTING;
|
||||
default:
|
||||
return null;
|
||||
}
|
||||
}
|
||||
@Override
|
||||
public ActionResultType onItemUseFirst(ItemStack stack, ItemUseContext context) {
|
||||
PlayerEntity player = context.getPlayer();
|
||||
Hand hand = context.getHand();
|
||||
if (player.isCrouching()) {
|
||||
final TileEntity te = context.getWorld().getTileEntity(context.getPos());
|
||||
IItemHandler upgrades = null;
|
||||
|
||||
@Override
|
||||
public ActionResultType onItemUseFirst( ItemStack stack, ItemUseContext context )
|
||||
{
|
||||
PlayerEntity player = context.getPlayer();
|
||||
Hand hand = context.getHand();
|
||||
if( player.isCrouching() )
|
||||
{
|
||||
final TileEntity te = context.getWorld().getTileEntity( context.getPos() );
|
||||
IItemHandler upgrades = null;
|
||||
if (te instanceof IPartHost) {
|
||||
final SelectedPart sp = ((IPartHost) te).selectPart(context.getHitVec());
|
||||
if (sp.part instanceof IUpgradeableHost) {
|
||||
upgrades = ((ISegmentedInventory) sp.part).getInventoryByName("upgrades");
|
||||
}
|
||||
} else if (te instanceof IUpgradeableHost) {
|
||||
upgrades = ((ISegmentedInventory) te).getInventoryByName("upgrades");
|
||||
}
|
||||
|
||||
if( te instanceof IPartHost )
|
||||
{
|
||||
final SelectedPart sp = ( (IPartHost) te ).selectPart( context.getHitVec() );
|
||||
if( sp.part instanceof IUpgradeableHost )
|
||||
{
|
||||
upgrades = ( (ISegmentedInventory) sp.part ).getInventoryByName( "upgrades" );
|
||||
}
|
||||
}
|
||||
else if( te instanceof IUpgradeableHost )
|
||||
{
|
||||
upgrades = ( (ISegmentedInventory) te ).getInventoryByName( "upgrades" );
|
||||
}
|
||||
if (upgrades != null && !player.getHeldItem(hand).isEmpty()
|
||||
&& player.getHeldItem(hand).getItem() instanceof IUpgradeModule) {
|
||||
final IUpgradeModule um = (IUpgradeModule) player.getHeldItem(hand).getItem();
|
||||
final Upgrades u = um.getType(player.getHeldItem(hand));
|
||||
|
||||
if( upgrades != null && !player.getHeldItem( hand ).isEmpty() && player.getHeldItem( hand ).getItem() instanceof IUpgradeModule )
|
||||
{
|
||||
final IUpgradeModule um = (IUpgradeModule) player.getHeldItem( hand ).getItem();
|
||||
final Upgrades u = um.getType( player.getHeldItem( hand ) );
|
||||
if (u != null) {
|
||||
if (player.world.isRemote) {
|
||||
return ActionResultType.PASS;
|
||||
}
|
||||
|
||||
if( u != null )
|
||||
{
|
||||
if( player.world.isRemote )
|
||||
{
|
||||
return ActionResultType.PASS;
|
||||
}
|
||||
final InventoryAdaptor ad = new AdaptorItemHandler(upgrades);
|
||||
player.setHeldItem(hand, ad.addItems(player.getHeldItem(hand)));
|
||||
return ActionResultType.SUCCESS;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
final InventoryAdaptor ad = new AdaptorItemHandler( upgrades );
|
||||
player.setHeldItem( hand, ad.addItems( player.getHeldItem( hand ) ) );
|
||||
return ActionResultType.SUCCESS;
|
||||
}
|
||||
}
|
||||
}
|
||||
return super.onItemUseFirst(stack, context);
|
||||
}
|
||||
|
||||
return super.onItemUseFirst( stack, context );
|
||||
}
|
||||
@Override
|
||||
public boolean hasCustomEntity(final ItemStack is) {
|
||||
return materialType.hasCustomEntity();
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean hasCustomEntity( final ItemStack is )
|
||||
{
|
||||
return materialType.hasCustomEntity();
|
||||
}
|
||||
@Override
|
||||
public Entity createEntity(final World w, final Entity location, final ItemStack itemstack) {
|
||||
final Class<? extends Entity> droppedEntity = materialType.getCustomEntityClass();
|
||||
final Entity eqi;
|
||||
|
||||
@Override
|
||||
public Entity createEntity( final World w, final Entity location, final ItemStack itemstack )
|
||||
{
|
||||
final Class<? extends Entity> droppedEntity = materialType.getCustomEntityClass();
|
||||
final Entity eqi;
|
||||
try {
|
||||
eqi = droppedEntity.getConstructor(World.class, double.class, double.class, double.class, ItemStack.class)
|
||||
.newInstance(w, location.getPosX(), location.getPosY(), location.getPosZ(), itemstack);
|
||||
} catch (final Throwable t) {
|
||||
throw new IllegalStateException(t);
|
||||
}
|
||||
|
||||
try
|
||||
{
|
||||
eqi = droppedEntity.getConstructor( World.class, double.class, double.class, double.class, ItemStack.class ).newInstance( w, location.getPosX(), location.getPosY(), location.getPosZ(), itemstack );
|
||||
}
|
||||
catch( final Throwable t )
|
||||
{
|
||||
throw new IllegalStateException( t );
|
||||
}
|
||||
eqi.setMotion(location.getMotion());
|
||||
|
||||
eqi.setMotion( location.getMotion() );
|
||||
if (location instanceof ItemEntity && eqi instanceof ItemEntity) {
|
||||
((ItemEntity) eqi).setDefaultPickupDelay();
|
||||
}
|
||||
|
||||
if( location instanceof ItemEntity && eqi instanceof ItemEntity )
|
||||
{
|
||||
( (ItemEntity) eqi ).setDefaultPickupDelay();
|
||||
}
|
||||
return eqi;
|
||||
}
|
||||
|
||||
return eqi;
|
||||
}
|
||||
@Override
|
||||
public int getBytes(final ItemStack is) {
|
||||
switch (materialType) {
|
||||
case ITEM_1K_CELL_COMPONENT:
|
||||
return KILO_SCALAR;
|
||||
case ITEM_4K_CELL_COMPONENT:
|
||||
return KILO_SCALAR * 4;
|
||||
case ITEM_16K_CELL_COMPONENT:
|
||||
return KILO_SCALAR * 16;
|
||||
case ITEM_64K_CELL_COMPONENT:
|
||||
return KILO_SCALAR * 64;
|
||||
default:
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getBytes( final ItemStack is )
|
||||
{
|
||||
switch( materialType )
|
||||
{
|
||||
case ITEM_1K_CELL_COMPONENT:
|
||||
return KILO_SCALAR;
|
||||
case ITEM_4K_CELL_COMPONENT:
|
||||
return KILO_SCALAR * 4;
|
||||
case ITEM_16K_CELL_COMPONENT:
|
||||
return KILO_SCALAR * 16;
|
||||
case ITEM_64K_CELL_COMPONENT:
|
||||
return KILO_SCALAR * 64;
|
||||
default:
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
@Override
|
||||
public boolean isStorageComponent(final ItemStack is) {
|
||||
switch (materialType) {
|
||||
case ITEM_1K_CELL_COMPONENT:
|
||||
case ITEM_4K_CELL_COMPONENT:
|
||||
case ITEM_16K_CELL_COMPONENT:
|
||||
case ITEM_64K_CELL_COMPONENT:
|
||||
return true;
|
||||
default:
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isStorageComponent( final ItemStack is )
|
||||
{
|
||||
switch( materialType )
|
||||
{
|
||||
case ITEM_1K_CELL_COMPONENT:
|
||||
case ITEM_4K_CELL_COMPONENT:
|
||||
case ITEM_16K_CELL_COMPONENT:
|
||||
case ITEM_64K_CELL_COMPONENT:
|
||||
return true;
|
||||
default:
|
||||
}
|
||||
return false;
|
||||
}
|
||||
private static class SlightlyBetterSort implements Comparator<ITextComponent> {
|
||||
private final Pattern pattern;
|
||||
|
||||
private static class SlightlyBetterSort implements Comparator<ITextComponent>
|
||||
{
|
||||
private final Pattern pattern;
|
||||
public SlightlyBetterSort(final Pattern pattern) {
|
||||
this.pattern = pattern;
|
||||
}
|
||||
|
||||
public SlightlyBetterSort( final Pattern pattern )
|
||||
{
|
||||
this.pattern = pattern;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int compare( final ITextComponent o1, final ITextComponent o2 )
|
||||
{
|
||||
try
|
||||
{
|
||||
final Matcher a = this.pattern.matcher( o1.getString() );
|
||||
final Matcher b = this.pattern.matcher( o2.getString() );
|
||||
if( a.find() && b.find() )
|
||||
{
|
||||
final int ia = Integer.parseInt( a.group( 1 ) );
|
||||
final int ib = Integer.parseInt( b.group( 1 ) );
|
||||
return Integer.compare( ia, ib );
|
||||
}
|
||||
}
|
||||
catch( final Throwable t )
|
||||
{
|
||||
// ek!
|
||||
}
|
||||
return o1.getString().compareTo( o2.getString() );
|
||||
}
|
||||
}
|
||||
@Override
|
||||
public int compare(final ITextComponent o1, final ITextComponent o2) {
|
||||
try {
|
||||
final Matcher a = this.pattern.matcher(o1.getString());
|
||||
final Matcher b = this.pattern.matcher(o2.getString());
|
||||
if (a.find() && b.find()) {
|
||||
final int ia = Integer.parseInt(a.group(1));
|
||||
final int ib = Integer.parseInt(b.group(1));
|
||||
return Integer.compare(ia, ib);
|
||||
}
|
||||
} catch (final Throwable t) {
|
||||
// ek!
|
||||
}
|
||||
return o1.getString().compareTo(o2.getString());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -18,7 +18,6 @@
|
||||
|
||||
package appeng.items.materials;
|
||||
|
||||
|
||||
import java.util.EnumSet;
|
||||
import java.util.Set;
|
||||
|
||||
@@ -27,190 +26,180 @@ import net.minecraft.item.Item;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.util.ResourceLocation;
|
||||
|
||||
import appeng.core.AppEng;
|
||||
import appeng.api.features.AEFeature;
|
||||
import appeng.core.AppEng;
|
||||
import appeng.core.features.MaterialStackSrc;
|
||||
import appeng.entity.EntityChargedQuartz;
|
||||
import appeng.entity.EntitySingularity;
|
||||
|
||||
public enum MaterialType {
|
||||
CERTUS_QUARTZ_CRYSTAL("certus_quartz_crystal", EnumSet.of(AEFeature.CERTUS), "crystalCertusQuartz"),
|
||||
CERTUS_QUARTZ_CRYSTAL_CHARGED("charged_certus_quartz_crystal", EnumSet.of(AEFeature.CERTUS),
|
||||
EntityChargedQuartz.class),
|
||||
|
||||
public enum MaterialType
|
||||
{
|
||||
CERTUS_QUARTZ_CRYSTAL("certus_quartz_crystal", EnumSet.of( AEFeature.CERTUS ), "crystalCertusQuartz" ),
|
||||
CERTUS_QUARTZ_CRYSTAL_CHARGED("charged_certus_quartz_crystal", EnumSet.of( AEFeature.CERTUS ), EntityChargedQuartz.class ),
|
||||
CERTUS_QUARTZ_DUST("certus_quartz_dust", EnumSet.of(AEFeature.DUSTS, AEFeature.CERTUS), "dustCertusQuartz"),
|
||||
NETHER_QUARTZ_DUST("nether_quartz_dust", EnumSet.of(AEFeature.DUSTS), "dustNetherQuartz,dustQuartz"),
|
||||
FLOUR("flour", EnumSet.of(AEFeature.FLOUR), "dustWheat"),
|
||||
GOLD_DUST("gold_dust", EnumSet.of(AEFeature.DUSTS), "dustGold"),
|
||||
IRON_DUST("iron_dust", EnumSet.of(AEFeature.DUSTS), "dustIron"),
|
||||
|
||||
CERTUS_QUARTZ_DUST("certus_quartz_dust", EnumSet.of( AEFeature.DUSTS, AEFeature.CERTUS ), "dustCertusQuartz" ),
|
||||
NETHER_QUARTZ_DUST("nether_quartz_dust", EnumSet.of( AEFeature.DUSTS ), "dustNetherQuartz,dustQuartz" ),
|
||||
FLOUR("flour", EnumSet.of( AEFeature.FLOUR ), "dustWheat" ),
|
||||
GOLD_DUST("gold_dust", EnumSet.of( AEFeature.DUSTS ), "dustGold" ),
|
||||
IRON_DUST("iron_dust", EnumSet.of( AEFeature.DUSTS ), "dustIron" ),
|
||||
SILICON("silicon", EnumSet.of(AEFeature.SILICON), "itemSilicon"),
|
||||
MATTER_BALL("matter_ball", EnumSet.of(AEFeature.MATTER_BALL)),
|
||||
|
||||
SILICON("silicon", EnumSet.of( AEFeature.SILICON ), "itemSilicon" ),
|
||||
MATTER_BALL("matter_ball", EnumSet.of( AEFeature.MATTER_BALL ) ),
|
||||
FLUIX_CRYSTAL("fluix_crystal", EnumSet.of(AEFeature.FLUIX), "crystalFluix"),
|
||||
FLUIX_DUST("fluix_dust", EnumSet.of(AEFeature.FLUIX, AEFeature.DUSTS), "dustFluix"),
|
||||
FLUIX_PEARL("fluix_pearl", EnumSet.of(AEFeature.FLUIX), "pearlFluix"),
|
||||
|
||||
FLUIX_CRYSTAL("fluix_crystal", EnumSet.of( AEFeature.FLUIX ), "crystalFluix" ),
|
||||
FLUIX_DUST("fluix_dust", EnumSet.of( AEFeature.FLUIX, AEFeature.DUSTS ), "dustFluix" ),
|
||||
FLUIX_PEARL("fluix_pearl", EnumSet.of( AEFeature.FLUIX ), "pearlFluix" ),
|
||||
PURIFIED_CERTUS_QUARTZ_CRYSTAL("purified_certus_quartz_crystal",
|
||||
EnumSet.of(AEFeature.CERTUS, AEFeature.PURE_CRYSTALS), "crystalPureCertusQuartz"),
|
||||
PURIFIED_NETHER_QUARTZ_CRYSTAL("purified_nether_quartz_crystal", EnumSet.of(AEFeature.PURE_CRYSTALS),
|
||||
"crystalPureNetherQuartz"),
|
||||
PURIFIED_FLUIX_CRYSTAL("purified_fluix_crystal", EnumSet.of(AEFeature.FLUIX, AEFeature.PURE_CRYSTALS),
|
||||
"crystalPureFluix"),
|
||||
|
||||
PURIFIED_CERTUS_QUARTZ_CRYSTAL("purified_certus_quartz_crystal", EnumSet.of( AEFeature.CERTUS,
|
||||
AEFeature.PURE_CRYSTALS ), "crystalPureCertusQuartz" ),
|
||||
PURIFIED_NETHER_QUARTZ_CRYSTAL("purified_nether_quartz_crystal", EnumSet.of( AEFeature.PURE_CRYSTALS ), "crystalPureNetherQuartz" ),
|
||||
PURIFIED_FLUIX_CRYSTAL("purified_fluix_crystal", EnumSet.of( AEFeature.FLUIX, AEFeature.PURE_CRYSTALS ), "crystalPureFluix" ),
|
||||
CALCULATION_PROCESSOR_PRESS("calculation_processor_press", EnumSet.of(AEFeature.PRESSES)),
|
||||
ENGINEERING_PROCESSOR_PRESS("engineering_processor_press", EnumSet.of(AEFeature.PRESSES)),
|
||||
LOGIC_PROCESSOR_PRESS("logic_processor_press", EnumSet.of(AEFeature.PRESSES)),
|
||||
|
||||
CALCULATION_PROCESSOR_PRESS("calculation_processor_press", EnumSet.of( AEFeature.PRESSES ) ),
|
||||
ENGINEERING_PROCESSOR_PRESS("engineering_processor_press", EnumSet.of( AEFeature.PRESSES ) ),
|
||||
LOGIC_PROCESSOR_PRESS("logic_processor_press", EnumSet.of( AEFeature.PRESSES ) ),
|
||||
CALCULATION_PROCESSOR_PRINT("printed_calculation_processor", EnumSet.of(AEFeature.PRINTED_CIRCUITS)),
|
||||
ENGINEERING_PROCESSOR_PRINT("printed_engineering_processor", EnumSet.of(AEFeature.PRINTED_CIRCUITS)),
|
||||
LOGIC_PROCESSOR_PRINT("printed_logic_processor", EnumSet.of(AEFeature.PRINTED_CIRCUITS)),
|
||||
|
||||
CALCULATION_PROCESSOR_PRINT("printed_calculation_processor", EnumSet.of( AEFeature.PRINTED_CIRCUITS ) ),
|
||||
ENGINEERING_PROCESSOR_PRINT("printed_engineering_processor", EnumSet.of( AEFeature.PRINTED_CIRCUITS ) ),
|
||||
LOGIC_PROCESSOR_PRINT("printed_logic_processor", EnumSet.of( AEFeature.PRINTED_CIRCUITS ) ),
|
||||
SILICON_PRESS("silicon_press", EnumSet.of(AEFeature.PRESSES)),
|
||||
SILICON_PRINT("printed_silicon", EnumSet.of(AEFeature.PRINTED_CIRCUITS)),
|
||||
|
||||
SILICON_PRESS("silicon_press", EnumSet.of( AEFeature.PRESSES ) ),
|
||||
SILICON_PRINT("printed_silicon", EnumSet.of( AEFeature.PRINTED_CIRCUITS ) ),
|
||||
NAME_PRESS("name_press", EnumSet.of(AEFeature.PRESSES)),
|
||||
|
||||
NAME_PRESS("name_press", EnumSet.of( AEFeature.PRESSES ) ),
|
||||
LOGIC_PROCESSOR("logic_processor", EnumSet.of(AEFeature.PROCESSORS)),
|
||||
CALCULATION_PROCESSOR("calculation_processor", EnumSet.of(AEFeature.PROCESSORS)),
|
||||
ENGINEERING_PROCESSOR("engineering_processor", EnumSet.of(AEFeature.PROCESSORS)),
|
||||
|
||||
LOGIC_PROCESSOR("logic_processor", EnumSet.of( AEFeature.PROCESSORS ) ),
|
||||
CALCULATION_PROCESSOR("calculation_processor", EnumSet.of( AEFeature.PROCESSORS ) ),
|
||||
ENGINEERING_PROCESSOR("engineering_processor", EnumSet.of( AEFeature.PROCESSORS ) ),
|
||||
// Basic Cards
|
||||
BASIC_CARD("basic_card", EnumSet.of(AEFeature.BASIC_CARDS)),
|
||||
CARD_REDSTONE("redstone_card", EnumSet.of(AEFeature.BASIC_CARDS)),
|
||||
CARD_CAPACITY("capacity_card", EnumSet.of(AEFeature.BASIC_CARDS)),
|
||||
|
||||
// Basic Cards
|
||||
BASIC_CARD("basic_card", EnumSet.of( AEFeature.BASIC_CARDS ) ),
|
||||
CARD_REDSTONE("redstone_card", EnumSet.of( AEFeature.BASIC_CARDS ) ),
|
||||
CARD_CAPACITY("capacity_card", EnumSet.of( AEFeature.BASIC_CARDS ) ),
|
||||
// Adv Cards
|
||||
ADVANCED_CARD("advanced_card", EnumSet.of(AEFeature.ADVANCED_CARDS)),
|
||||
CARD_FUZZY("fuzzy_card", EnumSet.of(AEFeature.ADVANCED_CARDS)),
|
||||
CARD_SPEED("speed_card", EnumSet.of(AEFeature.ADVANCED_CARDS)),
|
||||
CARD_INVERTER("inverter_card", EnumSet.of(AEFeature.ADVANCED_CARDS)),
|
||||
|
||||
// Adv Cards
|
||||
ADVANCED_CARD("advanced_card", EnumSet.of( AEFeature.ADVANCED_CARDS ) ),
|
||||
CARD_FUZZY("fuzzy_card", EnumSet.of( AEFeature.ADVANCED_CARDS ) ),
|
||||
CARD_SPEED("speed_card", EnumSet.of( AEFeature.ADVANCED_CARDS ) ),
|
||||
CARD_INVERTER("inverter_card", EnumSet.of( AEFeature.ADVANCED_CARDS ) ),
|
||||
SPATIAL_2_CELL_COMPONENT("2_cubed_spatial_cell_component", EnumSet.of(AEFeature.SPATIAL_IO)),
|
||||
SPATIAL_16_CELL_COMPONENT("16_cubed_spatial_cell_component", EnumSet.of(AEFeature.SPATIAL_IO)),
|
||||
SPATIAL_128_CELL_COMPONENT("128_cubed_spatial_cell_component", EnumSet.of(AEFeature.SPATIAL_IO)),
|
||||
|
||||
SPATIAL_2_CELL_COMPONENT("2_cubed_spatial_cell_component", EnumSet.of( AEFeature.SPATIAL_IO ) ),
|
||||
SPATIAL_16_CELL_COMPONENT("16_cubed_spatial_cell_component", EnumSet.of( AEFeature.SPATIAL_IO ) ),
|
||||
SPATIAL_128_CELL_COMPONENT("128_cubed_spatial_cell_component", EnumSet.of( AEFeature.SPATIAL_IO ) ),
|
||||
ITEM_1K_CELL_COMPONENT("1k_cell_component", EnumSet.of(AEFeature.STORAGE_CELLS)),
|
||||
ITEM_4K_CELL_COMPONENT("4k_cell_component", EnumSet.of(AEFeature.STORAGE_CELLS)),
|
||||
ITEM_16K_CELL_COMPONENT("16k_cell_component", EnumSet.of(AEFeature.STORAGE_CELLS)),
|
||||
ITEM_64K_CELL_COMPONENT("64k_cell_component", EnumSet.of(AEFeature.STORAGE_CELLS)),
|
||||
EMPTY_STORAGE_CELL("empty_storage_cell", EnumSet.of(AEFeature.STORAGE_CELLS)),
|
||||
|
||||
ITEM_1K_CELL_COMPONENT("1k_cell_component", EnumSet.of( AEFeature.STORAGE_CELLS ) ),
|
||||
ITEM_4K_CELL_COMPONENT("4k_cell_component", EnumSet.of( AEFeature.STORAGE_CELLS ) ),
|
||||
ITEM_16K_CELL_COMPONENT("16k_cell_component", EnumSet.of( AEFeature.STORAGE_CELLS ) ),
|
||||
ITEM_64K_CELL_COMPONENT("64k_cell_component", EnumSet.of( AEFeature.STORAGE_CELLS ) ),
|
||||
EMPTY_STORAGE_CELL("empty_storage_cell", EnumSet.of( AEFeature.STORAGE_CELLS ) ),
|
||||
WOODEN_GEAR("wooden_gear", EnumSet.of(AEFeature.GRIND_STONE), "gearWood"),
|
||||
|
||||
WOODEN_GEAR("wooden_gear", EnumSet.of( AEFeature.GRIND_STONE ), "gearWood" ),
|
||||
WIRELESS_RECEIVER("wireless_receiver", EnumSet.of(AEFeature.WIRELESS_ACCESS_TERMINAL)),
|
||||
WIRELESS_BOOSTER("wireless_booster", EnumSet.of(AEFeature.WIRELESS_ACCESS_TERMINAL)),
|
||||
|
||||
WIRELESS_RECEIVER("wireless_receiver", EnumSet.of( AEFeature.WIRELESS_ACCESS_TERMINAL ) ),
|
||||
WIRELESS_BOOSTER("wireless_booster", EnumSet.of( AEFeature.WIRELESS_ACCESS_TERMINAL ) ),
|
||||
FORMATION_CORE("formation_core", EnumSet.of(AEFeature.CORES)),
|
||||
ANNIHILATION_CORE("annihilation_core", EnumSet.of(AEFeature.CORES)),
|
||||
|
||||
FORMATION_CORE("formation_core", EnumSet.of( AEFeature.CORES ) ),
|
||||
ANNIHILATION_CORE("annihilation_core", EnumSet.of( AEFeature.CORES ) ),
|
||||
SKY_DUST("sky_dust", EnumSet.of(AEFeature.DUSTS)),
|
||||
|
||||
SKY_DUST("sky_dust", EnumSet.of( AEFeature.DUSTS ) ),
|
||||
ENDER_DUST("ender_dust", EnumSet.of(AEFeature.QUANTUM_NETWORK_BRIDGE), "dustEnder,dustEnderPearl",
|
||||
EntitySingularity.class),
|
||||
SINGULARITY("singularity", EnumSet.of(AEFeature.QUANTUM_NETWORK_BRIDGE), EntitySingularity.class),
|
||||
QUANTUM_ENTANGLED_SINGULARITY("quantum_entangled_singularity", EnumSet.of(AEFeature.QUANTUM_NETWORK_BRIDGE),
|
||||
EntitySingularity.class),
|
||||
|
||||
ENDER_DUST("ender_dust", EnumSet.of( AEFeature.QUANTUM_NETWORK_BRIDGE ), "dustEnder,dustEnderPearl", EntitySingularity.class ),
|
||||
SINGULARITY("singularity", EnumSet.of( AEFeature.QUANTUM_NETWORK_BRIDGE ), EntitySingularity.class ),
|
||||
QUANTUM_ENTANGLED_SINGULARITY("quantum_entangled_singularity", EnumSet.of( AEFeature.QUANTUM_NETWORK_BRIDGE ), EntitySingularity.class ),
|
||||
BLANK_PATTERN("blank_pattern", EnumSet.of(AEFeature.PATTERNS)),
|
||||
CARD_CRAFTING("crafting_card", EnumSet.of(AEFeature.ADVANCED_CARDS, AEFeature.CRAFTING_CPU)),
|
||||
|
||||
BLANK_PATTERN("blank_pattern", EnumSet.of( AEFeature.PATTERNS ) ),
|
||||
CARD_CRAFTING("crafting_card", EnumSet.of( AEFeature.ADVANCED_CARDS, AEFeature.CRAFTING_CPU ) ),
|
||||
FLUID_1K_CELL_COMPONENT("1k_fluid_cell_component", EnumSet.of(AEFeature.STORAGE_CELLS)),
|
||||
FLUID_4K_CELL_COMPONENT("4k_fluid_cell_component", EnumSet.of(AEFeature.STORAGE_CELLS)),
|
||||
FLUID_16K_CELL_COMPONENT("16k_fluid_cell_component", EnumSet.of(AEFeature.STORAGE_CELLS)),
|
||||
FLUID_64K_CELL_COMPONENT("64k_fluid_cell_component", EnumSet.of(AEFeature.STORAGE_CELLS));
|
||||
|
||||
FLUID_1K_CELL_COMPONENT("1k_fluid_cell_component", EnumSet.of( AEFeature.STORAGE_CELLS ) ),
|
||||
FLUID_4K_CELL_COMPONENT("4k_fluid_cell_component", EnumSet.of( AEFeature.STORAGE_CELLS ) ),
|
||||
FLUID_16K_CELL_COMPONENT("16k_fluid_cell_component", EnumSet.of( AEFeature.STORAGE_CELLS ) ),
|
||||
FLUID_64K_CELL_COMPONENT("64k_fluid_cell_component", EnumSet.of( AEFeature.STORAGE_CELLS ) );
|
||||
private final Set<AEFeature> features;
|
||||
private final ResourceLocation registryName;
|
||||
private Item itemInstance;
|
||||
// stack!
|
||||
private MaterialStackSrc stackSrc;
|
||||
private String oreName;
|
||||
private Class<? extends Entity> droppedEntity;
|
||||
private boolean isRegistered = false;
|
||||
|
||||
private final Set<AEFeature> features;
|
||||
private final ResourceLocation registryName;
|
||||
private Item itemInstance;
|
||||
// stack!
|
||||
private MaterialStackSrc stackSrc;
|
||||
private String oreName;
|
||||
private Class<? extends Entity> droppedEntity;
|
||||
private boolean isRegistered = false;
|
||||
MaterialType(String id, final Set<AEFeature> features) {
|
||||
this.features = features;
|
||||
this.registryName = new ResourceLocation(AppEng.MOD_ID, id);
|
||||
}
|
||||
|
||||
MaterialType(String id, final Set<AEFeature> features)
|
||||
{
|
||||
this.features = features;
|
||||
this.registryName = new ResourceLocation( AppEng.MOD_ID, id);
|
||||
}
|
||||
MaterialType(String id, final Set<AEFeature> features, final Class<? extends Entity> c) {
|
||||
this(id, features);
|
||||
this.droppedEntity = c;
|
||||
}
|
||||
|
||||
MaterialType(String id, final Set<AEFeature> features, final Class<? extends Entity> c)
|
||||
{
|
||||
this(id, features );
|
||||
this.droppedEntity = c;
|
||||
}
|
||||
MaterialType(String id, final Set<AEFeature> features, final String oreDictionary,
|
||||
final Class<? extends Entity> c) {
|
||||
this(id, features);
|
||||
this.oreName = oreDictionary;
|
||||
this.droppedEntity = c;
|
||||
}
|
||||
|
||||
MaterialType(String id, final Set<AEFeature> features, final String oreDictionary, final Class<? extends Entity> c)
|
||||
{
|
||||
this(id, features );
|
||||
this.oreName = oreDictionary;
|
||||
this.droppedEntity = c;
|
||||
}
|
||||
MaterialType(String id, final Set<AEFeature> features, final String oreDictionary) {
|
||||
this(id, features);
|
||||
this.oreName = oreDictionary;
|
||||
}
|
||||
|
||||
MaterialType(String id, final Set<AEFeature> features, final String oreDictionary)
|
||||
{
|
||||
this(id, features );
|
||||
this.oreName = oreDictionary;
|
||||
}
|
||||
public ItemStack stack(final int size) {
|
||||
return new ItemStack(this.getItemInstance(), size);
|
||||
}
|
||||
|
||||
public ItemStack stack( final int size )
|
||||
{
|
||||
return new ItemStack( this.getItemInstance(), size );
|
||||
}
|
||||
public Set<AEFeature> getFeature() {
|
||||
return this.features;
|
||||
}
|
||||
|
||||
public Set<AEFeature> getFeature()
|
||||
{
|
||||
return this.features;
|
||||
}
|
||||
public String getOreName() {
|
||||
return this.oreName;
|
||||
}
|
||||
|
||||
public String getOreName()
|
||||
{
|
||||
return this.oreName;
|
||||
}
|
||||
boolean hasCustomEntity() {
|
||||
return this.droppedEntity != null;
|
||||
}
|
||||
|
||||
boolean hasCustomEntity()
|
||||
{
|
||||
return this.droppedEntity != null;
|
||||
}
|
||||
Class<? extends Entity> getCustomEntityClass() {
|
||||
return this.droppedEntity;
|
||||
}
|
||||
|
||||
Class<? extends Entity> getCustomEntityClass()
|
||||
{
|
||||
return this.droppedEntity;
|
||||
}
|
||||
public boolean isRegistered() {
|
||||
return this.isRegistered;
|
||||
}
|
||||
|
||||
public boolean isRegistered()
|
||||
{
|
||||
return this.isRegistered;
|
||||
}
|
||||
public void markReady() {
|
||||
this.isRegistered = true;
|
||||
}
|
||||
|
||||
public void markReady()
|
||||
{
|
||||
this.isRegistered = true;
|
||||
}
|
||||
public Item getItemInstance() {
|
||||
return this.itemInstance;
|
||||
}
|
||||
|
||||
public Item getItemInstance()
|
||||
{
|
||||
return this.itemInstance;
|
||||
}
|
||||
public void setItemInstance(final Item itemInstance) {
|
||||
this.itemInstance = itemInstance;
|
||||
}
|
||||
|
||||
public void setItemInstance( final Item itemInstance )
|
||||
{
|
||||
this.itemInstance = itemInstance;
|
||||
}
|
||||
public MaterialStackSrc getStackSrc() {
|
||||
return this.stackSrc;
|
||||
}
|
||||
|
||||
public MaterialStackSrc getStackSrc()
|
||||
{
|
||||
return this.stackSrc;
|
||||
}
|
||||
public void setStackSrc(final MaterialStackSrc stackSrc) {
|
||||
this.stackSrc = stackSrc;
|
||||
}
|
||||
|
||||
public void setStackSrc( final MaterialStackSrc stackSrc )
|
||||
{
|
||||
this.stackSrc = stackSrc;
|
||||
}
|
||||
public String getId() {
|
||||
return registryName.getPath();
|
||||
}
|
||||
|
||||
public String getId() { return registryName.getPath(); }
|
||||
|
||||
public ResourceLocation getRegistryName()
|
||||
{
|
||||
return this.registryName;
|
||||
}
|
||||
public ResourceLocation getRegistryName() {
|
||||
return this.registryName;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -18,12 +18,12 @@
|
||||
|
||||
package appeng.items.misc;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import javax.annotation.Nullable;
|
||||
|
||||
import appeng.api.implementations.items.IGrowableCrystal;
|
||||
import appeng.core.localization.ButtonToolTips;
|
||||
import appeng.entity.EntityGrowingCrystal;
|
||||
import appeng.items.AEBaseItem;
|
||||
import com.google.common.base.Preconditions;
|
||||
|
||||
import net.minecraft.block.Block;
|
||||
import net.minecraft.block.material.Material;
|
||||
import net.minecraft.client.util.ITooltipFlag;
|
||||
@@ -41,121 +41,116 @@ import net.minecraft.world.World;
|
||||
import net.minecraftforge.api.distmarker.Dist;
|
||||
import net.minecraftforge.api.distmarker.OnlyIn;
|
||||
|
||||
import javax.annotation.Nullable;
|
||||
import java.util.List;
|
||||
import appeng.api.implementations.items.IGrowableCrystal;
|
||||
import appeng.core.localization.ButtonToolTips;
|
||||
import appeng.entity.EntityGrowingCrystal;
|
||||
import appeng.items.AEBaseItem;
|
||||
|
||||
/**
|
||||
* This item reprents one of the seeds used to grow various forms of quartz by
|
||||
* throwing them into water (for that behavior, see the linked entity)
|
||||
*/
|
||||
public class ItemCrystalSeed extends AEBaseItem implements IGrowableCrystal
|
||||
{
|
||||
public class ItemCrystalSeed extends AEBaseItem implements IGrowableCrystal {
|
||||
|
||||
/**
|
||||
* Name of NBT tag used to store the growth progress value.
|
||||
*/
|
||||
private static final String TAG_GROWTH_TICKS = "p";
|
||||
/**
|
||||
* Name of NBT tag used to store the growth progress value.
|
||||
*/
|
||||
private static final String TAG_GROWTH_TICKS = "p";
|
||||
|
||||
/**
|
||||
* The number of growth ticks required to finish growing.
|
||||
*/
|
||||
private static final int GROWTH_TICKS_REQUIRED = 600;
|
||||
/**
|
||||
* The number of growth ticks required to finish growing.
|
||||
*/
|
||||
private static final int GROWTH_TICKS_REQUIRED = 600;
|
||||
|
||||
/**
|
||||
* The item to convert to, when growth finishes.
|
||||
*/
|
||||
private final IItemProvider grownItem;
|
||||
/**
|
||||
* The item to convert to, when growth finishes.
|
||||
*/
|
||||
private final IItemProvider grownItem;
|
||||
|
||||
public ItemCrystalSeed(Properties properties, IItemProvider grownItem) {
|
||||
super(properties);
|
||||
this.grownItem = Preconditions.checkNotNull(grownItem);
|
||||
// Expose the growth of the seed to the model system
|
||||
addPropertyOverride(new ResourceLocation("appliedenergistics2:growth"),
|
||||
(is, w, p) -> getGrowthTicks(is) / (float) GROWTH_TICKS_REQUIRED);
|
||||
}
|
||||
public ItemCrystalSeed(Properties properties, IItemProvider grownItem) {
|
||||
super(properties);
|
||||
this.grownItem = Preconditions.checkNotNull(grownItem);
|
||||
// Expose the growth of the seed to the model system
|
||||
addPropertyOverride(new ResourceLocation("appliedenergistics2:growth"),
|
||||
(is, w, p) -> getGrowthTicks(is) / (float) GROWTH_TICKS_REQUIRED);
|
||||
}
|
||||
|
||||
@Nullable
|
||||
@Override
|
||||
public ItemStack triggerGrowth( final ItemStack is )
|
||||
{
|
||||
final int growthTicks = getGrowthTicks( is ) + 1;
|
||||
if (growthTicks >= GROWTH_TICKS_REQUIRED) {
|
||||
return new ItemStack(grownItem, is.getCount());
|
||||
} else {
|
||||
this.setGrowthTicks(is, growthTicks);
|
||||
return is;
|
||||
}
|
||||
}
|
||||
@Nullable
|
||||
@Override
|
||||
public ItemStack triggerGrowth(final ItemStack is) {
|
||||
final int growthTicks = getGrowthTicks(is) + 1;
|
||||
if (growthTicks >= GROWTH_TICKS_REQUIRED) {
|
||||
return new ItemStack(grownItem, is.getCount());
|
||||
} else {
|
||||
this.setGrowthTicks(is, growthTicks);
|
||||
return is;
|
||||
}
|
||||
}
|
||||
|
||||
private static int getGrowthTicks(final ItemStack is )
|
||||
{
|
||||
CompoundNBT tag = is.getTag();
|
||||
return tag != null ? tag.getInt(TAG_GROWTH_TICKS) : 0;
|
||||
}
|
||||
private static int getGrowthTicks(final ItemStack is) {
|
||||
CompoundNBT tag = is.getTag();
|
||||
return tag != null ? tag.getInt(TAG_GROWTH_TICKS) : 0;
|
||||
}
|
||||
|
||||
private void setGrowthTicks(final ItemStack is, int ticks)
|
||||
{
|
||||
ticks = MathHelper.clamp(ticks, 0, GROWTH_TICKS_REQUIRED);
|
||||
is.getOrCreateTag().putInt(TAG_GROWTH_TICKS, ticks);
|
||||
}
|
||||
private void setGrowthTicks(final ItemStack is, int ticks) {
|
||||
ticks = MathHelper.clamp(ticks, 0, GROWTH_TICKS_REQUIRED);
|
||||
is.getOrCreateTag().putInt(TAG_GROWTH_TICKS, ticks);
|
||||
}
|
||||
|
||||
@Override
|
||||
public float getMultiplier( final Block blk, final Material mat )
|
||||
{
|
||||
return 0.5f;
|
||||
}
|
||||
@Override
|
||||
public float getMultiplier(final Block blk, final Material mat) {
|
||||
return 0.5f;
|
||||
}
|
||||
|
||||
@Override
|
||||
@OnlyIn( Dist.CLIENT )
|
||||
public void addInformation(final ItemStack stack, final World world, final List<ITextComponent> lines, final ITooltipFlag advancedTooltips )
|
||||
{
|
||||
lines.add( ButtonToolTips.DoesntDespawn.getTranslationKey() );
|
||||
lines.add(getGrowthTooltipItem(stack));
|
||||
@Override
|
||||
@OnlyIn(Dist.CLIENT)
|
||||
public void addInformation(final ItemStack stack, final World world, final List<ITextComponent> lines,
|
||||
final ITooltipFlag advancedTooltips) {
|
||||
lines.add(ButtonToolTips.DoesntDespawn.getTranslationKey());
|
||||
lines.add(getGrowthTooltipItem(stack));
|
||||
|
||||
super.addInformation( stack, world, lines, advancedTooltips );
|
||||
}
|
||||
super.addInformation(stack, world, lines, advancedTooltips);
|
||||
}
|
||||
|
||||
public ITextComponent getGrowthTooltipItem(ItemStack stack) {
|
||||
final int progress = getGrowthTicks( stack );
|
||||
return new StringTextComponent( Math.round( 100 * progress / (float) GROWTH_TICKS_REQUIRED ) + "%" );
|
||||
}
|
||||
public ITextComponent getGrowthTooltipItem(ItemStack stack) {
|
||||
final int progress = getGrowthTicks(stack);
|
||||
return new StringTextComponent(Math.round(100 * progress / (float) GROWTH_TICKS_REQUIRED) + "%");
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getEntityLifespan( final ItemStack itemStack, final World world )
|
||||
{
|
||||
return Integer.MAX_VALUE;
|
||||
}
|
||||
@Override
|
||||
public int getEntityLifespan(final ItemStack itemStack, final World world) {
|
||||
return Integer.MAX_VALUE;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean hasCustomEntity( final ItemStack stack )
|
||||
{
|
||||
return true;
|
||||
}
|
||||
@Override
|
||||
public boolean hasCustomEntity(final ItemStack stack) {
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Entity createEntity( final World world, final Entity location, final ItemStack itemstack )
|
||||
{
|
||||
final EntityGrowingCrystal egc = new EntityGrowingCrystal( world, location.getPosX(), location.getPosY(), location.getPosZ(), itemstack );
|
||||
@Override
|
||||
public Entity createEntity(final World world, final Entity location, final ItemStack itemstack) {
|
||||
final EntityGrowingCrystal egc = new EntityGrowingCrystal(world, location.getPosX(), location.getPosY(),
|
||||
location.getPosZ(), itemstack);
|
||||
|
||||
egc.setMotion( location.getMotion() );
|
||||
egc.setMotion(location.getMotion());
|
||||
|
||||
// Cannot read the pickup delay of the original item, so we
|
||||
// use the pickup delay used for items dropped by a player instead
|
||||
egc.setPickupDelay( 40 );
|
||||
// Cannot read the pickup delay of the original item, so we
|
||||
// use the pickup delay used for items dropped by a player instead
|
||||
egc.setPickupDelay(40);
|
||||
|
||||
return egc;
|
||||
}
|
||||
return egc;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void fillItemGroup(ItemGroup group, NonNullList<ItemStack> items) {
|
||||
if (this.isInGroup(group)) {
|
||||
// lvl 0
|
||||
items.add(new ItemStack(this, 1));
|
||||
// one tick before maturity
|
||||
ItemStack almostFullGrown = new ItemStack(this, 1);
|
||||
setGrowthTicks(almostFullGrown, GROWTH_TICKS_REQUIRED - 1);
|
||||
items.add(almostFullGrown);
|
||||
}
|
||||
}
|
||||
@Override
|
||||
public void fillItemGroup(ItemGroup group, NonNullList<ItemStack> items) {
|
||||
if (this.isInGroup(group)) {
|
||||
// lvl 0
|
||||
items.add(new ItemStack(this, 1));
|
||||
// one tick before maturity
|
||||
ItemStack almostFullGrown = new ItemStack(this, 1);
|
||||
setGrowthTicks(almostFullGrown, GROWTH_TICKS_REQUIRED - 1);
|
||||
items.add(almostFullGrown);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -18,17 +18,10 @@
|
||||
|
||||
package appeng.items.misc;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.WeakHashMap;
|
||||
|
||||
import appeng.api.AEApi;
|
||||
import appeng.api.implementations.ICraftingPatternItem;
|
||||
import appeng.api.networking.crafting.ICraftingPatternDetails;
|
||||
import appeng.api.storage.data.IAEItemStack;
|
||||
import appeng.core.AppEng;
|
||||
import appeng.core.localization.GuiText;
|
||||
import appeng.helpers.InvalidPatternHelper;
|
||||
import appeng.helpers.PatternHelper;
|
||||
import appeng.items.AEBaseItem;
|
||||
import appeng.util.Platform;
|
||||
import net.minecraft.client.util.ITooltipFlag;
|
||||
import net.minecraft.entity.player.PlayerEntity;
|
||||
import net.minecraft.entity.player.PlayerInventory;
|
||||
@@ -44,189 +37,176 @@ import net.minecraft.world.World;
|
||||
import net.minecraftforge.api.distmarker.Dist;
|
||||
import net.minecraftforge.api.distmarker.OnlyIn;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.WeakHashMap;
|
||||
import appeng.api.AEApi;
|
||||
import appeng.api.implementations.ICraftingPatternItem;
|
||||
import appeng.api.networking.crafting.ICraftingPatternDetails;
|
||||
import appeng.api.storage.data.IAEItemStack;
|
||||
import appeng.core.AppEng;
|
||||
import appeng.core.localization.GuiText;
|
||||
import appeng.helpers.InvalidPatternHelper;
|
||||
import appeng.helpers.PatternHelper;
|
||||
import appeng.items.AEBaseItem;
|
||||
import appeng.util.Platform;
|
||||
|
||||
public class ItemEncodedPattern extends AEBaseItem implements ICraftingPatternItem {
|
||||
// rather simple client side caching.
|
||||
private static final Map<ItemStack, ItemStack> SIMPLE_CACHE = new WeakHashMap<>();
|
||||
|
||||
public class ItemEncodedPattern extends AEBaseItem implements ICraftingPatternItem
|
||||
{
|
||||
// rather simple client side caching.
|
||||
private static final Map<ItemStack, ItemStack> SIMPLE_CACHE = new WeakHashMap<>();
|
||||
public ItemEncodedPattern(Properties properties) {
|
||||
super(properties);
|
||||
}
|
||||
|
||||
public ItemEncodedPattern(Properties properties) {
|
||||
super(properties);
|
||||
}
|
||||
@Override
|
||||
public ActionResult<ItemStack> onItemRightClick(final World w, final PlayerEntity player, final Hand hand) {
|
||||
this.clearPattern(player.getHeldItem(hand), player);
|
||||
|
||||
@Override
|
||||
public ActionResult<ItemStack> onItemRightClick( final World w, final PlayerEntity player, final Hand hand )
|
||||
{
|
||||
this.clearPattern( player.getHeldItem( hand ), player );
|
||||
return new ActionResult<>(ActionResultType.SUCCESS, player.getHeldItem(hand));
|
||||
}
|
||||
|
||||
return new ActionResult<>( ActionResultType.SUCCESS, player.getHeldItem( hand ) );
|
||||
}
|
||||
@Override
|
||||
public ActionResultType onItemUseFirst(ItemStack stack, ItemUseContext context) {
|
||||
return this.clearPattern(stack, context.getPlayer()) ? ActionResultType.SUCCESS : ActionResultType.PASS;
|
||||
}
|
||||
|
||||
@Override
|
||||
public ActionResultType onItemUseFirst( ItemStack stack, ItemUseContext context )
|
||||
{
|
||||
return this.clearPattern( stack, context.getPlayer() ) ? ActionResultType.SUCCESS : ActionResultType.PASS;
|
||||
}
|
||||
private boolean clearPattern(final ItemStack stack, final PlayerEntity player) {
|
||||
if (player.isCrouching()) {
|
||||
if (Platform.isClient()) {
|
||||
return false;
|
||||
}
|
||||
|
||||
private boolean clearPattern( final ItemStack stack, final PlayerEntity player )
|
||||
{
|
||||
if( player.isCrouching() )
|
||||
{
|
||||
if( Platform.isClient() )
|
||||
{
|
||||
return false;
|
||||
}
|
||||
final PlayerInventory inv = player.inventory;
|
||||
|
||||
final PlayerInventory inv = player.inventory;
|
||||
ItemStack is = AEApi.instance().definitions().materials().blankPattern().maybeStack(stack.getCount())
|
||||
.orElse(ItemStack.EMPTY);
|
||||
if (!is.isEmpty()) {
|
||||
for (int s = 0; s < player.inventory.getSizeInventory(); s++) {
|
||||
if (inv.getStackInSlot(s) == stack) {
|
||||
inv.setInventorySlotContents(s, is);
|
||||
return true;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
ItemStack is = AEApi.instance().definitions().materials().blankPattern().maybeStack( stack.getCount() ).orElse( ItemStack.EMPTY );
|
||||
if( !is.isEmpty() )
|
||||
{
|
||||
for( int s = 0; s < player.inventory.getSizeInventory(); s++ )
|
||||
{
|
||||
if( inv.getStackInSlot( s ) == stack )
|
||||
{
|
||||
inv.setInventorySlotContents( s, is );
|
||||
return true;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
@Override
|
||||
@OnlyIn(Dist.CLIENT)
|
||||
public void addInformation(final ItemStack stack, final World world, final List<ITextComponent> lines,
|
||||
final ITooltipFlag advancedTooltips) {
|
||||
final ICraftingPatternDetails details = this.getPatternForItem(stack, world);
|
||||
|
||||
@Override
|
||||
@OnlyIn( Dist.CLIENT )
|
||||
public void addInformation( final ItemStack stack, final World world, final List<ITextComponent> lines, final ITooltipFlag advancedTooltips )
|
||||
{
|
||||
final ICraftingPatternDetails details = this.getPatternForItem( stack, world );
|
||||
if (details == null) {
|
||||
if (!stack.hasTag()) {
|
||||
return;
|
||||
}
|
||||
|
||||
if( details == null )
|
||||
{
|
||||
if( !stack.hasTag() )
|
||||
{
|
||||
return;
|
||||
}
|
||||
stack.setDisplayName(GuiText.InvalidPattern.textComponent().applyTextStyle(TextFormatting.RED));
|
||||
|
||||
stack.setDisplayName(GuiText.InvalidPattern.textComponent().applyTextStyle(TextFormatting.RED));
|
||||
InvalidPatternHelper invalid = new InvalidPatternHelper(stack);
|
||||
|
||||
InvalidPatternHelper invalid = new InvalidPatternHelper( stack );
|
||||
final ITextComponent label = (invalid.isCraftable() ? GuiText.Crafts.textComponent()
|
||||
: GuiText.Creates.textComponent()).appendText(": ");
|
||||
final ITextComponent and = new StringTextComponent(" ").appendSibling(GuiText.And.textComponent())
|
||||
.appendText(" ");
|
||||
final ITextComponent with = GuiText.With.textComponent().appendText(": ");
|
||||
|
||||
final ITextComponent label = (invalid.isCraftable() ? GuiText.Crafts.textComponent() : GuiText.Creates.textComponent()).appendText(": ");
|
||||
final ITextComponent and = new StringTextComponent(" ").appendSibling(GuiText.And.textComponent()).appendText(" ");
|
||||
final ITextComponent with = GuiText.With.textComponent().appendText(": ");
|
||||
boolean first = true;
|
||||
for (final InvalidPatternHelper.PatternIngredient output : invalid.getOutputs()) {
|
||||
lines.add((first ? label : and).deepCopy().appendSibling(output.getFormattedToolTip()));
|
||||
first = false;
|
||||
}
|
||||
|
||||
boolean first = true;
|
||||
for( final InvalidPatternHelper.PatternIngredient output : invalid.getOutputs() )
|
||||
{
|
||||
lines.add( ( first ? label : and ).deepCopy().appendSibling(output.getFormattedToolTip()) );
|
||||
first = false;
|
||||
}
|
||||
first = true;
|
||||
for (final InvalidPatternHelper.PatternIngredient input : invalid.getInputs()) {
|
||||
lines.add((first ? with : and).deepCopy().appendSibling(input.getFormattedToolTip()));
|
||||
first = false;
|
||||
}
|
||||
|
||||
first = true;
|
||||
for( final InvalidPatternHelper.PatternIngredient input : invalid.getInputs() )
|
||||
{
|
||||
lines.add( ( first ? with : and ).deepCopy().appendSibling(input.getFormattedToolTip()) );
|
||||
first = false;
|
||||
}
|
||||
if (invalid.isCraftable()) {
|
||||
final ITextComponent substitutionLabel = GuiText.Substitute.textComponent().appendText(" ");
|
||||
final ITextComponent canSubstitute = invalid.canSubstitute() ? GuiText.Yes.textComponent()
|
||||
: GuiText.No.textComponent();
|
||||
|
||||
if( invalid.isCraftable() )
|
||||
{
|
||||
final ITextComponent substitutionLabel = GuiText.Substitute.textComponent().appendText(" ");
|
||||
final ITextComponent canSubstitute = invalid.canSubstitute() ? GuiText.Yes.textComponent() : GuiText.No.textComponent();
|
||||
lines.add(substitutionLabel.appendSibling(canSubstitute));
|
||||
}
|
||||
|
||||
lines.add( substitutionLabel.appendSibling(canSubstitute) );
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
||||
return;
|
||||
}
|
||||
if (stack.hasDisplayName()) {
|
||||
stack.removeChildTag("display");
|
||||
}
|
||||
|
||||
if( stack.hasDisplayName() )
|
||||
{
|
||||
stack.removeChildTag( "display" );
|
||||
}
|
||||
final boolean isCrafting = details.isCraftable();
|
||||
final boolean substitute = details.canSubstitute();
|
||||
|
||||
final boolean isCrafting = details.isCraftable();
|
||||
final boolean substitute = details.canSubstitute();
|
||||
final IAEItemStack[] in = details.getCondensedInputs();
|
||||
final IAEItemStack[] out = details.getCondensedOutputs();
|
||||
|
||||
final IAEItemStack[] in = details.getCondensedInputs();
|
||||
final IAEItemStack[] out = details.getCondensedOutputs();
|
||||
final ITextComponent label = (isCrafting ? GuiText.Crafts.textComponent() : GuiText.Creates.textComponent())
|
||||
.appendText(": ");
|
||||
final ITextComponent and = new StringTextComponent(" ").appendSibling(GuiText.And.textComponent())
|
||||
.appendText(" ");
|
||||
final ITextComponent with = GuiText.With.textComponent().appendText(": ");
|
||||
|
||||
final ITextComponent label = ( isCrafting ? GuiText.Crafts.textComponent() : GuiText.Creates.textComponent() ).appendText(": ");
|
||||
final ITextComponent and = new StringTextComponent(" ").appendSibling(GuiText.And.textComponent()).appendText(" ");
|
||||
final ITextComponent with = GuiText.With.textComponent().appendText(": ");
|
||||
boolean first = true;
|
||||
for (final IAEItemStack anOut : out) {
|
||||
if (anOut == null) {
|
||||
continue;
|
||||
}
|
||||
|
||||
boolean first = true;
|
||||
for( final IAEItemStack anOut : out )
|
||||
{
|
||||
if( anOut == null )
|
||||
{
|
||||
continue;
|
||||
}
|
||||
lines.add((first ? label : and).deepCopy().appendText(anOut.getStackSize() + "x ")
|
||||
.appendSibling(Platform.getItemDisplayName(anOut)));
|
||||
first = false;
|
||||
}
|
||||
|
||||
lines.add( ( first ? label : and ).deepCopy().appendText(anOut.getStackSize() + "x ").appendSibling(Platform.getItemDisplayName( anOut )));
|
||||
first = false;
|
||||
}
|
||||
first = true;
|
||||
for (final IAEItemStack anIn : in) {
|
||||
if (anIn == null) {
|
||||
continue;
|
||||
}
|
||||
|
||||
first = true;
|
||||
for( final IAEItemStack anIn : in )
|
||||
{
|
||||
if( anIn == null )
|
||||
{
|
||||
continue;
|
||||
}
|
||||
lines.add((first ? with : and).deepCopy().appendText(anIn.getStackSize() + "x ")
|
||||
.appendSibling(Platform.getItemDisplayName(anIn)));
|
||||
first = false;
|
||||
}
|
||||
|
||||
lines.add((first ? with : and).deepCopy().appendText(anIn.getStackSize() + "x ").appendSibling(Platform.getItemDisplayName(anIn)));
|
||||
first = false;
|
||||
}
|
||||
if (isCrafting) {
|
||||
final ITextComponent substitutionLabel = GuiText.Substitute.textComponent().appendText(" ");
|
||||
final ITextComponent canSubstitute = substitute ? GuiText.Yes.textComponent() : GuiText.No.textComponent();
|
||||
|
||||
if( isCrafting )
|
||||
{
|
||||
final ITextComponent substitutionLabel = GuiText.Substitute.textComponent().appendText(" ");
|
||||
final ITextComponent canSubstitute = substitute ? GuiText.Yes.textComponent() : GuiText.No.textComponent();
|
||||
lines.add(substitutionLabel.appendSibling(canSubstitute));
|
||||
}
|
||||
}
|
||||
|
||||
lines.add( substitutionLabel.appendSibling(canSubstitute) );
|
||||
}
|
||||
}
|
||||
@Override
|
||||
public ICraftingPatternDetails getPatternForItem(final ItemStack is, final World w) {
|
||||
try {
|
||||
return new PatternHelper(is, w);
|
||||
} catch (final Throwable t) {
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public ICraftingPatternDetails getPatternForItem( final ItemStack is, final World w )
|
||||
{
|
||||
try
|
||||
{
|
||||
return new PatternHelper( is, w );
|
||||
}
|
||||
catch( final Throwable t )
|
||||
{
|
||||
return null;
|
||||
}
|
||||
}
|
||||
public ItemStack getOutput(final ItemStack item) {
|
||||
ItemStack out = SIMPLE_CACHE.get(item);
|
||||
|
||||
public ItemStack getOutput( final ItemStack item )
|
||||
{
|
||||
ItemStack out = SIMPLE_CACHE.get( item );
|
||||
if (out != null) {
|
||||
return out;
|
||||
}
|
||||
|
||||
if( out != null )
|
||||
{
|
||||
return out;
|
||||
}
|
||||
final World w = AppEng.proxy.getWorld();
|
||||
if (w == null) {
|
||||
return ItemStack.EMPTY;
|
||||
}
|
||||
|
||||
final World w = AppEng.proxy.getWorld();
|
||||
if( w == null )
|
||||
{
|
||||
return ItemStack.EMPTY;
|
||||
}
|
||||
final ICraftingPatternDetails details = this.getPatternForItem(item, w);
|
||||
|
||||
final ICraftingPatternDetails details = this.getPatternForItem( item, w );
|
||||
out = details != null ? details.getOutputs()[0].createItemStack() : ItemStack.EMPTY;
|
||||
|
||||
out = details != null ? details.getOutputs()[0].createItemStack() : ItemStack.EMPTY;
|
||||
|
||||
SIMPLE_CACHE.put( item, out );
|
||||
return out;
|
||||
}
|
||||
SIMPLE_CACHE.put(item, out);
|
||||
return out;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -18,9 +18,6 @@
|
||||
|
||||
package appeng.items.misc;
|
||||
|
||||
|
||||
import appeng.api.util.AEColor;
|
||||
import appeng.items.AEBaseItem;
|
||||
import net.minecraft.item.Item;
|
||||
import net.minecraft.item.ItemGroup;
|
||||
import net.minecraft.item.ItemStack;
|
||||
@@ -29,28 +26,27 @@ import net.minecraft.util.NonNullList;
|
||||
import net.minecraft.util.text.ITextComponent;
|
||||
import net.minecraft.util.text.TranslationTextComponent;
|
||||
|
||||
import appeng.api.util.AEColor;
|
||||
import appeng.items.AEBaseItem;
|
||||
|
||||
public class ItemPaintBall extends AEBaseItem
|
||||
{
|
||||
public class ItemPaintBall extends AEBaseItem {
|
||||
|
||||
private final AEColor color;
|
||||
private final AEColor color;
|
||||
|
||||
private final boolean lumen;
|
||||
private final boolean lumen;
|
||||
|
||||
public ItemPaintBall(Properties properties, AEColor color, boolean lumen) {
|
||||
super(properties);
|
||||
this.color = color;
|
||||
this.lumen = lumen;
|
||||
}
|
||||
public ItemPaintBall(Properties properties, AEColor color, boolean lumen) {
|
||||
super(properties);
|
||||
this.color = color;
|
||||
this.lumen = lumen;
|
||||
}
|
||||
|
||||
public AEColor getColor()
|
||||
{
|
||||
return color;
|
||||
}
|
||||
public AEColor getColor() {
|
||||
return color;
|
||||
}
|
||||
|
||||
public boolean isLumen()
|
||||
{
|
||||
return lumen;
|
||||
}
|
||||
public boolean isLumen() {
|
||||
return lumen;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -18,46 +18,39 @@
|
||||
|
||||
package appeng.items.misc;
|
||||
|
||||
|
||||
|
||||
import appeng.api.util.AEColor;
|
||||
import appeng.bootstrap.IItemRendering;
|
||||
import appeng.bootstrap.ItemRenderingCustomizer;
|
||||
|
||||
public class ItemPaintBallRendering extends ItemRenderingCustomizer {
|
||||
|
||||
public class ItemPaintBallRendering extends ItemRenderingCustomizer
|
||||
{
|
||||
private final boolean lumen;
|
||||
|
||||
private final boolean lumen;
|
||||
private final AEColor color;
|
||||
|
||||
private final AEColor color;
|
||||
public ItemPaintBallRendering(AEColor color, boolean lumen) {
|
||||
this.lumen = lumen;
|
||||
this.color = color;
|
||||
}
|
||||
|
||||
public ItemPaintBallRendering(AEColor color, boolean lumen) {
|
||||
this.lumen = lumen;
|
||||
this.color = color;
|
||||
}
|
||||
@Override
|
||||
public void customize(IItemRendering rendering) {
|
||||
final int colorValue = lumen ? color.mediumVariant : color.mediumVariant;
|
||||
final int r = (colorValue >> 16) & 0xff;
|
||||
final int g = (colorValue >> 8) & 0xff;
|
||||
final int b = (colorValue) & 0xff;
|
||||
|
||||
@Override
|
||||
public void customize( IItemRendering rendering )
|
||||
{
|
||||
final int colorValue = lumen ? color.mediumVariant : color.mediumVariant;
|
||||
final int r = ( colorValue >> 16 ) & 0xff;
|
||||
final int g = ( colorValue >> 8 ) & 0xff;
|
||||
final int b = ( colorValue ) & 0xff;
|
||||
int renderColor;
|
||||
if (lumen) {
|
||||
final float fail = 0.7f;
|
||||
final int full = (int) (255 * 0.3);
|
||||
renderColor = (int) (full + r * fail) << 16 | (int) (full + g * fail) << 8 | (int) (full + b * fail)
|
||||
| 0xff << 24;
|
||||
} else {
|
||||
renderColor = r << 16 | g << 8 | b | 0xff << 24;
|
||||
}
|
||||
|
||||
int renderColor;
|
||||
if( lumen )
|
||||
{
|
||||
final float fail = 0.7f;
|
||||
final int full = (int) ( 255 * 0.3 );
|
||||
renderColor = (int) ( full + r * fail ) << 16 | (int) ( full + g * fail ) << 8 | (int) ( full + b * fail ) | 0xff << 24;
|
||||
}
|
||||
else
|
||||
{
|
||||
renderColor = r << 16 | g << 8 | b | 0xff << 24;
|
||||
}
|
||||
|
||||
rendering.color( (is, tintIndex) -> renderColor );
|
||||
}
|
||||
rendering.color((is, tintIndex) -> renderColor);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -1,10 +1,11 @@
|
||||
package appeng.items.parts;
|
||||
|
||||
import java.util.function.Function;
|
||||
|
||||
import net.minecraft.item.ItemStack;
|
||||
|
||||
import appeng.api.parts.IPart;
|
||||
import appeng.api.util.AEColor;
|
||||
import net.minecraft.item.ItemStack;
|
||||
|
||||
import java.util.function.Function;
|
||||
|
||||
public class ColoredPartItem<T extends IPart> extends ItemPart<T> {
|
||||
|
||||
|
||||
@@ -18,21 +18,18 @@
|
||||
|
||||
package appeng.items.parts;
|
||||
|
||||
|
||||
import appeng.bootstrap.IItemRendering;
|
||||
import appeng.bootstrap.ItemRenderingCustomizer;
|
||||
|
||||
|
||||
/**
|
||||
* Handles rendering customization for facade items. Please note that this works very differently
|
||||
* from actually rendering a Facade in a cable bus.
|
||||
* Handles rendering customization for facade items. Please note that this works
|
||||
* very differently from actually rendering a Facade in a cable bus.
|
||||
*/
|
||||
public class FacadeRendering extends ItemRenderingCustomizer
|
||||
{
|
||||
@Override
|
||||
public void customize( IItemRendering rendering )
|
||||
{
|
||||
// This actually just uses the path it will look for by default, no custom model redirection needed
|
||||
// FIXME rendering.builtInModel( "models/item/facade", new FacadeItemModel() );
|
||||
}
|
||||
public class FacadeRendering extends ItemRenderingCustomizer {
|
||||
@Override
|
||||
public void customize(IItemRendering rendering) {
|
||||
// This actually just uses the path it will look for by default, no custom model
|
||||
// redirection needed
|
||||
// FIXME rendering.builtInModel( "models/item/facade", new FacadeItemModel() );
|
||||
}
|
||||
}
|
||||
|
||||
@@ -18,16 +18,15 @@
|
||||
|
||||
package appeng.items.parts;
|
||||
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
import net.minecraft.block.Block;
|
||||
import net.minecraft.block.BlockRenderType;
|
||||
import net.minecraft.block.BlockState;
|
||||
import net.minecraft.block.Blocks;
|
||||
import net.minecraft.client.renderer.RenderType;
|
||||
import net.minecraft.client.renderer.RenderTypeLookup;
|
||||
import net.minecraft.block.Blocks;
|
||||
import net.minecraft.item.*;
|
||||
import net.minecraft.nbt.CompoundNBT;
|
||||
import net.minecraft.util.ActionResultType;
|
||||
@@ -47,277 +46,232 @@ import appeng.facade.FacadePart;
|
||||
import appeng.facade.IFacadeItem;
|
||||
import appeng.items.AEBaseItem;
|
||||
|
||||
public class ItemFacade extends AEBaseItem implements IFacadeItem, IAlphaPassItem {
|
||||
|
||||
public class ItemFacade extends AEBaseItem implements IFacadeItem, IAlphaPassItem
|
||||
{
|
||||
private static final String TAG_ITEM_ID = "item";
|
||||
|
||||
private static final String TAG_ITEM_ID = "item";
|
||||
private List<ItemStack> subTypes = null;
|
||||
|
||||
private List<ItemStack> subTypes = null;
|
||||
public ItemFacade(Properties properties) {
|
||||
super(properties);
|
||||
// FIXME this.setHasSubtypes( true );
|
||||
}
|
||||
|
||||
public ItemFacade(Properties properties) {
|
||||
super(properties);
|
||||
// FIXME this.setHasSubtypes( true );
|
||||
}
|
||||
@Override
|
||||
public ActionResultType onItemUseFirst(ItemStack stack, ItemUseContext context) {
|
||||
return AEApi.instance().partHelper().placeBus(stack, context.getPos(), context.getFace(), context.getPlayer(),
|
||||
context.getHand(), context.getWorld());
|
||||
}
|
||||
|
||||
@Override
|
||||
public ActionResultType onItemUseFirst( ItemStack stack, ItemUseContext context )
|
||||
{
|
||||
return AEApi.instance().partHelper().placeBus( stack, context.getPos(), context.getFace(), context.getPlayer(), context.getHand(), context.getWorld() );
|
||||
}
|
||||
@Override
|
||||
public ITextComponent getDisplayName(ItemStack is) {
|
||||
try {
|
||||
final ItemStack in = this.getTextureItem(is);
|
||||
if (!in.isEmpty()) {
|
||||
return super.getDisplayName(is).deepCopy().appendText(" - ").appendSibling(in.getDisplayName());
|
||||
}
|
||||
} catch (final Throwable ignored) {
|
||||
|
||||
@Override
|
||||
public ITextComponent getDisplayName(ItemStack is) {
|
||||
try
|
||||
{
|
||||
final ItemStack in = this.getTextureItem( is );
|
||||
if( !in.isEmpty() )
|
||||
{
|
||||
return super.getDisplayName( is ).deepCopy().appendText(" - ").appendSibling(in.getDisplayName());
|
||||
}
|
||||
}
|
||||
catch( final Throwable ignored )
|
||||
{
|
||||
}
|
||||
|
||||
}
|
||||
return super.getDisplayName(is);
|
||||
}
|
||||
|
||||
return super.getDisplayName( is );
|
||||
}
|
||||
@Override
|
||||
public void fillItemGroup(ItemGroup group, NonNullList<ItemStack> items) {
|
||||
this.calculateSubTypes();
|
||||
items.addAll(this.subTypes);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void fillItemGroup(ItemGroup group, NonNullList<ItemStack> items) {
|
||||
this.calculateSubTypes();
|
||||
items.addAll( this.subTypes );
|
||||
}
|
||||
private void calculateSubTypes() {
|
||||
if (this.subTypes == null) {
|
||||
this.subTypes = new ArrayList<>(1000);
|
||||
for (final Block b : ForgeRegistries.BLOCKS) {
|
||||
try {
|
||||
final Item item = Item.getItemFromBlock(b);
|
||||
if (item == Items.AIR) {
|
||||
continue;
|
||||
}
|
||||
|
||||
private void calculateSubTypes()
|
||||
{
|
||||
if( this.subTypes == null )
|
||||
{
|
||||
this.subTypes = new ArrayList<>( 1000 );
|
||||
for( final Block b : ForgeRegistries.BLOCKS )
|
||||
{
|
||||
try
|
||||
{
|
||||
final Item item = Item.getItemFromBlock( b );
|
||||
if( item == Items.AIR )
|
||||
{
|
||||
continue;
|
||||
}
|
||||
Item blockItem = b.asItem();
|
||||
if (blockItem != null && blockItem.getGroup() != null) {
|
||||
final NonNullList<ItemStack> tmpList = NonNullList.create();
|
||||
b.fillItemGroup(blockItem.getGroup(), tmpList);
|
||||
for (final ItemStack l : tmpList) {
|
||||
final ItemStack facade = this.createFacadeForItem(l, false);
|
||||
if (!facade.isEmpty()) {
|
||||
this.subTypes.add(facade);
|
||||
}
|
||||
}
|
||||
}
|
||||
} catch (final Throwable t) {
|
||||
// just absorb..
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Item blockItem = b.asItem();
|
||||
if (blockItem != null && blockItem.getGroup() != null) {
|
||||
final NonNullList<ItemStack> tmpList = NonNullList.create();
|
||||
b.fillItemGroup(blockItem.getGroup(), tmpList);
|
||||
for (final ItemStack l : tmpList) {
|
||||
final ItemStack facade = this.createFacadeForItem(l, false);
|
||||
if (!facade.isEmpty()) {
|
||||
this.subTypes.add(facade);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
catch( final Throwable t )
|
||||
{
|
||||
// just absorb..
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
public ItemStack createFacadeForItem(final ItemStack itemStack, final boolean returnItem) {
|
||||
if (itemStack.isEmpty()) {
|
||||
return ItemStack.EMPTY;
|
||||
}
|
||||
|
||||
public ItemStack createFacadeForItem( final ItemStack itemStack, final boolean returnItem )
|
||||
{
|
||||
if( itemStack.isEmpty() )
|
||||
{
|
||||
return ItemStack.EMPTY;
|
||||
}
|
||||
final Block block = Block.getBlockFromItem(itemStack.getItem());
|
||||
if (block == Blocks.AIR || itemStack.hasTag()) {
|
||||
return ItemStack.EMPTY;
|
||||
}
|
||||
|
||||
final Block block = Block.getBlockFromItem( itemStack.getItem() );
|
||||
if( block == Blocks.AIR || itemStack.hasTag() )
|
||||
{
|
||||
return ItemStack.EMPTY;
|
||||
}
|
||||
final int metadata = 0; // FIXME itemStack.getItem().getMetadata( itemStack.getDamage() );
|
||||
|
||||
final int metadata = 0; // FIXME itemStack.getItem().getMetadata( itemStack.getDamage() );
|
||||
// Try to get the block state based on the item stack's meta. If this fails,
|
||||
// don't consider it for a facade
|
||||
// This for example fails for Pistons because they hardcoded an invalid meta
|
||||
// value in vanilla
|
||||
BlockState blockState;
|
||||
try {
|
||||
blockState = null; // FIXME block.getStateFromMeta( metadata );
|
||||
} catch (Exception e) {
|
||||
AELog.debug(e, "Cannot create a facade for " + block.getRegistryName());
|
||||
return ItemStack.EMPTY;
|
||||
}
|
||||
|
||||
// Try to get the block state based on the item stack's meta. If this fails, don't consider it for a facade
|
||||
// This for example fails for Pistons because they hardcoded an invalid meta value in vanilla
|
||||
BlockState blockState;
|
||||
try
|
||||
{
|
||||
blockState = null; // FIXME block.getStateFromMeta( metadata );
|
||||
}
|
||||
catch( Exception e )
|
||||
{
|
||||
AELog.debug( e, "Cannot create a facade for " + block.getRegistryName() );
|
||||
return ItemStack.EMPTY;
|
||||
}
|
||||
final boolean areTileEntitiesEnabled = FacadeConfig.instance().allowTileEntityFacades();
|
||||
final boolean isWhiteListed = FacadeConfig.instance().isWhiteListed(block, metadata);
|
||||
final boolean isModel = blockState.getRenderType() == BlockRenderType.MODEL;
|
||||
|
||||
final boolean areTileEntitiesEnabled = FacadeConfig.instance().allowTileEntityFacades();
|
||||
final boolean isWhiteListed = FacadeConfig.instance().isWhiteListed( block, metadata );
|
||||
final boolean isModel = blockState.getRenderType() == BlockRenderType.MODEL;
|
||||
final BlockState defaultState = block.getDefaultState();
|
||||
final boolean isTileEntity = block.hasTileEntity(defaultState);
|
||||
final boolean isFullCube = true; // FIXME defaultState.isFullCube( defaultState );
|
||||
|
||||
final BlockState defaultState = block.getDefaultState();
|
||||
final boolean isTileEntity = block.hasTileEntity( defaultState );
|
||||
final boolean isFullCube = true; // FIXME defaultState.isFullCube( defaultState );
|
||||
final boolean isTileEntityAllowed = !isTileEntity || (areTileEntitiesEnabled && isWhiteListed);
|
||||
final boolean isBlockAllowed = isFullCube || isWhiteListed;
|
||||
|
||||
final boolean isTileEntityAllowed = !isTileEntity || ( areTileEntitiesEnabled && isWhiteListed );
|
||||
final boolean isBlockAllowed = isFullCube || isWhiteListed;
|
||||
if (isModel && isTileEntityAllowed && isBlockAllowed) {
|
||||
if (returnItem) {
|
||||
return itemStack;
|
||||
}
|
||||
|
||||
if( isModel && isTileEntityAllowed && isBlockAllowed )
|
||||
{
|
||||
if( returnItem )
|
||||
{
|
||||
return itemStack;
|
||||
}
|
||||
final ItemStack is = new ItemStack(this);
|
||||
final CompoundNBT data = new CompoundNBT();
|
||||
data.putString(TAG_ITEM_ID, itemStack.getItem().getRegistryName().toString());
|
||||
is.setTag(data);
|
||||
return is;
|
||||
}
|
||||
return ItemStack.EMPTY;
|
||||
}
|
||||
|
||||
final ItemStack is = new ItemStack( this );
|
||||
final CompoundNBT data = new CompoundNBT();
|
||||
data.putString(TAG_ITEM_ID, itemStack.getItem().getRegistryName().toString());
|
||||
is.setTag( data );
|
||||
return is;
|
||||
}
|
||||
return ItemStack.EMPTY;
|
||||
}
|
||||
@Override
|
||||
public FacadePart createPartFromItemStack(final ItemStack is, final AEPartLocation side) {
|
||||
final ItemStack in = this.getTextureItem(is);
|
||||
if (!in.isEmpty()) {
|
||||
return new FacadePart(is, side);
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public FacadePart createPartFromItemStack( final ItemStack is, final AEPartLocation side )
|
||||
{
|
||||
final ItemStack in = this.getTextureItem( is );
|
||||
if( !in.isEmpty() )
|
||||
{
|
||||
return new FacadePart( is, side );
|
||||
}
|
||||
return null;
|
||||
}
|
||||
@Override
|
||||
public ItemStack getTextureItem(ItemStack is) {
|
||||
|
||||
@Override
|
||||
public ItemStack getTextureItem( ItemStack is )
|
||||
{
|
||||
CompoundNBT nbt = is.getTag();
|
||||
|
||||
CompoundNBT nbt = is.getTag();
|
||||
if (nbt == null) {
|
||||
return ItemStack.EMPTY;
|
||||
}
|
||||
|
||||
if( nbt == null )
|
||||
{
|
||||
return ItemStack.EMPTY;
|
||||
}
|
||||
ResourceLocation itemId;
|
||||
|
||||
ResourceLocation itemId;
|
||||
// Handle legacy facades
|
||||
if (nbt.contains("x")) {
|
||||
int[] data = nbt.getIntArray("x");
|
||||
if (data.length != 2) {
|
||||
return ItemStack.EMPTY;
|
||||
}
|
||||
|
||||
// Handle legacy facades
|
||||
if( nbt.contains("x") )
|
||||
{
|
||||
int[] data = nbt.getIntArray( "x" );
|
||||
if( data.length != 2 )
|
||||
{
|
||||
return ItemStack.EMPTY;
|
||||
}
|
||||
Item item = Registry.ITEM.getByValue(data[0]);
|
||||
if (item == null) {
|
||||
return ItemStack.EMPTY;
|
||||
}
|
||||
|
||||
Item item = Registry.ITEM.getByValue( data[0] );
|
||||
if( item == null )
|
||||
{
|
||||
return ItemStack.EMPTY;
|
||||
}
|
||||
itemId = item.getRegistryName();
|
||||
} else {
|
||||
// First item is numeric item id
|
||||
itemId = new ResourceLocation(nbt.getString(TAG_ITEM_ID));
|
||||
}
|
||||
|
||||
itemId = item.getRegistryName();
|
||||
}
|
||||
else
|
||||
{
|
||||
// First item is numeric item id
|
||||
itemId = new ResourceLocation( nbt.getString( TAG_ITEM_ID ) );
|
||||
}
|
||||
Item baseItem = ForgeRegistries.ITEMS.getValue(itemId);
|
||||
|
||||
Item baseItem = ForgeRegistries.ITEMS.getValue( itemId );
|
||||
if (baseItem == null) {
|
||||
return ItemStack.EMPTY;
|
||||
}
|
||||
|
||||
if( baseItem == null )
|
||||
{
|
||||
return ItemStack.EMPTY;
|
||||
}
|
||||
return new ItemStack(baseItem, 1);
|
||||
}
|
||||
|
||||
return new ItemStack( baseItem, 1 );
|
||||
}
|
||||
@Override
|
||||
public BlockState getTextureBlockState(ItemStack is) {
|
||||
|
||||
@Override
|
||||
public BlockState getTextureBlockState( ItemStack is )
|
||||
{
|
||||
ItemStack baseItemStack = this.getTextureItem(is);
|
||||
|
||||
ItemStack baseItemStack = this.getTextureItem( is );
|
||||
if (baseItemStack.isEmpty()) {
|
||||
return Blocks.GLASS.getDefaultState();
|
||||
}
|
||||
|
||||
if( baseItemStack.isEmpty() )
|
||||
{
|
||||
return Blocks.GLASS.getDefaultState();
|
||||
}
|
||||
Block block = Block.getBlockFromItem(baseItemStack.getItem());
|
||||
|
||||
Block block = Block.getBlockFromItem( baseItemStack.getItem() );
|
||||
if (block == Blocks.AIR) {
|
||||
return Blocks.GLASS.getDefaultState();
|
||||
}
|
||||
|
||||
if( block == Blocks.AIR )
|
||||
{
|
||||
return Blocks.GLASS.getDefaultState();
|
||||
}
|
||||
int metadata = 0; // FIXME baseItemStack.getItem().getMetadata( baseItemStack );
|
||||
|
||||
int metadata = 0; // FIXME baseItemStack.getItem().getMetadata( baseItemStack );
|
||||
try {
|
||||
return null; // FIXME block.getStateFromMeta( metadata );
|
||||
} catch (Exception e) {
|
||||
AELog.warn("Block %s has broken getStateFromMeta method for meta %d", block.getRegistryName().toString(),
|
||||
baseItemStack.getDamage());
|
||||
return Blocks.GLASS.getDefaultState();
|
||||
}
|
||||
}
|
||||
|
||||
try
|
||||
{
|
||||
return null; // FIXME block.getStateFromMeta( metadata );
|
||||
}
|
||||
catch( Exception e )
|
||||
{
|
||||
AELog.warn( "Block %s has broken getStateFromMeta method for meta %d", block.getRegistryName().toString(), baseItemStack.getDamage() );
|
||||
return Blocks.GLASS.getDefaultState();
|
||||
}
|
||||
}
|
||||
public List<ItemStack> getFacades() {
|
||||
this.calculateSubTypes();
|
||||
return this.subTypes;
|
||||
}
|
||||
|
||||
public List<ItemStack> getFacades()
|
||||
{
|
||||
this.calculateSubTypes();
|
||||
return this.subTypes;
|
||||
}
|
||||
public ItemStack getCreativeTabIcon() {
|
||||
this.calculateSubTypes();
|
||||
if (this.subTypes.isEmpty()) {
|
||||
return new ItemStack(Items.CAKE);
|
||||
}
|
||||
return this.subTypes.get(0);
|
||||
}
|
||||
|
||||
public ItemStack getCreativeTabIcon()
|
||||
{
|
||||
this.calculateSubTypes();
|
||||
if( this.subTypes.isEmpty() )
|
||||
{
|
||||
return new ItemStack( Items.CAKE );
|
||||
}
|
||||
return this.subTypes.get( 0 );
|
||||
}
|
||||
public ItemStack createFromID(final int id) {
|
||||
ItemStack facadeStack = AEApi.instance().definitions().items().facade().maybeStack(1).orElseThrow(
|
||||
() -> new MissingDefinitionException("Tried to create a facade, while facades are being deactivated."));
|
||||
|
||||
public ItemStack createFromID( final int id )
|
||||
{
|
||||
ItemStack facadeStack = AEApi.instance()
|
||||
.definitions()
|
||||
.items()
|
||||
.facade()
|
||||
.maybeStack( 1 )
|
||||
.orElseThrow( () -> new MissingDefinitionException( "Tried to create a facade, while facades are being deactivated." ) );
|
||||
// Convert back to a registry name...
|
||||
Item item = Registry.ITEM.getByValue(id);
|
||||
if (item == null) {
|
||||
return ItemStack.EMPTY;
|
||||
}
|
||||
|
||||
// Convert back to a registry name...
|
||||
Item item = Registry.ITEM.getByValue( id );
|
||||
if( item == null )
|
||||
{
|
||||
return ItemStack.EMPTY;
|
||||
}
|
||||
final CompoundNBT facadeTag = new CompoundNBT();
|
||||
facadeTag.putString(TAG_ITEM_ID, item.getRegistryName().toString());
|
||||
facadeStack.setTag(facadeTag);
|
||||
|
||||
final CompoundNBT facadeTag = new CompoundNBT();
|
||||
facadeTag.putString(TAG_ITEM_ID, item.getRegistryName().toString());
|
||||
facadeStack.setTag( facadeTag );
|
||||
return facadeStack;
|
||||
}
|
||||
|
||||
return facadeStack;
|
||||
}
|
||||
@Override
|
||||
public boolean useAlphaPass(final ItemStack is) {
|
||||
BlockState blockState = this.getTextureBlockState(is);
|
||||
|
||||
@Override
|
||||
public boolean useAlphaPass( final ItemStack is )
|
||||
{
|
||||
BlockState blockState = this.getTextureBlockState( is );
|
||||
if (blockState == null) {
|
||||
return false;
|
||||
}
|
||||
|
||||
if( blockState == null )
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
return RenderTypeLookup.canRenderInLayer( blockState, RenderType.getTranslucent() )
|
||||
|| RenderTypeLookup.canRenderInLayer( blockState, RenderType.getTranslucentNoCrumbling() );
|
||||
}
|
||||
return RenderTypeLookup.canRenderInLayer(blockState, RenderType.getTranslucent())
|
||||
|| RenderTypeLookup.canRenderInLayer(blockState, RenderType.getTranslucentNoCrumbling());
|
||||
}
|
||||
}
|
||||
|
||||
@@ -18,6 +18,24 @@
|
||||
|
||||
package appeng.items.parts;
|
||||
|
||||
import java.lang.reflect.InvocationTargetException;
|
||||
import java.util.*;
|
||||
import java.util.Map.Entry;
|
||||
import java.util.function.Function;
|
||||
|
||||
import javax.annotation.Nonnull;
|
||||
import javax.annotation.Nullable;
|
||||
|
||||
import com.google.common.base.Preconditions;
|
||||
|
||||
import net.minecraft.entity.player.PlayerEntity;
|
||||
import net.minecraft.item.ItemGroup;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.item.ItemUseContext;
|
||||
import net.minecraft.util.ActionResultType;
|
||||
import net.minecraft.util.NonNullList;
|
||||
import net.minecraft.util.text.ITextComponent;
|
||||
import net.minecraft.util.text.TranslationTextComponent;
|
||||
|
||||
import appeng.api.AEApi;
|
||||
import appeng.api.implementations.items.IItemGroup;
|
||||
@@ -28,127 +46,99 @@ import appeng.core.features.ActivityState;
|
||||
import appeng.core.features.ItemStackSrc;
|
||||
import appeng.core.localization.GuiText;
|
||||
import appeng.items.AEBaseItem;
|
||||
import com.google.common.base.Preconditions;
|
||||
import net.minecraft.entity.player.PlayerEntity;
|
||||
import net.minecraft.item.ItemGroup;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.item.ItemUseContext;
|
||||
import net.minecraft.util.ActionResultType;
|
||||
import net.minecraft.util.NonNullList;
|
||||
import net.minecraft.util.text.ITextComponent;
|
||||
import net.minecraft.util.text.TranslationTextComponent;
|
||||
|
||||
import javax.annotation.Nonnull;
|
||||
import javax.annotation.Nullable;
|
||||
import java.lang.reflect.InvocationTargetException;
|
||||
import java.util.*;
|
||||
import java.util.Map.Entry;
|
||||
import java.util.function.Function;
|
||||
public class ItemPart<T extends IPart> extends AEBaseItem implements IPartItem<T>, IItemGroup {
|
||||
private final PartType type;
|
||||
|
||||
private final Function<ItemStack, T> factory;
|
||||
|
||||
public class ItemPart<T extends IPart> extends AEBaseItem implements IPartItem<T>, IItemGroup
|
||||
{
|
||||
private final PartType type;
|
||||
public ItemPart(Properties properties, PartType type, Function<ItemStack, T> factory) {
|
||||
super(properties);
|
||||
this.type = type;
|
||||
this.factory = factory;
|
||||
}
|
||||
|
||||
private final Function<ItemStack, T> factory;
|
||||
@Override
|
||||
public ActionResultType onItemUse(ItemUseContext context) {
|
||||
PlayerEntity player = context.getPlayer();
|
||||
ItemStack held = player.getHeldItem(context.getHand());
|
||||
if (held.getItem() != this) {
|
||||
return ActionResultType.PASS;
|
||||
}
|
||||
|
||||
public ItemPart(Properties properties, PartType type, Function<ItemStack, T> factory) {
|
||||
super(properties);
|
||||
this.type = type;
|
||||
this.factory = factory;
|
||||
}
|
||||
return AEApi.instance().partHelper().placeBus(held, context.getPos(), context.getFace(), player,
|
||||
context.getHand(), context.getWorld());
|
||||
}
|
||||
|
||||
@Override
|
||||
public ActionResultType onItemUse( ItemUseContext context )
|
||||
{
|
||||
PlayerEntity player = context.getPlayer();
|
||||
ItemStack held = player.getHeldItem( context.getHand() );
|
||||
if( held.getItem() != this )
|
||||
{
|
||||
return ActionResultType.PASS;
|
||||
}
|
||||
public PartType getType() {
|
||||
return type;
|
||||
}
|
||||
|
||||
return AEApi.instance().partHelper().placeBus( held, context.getPos(), context.getFace(), player, context.getHand(), context.getWorld() );
|
||||
}
|
||||
@Override
|
||||
public T createPart(ItemStack is) {
|
||||
return factory.apply(is);
|
||||
}
|
||||
|
||||
public PartType getType() {
|
||||
return type;
|
||||
}
|
||||
private static PartType getTypeByStack(ItemStack is) {
|
||||
if (is.getItem() instanceof ItemPart) {
|
||||
return ((ItemPart<?>) is.getItem()).getType();
|
||||
}
|
||||
return PartType.INVALID_TYPE;
|
||||
}
|
||||
|
||||
@Override
|
||||
public T createPart(ItemStack is) {
|
||||
return factory.apply(is);
|
||||
}
|
||||
@Nullable
|
||||
@Override
|
||||
public String getUnlocalizedGroupName(final Set<ItemStack> others, final ItemStack is) {
|
||||
boolean importBus = false;
|
||||
boolean importBusFluids = false;
|
||||
boolean exportBus = false;
|
||||
boolean exportBusFluids = false;
|
||||
boolean group = false;
|
||||
|
||||
private static PartType getTypeByStack(ItemStack is) {
|
||||
if (is.getItem() instanceof ItemPart) {
|
||||
return ((ItemPart<?>) is.getItem()).getType();
|
||||
}
|
||||
return PartType.INVALID_TYPE;
|
||||
}
|
||||
final PartType u = getTypeByStack(is);
|
||||
|
||||
@Nullable
|
||||
@Override
|
||||
public String getUnlocalizedGroupName( final Set<ItemStack> others, final ItemStack is )
|
||||
{
|
||||
boolean importBus = false;
|
||||
boolean importBusFluids = false;
|
||||
boolean exportBus = false;
|
||||
boolean exportBusFluids = false;
|
||||
boolean group = false;
|
||||
for (final ItemStack stack : others) {
|
||||
if (stack.getItem() == this) {
|
||||
final PartType pt = getTypeByStack(stack);
|
||||
switch (pt) {
|
||||
case IMPORT_BUS:
|
||||
importBus = true;
|
||||
if (u == pt) {
|
||||
group = true;
|
||||
}
|
||||
break;
|
||||
case FLUID_IMPORT_BUS:
|
||||
importBusFluids = true;
|
||||
if (u == pt) {
|
||||
group = true;
|
||||
}
|
||||
break;
|
||||
case EXPORT_BUS:
|
||||
exportBus = true;
|
||||
if (u == pt) {
|
||||
group = true;
|
||||
}
|
||||
break;
|
||||
case FLUID_EXPORT_BUS:
|
||||
exportBusFluids = true;
|
||||
if (u == pt) {
|
||||
group = true;
|
||||
}
|
||||
break;
|
||||
default:
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
final PartType u = getTypeByStack( is );
|
||||
if (group && importBus && exportBus && (u == PartType.IMPORT_BUS || u == PartType.EXPORT_BUS)) {
|
||||
return GuiText.IOBuses.getTranslationKey();
|
||||
}
|
||||
if (group && importBusFluids && exportBusFluids
|
||||
&& (u == PartType.FLUID_IMPORT_BUS || u == PartType.FLUID_EXPORT_BUS)) {
|
||||
return GuiText.IOBusesFluids.getTranslationKey();
|
||||
}
|
||||
|
||||
for( final ItemStack stack : others )
|
||||
{
|
||||
if( stack.getItem() == this )
|
||||
{
|
||||
final PartType pt = getTypeByStack( stack );
|
||||
switch( pt )
|
||||
{
|
||||
case IMPORT_BUS:
|
||||
importBus = true;
|
||||
if( u == pt )
|
||||
{
|
||||
group = true;
|
||||
}
|
||||
break;
|
||||
case FLUID_IMPORT_BUS:
|
||||
importBusFluids = true;
|
||||
if( u == pt )
|
||||
{
|
||||
group = true;
|
||||
}
|
||||
break;
|
||||
case EXPORT_BUS:
|
||||
exportBus = true;
|
||||
if( u == pt )
|
||||
{
|
||||
group = true;
|
||||
}
|
||||
break;
|
||||
case FLUID_EXPORT_BUS:
|
||||
exportBusFluids = true;
|
||||
if( u == pt )
|
||||
{
|
||||
group = true;
|
||||
}
|
||||
break;
|
||||
default:
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if( group && importBus && exportBus && ( u == PartType.IMPORT_BUS || u == PartType.EXPORT_BUS ) )
|
||||
{
|
||||
return GuiText.IOBuses.getTranslationKey();
|
||||
}
|
||||
if( group && importBusFluids && exportBusFluids && ( u == PartType.FLUID_IMPORT_BUS || u == PartType.FLUID_EXPORT_BUS ) )
|
||||
{
|
||||
return GuiText.IOBusesFluids.getTranslationKey();
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -18,32 +18,29 @@
|
||||
|
||||
package appeng.items.parts;
|
||||
|
||||
import net.minecraftforge.api.distmarker.Dist;
|
||||
import net.minecraftforge.api.distmarker.OnlyIn;
|
||||
|
||||
import appeng.api.util.AEColor;
|
||||
import appeng.bootstrap.IItemRendering;
|
||||
import appeng.bootstrap.ItemRenderingCustomizer;
|
||||
import appeng.client.render.StaticItemColor;
|
||||
import net.minecraftforge.api.distmarker.Dist;
|
||||
import net.minecraftforge.api.distmarker.OnlyIn;
|
||||
|
||||
public class ItemPartRendering extends ItemRenderingCustomizer {
|
||||
|
||||
public class ItemPartRendering extends ItemRenderingCustomizer
|
||||
{
|
||||
private final AEColor color;
|
||||
|
||||
private final AEColor color;
|
||||
public ItemPartRendering() {
|
||||
this.color = AEColor.TRANSPARENT;
|
||||
}
|
||||
|
||||
public ItemPartRendering() {
|
||||
this.color = AEColor.TRANSPARENT;
|
||||
}
|
||||
public ItemPartRendering(AEColor color) {
|
||||
this.color = color;
|
||||
}
|
||||
|
||||
public ItemPartRendering(AEColor color) {
|
||||
this.color = color;
|
||||
}
|
||||
|
||||
@Override
|
||||
@OnlyIn( Dist.CLIENT )
|
||||
public void customize( IItemRendering rendering )
|
||||
{
|
||||
rendering.color( new StaticItemColor(color) );
|
||||
}
|
||||
@Override
|
||||
@OnlyIn(Dist.CLIENT)
|
||||
public void customize(IItemRendering rendering) {
|
||||
rendering.color(new StaticItemColor(color));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -18,21 +18,17 @@
|
||||
|
||||
package appeng.items.parts;
|
||||
|
||||
|
||||
import java.lang.annotation.ElementType;
|
||||
import java.lang.annotation.Retention;
|
||||
import java.lang.annotation.RetentionPolicy;
|
||||
import java.lang.annotation.Target;
|
||||
|
||||
|
||||
/**
|
||||
* This annotation is used to mark static fields or static methods that return/contain models used
|
||||
* for a part. They are automatically registered as part of the part item registration.
|
||||
* This annotation is used to mark static fields or static methods that
|
||||
* return/contain models used for a part. They are automatically registered as
|
||||
* part of the part item registration.
|
||||
*/
|
||||
@Retention( RetentionPolicy.RUNTIME )
|
||||
@Target( {
|
||||
ElementType.FIELD,
|
||||
ElementType.METHOD
|
||||
} )
|
||||
public @interface PartModels
|
||||
{}
|
||||
@Retention(RetentionPolicy.RUNTIME)
|
||||
@Target({ ElementType.FIELD, ElementType.METHOD })
|
||||
public @interface PartModels {
|
||||
}
|
||||
|
||||
@@ -1,7 +1,6 @@
|
||||
|
||||
package appeng.items.parts;
|
||||
|
||||
|
||||
import java.lang.reflect.Field;
|
||||
import java.lang.reflect.InvocationTargetException;
|
||||
import java.lang.reflect.Method;
|
||||
@@ -15,130 +14,111 @@ import net.minecraft.util.ResourceLocation;
|
||||
import appeng.api.parts.IPartModel;
|
||||
import appeng.core.AELog;
|
||||
|
||||
|
||||
/**
|
||||
* Helps with the reflection magic needed to gather all models for AE2 cable bus parts.
|
||||
* Helps with the reflection magic needed to gather all models for AE2 cable bus
|
||||
* parts.
|
||||
*/
|
||||
class PartModelsHelper
|
||||
{
|
||||
class PartModelsHelper {
|
||||
|
||||
static List<ResourceLocation> createModels( Class<?> clazz )
|
||||
{
|
||||
List<ResourceLocation> locations = new ArrayList<>();
|
||||
static List<ResourceLocation> createModels(Class<?> clazz) {
|
||||
List<ResourceLocation> locations = new ArrayList<>();
|
||||
|
||||
// Check all static fields for used models
|
||||
Field[] fields = clazz.getDeclaredFields();
|
||||
for( Field field : fields )
|
||||
{
|
||||
if( field.getAnnotation( PartModels.class ) == null )
|
||||
{
|
||||
continue;
|
||||
}
|
||||
// Check all static fields for used models
|
||||
Field[] fields = clazz.getDeclaredFields();
|
||||
for (Field field : fields) {
|
||||
if (field.getAnnotation(PartModels.class) == null) {
|
||||
continue;
|
||||
}
|
||||
|
||||
if( !Modifier.isStatic( field.getModifiers() ) )
|
||||
{
|
||||
AELog.error( "The @PartModels annotation can only be used on static fields or methods. Was seen on: " + field );
|
||||
continue;
|
||||
}
|
||||
if (!Modifier.isStatic(field.getModifiers())) {
|
||||
AELog.error("The @PartModels annotation can only be used on static fields or methods. Was seen on: "
|
||||
+ field);
|
||||
continue;
|
||||
}
|
||||
|
||||
Object value;
|
||||
try
|
||||
{
|
||||
field.setAccessible( true );
|
||||
value = field.get( null );
|
||||
}
|
||||
catch( IllegalAccessException e )
|
||||
{
|
||||
AELog.error( e, "Cannot access field annotated with @PartModels: " + field );
|
||||
continue;
|
||||
}
|
||||
Object value;
|
||||
try {
|
||||
field.setAccessible(true);
|
||||
value = field.get(null);
|
||||
} catch (IllegalAccessException e) {
|
||||
AELog.error(e, "Cannot access field annotated with @PartModels: " + field);
|
||||
continue;
|
||||
}
|
||||
|
||||
convertAndAddLocation( field, value, locations );
|
||||
}
|
||||
convertAndAddLocation(field, value, locations);
|
||||
}
|
||||
|
||||
// Check all static methods for the annotation
|
||||
for( Method method : clazz.getDeclaredMethods() )
|
||||
{
|
||||
if( method.getAnnotation( PartModels.class ) == null )
|
||||
{
|
||||
continue;
|
||||
}
|
||||
// Check all static methods for the annotation
|
||||
for (Method method : clazz.getDeclaredMethods()) {
|
||||
if (method.getAnnotation(PartModels.class) == null) {
|
||||
continue;
|
||||
}
|
||||
|
||||
if( !Modifier.isStatic( method.getModifiers() ) )
|
||||
{
|
||||
AELog.error( "The @PartModels annotation can only be used on static fields or methods. Was seen on: " + method );
|
||||
continue;
|
||||
}
|
||||
if (!Modifier.isStatic(method.getModifiers())) {
|
||||
AELog.error("The @PartModels annotation can only be used on static fields or methods. Was seen on: "
|
||||
+ method);
|
||||
continue;
|
||||
}
|
||||
|
||||
// Check for parameter count
|
||||
if( method.getParameters().length != 0 )
|
||||
{
|
||||
AELog.error( "The @PartModels annotation can only be used on static methods without parameters. Was seen on: " + method );
|
||||
continue;
|
||||
}
|
||||
// Check for parameter count
|
||||
if (method.getParameters().length != 0) {
|
||||
AELog.error(
|
||||
"The @PartModels annotation can only be used on static methods without parameters. Was seen on: "
|
||||
+ method);
|
||||
continue;
|
||||
}
|
||||
|
||||
// Make sure we can handle the return type
|
||||
Class<?> returnType = method.getReturnType();
|
||||
if( !ResourceLocation.class.isAssignableFrom( returnType ) && !Collection.class.isAssignableFrom( returnType ) )
|
||||
{
|
||||
AELog.error(
|
||||
"The @PartModels annotation can only be used on static methods that return a ResourceLocation or Collection of " + "ResourceLocations. Was seen on: " + method );
|
||||
continue;
|
||||
}
|
||||
// Make sure we can handle the return type
|
||||
Class<?> returnType = method.getReturnType();
|
||||
if (!ResourceLocation.class.isAssignableFrom(returnType)
|
||||
&& !Collection.class.isAssignableFrom(returnType)) {
|
||||
AELog.error(
|
||||
"The @PartModels annotation can only be used on static methods that return a ResourceLocation or Collection of "
|
||||
+ "ResourceLocations. Was seen on: " + method);
|
||||
continue;
|
||||
}
|
||||
|
||||
Object value = null;
|
||||
try
|
||||
{
|
||||
method.setAccessible( true );
|
||||
value = method.invoke( null );
|
||||
}
|
||||
catch( IllegalAccessException | InvocationTargetException e )
|
||||
{
|
||||
AELog.error( e, "Failed to invoke the @PartModels annotated method " + method );
|
||||
continue;
|
||||
}
|
||||
Object value = null;
|
||||
try {
|
||||
method.setAccessible(true);
|
||||
value = method.invoke(null);
|
||||
} catch (IllegalAccessException | InvocationTargetException e) {
|
||||
AELog.error(e, "Failed to invoke the @PartModels annotated method " + method);
|
||||
continue;
|
||||
}
|
||||
|
||||
convertAndAddLocation( method, value, locations );
|
||||
}
|
||||
convertAndAddLocation(method, value, locations);
|
||||
}
|
||||
|
||||
if( clazz.getSuperclass() != null )
|
||||
{
|
||||
locations.addAll( createModels( clazz.getSuperclass() ) );
|
||||
}
|
||||
if (clazz.getSuperclass() != null) {
|
||||
locations.addAll(createModels(clazz.getSuperclass()));
|
||||
}
|
||||
|
||||
return locations;
|
||||
}
|
||||
return locations;
|
||||
}
|
||||
|
||||
private static void convertAndAddLocation( Object source, Object value, List<ResourceLocation> locations )
|
||||
{
|
||||
if( value == null )
|
||||
{
|
||||
return;
|
||||
}
|
||||
private static void convertAndAddLocation(Object source, Object value, List<ResourceLocation> locations) {
|
||||
if (value == null) {
|
||||
return;
|
||||
}
|
||||
|
||||
if( value instanceof ResourceLocation )
|
||||
{
|
||||
locations.add( (ResourceLocation) value );
|
||||
}
|
||||
else if( value instanceof IPartModel )
|
||||
{
|
||||
locations.addAll( ( (IPartModel) value ).getModels() );
|
||||
}
|
||||
else if( value instanceof Collection )
|
||||
{
|
||||
// Check that each object is an IPartModel
|
||||
Collection values = (Collection) value;
|
||||
for( Object candidate : values )
|
||||
{
|
||||
if( !( candidate instanceof IPartModel ) )
|
||||
{
|
||||
AELog.error( "List of locations obtained from {} contains a non resource location: {}", source, candidate );
|
||||
continue;
|
||||
}
|
||||
if (value instanceof ResourceLocation) {
|
||||
locations.add((ResourceLocation) value);
|
||||
} else if (value instanceof IPartModel) {
|
||||
locations.addAll(((IPartModel) value).getModels());
|
||||
} else if (value instanceof Collection) {
|
||||
// Check that each object is an IPartModel
|
||||
Collection values = (Collection) value;
|
||||
for (Object candidate : values) {
|
||||
if (!(candidate instanceof IPartModel)) {
|
||||
AELog.error("List of locations obtained from {} contains a non resource location: {}", source,
|
||||
candidate);
|
||||
continue;
|
||||
}
|
||||
|
||||
locations.addAll( ( (IPartModel) candidate ).getModels() );
|
||||
}
|
||||
}
|
||||
}
|
||||
locations.addAll(((IPartModel) candidate).getModels());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -18,21 +18,18 @@
|
||||
|
||||
package appeng.items.parts;
|
||||
|
||||
|
||||
import java.util.Collections;
|
||||
import java.util.EnumSet;
|
||||
import java.util.HashSet;
|
||||
import java.util.Set;
|
||||
|
||||
import appeng.fluids.parts.*;
|
||||
import appeng.parts.p2p.*;
|
||||
|
||||
import net.minecraft.util.ResourceLocation;
|
||||
import net.minecraftforge.api.distmarker.Dist;
|
||||
import net.minecraftforge.api.distmarker.OnlyIn;
|
||||
|
||||
import appeng.api.parts.IPart;
|
||||
import appeng.api.features.AEFeature;
|
||||
import appeng.api.parts.IPart;
|
||||
import appeng.fluids.parts.*;
|
||||
import appeng.parts.automation.PartAnnihilationPlane;
|
||||
import appeng.parts.automation.PartExportBus;
|
||||
import appeng.parts.automation.PartFormationPlane;
|
||||
@@ -50,6 +47,7 @@ import appeng.parts.networking.PartCableSmart;
|
||||
import appeng.parts.networking.PartDenseCableCovered;
|
||||
import appeng.parts.networking.PartDenseCableSmart;
|
||||
import appeng.parts.networking.PartQuartzFiber;
|
||||
import appeng.parts.p2p.*;
|
||||
import appeng.parts.reporting.PartConversionMonitor;
|
||||
import appeng.parts.reporting.PartCraftingTerminal;
|
||||
import appeng.parts.reporting.PartDarkPanel;
|
||||
@@ -60,187 +58,177 @@ import appeng.parts.reporting.PartSemiDarkPanel;
|
||||
import appeng.parts.reporting.PartStorageMonitor;
|
||||
import appeng.parts.reporting.PartTerminal;
|
||||
|
||||
public enum PartType {
|
||||
INVALID_TYPE(EnumSet.of(AEFeature.CORE), EnumSet.noneOf(IntegrationType.class), null),
|
||||
|
||||
public enum PartType
|
||||
{
|
||||
INVALID_TYPE(EnumSet.of( AEFeature.CORE ), EnumSet.noneOf( IntegrationType.class ), null ),
|
||||
CABLE_GLASS(EnumSet.of(AEFeature.GLASS_CABLES), EnumSet.noneOf(IntegrationType.class), PartCableGlass.class) {
|
||||
@Override
|
||||
public boolean isCable() {
|
||||
return true;
|
||||
}
|
||||
},
|
||||
|
||||
CABLE_GLASS(EnumSet.of( AEFeature.GLASS_CABLES ), EnumSet.noneOf( IntegrationType.class ), PartCableGlass.class )
|
||||
{
|
||||
@Override
|
||||
public boolean isCable()
|
||||
{
|
||||
return true;
|
||||
}
|
||||
},
|
||||
CABLE_COVERED(EnumSet.of(AEFeature.COVERED_CABLES), EnumSet.noneOf(IntegrationType.class), PartCableCovered.class) {
|
||||
@Override
|
||||
public boolean isCable() {
|
||||
return true;
|
||||
}
|
||||
},
|
||||
|
||||
CABLE_COVERED(EnumSet.of( AEFeature.COVERED_CABLES ), EnumSet.noneOf( IntegrationType.class ), PartCableCovered.class )
|
||||
{
|
||||
@Override
|
||||
public boolean isCable()
|
||||
{
|
||||
return true;
|
||||
}
|
||||
},
|
||||
CABLE_SMART(EnumSet.of(AEFeature.CHANNELS, AEFeature.SMART_CABLES), EnumSet.noneOf(IntegrationType.class),
|
||||
PartCableSmart.class) {
|
||||
@Override
|
||||
public boolean isCable() {
|
||||
return true;
|
||||
}
|
||||
},
|
||||
|
||||
CABLE_SMART(EnumSet.of( AEFeature.CHANNELS, AEFeature.SMART_CABLES ), EnumSet.noneOf( IntegrationType.class ), PartCableSmart.class )
|
||||
{
|
||||
@Override
|
||||
public boolean isCable()
|
||||
{
|
||||
return true;
|
||||
}
|
||||
},
|
||||
CABLE_DENSE_SMART(EnumSet.of(AEFeature.CHANNELS, AEFeature.DENSE_CABLES), EnumSet.noneOf(IntegrationType.class),
|
||||
PartDenseCableSmart.class) {
|
||||
@Override
|
||||
public boolean isCable() {
|
||||
return true;
|
||||
}
|
||||
},
|
||||
|
||||
CABLE_DENSE_SMART(EnumSet.of( AEFeature.CHANNELS, AEFeature.DENSE_CABLES ), EnumSet
|
||||
.noneOf( IntegrationType.class ), PartDenseCableSmart.class )
|
||||
{
|
||||
@Override
|
||||
public boolean isCable()
|
||||
{
|
||||
return true;
|
||||
}
|
||||
},
|
||||
CABLE_DENSE_COVERED(EnumSet.of(AEFeature.CHANNELS, AEFeature.DENSE_CABLES), EnumSet.noneOf(IntegrationType.class),
|
||||
PartDenseCableCovered.class) {
|
||||
@Override
|
||||
public boolean isCable() {
|
||||
return true;
|
||||
}
|
||||
},
|
||||
|
||||
CABLE_DENSE_COVERED(EnumSet.of( AEFeature.CHANNELS, AEFeature.DENSE_CABLES ), EnumSet
|
||||
.noneOf( IntegrationType.class ), PartDenseCableCovered.class )
|
||||
{
|
||||
@Override
|
||||
public boolean isCable()
|
||||
{
|
||||
return true;
|
||||
}
|
||||
},
|
||||
TOGGLE_BUS(EnumSet.of(AEFeature.TOGGLE_BUS), EnumSet.noneOf(IntegrationType.class), PartToggleBus.class),
|
||||
|
||||
TOGGLE_BUS(EnumSet.of( AEFeature.TOGGLE_BUS ), EnumSet.noneOf( IntegrationType.class ), PartToggleBus.class ),
|
||||
INVERTED_TOGGLE_BUS(EnumSet.of(AEFeature.TOGGLE_BUS), EnumSet.noneOf(IntegrationType.class),
|
||||
PartInvertedToggleBus.class),
|
||||
|
||||
INVERTED_TOGGLE_BUS(EnumSet.of( AEFeature.TOGGLE_BUS ), EnumSet.noneOf( IntegrationType.class ), PartInvertedToggleBus.class ),
|
||||
CABLE_ANCHOR(EnumSet.of(AEFeature.CABLE_ANCHOR), EnumSet.noneOf(IntegrationType.class), PartCableAnchor.class),
|
||||
|
||||
CABLE_ANCHOR(EnumSet.of( AEFeature.CABLE_ANCHOR ), EnumSet.noneOf( IntegrationType.class ), PartCableAnchor.class ),
|
||||
QUARTZ_FIBER(EnumSet.of(AEFeature.QUARTZ_FIBER), EnumSet.noneOf(IntegrationType.class), PartQuartzFiber.class),
|
||||
|
||||
QUARTZ_FIBER(EnumSet.of( AEFeature.QUARTZ_FIBER ), EnumSet.noneOf( IntegrationType.class ), PartQuartzFiber.class ),
|
||||
MONITOR(EnumSet.of(AEFeature.PANELS), EnumSet.noneOf(IntegrationType.class), PartPanel.class),
|
||||
|
||||
MONITOR(EnumSet.of( AEFeature.PANELS ), EnumSet.noneOf( IntegrationType.class ), PartPanel.class),
|
||||
SEMI_DARK_MONITOR(EnumSet.of(AEFeature.PANELS), EnumSet.noneOf(IntegrationType.class), PartSemiDarkPanel.class),
|
||||
|
||||
SEMI_DARK_MONITOR(EnumSet.of( AEFeature.PANELS ), EnumSet
|
||||
.noneOf( IntegrationType.class ), PartSemiDarkPanel.class),
|
||||
DARK_MONITOR(EnumSet.of(AEFeature.PANELS), EnumSet.noneOf(IntegrationType.class), PartDarkPanel.class),
|
||||
|
||||
DARK_MONITOR(EnumSet.of( AEFeature.PANELS ), EnumSet.noneOf( IntegrationType.class ), PartDarkPanel.class),
|
||||
STORAGE_BUS(EnumSet.of(AEFeature.STORAGE_BUS), EnumSet.noneOf(IntegrationType.class), PartStorageBus.class),
|
||||
FLUID_STORAGE_BUS(EnumSet.of(AEFeature.FLUID_STORAGE_BUS), EnumSet.noneOf(IntegrationType.class),
|
||||
PartFluidStorageBus.class),
|
||||
|
||||
STORAGE_BUS(EnumSet.of( AEFeature.STORAGE_BUS ), EnumSet.noneOf( IntegrationType.class ), PartStorageBus.class ),
|
||||
FLUID_STORAGE_BUS(EnumSet.of( AEFeature.FLUID_STORAGE_BUS ), EnumSet
|
||||
.noneOf( IntegrationType.class ), PartFluidStorageBus.class ),
|
||||
IMPORT_BUS(EnumSet.of(AEFeature.IMPORT_BUS), EnumSet.noneOf(IntegrationType.class), PartImportBus.class),
|
||||
|
||||
IMPORT_BUS(EnumSet.of( AEFeature.IMPORT_BUS ), EnumSet.noneOf( IntegrationType.class ), PartImportBus.class ),
|
||||
FLUID_IMPORT_BUS(EnumSet.of(AEFeature.FLUID_IMPORT_BUS), EnumSet.noneOf(IntegrationType.class),
|
||||
PartFluidImportBus.class),
|
||||
|
||||
FLUID_IMPORT_BUS(EnumSet.of( AEFeature.FLUID_IMPORT_BUS ), EnumSet.noneOf( IntegrationType.class ), PartFluidImportBus.class ),
|
||||
EXPORT_BUS(EnumSet.of(AEFeature.EXPORT_BUS), EnumSet.noneOf(IntegrationType.class), PartExportBus.class),
|
||||
|
||||
EXPORT_BUS(EnumSet.of( AEFeature.EXPORT_BUS ), EnumSet.noneOf( IntegrationType.class ), PartExportBus.class ),
|
||||
FLUID_EXPORT_BUS(EnumSet.of(AEFeature.FLUID_EXPORT_BUS), EnumSet.noneOf(IntegrationType.class),
|
||||
PartFluidExportBus.class),
|
||||
|
||||
FLUID_EXPORT_BUS(EnumSet.of( AEFeature.FLUID_EXPORT_BUS ), EnumSet.noneOf( IntegrationType.class ), PartFluidExportBus.class ),
|
||||
LEVEL_EMITTER(EnumSet.of(AEFeature.LEVEL_EMITTER), EnumSet.noneOf(IntegrationType.class), PartLevelEmitter.class),
|
||||
FLUID_LEVEL_EMITTER(EnumSet.of(AEFeature.FLUID_LEVEL_EMITTER), EnumSet.noneOf(IntegrationType.class),
|
||||
PartFluidLevelEmitter.class),
|
||||
|
||||
LEVEL_EMITTER(EnumSet.of( AEFeature.LEVEL_EMITTER ), EnumSet.noneOf( IntegrationType.class ), PartLevelEmitter.class ),
|
||||
FLUID_LEVEL_EMITTER(EnumSet.of( AEFeature.FLUID_LEVEL_EMITTER ), EnumSet
|
||||
.noneOf( IntegrationType.class ), PartFluidLevelEmitter.class ),
|
||||
ANNIHILATION_PLANE(EnumSet.of(AEFeature.ANNIHILATION_PLANE), EnumSet.noneOf(IntegrationType.class),
|
||||
PartAnnihilationPlane.class),
|
||||
|
||||
ANNIHILATION_PLANE(EnumSet.of( AEFeature.ANNIHILATION_PLANE ), EnumSet
|
||||
.noneOf( IntegrationType.class ), PartAnnihilationPlane.class ),
|
||||
IDENTITY_ANNIHILATION_PLANE(EnumSet.of(AEFeature.ANNIHILATION_PLANE, AEFeature.IDENTITY_ANNIHILATION_PLANE),
|
||||
EnumSet.noneOf(IntegrationType.class), PartIdentityAnnihilationPlane.class),
|
||||
|
||||
IDENTITY_ANNIHILATION_PLANE(EnumSet.of( AEFeature.ANNIHILATION_PLANE, AEFeature.IDENTITY_ANNIHILATION_PLANE ), EnumSet
|
||||
.noneOf( IntegrationType.class ), PartIdentityAnnihilationPlane.class ),
|
||||
FLUID_ANNIHILATION_PLANE(EnumSet.of(AEFeature.FLUID_ANNIHILATION_PLANE), EnumSet.noneOf(IntegrationType.class),
|
||||
PartFluidAnnihilationPlane.class),
|
||||
|
||||
FLUID_ANNIHILATION_PLANE(EnumSet.of( AEFeature.FLUID_ANNIHILATION_PLANE ), EnumSet
|
||||
.noneOf( IntegrationType.class ), PartFluidAnnihilationPlane.class ),
|
||||
FORMATION_PLANE(EnumSet.of(AEFeature.FORMATION_PLANE), EnumSet.noneOf(IntegrationType.class),
|
||||
PartFormationPlane.class),
|
||||
|
||||
FORMATION_PLANE(EnumSet.of( AEFeature.FORMATION_PLANE ), EnumSet.noneOf( IntegrationType.class ), PartFormationPlane.class ),
|
||||
FLUID_FORMATION_PLANE(EnumSet.of(AEFeature.FLUID_FORMATION_PLANE), EnumSet.noneOf(IntegrationType.class),
|
||||
PartFluidFormationPlane.class),
|
||||
|
||||
FLUID_FORMATION_PLANE(EnumSet.of( AEFeature.FLUID_FORMATION_PLANE ), EnumSet
|
||||
.noneOf( IntegrationType.class ), PartFluidFormationPlane.class ),
|
||||
PATTERN_TERMINAL(EnumSet.of(AEFeature.PATTERNS), EnumSet.noneOf(IntegrationType.class), PartPatternTerminal.class),
|
||||
|
||||
PATTERN_TERMINAL(EnumSet.of( AEFeature.PATTERNS ), EnumSet.noneOf( IntegrationType.class ), PartPatternTerminal.class ),
|
||||
CRAFTING_TERMINAL(EnumSet.of(AEFeature.CRAFTING_TERMINAL), EnumSet.noneOf(IntegrationType.class),
|
||||
PartCraftingTerminal.class),
|
||||
|
||||
CRAFTING_TERMINAL(EnumSet.of( AEFeature.CRAFTING_TERMINAL ), EnumSet
|
||||
.noneOf( IntegrationType.class ), PartCraftingTerminal.class ),
|
||||
TERMINAL(EnumSet.of(AEFeature.TERMINAL), EnumSet.noneOf(IntegrationType.class), PartTerminal.class),
|
||||
|
||||
TERMINAL(EnumSet.of( AEFeature.TERMINAL ), EnumSet.noneOf( IntegrationType.class ), PartTerminal.class ),
|
||||
STORAGE_MONITOR(EnumSet.of(AEFeature.STORAGE_MONITOR), EnumSet.noneOf(IntegrationType.class),
|
||||
PartStorageMonitor.class),
|
||||
|
||||
STORAGE_MONITOR(EnumSet.of( AEFeature.STORAGE_MONITOR ), EnumSet.noneOf( IntegrationType.class ), PartStorageMonitor.class ),
|
||||
CONVERSION_MONITOR(EnumSet.of(AEFeature.PART_CONVERSION_MONITOR), EnumSet.noneOf(IntegrationType.class),
|
||||
PartConversionMonitor.class),
|
||||
|
||||
CONVERSION_MONITOR(EnumSet.of( AEFeature.PART_CONVERSION_MONITOR ), EnumSet
|
||||
.noneOf( IntegrationType.class ), PartConversionMonitor.class ),
|
||||
INTERFACE(EnumSet.of(AEFeature.INTERFACE), EnumSet.noneOf(IntegrationType.class), PartInterface.class),
|
||||
FLUID_INTERFACE(EnumSet.of(AEFeature.FLUID_INTERFACE), EnumSet.noneOf(IntegrationType.class),
|
||||
PartFluidInterface.class),
|
||||
|
||||
INTERFACE(EnumSet.of( AEFeature.INTERFACE ), EnumSet.noneOf( IntegrationType.class ), PartInterface.class ),
|
||||
FLUID_INTERFACE(EnumSet.of( AEFeature.FLUID_INTERFACE ), EnumSet.noneOf( IntegrationType.class ), PartFluidInterface.class ),
|
||||
P2P_TUNNEL_ME(EnumSet.of(AEFeature.P2P_TUNNEL, AEFeature.P2P_TUNNEL_ME), EnumSet.noneOf(IntegrationType.class),
|
||||
PartP2PTunnelME.class),
|
||||
|
||||
P2P_TUNNEL_ME(EnumSet.of( AEFeature.P2P_TUNNEL, AEFeature.P2P_TUNNEL_ME ), EnumSet
|
||||
.noneOf( IntegrationType.class ), PartP2PTunnelME.class),
|
||||
P2P_TUNNEL_REDSTONE(EnumSet.of(AEFeature.P2P_TUNNEL, AEFeature.P2P_TUNNEL_REDSTONE),
|
||||
EnumSet.noneOf(IntegrationType.class), PartP2PRedstone.class),
|
||||
|
||||
P2P_TUNNEL_REDSTONE(EnumSet.of( AEFeature.P2P_TUNNEL, AEFeature.P2P_TUNNEL_REDSTONE ), EnumSet
|
||||
.noneOf( IntegrationType.class ), PartP2PRedstone.class),
|
||||
P2P_TUNNEL_ITEM(EnumSet.of(AEFeature.P2P_TUNNEL, AEFeature.P2P_TUNNEL_ITEMS), EnumSet.noneOf(IntegrationType.class),
|
||||
PartP2PItems.class),
|
||||
|
||||
P2P_TUNNEL_ITEM(EnumSet.of( AEFeature.P2P_TUNNEL, AEFeature.P2P_TUNNEL_ITEMS ), EnumSet
|
||||
.noneOf( IntegrationType.class ), PartP2PItems.class),
|
||||
|
||||
P2P_TUNNEL_FLUID(EnumSet.of( AEFeature.P2P_TUNNEL, AEFeature.P2P_TUNNEL_FLUIDS ), EnumSet
|
||||
.noneOf( IntegrationType.class ), PartP2PFluids.class),
|
||||
P2P_TUNNEL_FLUID(EnumSet.of(AEFeature.P2P_TUNNEL, AEFeature.P2P_TUNNEL_FLUIDS),
|
||||
EnumSet.noneOf(IntegrationType.class), PartP2PFluids.class),
|
||||
|
||||
//FIXME P2P_TUNNEL_IC2( 465, "p2p_tunnel_ic2", EnumSet.of( AEFeature.P2P_TUNNEL, AEFeature.P2P_TUNNEL_EU ), EnumSet
|
||||
//FIXME .of( IntegrationType.IC2 ), PartP2PIC2Power.class ),
|
||||
|
||||
P2P_TUNNEL_LIGHT(EnumSet.of( AEFeature.P2P_TUNNEL, AEFeature.P2P_TUNNEL_LIGHT ), EnumSet
|
||||
.noneOf( IntegrationType.class ), PartP2PLight.class),
|
||||
P2P_TUNNEL_LIGHT(EnumSet.of(AEFeature.P2P_TUNNEL, AEFeature.P2P_TUNNEL_LIGHT),
|
||||
EnumSet.noneOf(IntegrationType.class), PartP2PLight.class),
|
||||
|
||||
P2P_TUNNEL_FE(EnumSet.of( AEFeature.P2P_TUNNEL, AEFeature.P2P_TUNNEL_FE ), EnumSet
|
||||
.noneOf( IntegrationType.class ), PartP2PFEPower.class),
|
||||
P2P_TUNNEL_FE(EnumSet.of(AEFeature.P2P_TUNNEL, AEFeature.P2P_TUNNEL_FE), EnumSet.noneOf(IntegrationType.class),
|
||||
PartP2PFEPower.class),
|
||||
|
||||
// P2PTunnelOpenComputers( 468, EnumSet.of( AEFeature.P2PTunnel, AEFeature.P2PTunnelOpenComputers ), EnumSet.of(
|
||||
// IntegrationType.OpenComputers ), PartP2POpenComputers.class, GuiText.OCTunnel ),
|
||||
// P2PTunnelOpenComputers( 468, EnumSet.of( AEFeature.P2PTunnel,
|
||||
// AEFeature.P2PTunnelOpenComputers ), EnumSet.of(
|
||||
// IntegrationType.OpenComputers ), PartP2POpenComputers.class, GuiText.OCTunnel
|
||||
// ),
|
||||
|
||||
INTERFACE_TERMINAL(EnumSet.of( AEFeature.INTERFACE_TERMINAL ), EnumSet
|
||||
.noneOf( IntegrationType.class ), PartInterfaceTerminal.class ),
|
||||
INTERFACE_TERMINAL(EnumSet.of(AEFeature.INTERFACE_TERMINAL), EnumSet.noneOf(IntegrationType.class),
|
||||
PartInterfaceTerminal.class),
|
||||
|
||||
FLUID_TERMINAL(EnumSet.of( AEFeature.FLUID_TERMINAL ), EnumSet.noneOf( IntegrationType.class ), PartFluidTerminal.class );
|
||||
FLUID_TERMINAL(EnumSet.of(AEFeature.FLUID_TERMINAL), EnumSet.noneOf(IntegrationType.class),
|
||||
PartFluidTerminal.class);
|
||||
|
||||
private final Set<AEFeature> features;
|
||||
private final Set<IntegrationType> integrations;
|
||||
@OnlyIn( Dist.CLIENT )
|
||||
private final Set<ResourceLocation> models;
|
||||
private final Set<AEFeature> features;
|
||||
private final Set<IntegrationType> integrations;
|
||||
@OnlyIn(Dist.CLIENT)
|
||||
private final Set<ResourceLocation> models;
|
||||
|
||||
PartType(final Set<AEFeature> features, final Set<IntegrationType> integrations, final Class<? extends IPart> c)
|
||||
{
|
||||
this.features = Collections.unmodifiableSet( features );
|
||||
this.integrations = Collections.unmodifiableSet( integrations );
|
||||
PartType(final Set<AEFeature> features, final Set<IntegrationType> integrations, final Class<? extends IPart> c) {
|
||||
this.features = Collections.unmodifiableSet(features);
|
||||
this.integrations = Collections.unmodifiableSet(integrations);
|
||||
|
||||
if( c != null )
|
||||
{
|
||||
this.models = new HashSet<>( PartModelsHelper.createModels( c ) );
|
||||
}
|
||||
else
|
||||
{
|
||||
this.models = Collections.emptySet();
|
||||
}
|
||||
}
|
||||
if (c != null) {
|
||||
this.models = new HashSet<>(PartModelsHelper.createModels(c));
|
||||
} else {
|
||||
this.models = Collections.emptySet();
|
||||
}
|
||||
}
|
||||
|
||||
public boolean isCable()
|
||||
{
|
||||
return false;
|
||||
}
|
||||
public boolean isCable() {
|
||||
return false;
|
||||
}
|
||||
|
||||
public Set<AEFeature> getFeature()
|
||||
{
|
||||
return this.features;
|
||||
}
|
||||
public Set<AEFeature> getFeature() {
|
||||
return this.features;
|
||||
}
|
||||
|
||||
Set<IntegrationType> getIntegrations()
|
||||
{
|
||||
return this.integrations;
|
||||
}
|
||||
Set<IntegrationType> getIntegrations() {
|
||||
return this.integrations;
|
||||
}
|
||||
|
||||
public Set<ResourceLocation> getModels()
|
||||
{
|
||||
return this.models;
|
||||
}
|
||||
public Set<ResourceLocation> getModels() {
|
||||
return this.models;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
enum IntegrationType {}
|
||||
enum IntegrationType {
|
||||
}
|
||||
@@ -18,7 +18,6 @@
|
||||
|
||||
package appeng.items.storage;
|
||||
|
||||
|
||||
import java.util.List;
|
||||
import java.util.Set;
|
||||
|
||||
@@ -29,7 +28,6 @@ import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.item.ItemUseContext;
|
||||
import net.minecraft.util.ActionResult;
|
||||
import net.minecraft.util.ActionResultType;
|
||||
import net.minecraft.util.ActionResultType;
|
||||
import net.minecraft.util.Direction;
|
||||
import net.minecraft.util.Hand;
|
||||
import net.minecraft.util.math.BlockPos;
|
||||
@@ -42,6 +40,7 @@ import net.minecraftforge.items.IItemHandler;
|
||||
import appeng.api.AEApi;
|
||||
import appeng.api.config.FuzzyMode;
|
||||
import appeng.api.exceptions.MissingDefinitionException;
|
||||
import appeng.api.features.AEFeature;
|
||||
import appeng.api.implementations.items.IItemGroup;
|
||||
import appeng.api.implementations.items.IStorageCell;
|
||||
import appeng.api.implementations.items.IUpgradeModule;
|
||||
@@ -50,7 +49,6 @@ import appeng.api.storage.data.IAEItemStack;
|
||||
import appeng.api.storage.data.IAEStack;
|
||||
import appeng.api.storage.data.IItemList;
|
||||
import appeng.core.AEConfig;
|
||||
import appeng.api.features.AEFeature;
|
||||
import appeng.core.localization.GuiText;
|
||||
import appeng.items.AEBaseItem;
|
||||
import appeng.items.contents.CellConfig;
|
||||
@@ -59,191 +57,159 @@ import appeng.items.materials.MaterialType;
|
||||
import appeng.util.InventoryAdaptor;
|
||||
import appeng.util.Platform;
|
||||
|
||||
|
||||
/**
|
||||
* @author DrummerMC
|
||||
* @version rv6 - 2018-01-17
|
||||
* @since rv6 2018-01-17
|
||||
*/
|
||||
public abstract class AbstractStorageCell<T extends IAEStack<T>> extends AEBaseItem implements IStorageCell<T>, IItemGroup
|
||||
{
|
||||
protected final MaterialType component;
|
||||
protected final int totalBytes;
|
||||
public abstract class AbstractStorageCell<T extends IAEStack<T>> extends AEBaseItem
|
||||
implements IStorageCell<T>, IItemGroup {
|
||||
protected final MaterialType component;
|
||||
protected final int totalBytes;
|
||||
|
||||
public AbstractStorageCell(Properties properties, final MaterialType whichCell, final int kilobytes ) {
|
||||
super(properties);
|
||||
this.totalBytes = kilobytes * 1024;
|
||||
this.component = whichCell;
|
||||
}
|
||||
public AbstractStorageCell(Properties properties, final MaterialType whichCell, final int kilobytes) {
|
||||
super(properties);
|
||||
this.totalBytes = kilobytes * 1024;
|
||||
this.component = whichCell;
|
||||
}
|
||||
|
||||
@OnlyIn( Dist.CLIENT )
|
||||
@Override
|
||||
public void addInformation(final ItemStack stack, final World world, final List<ITextComponent> lines, final ITooltipFlag advancedTooltips )
|
||||
{
|
||||
AEApi.instance()
|
||||
.client()
|
||||
.addCellInformation( AEApi.instance().registries().cell().getCellInventory( stack, null, this.getChannel() ), lines );
|
||||
}
|
||||
@OnlyIn(Dist.CLIENT)
|
||||
@Override
|
||||
public void addInformation(final ItemStack stack, final World world, final List<ITextComponent> lines,
|
||||
final ITooltipFlag advancedTooltips) {
|
||||
AEApi.instance().client().addCellInformation(
|
||||
AEApi.instance().registries().cell().getCellInventory(stack, null, this.getChannel()), lines);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getBytes( final ItemStack cellItem )
|
||||
{
|
||||
return this.totalBytes;
|
||||
}
|
||||
@Override
|
||||
public int getBytes(final ItemStack cellItem) {
|
||||
return this.totalBytes;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getTotalTypes( final ItemStack cellItem )
|
||||
{
|
||||
return 63;
|
||||
}
|
||||
@Override
|
||||
public int getTotalTypes(final ItemStack cellItem) {
|
||||
return 63;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isBlackListed( final ItemStack cellItem, final T requestedAddition )
|
||||
{
|
||||
return false;
|
||||
}
|
||||
@Override
|
||||
public boolean isBlackListed(final ItemStack cellItem, final T 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 String getUnlocalizedGroupName( final Set<ItemStack> others, final ItemStack is )
|
||||
{
|
||||
return GuiText.StorageCells.getTranslationKey();
|
||||
}
|
||||
@Override
|
||||
public String getUnlocalizedGroupName(final Set<ItemStack> others, final ItemStack is) {
|
||||
return GuiText.StorageCells.getTranslationKey();
|
||||
}
|
||||
|
||||
@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 = is.getOrCreateTag().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 = is.getOrCreateTag().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 )
|
||||
{
|
||||
@Override
|
||||
public void setFuzzyMode(final ItemStack is, final FuzzyMode fzMode) {
|
||||
is.getOrCreateTag().putString("FuzzyMode", fzMode.name());
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public ActionResult<ItemStack> onItemRightClick( final World world, final PlayerEntity player, final Hand hand )
|
||||
{
|
||||
this.disassembleDrive( player.getHeldItem( hand ), world, player );
|
||||
return new ActionResult<>( ActionResultType.SUCCESS, player.getHeldItem( hand ) );
|
||||
}
|
||||
@Override
|
||||
public ActionResult<ItemStack> onItemRightClick(final World world, final PlayerEntity player, final Hand hand) {
|
||||
this.disassembleDrive(player.getHeldItem(hand), world, player);
|
||||
return new ActionResult<>(ActionResultType.SUCCESS, player.getHeldItem(hand));
|
||||
}
|
||||
|
||||
private boolean disassembleDrive( final ItemStack stack, final World world, final PlayerEntity player )
|
||||
{
|
||||
if( player.isCrouching() )
|
||||
{
|
||||
if( Platform.isClient() )
|
||||
{
|
||||
return false;
|
||||
}
|
||||
private boolean disassembleDrive(final ItemStack stack, final World world, final PlayerEntity player) {
|
||||
if (player.isCrouching()) {
|
||||
if (Platform.isClient()) {
|
||||
return false;
|
||||
}
|
||||
|
||||
final PlayerInventory playerInventory = player.inventory;
|
||||
final IMEInventoryHandler inv = AEApi.instance().registries().cell().getCellInventory( stack, null, this.getChannel() );
|
||||
if( inv != null && playerInventory.getCurrentItem() == stack )
|
||||
{
|
||||
final InventoryAdaptor ia = InventoryAdaptor.getAdaptor( player );
|
||||
final IItemList<IAEItemStack> list = inv.getAvailableItems( this.getChannel().createList() );
|
||||
if( list.isEmpty() && ia != null )
|
||||
{
|
||||
playerInventory.setInventorySlotContents( playerInventory.currentItem, ItemStack.EMPTY );
|
||||
final PlayerInventory playerInventory = player.inventory;
|
||||
final IMEInventoryHandler inv = AEApi.instance().registries().cell().getCellInventory(stack, null,
|
||||
this.getChannel());
|
||||
if (inv != null && playerInventory.getCurrentItem() == stack) {
|
||||
final InventoryAdaptor ia = InventoryAdaptor.getAdaptor(player);
|
||||
final IItemList<IAEItemStack> list = inv.getAvailableItems(this.getChannel().createList());
|
||||
if (list.isEmpty() && ia != null) {
|
||||
playerInventory.setInventorySlotContents(playerInventory.currentItem, ItemStack.EMPTY);
|
||||
|
||||
// drop core
|
||||
final ItemStack extraB = ia.addItems( this.component.stack( 1 ) );
|
||||
if( !extraB.isEmpty() )
|
||||
{
|
||||
player.dropItem( extraB, false );
|
||||
}
|
||||
// drop core
|
||||
final ItemStack extraB = ia.addItems(this.component.stack(1));
|
||||
if (!extraB.isEmpty()) {
|
||||
player.dropItem(extraB, false);
|
||||
}
|
||||
|
||||
// drop upgrades
|
||||
final IItemHandler upgradesInventory = this.getUpgradesInventory( stack );
|
||||
for( int upgradeIndex = 0; upgradeIndex < upgradesInventory.getSlots(); upgradeIndex++ )
|
||||
{
|
||||
final ItemStack upgradeStack = upgradesInventory.getStackInSlot( upgradeIndex );
|
||||
final ItemStack leftStack = ia.addItems( upgradeStack );
|
||||
if( !leftStack.isEmpty() && upgradeStack.getItem() instanceof IUpgradeModule )
|
||||
{
|
||||
player.dropItem( upgradeStack, false );
|
||||
}
|
||||
}
|
||||
// drop upgrades
|
||||
final IItemHandler upgradesInventory = this.getUpgradesInventory(stack);
|
||||
for (int upgradeIndex = 0; upgradeIndex < upgradesInventory.getSlots(); upgradeIndex++) {
|
||||
final ItemStack upgradeStack = upgradesInventory.getStackInSlot(upgradeIndex);
|
||||
final ItemStack leftStack = ia.addItems(upgradeStack);
|
||||
if (!leftStack.isEmpty() && upgradeStack.getItem() instanceof IUpgradeModule) {
|
||||
player.dropItem(upgradeStack, false);
|
||||
}
|
||||
}
|
||||
|
||||
// drop empty storage cell case
|
||||
this.dropEmptyStorageCellCase( ia, player );
|
||||
// drop empty storage cell case
|
||||
this.dropEmptyStorageCellCase(ia, player);
|
||||
|
||||
if( player.container != null )
|
||||
{
|
||||
player.container.detectAndSendChanges();
|
||||
}
|
||||
if (player.container != null) {
|
||||
player.container.detectAndSendChanges();
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
protected abstract void dropEmptyStorageCellCase( final InventoryAdaptor ia, final PlayerEntity player );
|
||||
protected abstract void dropEmptyStorageCellCase(final InventoryAdaptor ia, final PlayerEntity player);
|
||||
|
||||
@Override
|
||||
public ActionResultType onItemUseFirst( ItemStack stack, ItemUseContext context )
|
||||
{
|
||||
return this.disassembleDrive( stack, context.getWorld(), context.getPlayer() ) ? ActionResultType.SUCCESS : ActionResultType.PASS;
|
||||
}
|
||||
|
||||
@Override
|
||||
public ItemStack getContainerItem( final ItemStack itemStack )
|
||||
{
|
||||
return AEApi.instance()
|
||||
.definitions()
|
||||
.materials()
|
||||
.emptyStorageCell()
|
||||
.maybeStack( 1 )
|
||||
.orElseThrow( () -> new MissingDefinitionException( "Tried to use empty storage cells while basic storage cells are defined." ) );
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean hasContainerItem( final ItemStack stack )
|
||||
{
|
||||
return AEConfig.instance().isFeatureEnabled( AEFeature.ENABLE_DISASSEMBLY_CRAFTING );
|
||||
}
|
||||
@Override
|
||||
public ActionResultType onItemUseFirst(ItemStack stack, ItemUseContext context) {
|
||||
return this.disassembleDrive(stack, context.getWorld(), context.getPlayer()) ? ActionResultType.SUCCESS
|
||||
: ActionResultType.PASS;
|
||||
}
|
||||
|
||||
@Override
|
||||
public ItemStack getContainerItem(final ItemStack itemStack) {
|
||||
return AEApi.instance().definitions().materials().emptyStorageCell().maybeStack(1)
|
||||
.orElseThrow(() -> new MissingDefinitionException(
|
||||
"Tried to use empty storage cells while basic storage cells are defined."));
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean hasContainerItem(final ItemStack stack) {
|
||||
return AEConfig.instance().isFeatureEnabled(AEFeature.ENABLE_DISASSEMBLY_CRAFTING);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -18,7 +18,6 @@
|
||||
|
||||
package appeng.items.storage;
|
||||
|
||||
|
||||
import net.minecraft.entity.player.PlayerEntity;
|
||||
import net.minecraft.item.ItemStack;
|
||||
|
||||
@@ -29,69 +28,59 @@ import appeng.api.storage.data.IAEItemStack;
|
||||
import appeng.items.materials.MaterialType;
|
||||
import appeng.util.InventoryAdaptor;
|
||||
|
||||
public final class BasicItemStorageCell extends AbstractStorageCell<IAEItemStack> {
|
||||
|
||||
public final class BasicItemStorageCell extends AbstractStorageCell<IAEItemStack>
|
||||
{
|
||||
protected final int perType;
|
||||
protected final double idleDrain;
|
||||
|
||||
protected final int perType;
|
||||
protected final double idleDrain;
|
||||
public BasicItemStorageCell(Properties props, final MaterialType whichCell, final int kilobytes) {
|
||||
super(props, whichCell, kilobytes);
|
||||
switch (whichCell) {
|
||||
case ITEM_1K_CELL_COMPONENT:
|
||||
this.idleDrain = 0.5;
|
||||
this.perType = 8;
|
||||
break;
|
||||
case ITEM_4K_CELL_COMPONENT:
|
||||
this.idleDrain = 1.0;
|
||||
this.perType = 32;
|
||||
break;
|
||||
case ITEM_16K_CELL_COMPONENT:
|
||||
this.idleDrain = 1.5;
|
||||
this.perType = 128;
|
||||
break;
|
||||
case ITEM_64K_CELL_COMPONENT:
|
||||
this.idleDrain = 2.0;
|
||||
this.perType = 512;
|
||||
break;
|
||||
default:
|
||||
this.idleDrain = 0.0;
|
||||
this.perType = 8;
|
||||
}
|
||||
|
||||
public BasicItemStorageCell( Properties props, final MaterialType whichCell, final int kilobytes )
|
||||
{
|
||||
super( props, whichCell, kilobytes );
|
||||
switch( whichCell )
|
||||
{
|
||||
case ITEM_1K_CELL_COMPONENT:
|
||||
this.idleDrain = 0.5;
|
||||
this.perType = 8;
|
||||
break;
|
||||
case ITEM_4K_CELL_COMPONENT:
|
||||
this.idleDrain = 1.0;
|
||||
this.perType = 32;
|
||||
break;
|
||||
case ITEM_16K_CELL_COMPONENT:
|
||||
this.idleDrain = 1.5;
|
||||
this.perType = 128;
|
||||
break;
|
||||
case ITEM_64K_CELL_COMPONENT:
|
||||
this.idleDrain = 2.0;
|
||||
this.perType = 512;
|
||||
break;
|
||||
default:
|
||||
this.idleDrain = 0.0;
|
||||
this.perType = 8;
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
@Override
|
||||
public int getBytesPerType(ItemStack cellItem) {
|
||||
return this.perType;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getBytesPerType( ItemStack cellItem )
|
||||
{
|
||||
return this.perType;
|
||||
}
|
||||
@Override
|
||||
public double getIdleDrain() {
|
||||
return this.idleDrain;
|
||||
}
|
||||
|
||||
@Override
|
||||
public double getIdleDrain()
|
||||
{
|
||||
return this.idleDrain;
|
||||
}
|
||||
@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
|
||||
protected void dropEmptyStorageCellCase( final InventoryAdaptor ia, final PlayerEntity player )
|
||||
{
|
||||
AEApi.instance().definitions().materials().emptyStorageCell().maybeStack( 1 ).ifPresent( is ->
|
||||
{
|
||||
final ItemStack extraA = ia.addItems( is );
|
||||
if( !extraA.isEmpty() )
|
||||
{
|
||||
player.dropItem( extraA, false );
|
||||
}
|
||||
} );
|
||||
}
|
||||
@Override
|
||||
protected void dropEmptyStorageCellCase(final InventoryAdaptor ia, final PlayerEntity player) {
|
||||
AEApi.instance().definitions().materials().emptyStorageCell().maybeStack(1).ifPresent(is -> {
|
||||
final ItemStack extraA = ia.addItems(is);
|
||||
if (!extraA.isEmpty()) {
|
||||
player.dropItem(extraA, false);
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
@@ -18,7 +18,6 @@
|
||||
|
||||
package appeng.items.storage;
|
||||
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import net.minecraft.client.util.ITooltipFlag;
|
||||
@@ -38,66 +37,52 @@ import appeng.api.storage.channels.IItemStorageChannel;
|
||||
import appeng.items.AEBaseItem;
|
||||
import appeng.items.contents.CellConfig;
|
||||
|
||||
public class ItemCreativeStorageCell extends AEBaseItem implements ICellWorkbenchItem {
|
||||
|
||||
public class ItemCreativeStorageCell extends AEBaseItem implements ICellWorkbenchItem
|
||||
{
|
||||
public ItemCreativeStorageCell(Properties props) {
|
||||
super(props);
|
||||
}
|
||||
|
||||
public ItemCreativeStorageCell(Properties props)
|
||||
{
|
||||
super(props);
|
||||
}
|
||||
@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 null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public IItemHandler getUpgradesInventory( final ItemStack is )
|
||||
{
|
||||
return null;
|
||||
}
|
||||
@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) {
|
||||
return FuzzyMode.IGNORE_ALL;
|
||||
}
|
||||
|
||||
@Override
|
||||
public FuzzyMode getFuzzyMode( final ItemStack is )
|
||||
{
|
||||
return FuzzyMode.IGNORE_ALL;
|
||||
}
|
||||
@Override
|
||||
public void setFuzzyMode(final ItemStack is, final FuzzyMode fzMode) {
|
||||
|
||||
@Override
|
||||
public void setFuzzyMode( final ItemStack is, final FuzzyMode fzMode )
|
||||
{
|
||||
}
|
||||
|
||||
}
|
||||
@OnlyIn(Dist.CLIENT)
|
||||
@Override
|
||||
public void addInformation(final ItemStack stack, final World world, final List<ITextComponent> lines,
|
||||
final ITooltipFlag advancedTooltips) {
|
||||
final IMEInventoryHandler<?> inventory = AEApi.instance().registries().cell().getCellInventory(stack, null,
|
||||
AEApi.instance().storage().getStorageChannel(IItemStorageChannel.class));
|
||||
|
||||
@OnlyIn( Dist.CLIENT )
|
||||
@Override
|
||||
public void addInformation(final ItemStack stack, final World world, final List<ITextComponent> lines, final ITooltipFlag advancedTooltips )
|
||||
{
|
||||
final IMEInventoryHandler<?> inventory = AEApi.instance()
|
||||
.registries()
|
||||
.cell()
|
||||
.getCellInventory( stack, null,
|
||||
AEApi.instance().storage().getStorageChannel( IItemStorageChannel.class ) );
|
||||
if (inventory instanceof ICellInventoryHandler) {
|
||||
final CellConfig cc = new CellConfig(stack);
|
||||
|
||||
if( inventory instanceof ICellInventoryHandler )
|
||||
{
|
||||
final CellConfig cc = new CellConfig( stack );
|
||||
|
||||
for( final ItemStack is : cc )
|
||||
{
|
||||
if( !is.isEmpty() )
|
||||
{
|
||||
lines.add( is.getDisplayName() );
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
for (final ItemStack is : cc) {
|
||||
if (!is.isEmpty()) {
|
||||
lines.add(is.getDisplayName());
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -18,16 +18,8 @@
|
||||
|
||||
package appeng.items.storage;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import appeng.api.implementations.TransitionResult;
|
||||
import appeng.api.implementations.items.ISpatialStorageCell;
|
||||
import appeng.api.storage.ISpatialDimension;
|
||||
import appeng.api.util.WorldCoord;
|
||||
import appeng.core.AELog;
|
||||
import appeng.core.localization.GuiText;
|
||||
import appeng.spatial.SpatialDimensionManager;
|
||||
import appeng.items.AEBaseItem;
|
||||
import appeng.spatial.StorageHelper;
|
||||
import net.minecraft.client.util.ITooltipFlag;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.nbt.CompoundNBT;
|
||||
@@ -41,130 +33,120 @@ import net.minecraft.world.dimension.DimensionType;
|
||||
import net.minecraftforge.api.distmarker.Dist;
|
||||
import net.minecraftforge.api.distmarker.OnlyIn;
|
||||
|
||||
import java.util.List;
|
||||
import appeng.api.implementations.TransitionResult;
|
||||
import appeng.api.implementations.items.ISpatialStorageCell;
|
||||
import appeng.api.storage.ISpatialDimension;
|
||||
import appeng.api.util.WorldCoord;
|
||||
import appeng.core.AELog;
|
||||
import appeng.core.localization.GuiText;
|
||||
import appeng.items.AEBaseItem;
|
||||
import appeng.spatial.SpatialDimensionManager;
|
||||
import appeng.spatial.StorageHelper;
|
||||
|
||||
public class ItemSpatialStorageCell extends AEBaseItem implements ISpatialStorageCell {
|
||||
private static final String TAG_DIMENSION_ID = "dimension_id";
|
||||
|
||||
public class ItemSpatialStorageCell extends AEBaseItem implements ISpatialStorageCell
|
||||
{
|
||||
private static final String TAG_DIMENSION_ID = "dimension_id";
|
||||
private final int maxRegion;
|
||||
|
||||
private final int maxRegion;
|
||||
public ItemSpatialStorageCell(Properties props, final int spatialScale) {
|
||||
super(props);
|
||||
this.maxRegion = spatialScale;
|
||||
}
|
||||
|
||||
public ItemSpatialStorageCell( Properties props, final int spatialScale )
|
||||
{
|
||||
super(props);
|
||||
this.maxRegion = spatialScale;
|
||||
}
|
||||
@OnlyIn(Dist.CLIENT)
|
||||
@Override
|
||||
public void addInformation(final ItemStack stack, final World world, final List<ITextComponent> lines,
|
||||
final ITooltipFlag advancedTooltips) {
|
||||
final DimensionType dimType = this.getStoredDimension(stack);
|
||||
if (dimType == null) {
|
||||
lines.add(GuiText.Unformatted.textComponent().applyTextStyle(TextFormatting.ITALIC));
|
||||
lines.add(GuiText.SpatialCapacity.textComponent(maxRegion, maxRegion, maxRegion));
|
||||
} else {
|
||||
SpatialDimensionManager.INSTANCE.addCellDimensionTooltip(dimType, lines);
|
||||
}
|
||||
|
||||
@OnlyIn( Dist.CLIENT )
|
||||
@Override
|
||||
public void addInformation(final ItemStack stack, final World world, final List<ITextComponent> lines, final ITooltipFlag advancedTooltips )
|
||||
{
|
||||
final DimensionType dimType = this.getStoredDimension(stack);
|
||||
if (dimType == null) {
|
||||
lines.add(GuiText.Unformatted.textComponent().applyTextStyle(TextFormatting.ITALIC));
|
||||
lines.add( GuiText.SpatialCapacity.textComponent(maxRegion, maxRegion, maxRegion));
|
||||
} else {
|
||||
SpatialDimensionManager.INSTANCE.addCellDimensionTooltip(dimType, lines);
|
||||
}
|
||||
if (advancedTooltips.isAdvanced()) {
|
||||
if (dimType != null && dimType.getRegistryName() != null) {
|
||||
lines.add(new StringTextComponent("Dimension: " + dimType.getRegistryName()));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (advancedTooltips.isAdvanced()) {
|
||||
if (dimType != null && dimType.getRegistryName() != null) {
|
||||
lines.add(new StringTextComponent("Dimension: " + dimType.getRegistryName()));
|
||||
}
|
||||
}
|
||||
}
|
||||
@Override
|
||||
public boolean isSpatialStorage(final ItemStack is) {
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isSpatialStorage( final ItemStack is )
|
||||
{
|
||||
return true;
|
||||
}
|
||||
@Override
|
||||
public int getMaxStoredDim(final ItemStack is) {
|
||||
return this.maxRegion;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getMaxStoredDim( final ItemStack is )
|
||||
{
|
||||
return this.maxRegion;
|
||||
}
|
||||
@Override
|
||||
public DimensionType getStoredDimension(final ItemStack is) {
|
||||
final CompoundNBT c = is.getTag();
|
||||
if (c != null && c.contains(TAG_DIMENSION_ID)) {
|
||||
try {
|
||||
ResourceLocation dimTypeId = new ResourceLocation(c.getString(TAG_DIMENSION_ID));
|
||||
return DimensionType.byName(dimTypeId);
|
||||
} catch (Exception e) {
|
||||
AELog.warn("Failed to retrieve storage cell dimension.", e);
|
||||
}
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public DimensionType getStoredDimension(final ItemStack is )
|
||||
{
|
||||
final CompoundNBT c = is.getTag();
|
||||
if( c != null && c.contains(TAG_DIMENSION_ID) )
|
||||
{
|
||||
try {
|
||||
ResourceLocation dimTypeId = new ResourceLocation(c.getString(TAG_DIMENSION_ID) );
|
||||
return DimensionType.byName(dimTypeId);
|
||||
} catch (Exception e) {
|
||||
AELog.warn("Failed to retrieve storage cell dimension.", e);
|
||||
}
|
||||
}
|
||||
return null;
|
||||
}
|
||||
@Override
|
||||
public TransitionResult doSpatialTransition(final ItemStack is, final World w, final WorldCoord min,
|
||||
final WorldCoord max, int playerId) {
|
||||
final int targetX = max.x - min.x - 1;
|
||||
final int targetY = max.y - min.y - 1;
|
||||
final int targetZ = max.z - min.z - 1;
|
||||
final int maxSize = this.getMaxStoredDim(is);
|
||||
|
||||
@Override
|
||||
public TransitionResult doSpatialTransition( final ItemStack is, final World w, final WorldCoord min, final WorldCoord max, int playerId )
|
||||
{
|
||||
final int targetX = max.x - min.x - 1;
|
||||
final int targetY = max.y - min.y - 1;
|
||||
final int targetZ = max.z - min.z - 1;
|
||||
final int maxSize = this.getMaxStoredDim( is );
|
||||
final BlockPos targetSize = new BlockPos(targetX, targetY, targetZ);
|
||||
|
||||
final BlockPos targetSize = new BlockPos( targetX, targetY, targetZ );
|
||||
ISpatialDimension manager = SpatialDimensionManager.INSTANCE;
|
||||
|
||||
ISpatialDimension manager = SpatialDimensionManager.INSTANCE;
|
||||
DimensionType storedDim = this.getStoredDimension(is);
|
||||
if (storedDim == null) {
|
||||
storedDim = manager.createNewCellDimension(targetSize);
|
||||
}
|
||||
|
||||
DimensionType storedDim = this.getStoredDimension( is );
|
||||
if( storedDim == null )
|
||||
{
|
||||
storedDim = manager.createNewCellDimension( targetSize);
|
||||
}
|
||||
if (storedDim == null) {
|
||||
// Failed to create the dimension
|
||||
return new TransitionResult(false, 0);
|
||||
}
|
||||
|
||||
if (storedDim == null) {
|
||||
// Failed to create the dimension
|
||||
return new TransitionResult(false, 0);
|
||||
}
|
||||
try {
|
||||
if (manager.isCellDimension(storedDim)) {
|
||||
World cellWorld = manager.getWorld(storedDim);
|
||||
|
||||
try
|
||||
{
|
||||
if( manager.isCellDimension( storedDim ) )
|
||||
{
|
||||
World cellWorld = manager.getWorld(storedDim);
|
||||
BlockPos scale = manager.getCellDimensionSize(storedDim);
|
||||
|
||||
BlockPos scale = manager.getCellDimensionSize( storedDim );
|
||||
if (scale.equals(targetSize)) {
|
||||
if (targetX <= maxSize && targetY <= maxSize && targetZ <= maxSize) {
|
||||
BlockPos offset = manager.getCellDimensionOrigin(storedDim);
|
||||
|
||||
if( scale.equals( targetSize ) )
|
||||
{
|
||||
if( targetX <= maxSize && targetY <= maxSize && targetZ <= maxSize )
|
||||
{
|
||||
BlockPos offset = manager.getCellDimensionOrigin( storedDim );
|
||||
this.setStoredDimension(is, storedDim);
|
||||
StorageHelper.getInstance().swapRegions(w, min.x + 1, min.y + 1, min.z + 1, cellWorld,
|
||||
offset.getX(), offset.getY(), offset.getZ(), targetX - 1, targetY - 1, targetZ - 1);
|
||||
|
||||
this.setStoredDimension( is, storedDim);
|
||||
StorageHelper.getInstance()
|
||||
.swapRegions( w, min.x + 1, min.y + 1, min.z + 1, cellWorld, offset.getX(), offset.getY(),
|
||||
offset.getZ(), targetX - 1, targetY - 1,
|
||||
targetZ - 1 );
|
||||
return new TransitionResult(true, 0);
|
||||
}
|
||||
}
|
||||
}
|
||||
return new TransitionResult(false, 0);
|
||||
} finally {
|
||||
// clean up newly created dimensions that failed transfer
|
||||
if (manager.isCellDimension(storedDim) && this.getStoredDimension(is) == null) {
|
||||
manager.deleteCellDimension(storedDim);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return new TransitionResult( true, 0 );
|
||||
}
|
||||
}
|
||||
}
|
||||
return new TransitionResult( false, 0 );
|
||||
}
|
||||
finally
|
||||
{
|
||||
// clean up newly created dimensions that failed transfer
|
||||
if( manager.isCellDimension( storedDim ) && this.getStoredDimension( is ) == null )
|
||||
{
|
||||
manager.deleteCellDimension( storedDim );
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private void setStoredDimension(final ItemStack is, DimensionType dim)
|
||||
{
|
||||
private void setStoredDimension(final ItemStack is, DimensionType dim) {
|
||||
final CompoundNBT c = is.getOrCreateTag();
|
||||
c.putString(TAG_DIMENSION_ID, dim.getRegistryName().toString() );
|
||||
}
|
||||
c.putString(TAG_DIMENSION_ID, dim.getRegistryName().toString());
|
||||
}
|
||||
}
|
||||
|
||||
@@ -18,7 +18,6 @@
|
||||
|
||||
package appeng.items.storage;
|
||||
|
||||
|
||||
import net.minecraft.item.Item;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraftforge.items.IItemHandler;
|
||||
@@ -40,124 +39,101 @@ import appeng.util.prioritylist.IPartitionList;
|
||||
import appeng.util.prioritylist.MergedPriorityList;
|
||||
import appeng.util.prioritylist.PrecisePriorityList;
|
||||
|
||||
public class ItemViewCell extends AEBaseItem implements ICellWorkbenchItem {
|
||||
|
||||
public class ItemViewCell extends AEBaseItem implements ICellWorkbenchItem
|
||||
{
|
||||
public ItemViewCell(Properties properties) {
|
||||
super(properties);
|
||||
}
|
||||
|
||||
public ItemViewCell(Properties properties) {
|
||||
super(properties);
|
||||
}
|
||||
public static IPartitionList<IAEItemStack> createFilter(final ItemStack[] list) {
|
||||
IPartitionList<IAEItemStack> myPartitionList = null;
|
||||
|
||||
public static IPartitionList<IAEItemStack> createFilter(final ItemStack[] list )
|
||||
{
|
||||
IPartitionList<IAEItemStack> myPartitionList = null;
|
||||
final MergedPriorityList<IAEItemStack> myMergedList = new MergedPriorityList<>();
|
||||
|
||||
final MergedPriorityList<IAEItemStack> myMergedList = new MergedPriorityList<>();
|
||||
for (final ItemStack currentViewCell : list) {
|
||||
if (currentViewCell == null) {
|
||||
continue;
|
||||
}
|
||||
|
||||
for( final ItemStack currentViewCell : list )
|
||||
{
|
||||
if( currentViewCell == null )
|
||||
{
|
||||
continue;
|
||||
}
|
||||
if ((currentViewCell.getItem() instanceof ItemViewCell)) {
|
||||
final IItemList<IAEItemStack> priorityList = AEApi.instance().storage()
|
||||
.getStorageChannel(IItemStorageChannel.class).createList();
|
||||
|
||||
if( ( currentViewCell.getItem() instanceof ItemViewCell ) )
|
||||
{
|
||||
final IItemList<IAEItemStack> priorityList = AEApi.instance().storage().getStorageChannel( IItemStorageChannel.class ).createList();
|
||||
final ICellWorkbenchItem vc = (ICellWorkbenchItem) currentViewCell.getItem();
|
||||
final IItemHandler upgrades = vc.getUpgradesInventory(currentViewCell);
|
||||
final IItemHandler config = vc.getConfigInventory(currentViewCell);
|
||||
final FuzzyMode fzMode = vc.getFuzzyMode(currentViewCell);
|
||||
|
||||
final ICellWorkbenchItem vc = (ICellWorkbenchItem) currentViewCell.getItem();
|
||||
final IItemHandler upgrades = vc.getUpgradesInventory( currentViewCell );
|
||||
final IItemHandler config = vc.getConfigInventory( currentViewCell );
|
||||
final FuzzyMode fzMode = vc.getFuzzyMode( currentViewCell );
|
||||
boolean hasInverter = false;
|
||||
boolean hasFuzzy = false;
|
||||
|
||||
boolean hasInverter = false;
|
||||
boolean hasFuzzy = false;
|
||||
for (int x = 0; x < upgrades.getSlots(); x++) {
|
||||
final ItemStack is = upgrades.getStackInSlot(x);
|
||||
if (!is.isEmpty() && is.getItem() instanceof IUpgradeModule) {
|
||||
final Upgrades u = ((IUpgradeModule) is.getItem()).getType(is);
|
||||
if (u != null) {
|
||||
switch (u) {
|
||||
case FUZZY:
|
||||
hasFuzzy = true;
|
||||
break;
|
||||
case INVERTER:
|
||||
hasInverter = true;
|
||||
break;
|
||||
default:
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
for( int x = 0; x < upgrades.getSlots(); x++ )
|
||||
{
|
||||
final ItemStack is = upgrades.getStackInSlot( x );
|
||||
if( !is.isEmpty() && is.getItem() instanceof IUpgradeModule )
|
||||
{
|
||||
final Upgrades u = ( (IUpgradeModule) is.getItem() ).getType( is );
|
||||
if( u != null )
|
||||
{
|
||||
switch( u )
|
||||
{
|
||||
case FUZZY:
|
||||
hasFuzzy = true;
|
||||
break;
|
||||
case INVERTER:
|
||||
hasInverter = true;
|
||||
break;
|
||||
default:
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
for (int x = 0; x < config.getSlots(); x++) {
|
||||
final ItemStack is = config.getStackInSlot(x);
|
||||
if (!is.isEmpty()) {
|
||||
priorityList.add(AEItemStack.fromItemStack(is));
|
||||
}
|
||||
}
|
||||
|
||||
for( int x = 0; x < config.getSlots(); x++ )
|
||||
{
|
||||
final ItemStack is = config.getStackInSlot( x );
|
||||
if( !is.isEmpty() )
|
||||
{
|
||||
priorityList.add( AEItemStack.fromItemStack( is ) );
|
||||
}
|
||||
}
|
||||
if (!priorityList.isEmpty()) {
|
||||
if (hasFuzzy) {
|
||||
myMergedList.addNewList(new FuzzyPriorityList<>(priorityList, fzMode), !hasInverter);
|
||||
} else {
|
||||
myMergedList.addNewList(new PrecisePriorityList<>(priorityList), !hasInverter);
|
||||
}
|
||||
|
||||
if( !priorityList.isEmpty() )
|
||||
{
|
||||
if( hasFuzzy )
|
||||
{
|
||||
myMergedList.addNewList( new FuzzyPriorityList<>( priorityList, fzMode ), !hasInverter );
|
||||
}
|
||||
else
|
||||
{
|
||||
myMergedList.addNewList( new PrecisePriorityList<>( priorityList ), !hasInverter );
|
||||
}
|
||||
myPartitionList = myMergedList;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
myPartitionList = myMergedList;
|
||||
}
|
||||
}
|
||||
}
|
||||
return myPartitionList;
|
||||
}
|
||||
|
||||
return myPartitionList;
|
||||
}
|
||||
@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 = is.getOrCreateTag().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 = is.getOrCreateTag().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 )
|
||||
{
|
||||
@Override
|
||||
public void setFuzzyMode(final ItemStack is, final FuzzyMode fzMode) {
|
||||
is.getOrCreateTag().putString("FuzzyMode", fzMode.name());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -18,7 +18,6 @@
|
||||
|
||||
package appeng.items.tools;
|
||||
|
||||
|
||||
import java.util.EnumSet;
|
||||
import java.util.List;
|
||||
|
||||
@@ -46,163 +45,132 @@ import appeng.core.localization.GuiText;
|
||||
import appeng.items.AEBaseItem;
|
||||
import appeng.util.Platform;
|
||||
|
||||
public class ToolBiometricCard extends AEBaseItem implements IBiometricCard {
|
||||
public ToolBiometricCard(Properties properties) {
|
||||
super(properties);
|
||||
}
|
||||
|
||||
public class ToolBiometricCard extends AEBaseItem implements IBiometricCard
|
||||
{
|
||||
public ToolBiometricCard(Properties properties) {
|
||||
super(properties);
|
||||
}
|
||||
@Override
|
||||
public ActionResult<ItemStack> onItemRightClick(final World w, final PlayerEntity p, final Hand hand) {
|
||||
if (p.isCrouching()) {
|
||||
this.encode(p.getHeldItem(hand), p);
|
||||
p.swingArm(hand);
|
||||
return ActionResult.resultSuccess(p.getHeldItem(hand));
|
||||
}
|
||||
|
||||
@Override
|
||||
public ActionResult<ItemStack> onItemRightClick( final World w, final PlayerEntity p, final Hand hand )
|
||||
{
|
||||
if( p.isCrouching() )
|
||||
{
|
||||
this.encode( p.getHeldItem( hand ), p );
|
||||
p.swingArm( hand );
|
||||
return ActionResult.resultSuccess( p.getHeldItem( hand ) );
|
||||
}
|
||||
return ActionResult.resultPass(p.getHeldItem(hand));
|
||||
}
|
||||
|
||||
return ActionResult.resultPass( p.getHeldItem( hand ) );
|
||||
}
|
||||
@Override
|
||||
public boolean itemInteractionForEntity(ItemStack is, final PlayerEntity player, final LivingEntity target,
|
||||
final Hand hand) {
|
||||
if (target instanceof PlayerEntity && !player.isCrouching()) {
|
||||
if (player.isCreative()) {
|
||||
is = player.getHeldItem(hand);
|
||||
}
|
||||
this.encode(is, (PlayerEntity) target);
|
||||
player.swingArm(hand);
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean itemInteractionForEntity( ItemStack is, final PlayerEntity player, final LivingEntity target, final Hand hand )
|
||||
{
|
||||
if( target instanceof PlayerEntity && !player.isCrouching() )
|
||||
{
|
||||
if( player.isCreative() )
|
||||
{
|
||||
is = player.getHeldItem( hand );
|
||||
}
|
||||
this.encode( is, (PlayerEntity) target );
|
||||
player.swingArm( hand );
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
@Override
|
||||
public ITextComponent getDisplayName(final ItemStack is) {
|
||||
final GameProfile username = this.getProfile(is);
|
||||
return username != null ? super.getDisplayName(is).appendText(" - " + username.getName())
|
||||
: super.getDisplayName(is);
|
||||
}
|
||||
|
||||
@Override
|
||||
public ITextComponent getDisplayName( final ItemStack is )
|
||||
{
|
||||
final GameProfile username = this.getProfile( is );
|
||||
return username != null ? super.getDisplayName( is ).appendText( " - " + username.getName() ) : super.getDisplayName( is );
|
||||
}
|
||||
private void encode(final ItemStack is, final PlayerEntity p) {
|
||||
final GameProfile username = this.getProfile(is);
|
||||
|
||||
private void encode( final ItemStack is, final PlayerEntity 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 CompoundNBT tag = itemStack.getOrCreateTag();
|
||||
|
||||
@Override
|
||||
public void setProfile( final ItemStack itemStack, final GameProfile profile )
|
||||
{
|
||||
final CompoundNBT tag = itemStack.getOrCreateTag();
|
||||
if (profile != null) {
|
||||
final CompoundNBT pNBT = new CompoundNBT();
|
||||
NBTUtil.writeGameProfile(pNBT, profile);
|
||||
tag.put("profile", pNBT);
|
||||
} else {
|
||||
tag.remove("profile");
|
||||
}
|
||||
}
|
||||
|
||||
if( profile != null )
|
||||
{
|
||||
final CompoundNBT pNBT = new CompoundNBT();
|
||||
NBTUtil.writeGameProfile( pNBT, profile );
|
||||
tag.put( "profile", pNBT );
|
||||
}
|
||||
else
|
||||
{
|
||||
tag.remove( "profile" );
|
||||
}
|
||||
}
|
||||
@Override
|
||||
public GameProfile getProfile(final ItemStack is) {
|
||||
final CompoundNBT tag = is.getOrCreateTag();
|
||||
if (tag.contains("profile")) {
|
||||
return NBTUtil.readGameProfile(tag.getCompound("profile"));
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public GameProfile getProfile( final ItemStack is )
|
||||
{
|
||||
final CompoundNBT tag = is.getOrCreateTag();
|
||||
if( tag.contains( "profile" ) )
|
||||
{
|
||||
return NBTUtil.readGameProfile( tag.getCompound( "profile" ) );
|
||||
}
|
||||
return null;
|
||||
}
|
||||
@Override
|
||||
public EnumSet<SecurityPermissions> getPermissions(final ItemStack is) {
|
||||
final CompoundNBT tag = is.getOrCreateTag();
|
||||
final EnumSet<SecurityPermissions> result = EnumSet.noneOf(SecurityPermissions.class);
|
||||
|
||||
@Override
|
||||
public EnumSet<SecurityPermissions> getPermissions( final ItemStack is )
|
||||
{
|
||||
final CompoundNBT tag = is.getOrCreateTag();
|
||||
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 CompoundNBT tag = is.getOrCreateTag();
|
||||
return tag.getBoolean(permission.name());
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean hasPermission( final ItemStack is, final SecurityPermissions permission )
|
||||
{
|
||||
final CompoundNBT tag = is.getOrCreateTag();
|
||||
return tag.getBoolean( permission.name() );
|
||||
}
|
||||
@Override
|
||||
public void removePermission(final ItemStack itemStack, final SecurityPermissions permission) {
|
||||
final CompoundNBT tag = itemStack.getOrCreateTag();
|
||||
if (tag.contains(permission.name())) {
|
||||
tag.remove(permission.name());
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void removePermission( final ItemStack itemStack, final SecurityPermissions permission )
|
||||
{
|
||||
final CompoundNBT tag = itemStack.getOrCreateTag();
|
||||
if( tag.contains( permission.name() ) )
|
||||
{
|
||||
tag.remove( permission.name() );
|
||||
}
|
||||
}
|
||||
@Override
|
||||
public void addPermission(final ItemStack itemStack, final SecurityPermissions permission) {
|
||||
final CompoundNBT tag = itemStack.getOrCreateTag();
|
||||
tag.putBoolean(permission.name(), true);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void addPermission( final ItemStack itemStack, final SecurityPermissions permission )
|
||||
{
|
||||
final CompoundNBT tag = itemStack.getOrCreateTag();
|
||||
tag.putBoolean( 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
|
||||
@OnlyIn(Dist.CLIENT)
|
||||
public void addInformation(final ItemStack stack, final World world, final List<ITextComponent> lines,
|
||||
final ITooltipFlag advancedTooltips) {
|
||||
final EnumSet<SecurityPermissions> perms = this.getPermissions(stack);
|
||||
if (perms.isEmpty()) {
|
||||
lines.add(new TranslationTextComponent(GuiText.NoPermissions.getLocal()));
|
||||
} else {
|
||||
ITextComponent msg = null;
|
||||
|
||||
@Override
|
||||
@OnlyIn( Dist.CLIENT )
|
||||
public void addInformation( final ItemStack stack, final World world, final List<ITextComponent> lines, final ITooltipFlag advancedTooltips )
|
||||
{
|
||||
final EnumSet<SecurityPermissions> perms = this.getPermissions( stack );
|
||||
if( perms.isEmpty() )
|
||||
{
|
||||
lines.add( new TranslationTextComponent( GuiText.NoPermissions.getLocal() ) );
|
||||
}
|
||||
else
|
||||
{
|
||||
ITextComponent msg = null;
|
||||
|
||||
for( final SecurityPermissions sp : perms )
|
||||
{
|
||||
if( msg == null )
|
||||
{
|
||||
msg = new TranslationTextComponent( sp.getTranslatedName() );
|
||||
}
|
||||
else
|
||||
{
|
||||
msg = msg.appendText( ", " ).appendSibling( new TranslationTextComponent( sp.getTranslatedName() ) );
|
||||
}
|
||||
}
|
||||
lines.add( msg );
|
||||
}
|
||||
}
|
||||
for (final SecurityPermissions sp : perms) {
|
||||
if (msg == null) {
|
||||
msg = new TranslationTextComponent(sp.getTranslatedName());
|
||||
} else {
|
||||
msg = msg.appendText(", ").appendSibling(new TranslationTextComponent(sp.getTranslatedName()));
|
||||
}
|
||||
}
|
||||
lines.add(msg);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -18,7 +18,6 @@
|
||||
|
||||
package appeng.items.tools;
|
||||
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import net.minecraft.client.resources.I18n;
|
||||
@@ -47,192 +46,154 @@ import appeng.core.localization.PlayerMessages;
|
||||
import appeng.items.AEBaseItem;
|
||||
import appeng.util.Platform;
|
||||
|
||||
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(Properties properties) {
|
||||
super(properties);
|
||||
}
|
||||
|
||||
public ToolMemoryCard(Properties properties) {
|
||||
super(properties);
|
||||
}
|
||||
@Override
|
||||
@OnlyIn(Dist.CLIENT)
|
||||
public void addInformation(final ItemStack stack, final World world, final List<ITextComponent> lines,
|
||||
final ITooltipFlag advancedTooltips) {
|
||||
String firstLineKey = this.getFirstValidTranslationKey(this.getSettingsName(stack) + ".name",
|
||||
this.getSettingsName(stack));
|
||||
lines.add(new TranslationTextComponent(firstLineKey));
|
||||
|
||||
@Override
|
||||
@OnlyIn( Dist.CLIENT )
|
||||
public void addInformation( final ItemStack stack, final World world, final List<ITextComponent> lines, final ITooltipFlag advancedTooltips )
|
||||
{
|
||||
String firstLineKey = this.getFirstValidTranslationKey( this.getSettingsName( stack ) + ".name", this.getSettingsName( stack ) );
|
||||
lines.add( new TranslationTextComponent(firstLineKey));
|
||||
final CompoundNBT data = this.getData(stack);
|
||||
if (data.contains("tooltip")) {
|
||||
String tooltipKey = getFirstValidTranslationKey(data.getString("tooltip") + ".name",
|
||||
data.getString("tooltip"));
|
||||
lines.add(new TranslationTextComponent(tooltipKey));
|
||||
}
|
||||
|
||||
final CompoundNBT data = this.getData( stack );
|
||||
if( data.contains( "tooltip" ) )
|
||||
{
|
||||
String tooltipKey = getFirstValidTranslationKey( data.getString( "tooltip" ) + ".name", data.getString( "tooltip" ) );
|
||||
lines.add( new TranslationTextComponent(tooltipKey) );
|
||||
}
|
||||
if (data.contains("freq")) {
|
||||
final short freq = data.getShort("freq");
|
||||
final String freqTooltip = TextFormatting.BOLD + Platform.p2p().toHexString(freq);
|
||||
|
||||
if( data.contains( "freq" ) )
|
||||
{
|
||||
final short freq = data.getShort( "freq" );
|
||||
final String freqTooltip = TextFormatting.BOLD + Platform.p2p().toHexString( freq );
|
||||
lines.add(new TranslationTextComponent("gui.tooltips.appliedenergistics2.P2PFrequency", freqTooltip));
|
||||
}
|
||||
}
|
||||
|
||||
lines.add( new TranslationTextComponent( "gui.tooltips.appliedenergistics2.P2PFrequency", freqTooltip ) );
|
||||
}
|
||||
}
|
||||
/**
|
||||
* Find the localized string...
|
||||
*
|
||||
* @param name possible names for the localized string
|
||||
*
|
||||
* @return localized name
|
||||
*/
|
||||
private String getFirstValidTranslationKey(final String... name) {
|
||||
for (final String n : name) {
|
||||
if (I18n.hasKey(n)) {
|
||||
return n;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Find the localized string...
|
||||
*
|
||||
* @param name possible names for the localized string
|
||||
*
|
||||
* @return localized name
|
||||
*/
|
||||
private String getFirstValidTranslationKey( final String... name )
|
||||
{
|
||||
for( final String n : name )
|
||||
{
|
||||
if( I18n.hasKey(n) )
|
||||
{
|
||||
return n;
|
||||
}
|
||||
}
|
||||
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 CompoundNBT data) {
|
||||
final CompoundNBT c = is.getOrCreateTag();
|
||||
c.putString("Config", settingsName);
|
||||
c.put("Data", data);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setMemoryCardContents( final ItemStack is, final String settingsName, final CompoundNBT data )
|
||||
{
|
||||
final CompoundNBT c = is.getOrCreateTag();
|
||||
c.putString( "Config", settingsName );
|
||||
c.put( "Data", data );
|
||||
}
|
||||
@Override
|
||||
public String getSettingsName(final ItemStack is) {
|
||||
final CompoundNBT c = is.getOrCreateTag();
|
||||
final String name = c.getString("Config");
|
||||
return name.isEmpty() ? GuiText.Blank.getTranslationKey() : name;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getSettingsName( final ItemStack is )
|
||||
{
|
||||
final CompoundNBT c = is.getOrCreateTag();
|
||||
final String name = c.getString( "Config" );
|
||||
return name.isEmpty() ? GuiText.Blank.getTranslationKey() : name;
|
||||
}
|
||||
@Override
|
||||
public CompoundNBT getData(final ItemStack is) {
|
||||
final CompoundNBT c = is.getOrCreateTag();
|
||||
CompoundNBT o = c.getCompound("Data");
|
||||
return o.copy();
|
||||
}
|
||||
|
||||
@Override
|
||||
public CompoundNBT getData( final ItemStack is )
|
||||
{
|
||||
final CompoundNBT c = is.getOrCreateTag();
|
||||
CompoundNBT o = c.getCompound( "Data" );
|
||||
return o.copy();
|
||||
}
|
||||
@Override
|
||||
public AEColor[] getColorCode(ItemStack is) {
|
||||
final CompoundNBT tag = this.getData(is);
|
||||
|
||||
@Override
|
||||
public AEColor[] getColorCode( ItemStack is )
|
||||
{
|
||||
final CompoundNBT tag = this.getData( is );
|
||||
if (tag.contains("colorCode")) {
|
||||
final int[] frequency = tag.getIntArray("colorCode");
|
||||
final AEColor[] colorArray = AEColor.values();
|
||||
|
||||
if( tag.contains( "colorCode" ) )
|
||||
{
|
||||
final int[] frequency = tag.getIntArray( "colorCode" );
|
||||
final AEColor[] colorArray = AEColor.values();
|
||||
return new AEColor[] { colorArray[frequency[0]], colorArray[frequency[1]], colorArray[frequency[2]],
|
||||
colorArray[frequency[3]], colorArray[frequency[4]], colorArray[frequency[5]],
|
||||
colorArray[frequency[6]], colorArray[frequency[7]], };
|
||||
}
|
||||
|
||||
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 PlayerEntity player, final MemoryCardMessages msg) {
|
||||
if (Platform.isClient()) {
|
||||
return;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void notifyUser( final PlayerEntity 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 ActionResultType onItemUse(ItemUseContext context) {
|
||||
if (context.getPlayer().isCrouching()) {
|
||||
if (!context.getPlayer().world.isRemote) {
|
||||
this.clearCard(context.getPlayer(), context.getWorld(), context.getHand());
|
||||
}
|
||||
return ActionResultType.SUCCESS;
|
||||
} else {
|
||||
return super.onItemUse(context);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public ActionResultType onItemUse( ItemUseContext context )
|
||||
{
|
||||
if( context.getPlayer().isCrouching() )
|
||||
{
|
||||
if( !context.getPlayer().world.isRemote )
|
||||
{
|
||||
this.clearCard( context.getPlayer(), context.getWorld(), context.getHand() );
|
||||
}
|
||||
return ActionResultType.SUCCESS;
|
||||
}
|
||||
else
|
||||
{
|
||||
return super.onItemUse( context );
|
||||
}
|
||||
}
|
||||
@Override
|
||||
public ActionResult<ItemStack> onItemRightClick(World w, PlayerEntity player, Hand hand) {
|
||||
if (player.isCrouching()) {
|
||||
if (!w.isRemote) {
|
||||
this.clearCard(player, w, hand);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public ActionResult<ItemStack> onItemRightClick( World w, PlayerEntity player, Hand hand )
|
||||
{
|
||||
if( player.isCrouching() )
|
||||
{
|
||||
if( !w.isRemote )
|
||||
{
|
||||
this.clearCard( player, w, hand );
|
||||
}
|
||||
}
|
||||
return super.onItemRightClick(w, player, hand);
|
||||
}
|
||||
|
||||
return super.onItemRightClick( w, player, hand );
|
||||
}
|
||||
@Override
|
||||
public boolean doesSneakBypassUse(ItemStack stack, IWorldReader world, BlockPos pos, PlayerEntity player) {
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean doesSneakBypassUse( ItemStack stack, IWorldReader world, BlockPos pos, PlayerEntity player )
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
private void clearCard( final PlayerEntity player, final World w, final Hand hand )
|
||||
{
|
||||
final IMemoryCard mem = (IMemoryCard) player.getHeldItem( hand ).getItem();
|
||||
mem.notifyUser( player, MemoryCardMessages.SETTINGS_CLEARED );
|
||||
player.getHeldItem( hand ).setTag( null );
|
||||
}
|
||||
private void clearCard(final PlayerEntity player, final World w, final Hand hand) {
|
||||
final IMemoryCard mem = (IMemoryCard) player.getHeldItem(hand).getItem();
|
||||
mem.notifyUser(player, MemoryCardMessages.SETTINGS_CLEARED);
|
||||
player.getHeldItem(hand).setTag(null);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -18,11 +18,6 @@
|
||||
|
||||
package appeng.items.tools;
|
||||
|
||||
|
||||
import appeng.container.ContainerLocator;
|
||||
import appeng.container.ContainerOpener;
|
||||
import appeng.container.implementations.ContainerNetworkStatus;
|
||||
import appeng.container.implementations.ContainerNetworkTool;
|
||||
import net.minecraft.block.Block;
|
||||
import net.minecraft.block.BlockState;
|
||||
import net.minecraft.entity.player.PlayerEntity;
|
||||
@@ -50,149 +45,126 @@ import appeng.api.util.AEPartLocation;
|
||||
import appeng.api.util.DimensionalCoord;
|
||||
import appeng.api.util.INetworkToolAgent;
|
||||
import appeng.container.AEBaseContainer;
|
||||
import appeng.container.ContainerLocator;
|
||||
import appeng.container.ContainerOpener;
|
||||
import appeng.container.implementations.ContainerNetworkStatus;
|
||||
import appeng.container.implementations.ContainerNetworkTool;
|
||||
import appeng.core.AppEng;
|
||||
|
||||
import appeng.core.sync.network.NetworkHandler;
|
||||
import appeng.core.sync.packets.PacketClick;
|
||||
import appeng.items.AEBaseItem;
|
||||
import appeng.items.contents.NetworkToolViewer;
|
||||
import appeng.util.Platform;
|
||||
|
||||
public class ToolNetworkTool extends AEBaseItem implements IGuiItem, IAEWrench {
|
||||
|
||||
public class ToolNetworkTool extends AEBaseItem implements IGuiItem, IAEWrench
|
||||
{
|
||||
public ToolNetworkTool(Properties properties) {
|
||||
super(properties);
|
||||
}
|
||||
|
||||
public ToolNetworkTool(Properties properties) {
|
||||
super(properties);
|
||||
}
|
||||
@Override
|
||||
public IGuiItemObject getGuiObject(final ItemStack is, int playerInventorySlot, final World world,
|
||||
final BlockPos pos) {
|
||||
if (pos == null) {
|
||||
return new NetworkToolViewer(is, null);
|
||||
}
|
||||
final TileEntity te = world.getTileEntity(pos);
|
||||
return new NetworkToolViewer(is, (IGridHost) (te instanceof IGridHost ? te : null));
|
||||
}
|
||||
|
||||
@Override
|
||||
public IGuiItemObject getGuiObject( final ItemStack is, int playerInventorySlot, final World world, final BlockPos pos )
|
||||
{
|
||||
if (pos == null) {
|
||||
return new NetworkToolViewer( is, null );
|
||||
}
|
||||
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 PlayerEntity p, final Hand hand) {
|
||||
if (Platform.isClient()) {
|
||||
final RayTraceResult mop = AppEng.proxy.getRTR();
|
||||
|
||||
@Override
|
||||
public ActionResult<ItemStack> onItemRightClick( final World w, final PlayerEntity p, final Hand hand )
|
||||
{
|
||||
if( Platform.isClient() )
|
||||
{
|
||||
final RayTraceResult mop = AppEng.proxy.getRTR();
|
||||
if (mop == null || mop.getType() == RayTraceResult.Type.MISS) {
|
||||
NetworkHandler.instance().sendToServer(new PacketClick(hand));
|
||||
}
|
||||
}
|
||||
|
||||
if( mop == null || mop.getType() == RayTraceResult.Type.MISS )
|
||||
{
|
||||
NetworkHandler.instance().sendToServer( new PacketClick( hand ) );
|
||||
}
|
||||
}
|
||||
return new ActionResult<>(ActionResultType.SUCCESS, p.getHeldItem(hand));
|
||||
}
|
||||
|
||||
return new ActionResult<>( ActionResultType.SUCCESS, p.getHeldItem( hand ) );
|
||||
}
|
||||
@Override
|
||||
public ActionResultType onItemUseFirst(ItemStack stack, ItemUseContext context) {
|
||||
final BlockRayTraceResult mop = new BlockRayTraceResult(context.getHitVec(), context.getFace(),
|
||||
context.getPos(), context.isInside());
|
||||
final TileEntity te = context.getWorld().getTileEntity(context.getPos());
|
||||
|
||||
@Override
|
||||
public ActionResultType onItemUseFirst( ItemStack stack, ItemUseContext context )
|
||||
{
|
||||
final BlockRayTraceResult mop = new BlockRayTraceResult( context.getHitVec(), context.getFace(), context.getPos(), context.isInside() );
|
||||
final TileEntity te = context.getWorld().getTileEntity( context.getPos() );
|
||||
if (te instanceof IPartHost) {
|
||||
final SelectedPart part = ((IPartHost) te).selectPart(mop.getHitVec());
|
||||
|
||||
if( te instanceof IPartHost )
|
||||
{
|
||||
final SelectedPart part = ( (IPartHost) te ).selectPart( mop.getHitVec() );
|
||||
if (part.part != null || part.facade != null) {
|
||||
if (part.part instanceof INetworkToolAgent && !((INetworkToolAgent) part.part).showNetworkInfo(mop)) {
|
||||
return ActionResultType.FAIL;
|
||||
} else if (context.getPlayer().isCrouching()) {
|
||||
return ActionResultType.PASS;
|
||||
}
|
||||
}
|
||||
} else if (te instanceof INetworkToolAgent && !((INetworkToolAgent) te).showNetworkInfo(mop)) {
|
||||
return ActionResultType.FAIL;
|
||||
}
|
||||
|
||||
if( part.part != null || part.facade != null )
|
||||
{
|
||||
if( part.part instanceof INetworkToolAgent && !( (INetworkToolAgent) part.part ).showNetworkInfo( mop ) )
|
||||
{
|
||||
return ActionResultType.FAIL;
|
||||
}
|
||||
else if( context.getPlayer().isCrouching() )
|
||||
{
|
||||
return ActionResultType.PASS;
|
||||
}
|
||||
}
|
||||
}
|
||||
else if( te instanceof INetworkToolAgent && !( (INetworkToolAgent) te ).showNetworkInfo( mop ) )
|
||||
{
|
||||
return ActionResultType.FAIL;
|
||||
}
|
||||
if (Platform.isClient()) {
|
||||
NetworkHandler.instance().sendToServer(new PacketClick(context));
|
||||
}
|
||||
|
||||
if( Platform.isClient() )
|
||||
{
|
||||
NetworkHandler.instance().sendToServer( new PacketClick( context ) );
|
||||
}
|
||||
return ActionResultType.SUCCESS;
|
||||
}
|
||||
|
||||
return ActionResultType.SUCCESS;
|
||||
}
|
||||
@Override
|
||||
public boolean doesSneakBypassUse(ItemStack stack, IWorldReader world, BlockPos pos, PlayerEntity player) {
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean doesSneakBypassUse( ItemStack stack, IWorldReader world, BlockPos pos, PlayerEntity player )
|
||||
{
|
||||
return true;
|
||||
}
|
||||
public boolean serverSideToolLogic(ItemUseContext useContext) {
|
||||
BlockPos pos = useContext.getPos();
|
||||
PlayerEntity p = useContext.getPlayer();
|
||||
World w = p.world;
|
||||
Hand hand = useContext.getHand();
|
||||
Direction side = useContext.getFace();
|
||||
|
||||
public boolean serverSideToolLogic( ItemUseContext useContext )
|
||||
{
|
||||
BlockPos pos = useContext.getPos();
|
||||
PlayerEntity p = useContext.getPlayer();
|
||||
World w = p.world;
|
||||
Hand hand = useContext.getHand();
|
||||
Direction side = useContext.getFace();
|
||||
if (!Platform.hasPermissions(new DimensionalCoord(w, pos), p)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
if( !Platform.hasPermissions( new DimensionalCoord( w, pos ), p ) )
|
||||
{
|
||||
return false;
|
||||
}
|
||||
final BlockState bs = w.getBlockState(pos);
|
||||
if (!p.isCrouching()) {
|
||||
final TileEntity te = w.getTileEntity(pos);
|
||||
if (!(te instanceof IGridHost)) {
|
||||
if (bs.rotate(w, pos, Rotation.CLOCKWISE_90) != bs) {
|
||||
bs.neighborChanged(w, pos, Platform.AIR_BLOCK, pos, false);
|
||||
p.swingArm(hand);
|
||||
return !w.isRemote;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
final BlockState bs = w.getBlockState( pos );
|
||||
if( !p.isCrouching() )
|
||||
{
|
||||
final TileEntity te = w.getTileEntity( pos );
|
||||
if( !( te instanceof IGridHost ) )
|
||||
{
|
||||
if( bs.rotate( w, pos, Rotation.CLOCKWISE_90 ) != bs )
|
||||
{
|
||||
bs.neighborChanged( w, pos, Platform.AIR_BLOCK, pos, false );
|
||||
p.swingArm( hand );
|
||||
return !w.isRemote;
|
||||
}
|
||||
}
|
||||
}
|
||||
if (!p.isCrouching()) {
|
||||
if (p.openContainer instanceof AEBaseContainer) {
|
||||
return true;
|
||||
}
|
||||
|
||||
if( !p.isCrouching() )
|
||||
{
|
||||
if( p.openContainer instanceof AEBaseContainer )
|
||||
{
|
||||
return true;
|
||||
}
|
||||
final TileEntity te = w.getTileEntity(pos);
|
||||
|
||||
final TileEntity te = w.getTileEntity( pos );
|
||||
if (te instanceof IGridHost) {
|
||||
ContainerOpener.openContainer(ContainerNetworkStatus.TYPE, p,
|
||||
ContainerLocator.forItemUseContext(useContext));
|
||||
} else {
|
||||
ContainerOpener.openContainer(ContainerNetworkTool.TYPE, p, ContainerLocator.forHand(p, hand));
|
||||
}
|
||||
|
||||
if( te instanceof IGridHost )
|
||||
{
|
||||
ContainerOpener.openContainer(ContainerNetworkStatus.TYPE, p, ContainerLocator.forItemUseContext(useContext));
|
||||
}
|
||||
else
|
||||
{
|
||||
ContainerOpener.openContainer(ContainerNetworkTool.TYPE, p, ContainerLocator.forHand(p, hand));
|
||||
}
|
||||
return true;
|
||||
} else {
|
||||
BlockRayTraceResult rtr = new BlockRayTraceResult(useContext.getHitVec(), side, pos, false);
|
||||
bs.onBlockActivated(w, p, hand, rtr);
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
else
|
||||
{
|
||||
BlockRayTraceResult rtr = new BlockRayTraceResult(useContext.getHitVec(), side, pos, false);
|
||||
bs.onBlockActivated( w, p, hand, rtr );
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean canWrench( final ItemStack wrench, final PlayerEntity player, final BlockPos pos )
|
||||
{
|
||||
return true;
|
||||
}
|
||||
@Override
|
||||
public boolean canWrench(final ItemStack wrench, final PlayerEntity player, final BlockPos pos) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -18,7 +18,6 @@
|
||||
|
||||
package appeng.items.tools.powered;
|
||||
|
||||
|
||||
import net.minecraft.entity.LivingEntity;
|
||||
import net.minecraft.item.Item;
|
||||
import net.minecraft.item.ItemStack;
|
||||
@@ -32,36 +31,30 @@ import appeng.core.sync.packets.PacketLightning;
|
||||
import appeng.items.tools.powered.powersink.AEBasePoweredItem;
|
||||
import appeng.util.Platform;
|
||||
|
||||
public class ToolChargedStaff extends AEBasePoweredItem {
|
||||
|
||||
public class ToolChargedStaff extends AEBasePoweredItem
|
||||
{
|
||||
public ToolChargedStaff(Item.Properties props) {
|
||||
super(AEConfig.instance().getChargedStaffBattery(), props);
|
||||
}
|
||||
|
||||
public ToolChargedStaff(Item.Properties props)
|
||||
{
|
||||
super( AEConfig.instance().getChargedStaffBattery(), props );
|
||||
}
|
||||
@Override
|
||||
public boolean hitEntity(final ItemStack item, final LivingEntity target, final LivingEntity 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.getBoundingBox();
|
||||
final float dx = (float) (Platform.getRandomFloat() * target.getWidth() + entityBoundingBox.minX);
|
||||
final float dy = (float) (Platform.getRandomFloat() * target.getHeight() + entityBoundingBox.minY);
|
||||
final float dz = (float) (Platform.getRandomFloat() * target.getWidth() + 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 LivingEntity target, final LivingEntity 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.getBoundingBox();
|
||||
final float dx = (float) ( Platform.getRandomFloat() * target.getWidth() + entityBoundingBox.minX );
|
||||
final float dy = (float) ( Platform.getRandomFloat() * target.getHeight() + entityBoundingBox.minY );
|
||||
final float dz = (float) ( Platform.getRandomFloat() * target.getWidth() + 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;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -18,6 +18,30 @@
|
||||
|
||||
package appeng.items.tools.powered;
|
||||
|
||||
import java.util.*;
|
||||
|
||||
import org.apache.commons.lang3.text.WordUtils;
|
||||
|
||||
import net.minecraft.block.Block;
|
||||
import net.minecraft.block.BlockState;
|
||||
import net.minecraft.client.util.ITooltipFlag;
|
||||
import net.minecraft.entity.player.PlayerEntity;
|
||||
import net.minecraft.item.Item;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.item.SnowballItem;
|
||||
import net.minecraft.nbt.CompoundNBT;
|
||||
import net.minecraft.tileentity.TileEntity;
|
||||
import net.minecraft.util.ActionResultType;
|
||||
import net.minecraft.util.Direction;
|
||||
import net.minecraft.util.Hand;
|
||||
import net.minecraft.util.ResourceLocation;
|
||||
import net.minecraft.util.math.BlockPos;
|
||||
import net.minecraft.util.text.ITextComponent;
|
||||
import net.minecraft.util.text.TranslationTextComponent;
|
||||
import net.minecraft.world.World;
|
||||
import net.minecraftforge.api.distmarker.Dist;
|
||||
import net.minecraftforge.api.distmarker.OnlyIn;
|
||||
import net.minecraftforge.items.IItemHandler;
|
||||
|
||||
import appeng.api.AEApi;
|
||||
import appeng.api.config.Actionable;
|
||||
@@ -48,311 +72,239 @@ import appeng.me.helpers.BaseActionSource;
|
||||
import appeng.tile.misc.TilePaint;
|
||||
import appeng.util.Platform;
|
||||
import appeng.util.item.AEItemStack;
|
||||
import net.minecraft.block.Block;
|
||||
import net.minecraft.block.BlockState;
|
||||
import net.minecraft.client.util.ITooltipFlag;
|
||||
import net.minecraft.entity.player.PlayerEntity;
|
||||
import net.minecraft.item.Item;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.item.SnowballItem;
|
||||
import net.minecraft.nbt.CompoundNBT;
|
||||
import net.minecraft.tileentity.TileEntity;
|
||||
import net.minecraft.util.ActionResultType;
|
||||
import net.minecraft.util.Direction;
|
||||
import net.minecraft.util.Hand;
|
||||
import net.minecraft.util.ResourceLocation;
|
||||
import net.minecraft.util.math.BlockPos;
|
||||
import net.minecraft.util.text.ITextComponent;
|
||||
import net.minecraft.util.text.TranslationTextComponent;
|
||||
import net.minecraft.world.World;
|
||||
import net.minecraftforge.api.distmarker.Dist;
|
||||
import net.minecraftforge.api.distmarker.OnlyIn;
|
||||
import net.minecraftforge.items.IItemHandler;
|
||||
import org.apache.commons.lang3.text.WordUtils;
|
||||
|
||||
import java.util.*;
|
||||
public class ToolColorApplicator extends AEBasePoweredItem
|
||||
implements IStorageCell<IAEItemStack>, IItemGroup, IBlockTool, IMouseWheelItem {
|
||||
|
||||
private static final Map<Integer, AEColor> ORE_TO_COLOR = new HashMap<>();
|
||||
|
||||
public class ToolColorApplicator extends AEBasePoweredItem implements IStorageCell<IAEItemStack>, IItemGroup, IBlockTool, IMouseWheelItem
|
||||
{
|
||||
private static final String TAG_COLOR = "color";
|
||||
|
||||
private static final Map<Integer, AEColor> ORE_TO_COLOR = new HashMap<>();
|
||||
static {
|
||||
for (final AEColor color : AEColor.VALID_COLORS) {
|
||||
final String dyeName = color.dye.getTranslationKey();
|
||||
final String oreDictName = "dye" + WordUtils.capitalize(dyeName);
|
||||
// FIXME final int oreDictId = OreDictionary.getOreID( oreDictName );
|
||||
|
||||
private static final String TAG_COLOR = "color";
|
||||
// FIXME ORE_TO_COLOR.put( oreDictId, color );
|
||||
}
|
||||
}
|
||||
|
||||
static
|
||||
{
|
||||
for( final AEColor color : AEColor.VALID_COLORS )
|
||||
{
|
||||
final String dyeName = color.dye.getTranslationKey();
|
||||
final String oreDictName = "dye" + WordUtils.capitalize( dyeName );
|
||||
// FIXME final int oreDictId = OreDictionary.getOreID( oreDictName );
|
||||
public ToolColorApplicator(Item.Properties props) {
|
||||
super(AEConfig.instance().getColorApplicatorBattery(), props);
|
||||
addPropertyOverride(new ResourceLocation(AppEng.MOD_ID, "colored"), (itemStack, world, entity) -> {
|
||||
// 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 = getActiveColor(itemStack);
|
||||
return (col != null) ? 1 : 0;
|
||||
});
|
||||
}
|
||||
|
||||
// FIXME ORE_TO_COLOR.put( oreDictId, color );
|
||||
}
|
||||
}
|
||||
@Override
|
||||
public ActionResultType onItemUse(PlayerEntity p, World w, BlockPos pos, Hand hand, Direction side, float hitX,
|
||||
float hitY, float hitZ) {
|
||||
return this.onItemUse(p.getHeldItem(hand), p, w, pos, hand, side, hitX, hitY, hitZ);
|
||||
}
|
||||
|
||||
public ToolColorApplicator(Item.Properties props)
|
||||
{
|
||||
super( AEConfig.instance().getColorApplicatorBattery(), props );
|
||||
addPropertyOverride(
|
||||
new ResourceLocation(AppEng.MOD_ID, "colored"),
|
||||
(itemStack, world, entity) -> {
|
||||
// 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 = getActiveColor( itemStack );
|
||||
return ( col != null ) ? 1 : 0;
|
||||
}
|
||||
);
|
||||
}
|
||||
@Override
|
||||
public ActionResultType onItemUse(ItemStack is, PlayerEntity p, World w, BlockPos pos, Hand hand, Direction side,
|
||||
float hitX, float hitY, float hitZ) {
|
||||
final Block blk = w.getBlockState(pos).getBlock();
|
||||
|
||||
@Override
|
||||
public ActionResultType onItemUse( PlayerEntity p, World w, BlockPos pos, Hand hand, Direction side, float hitX, float hitY, float hitZ )
|
||||
{
|
||||
return this.onItemUse( p.getHeldItem( hand ), p, w, pos, hand, side, hitX, hitY, hitZ );
|
||||
}
|
||||
ItemStack paintBall = this.getColor(is);
|
||||
|
||||
@Override
|
||||
public ActionResultType onItemUse( ItemStack is, PlayerEntity p, World w, BlockPos pos, Hand hand, Direction side, float hitX, float hitY, float hitZ )
|
||||
{
|
||||
final Block blk = w.getBlockState( pos ).getBlock();
|
||||
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());
|
||||
|
||||
ItemStack paintBall = this.getColor( is );
|
||||
if (option != null) {
|
||||
paintBall = option.createItemStack();
|
||||
paintBall.setCount(1);
|
||||
} else {
|
||||
paintBall = ItemStack.EMPTY;
|
||||
}
|
||||
|
||||
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 (!Platform.hasPermissions(new DimensionalCoord(w, pos), p)) {
|
||||
return ActionResultType.FAIL;
|
||||
}
|
||||
|
||||
if( option != null )
|
||||
{
|
||||
paintBall = option.createItemStack();
|
||||
paintBall.setCount( 1 );
|
||||
}
|
||||
else
|
||||
{
|
||||
paintBall = ItemStack.EMPTY;
|
||||
}
|
||||
final double powerPerUse = 100;
|
||||
if (!paintBall.isEmpty() && paintBall.getItem() instanceof SnowballItem) {
|
||||
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 ActionResultType.SUCCESS;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if( !Platform.hasPermissions( new DimensionalCoord( w, pos ), p ) )
|
||||
{
|
||||
return ActionResultType.FAIL;
|
||||
}
|
||||
// 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 ActionResultType.SUCCESS;
|
||||
}
|
||||
} else if (!paintBall.isEmpty()) {
|
||||
final AEColor color = this.getColorFromItem(paintBall);
|
||||
|
||||
final double powerPerUse = 100;
|
||||
if( !paintBall.isEmpty() && paintBall.getItem() instanceof SnowballItem )
|
||||
{
|
||||
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 ActionResultType.SUCCESS;
|
||||
}
|
||||
}
|
||||
}
|
||||
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 ActionResultType.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 ActionResultType.SUCCESS;
|
||||
}
|
||||
}
|
||||
else if( !paintBall.isEmpty() )
|
||||
{
|
||||
final AEColor color = this.getColorFromItem( paintBall );
|
||||
if (p.isCrouching()) {
|
||||
this.cycleColors(is, paintBall, 1);
|
||||
}
|
||||
|
||||
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 ActionResultType.SUCCESS;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
return ActionResultType.FAIL;
|
||||
}
|
||||
|
||||
if( p.isCrouching() )
|
||||
{
|
||||
this.cycleColors( is, paintBall, 1 );
|
||||
}
|
||||
@Override
|
||||
public ITextComponent getDisplayName(final ItemStack is) {
|
||||
ITextComponent extra = GuiText.Empty.textComponent();
|
||||
|
||||
return ActionResultType.FAIL;
|
||||
}
|
||||
final AEColor selected = this.getActiveColor(is);
|
||||
|
||||
@Override
|
||||
public ITextComponent getDisplayName( final ItemStack is )
|
||||
{
|
||||
ITextComponent extra = GuiText.Empty.textComponent();
|
||||
if (selected != null && Platform.isClient()) {
|
||||
extra = new TranslationTextComponent(selected.translationKey);
|
||||
}
|
||||
|
||||
final AEColor selected = this.getActiveColor( is );
|
||||
return super.getDisplayName(is).appendText(" - ").appendSibling(extra);
|
||||
}
|
||||
|
||||
if( selected != null && Platform.isClient() )
|
||||
{
|
||||
extra = new TranslationTextComponent(selected.translationKey);
|
||||
}
|
||||
public AEColor getActiveColor(final ItemStack tol) {
|
||||
return this.getColorFromItem(this.getColor(tol));
|
||||
}
|
||||
|
||||
return super.getDisplayName( is ).appendText(" - ").appendSibling( extra );
|
||||
}
|
||||
private AEColor getColorFromItem(final ItemStack paintBall) {
|
||||
if (paintBall.isEmpty()) {
|
||||
return null;
|
||||
}
|
||||
|
||||
public AEColor getActiveColor( final ItemStack tol )
|
||||
{
|
||||
return this.getColorFromItem( this.getColor( tol ) );
|
||||
}
|
||||
if (paintBall.getItem() instanceof SnowballItem) {
|
||||
return AEColor.TRANSPARENT;
|
||||
}
|
||||
|
||||
private AEColor getColorFromItem( final ItemStack paintBall )
|
||||
{
|
||||
if( paintBall.isEmpty() )
|
||||
{
|
||||
return null;
|
||||
}
|
||||
|
||||
if( paintBall.getItem() instanceof SnowballItem )
|
||||
{
|
||||
return AEColor.TRANSPARENT;
|
||||
}
|
||||
|
||||
if( paintBall.getItem() instanceof ItemPaintBall )
|
||||
{
|
||||
final ItemPaintBall ipb = (ItemPaintBall) paintBall.getItem();
|
||||
return ipb.getColor();
|
||||
}
|
||||
else
|
||||
{
|
||||
// FIXME final int[] id = OreDictionary.getOreIDs( paintBall );
|
||||
if (paintBall.getItem() instanceof ItemPaintBall) {
|
||||
final ItemPaintBall ipb = (ItemPaintBall) paintBall.getItem();
|
||||
return ipb.getColor();
|
||||
} else {
|
||||
// FIXME final int[] id = OreDictionary.getOreIDs( paintBall );
|
||||
// FIXME
|
||||
// FIXME for( final int oreID : id )
|
||||
// FIXME {
|
||||
// FIXME if( ORE_TO_COLOR.containsKey( oreID ) )
|
||||
// FIXME {
|
||||
// FIXME return ORE_TO_COLOR.get( oreID );
|
||||
// FIXME }
|
||||
// FIXME }
|
||||
}
|
||||
// FIXME for( final int oreID : id )
|
||||
// FIXME {
|
||||
// FIXME if( ORE_TO_COLOR.containsKey( oreID ) )
|
||||
// FIXME {
|
||||
// FIXME return ORE_TO_COLOR.get( oreID );
|
||||
// FIXME }
|
||||
// FIXME }
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
public ItemStack getColor( final ItemStack is )
|
||||
{
|
||||
final CompoundNBT c = is.getTag();
|
||||
if( c != null && c.contains(TAG_COLOR) )
|
||||
{
|
||||
final CompoundNBT color = c.getCompound( TAG_COLOR );
|
||||
final ItemStack oldColor = ItemStack.read(color);
|
||||
if( !oldColor.isEmpty() )
|
||||
{
|
||||
return oldColor;
|
||||
}
|
||||
}
|
||||
public ItemStack getColor(final ItemStack is) {
|
||||
final CompoundNBT c = is.getTag();
|
||||
if (c != null && c.contains(TAG_COLOR)) {
|
||||
final CompoundNBT color = c.getCompound(TAG_COLOR);
|
||||
final ItemStack oldColor = ItemStack.read(color);
|
||||
if (!oldColor.isEmpty()) {
|
||||
return oldColor;
|
||||
}
|
||||
}
|
||||
|
||||
return this.findNextColor( is, ItemStack.EMPTY, 0 );
|
||||
}
|
||||
return this.findNextColor(is, ItemStack.EMPTY, 0);
|
||||
}
|
||||
|
||||
private ItemStack findNextColor( final ItemStack is, final ItemStack anchor, final int scrollOffset )
|
||||
{
|
||||
ItemStack newColor = ItemStack.EMPTY;
|
||||
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<>();
|
||||
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 );
|
||||
}
|
||||
for (final IAEItemStack i : itemList) {
|
||||
list.add(i);
|
||||
}
|
||||
|
||||
Collections.sort( list, ( a, b ) -> Integer.compare( a.getItemDamage(), b.getItemDamage() ) );
|
||||
Collections.sort(list, (a, b) -> Integer.compare(a.getItemDamage(), b.getItemDamage()));
|
||||
|
||||
if( list.size() <= 0 )
|
||||
{
|
||||
return ItemStack.EMPTY;
|
||||
}
|
||||
if (list.size() <= 0) {
|
||||
return ItemStack.EMPTY;
|
||||
}
|
||||
|
||||
IAEItemStack where = list.getFirst();
|
||||
int cycles = 1 + list.size();
|
||||
IAEItemStack where = list.getFirst();
|
||||
int cycles = 1 + list.size();
|
||||
|
||||
while( cycles > 0 && !where.equals( anchor ) )
|
||||
{
|
||||
list.addLast( list.removeFirst() );
|
||||
cycles--;
|
||||
where = list.getFirst();
|
||||
}
|
||||
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.addLast(list.removeFirst());
|
||||
}
|
||||
|
||||
if( scrollOffset < 0 )
|
||||
{
|
||||
list.addFirst( list.removeLast() );
|
||||
}
|
||||
if (scrollOffset < 0) {
|
||||
list.addFirst(list.removeLast());
|
||||
}
|
||||
|
||||
return list.get( 0 ).asItemStackRepresentation();
|
||||
}
|
||||
}
|
||||
return list.get(0).asItemStackRepresentation();
|
||||
}
|
||||
}
|
||||
|
||||
if( !newColor.isEmpty() )
|
||||
{
|
||||
this.setColor( is, newColor );
|
||||
}
|
||||
if (!newColor.isEmpty()) {
|
||||
this.setColor(is, newColor);
|
||||
}
|
||||
|
||||
return newColor;
|
||||
}
|
||||
return newColor;
|
||||
}
|
||||
|
||||
private void setColor( final ItemStack is, final ItemStack newColor )
|
||||
{
|
||||
private void setColor(final ItemStack is, final ItemStack newColor) {
|
||||
final CompoundNBT data = is.getOrCreateTag();
|
||||
if( newColor.isEmpty() )
|
||||
{
|
||||
data.remove( TAG_COLOR );
|
||||
}
|
||||
else
|
||||
{
|
||||
final CompoundNBT color = new CompoundNBT();
|
||||
newColor.write(color);
|
||||
data.put( TAG_COLOR, color );
|
||||
}
|
||||
}
|
||||
if (newColor.isEmpty()) {
|
||||
data.remove(TAG_COLOR);
|
||||
} else {
|
||||
final CompoundNBT color = new CompoundNBT();
|
||||
newColor.write(color);
|
||||
data.put(TAG_COLOR, color);
|
||||
}
|
||||
}
|
||||
|
||||
private boolean recolourBlock( final Block blk, final Direction side, final World w, final BlockPos pos, final Direction orientation, final AEColor newColor, final PlayerEntity p )
|
||||
{
|
||||
final BlockState state = w.getBlockState( pos );
|
||||
private boolean recolourBlock(final Block blk, final Direction side, final World w, final BlockPos pos,
|
||||
final Direction orientation, final AEColor newColor, final PlayerEntity p) {
|
||||
final BlockState state = w.getBlockState(pos);
|
||||
|
||||
// FIXME if( blk instanceof BlockColored )
|
||||
// FIXME {
|
||||
@@ -405,156 +357,129 @@ public class ToolColorApplicator extends AEBasePoweredItem implements IStorageCe
|
||||
// return w.setBlockState( pos, Blocks.STAINED_HARDENED_CLAY.getDefaultState().with( BlockColored.COLOR, newColor.dye ) );
|
||||
// }
|
||||
|
||||
if( blk instanceof BlockCableBus )
|
||||
{
|
||||
return ( (BlockCableBus) blk ).recolorBlock( w, pos, side, newColor.dye, p );
|
||||
}
|
||||
if (blk instanceof BlockCableBus) {
|
||||
return ((BlockCableBus) blk).recolorBlock(w, pos, side, newColor.dye, p);
|
||||
}
|
||||
|
||||
return blk.recolorBlock( state, w, pos, side, newColor.dye );
|
||||
}
|
||||
return blk.recolorBlock(state, w, pos, side, newColor.dye);
|
||||
}
|
||||
|
||||
public void cycleColors( final ItemStack is, final ItemStack paintBall, final int i )
|
||||
{
|
||||
if( paintBall.isEmpty() )
|
||||
{
|
||||
this.setColor( is, this.getColor( is ) );
|
||||
}
|
||||
else
|
||||
{
|
||||
this.setColor( is, this.findNextColor( is, paintBall, i ) );
|
||||
}
|
||||
}
|
||||
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
|
||||
@OnlyIn( Dist.CLIENT )
|
||||
public void addInformation(final ItemStack stack, final World world, final List<ITextComponent> lines, final ITooltipFlag advancedTooltips )
|
||||
{
|
||||
super.addInformation( stack, world, lines, advancedTooltips );
|
||||
@Override
|
||||
@OnlyIn(Dist.CLIENT)
|
||||
public void addInformation(final ItemStack stack, final World world, final List<ITextComponent> lines,
|
||||
final ITooltipFlag advancedTooltips) {
|
||||
super.addInformation(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 )
|
||||
{
|
||||
if( requestedAddition != null )
|
||||
{
|
||||
// FIXME final int[] id = OreDictionary.getOreIDs( requestedAddition.getDefinition() );
|
||||
@Override
|
||||
public boolean isBlackListed(final ItemStack cellItem, final IAEItemStack requestedAddition) {
|
||||
if (requestedAddition != null) {
|
||||
// FIXME final int[] id = OreDictionary.getOreIDs(
|
||||
// requestedAddition.getDefinition() );
|
||||
|
||||
// FIXME for( final int x : id )
|
||||
// FIXME {
|
||||
// FIXME if( ORE_TO_COLOR.containsKey( x ) )
|
||||
// FIXME {
|
||||
// FIXME return false;
|
||||
// FIXME }
|
||||
// FIXME }
|
||||
// FIXME for( final int x : id )
|
||||
// FIXME {
|
||||
// FIXME if( ORE_TO_COLOR.containsKey( x ) )
|
||||
// FIXME {
|
||||
// FIXME return false;
|
||||
// FIXME }
|
||||
// FIXME }
|
||||
|
||||
if( requestedAddition.getItem() instanceof SnowballItem )
|
||||
{
|
||||
return false;
|
||||
}
|
||||
if (requestedAddition.getItem() instanceof SnowballItem) {
|
||||
return false;
|
||||
}
|
||||
|
||||
return !( requestedAddition.getItem() instanceof ItemPaintBall && requestedAddition.getItemDamage() < 20 );
|
||||
}
|
||||
return true;
|
||||
}
|
||||
return !(requestedAddition.getItem() instanceof ItemPaintBall && requestedAddition.getItemDamage() < 20);
|
||||
}
|
||||
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);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getUnlocalizedGroupName( final Set<ItemStack> others, final ItemStack is )
|
||||
{
|
||||
return GuiText.StorageCells.getTranslationKey();
|
||||
}
|
||||
@Override
|
||||
public String getUnlocalizedGroupName(final Set<ItemStack> others, final ItemStack is) {
|
||||
return GuiText.StorageCells.getTranslationKey();
|
||||
}
|
||||
|
||||
@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 = is.getOrCreateTag().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 = is.getOrCreateTag().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 )
|
||||
{
|
||||
@Override
|
||||
public void setFuzzyMode(final ItemStack is, final FuzzyMode fzMode) {
|
||||
is.getOrCreateTag().putString("FuzzyMode", fzMode.name());
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onWheel( final ItemStack is, final boolean up )
|
||||
{
|
||||
this.cycleColors( is, this.getColor( is ), up ? 1 : -1 );
|
||||
}
|
||||
@Override
|
||||
public void onWheel(final ItemStack is, final boolean up) {
|
||||
this.cycleColors(is, this.getColor(is), up ? 1 : -1);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -1,6 +1,5 @@
|
||||
package appeng.items.tools.powered;
|
||||
|
||||
|
||||
import net.minecraft.client.renderer.model.ModelResourceLocation;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.util.ResourceLocation;
|
||||
@@ -12,56 +11,52 @@ import appeng.bootstrap.IItemRendering;
|
||||
import appeng.bootstrap.ItemRenderingCustomizer;
|
||||
import appeng.core.AppEng;
|
||||
|
||||
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
|
||||
@OnlyIn(Dist.CLIENT)
|
||||
public void customize(IItemRendering rendering) {
|
||||
// FIXME rendering.builtInModel( "models/item/builtin/color_applicator_colored",
|
||||
// new ColorApplicatorModel() );
|
||||
rendering.variants(MODEL_COLORED, MODEL_UNCOLORED);
|
||||
rendering.color(this::getColor);
|
||||
// FIXME rendering.meshDefinition( this::getMesh );
|
||||
}
|
||||
|
||||
@Override
|
||||
@OnlyIn( Dist.CLIENT )
|
||||
public void customize( IItemRendering rendering )
|
||||
{
|
||||
// FIXME rendering.builtInModel( "models/item/builtin/color_applicator_colored", new ColorApplicatorModel() );
|
||||
rendering.variants( MODEL_COLORED, MODEL_UNCOLORED );
|
||||
rendering.color( this::getColor );
|
||||
// FIXME 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;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -18,7 +18,6 @@
|
||||
|
||||
package appeng.items.tools.powered;
|
||||
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
@@ -55,246 +54,206 @@ import appeng.items.tools.powered.powersink.AEBasePoweredItem;
|
||||
import appeng.util.InWorldToolOperationResult;
|
||||
import appeng.util.Platform;
|
||||
|
||||
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(Item.Properties props) {
|
||||
super(AEConfig.instance().getEntropyManipulatorBattery(), props);
|
||||
|
||||
public ToolEntropyManipulator(Item.Properties props)
|
||||
{
|
||||
super( AEConfig.instance().getEntropyManipulatorBattery(), props );
|
||||
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.STONE.getDefaultState()),
|
||||
new InWorldToolOperationResult(Blocks.COBBLESTONE.getDefaultState()));
|
||||
// FIXME this.coolDown.put( new InWorldToolOperationIngredient( Blocks.STONE_BRICKS.getDefaultState() ),
|
||||
// FIXME new InWorldToolOperationResult( Blocks.STONE_BRICKS.getStateFromMeta( 2 ) ) );
|
||||
this.coolDown.put( new InWorldToolOperationIngredient( Blocks.LAVA, true ), new InWorldToolOperationResult( Blocks.OBSIDIAN.getDefaultState() ) );
|
||||
this.coolDown.put(new InWorldToolOperationIngredient(Blocks.LAVA, true),
|
||||
new InWorldToolOperationResult(Blocks.OBSIDIAN.getDefaultState()));
|
||||
// FIXME this.coolDown.put( new InWorldToolOperationIngredient( Blocks.FLOWING_LAVA, true ),
|
||||
// FIXME new InWorldToolOperationResult( Blocks.OBSIDIAN.getDefaultState() ) );
|
||||
this.coolDown.put( new InWorldToolOperationIngredient( Blocks.GRASS, true ), new InWorldToolOperationResult( Blocks.DIRT.getDefaultState() ) );
|
||||
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 ) );
|
||||
final List<ItemStack> snowBalls = new ArrayList<>();
|
||||
snowBalls.add(new ItemStack(Items.SNOWBALL));
|
||||
// FIXME this.coolDown.put( new InWorldToolOperationIngredient( Blocks.FLOWING_WATER, true ), new InWorldToolOperationResult( null, snowBalls ) );
|
||||
this.coolDown.put( new InWorldToolOperationIngredient( Blocks.WATER, true ), new InWorldToolOperationResult( Blocks.ICE.getDefaultState() ) );
|
||||
this.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.ICE.getDefaultState()),
|
||||
new InWorldToolOperationResult(Blocks.WATER.getDefaultState()));
|
||||
// FIXME this.heatUp.put( new InWorldToolOperationIngredient( Blocks.FLOWING_WATER, true ), new InWorldToolOperationResult() );
|
||||
this.heatUp.put( new InWorldToolOperationIngredient( Blocks.WATER, true ), new InWorldToolOperationResult() );
|
||||
this.heatUp.put(new InWorldToolOperationIngredient(Blocks.WATER, true), new InWorldToolOperationResult());
|
||||
// FIXME this.heatUp.put( new InWorldToolOperationIngredient( Blocks.SNOW, true ),
|
||||
// FIXME new InWorldToolOperationResult( Blocks.FLOWING_WATER.getStateFromMeta( 7 ) ) );
|
||||
}
|
||||
}
|
||||
|
||||
private static class InWorldToolOperationIngredient
|
||||
{
|
||||
private final BlockState state;
|
||||
private final boolean blockOnly;
|
||||
private static class InWorldToolOperationIngredient {
|
||||
private final BlockState state;
|
||||
private final boolean blockOnly;
|
||||
|
||||
public InWorldToolOperationIngredient( final BlockState state )
|
||||
{
|
||||
this.state = state;
|
||||
this.blockOnly = false;
|
||||
}
|
||||
public InWorldToolOperationIngredient(final BlockState 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 BlockState state, final World w, final BlockPos pos )
|
||||
{
|
||||
InWorldToolOperationResult r = this.heatUp.get( new InWorldToolOperationIngredient( state ) );
|
||||
private void heat(final BlockState 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.removeBlock(pos, false);
|
||||
}
|
||||
if (r.getBlockState() != null) {
|
||||
w.setBlockState(pos, r.getBlockState(), 3);
|
||||
} else {
|
||||
w.removeBlock(pos, false);
|
||||
}
|
||||
|
||||
if( r.getDrops() != null )
|
||||
{
|
||||
Platform.spawnDrops( w, pos, r.getDrops() );
|
||||
}
|
||||
}
|
||||
if (r.getDrops() != null) {
|
||||
Platform.spawnDrops(w, pos, r.getDrops());
|
||||
}
|
||||
}
|
||||
|
||||
private boolean canHeat( final BlockState state )
|
||||
{
|
||||
InWorldToolOperationResult r = this.heatUp.get( new InWorldToolOperationIngredient( state ) );
|
||||
private boolean canHeat(final BlockState 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 BlockState state, final World w, final BlockPos pos )
|
||||
{
|
||||
InWorldToolOperationResult r = this.coolDown.get( new InWorldToolOperationIngredient( state ) );
|
||||
private void cool(final BlockState 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.removeBlock(pos, false);
|
||||
}
|
||||
if (r.getBlockState() != null) {
|
||||
w.setBlockState(pos, r.getBlockState(), 3);
|
||||
} else {
|
||||
w.removeBlock(pos, false);
|
||||
}
|
||||
|
||||
if( r.getDrops() != null )
|
||||
{
|
||||
Platform.spawnDrops( w, pos, r.getDrops() );
|
||||
}
|
||||
}
|
||||
if (r.getDrops() != null) {
|
||||
Platform.spawnDrops(w, pos, r.getDrops());
|
||||
}
|
||||
}
|
||||
|
||||
private boolean canCool( final BlockState state )
|
||||
{
|
||||
InWorldToolOperationResult r = this.coolDown.get( new InWorldToolOperationIngredient( state ) );
|
||||
private boolean canCool(final BlockState 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 LivingEntity target, final LivingEntity hitter )
|
||||
{
|
||||
if( this.getAECurrentPower( item ) > 1600 )
|
||||
{
|
||||
this.extractAEPower( item, 1600, Actionable.MODULATE );
|
||||
target.setFire( 8 );
|
||||
}
|
||||
@Override
|
||||
public boolean hitEntity(final ItemStack item, final LivingEntity target, final LivingEntity 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 PlayerEntity p, final Hand hand )
|
||||
{
|
||||
final RayTraceResult target = this.rayTrace( w, p, RayTraceContext.FluidMode.ANY );
|
||||
@Override
|
||||
public ActionResult<ItemStack> onItemRightClick(final World w, final PlayerEntity p, final Hand hand) {
|
||||
final RayTraceResult target = this.rayTrace(w, p, RayTraceContext.FluidMode.ANY);
|
||||
|
||||
if( target.getType() != RayTraceResult.Type.BLOCK )
|
||||
{
|
||||
return new ActionResult<>( ActionResultType.FAIL, p.getHeldItem( hand ) );
|
||||
}
|
||||
else
|
||||
{
|
||||
BlockPos pos = ((BlockRayTraceResult) target).getPos();
|
||||
final BlockState state = w.getBlockState( pos );
|
||||
if( state.getMaterial() == Material.LAVA || state.getMaterial() == Material.WATER )
|
||||
{
|
||||
if( Platform.hasPermissions( new DimensionalCoord( w, pos ), p ) )
|
||||
{
|
||||
this.onItemUse( p, w, pos, hand, Direction.UP, 0.0F, 0.0F, 0.0F );
|
||||
}
|
||||
}
|
||||
}
|
||||
if (target.getType() != RayTraceResult.Type.BLOCK) {
|
||||
return new ActionResult<>(ActionResultType.FAIL, p.getHeldItem(hand));
|
||||
} else {
|
||||
BlockPos pos = ((BlockRayTraceResult) target).getPos();
|
||||
final BlockState state = w.getBlockState(pos);
|
||||
if (state.getMaterial() == Material.LAVA || state.getMaterial() == Material.WATER) {
|
||||
if (Platform.hasPermissions(new DimensionalCoord(w, pos), p)) {
|
||||
this.onItemUse(p, w, pos, hand, Direction.UP, 0.0F, 0.0F, 0.0F);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return new ActionResult<>( ActionResultType.SUCCESS, p.getHeldItem( hand ) );
|
||||
}
|
||||
return new ActionResult<>(ActionResultType.SUCCESS, p.getHeldItem(hand));
|
||||
}
|
||||
|
||||
@Override
|
||||
public ActionResultType onItemUse( PlayerEntity p, World w, BlockPos pos, Hand hand, Direction side, float hitX, float hitY, float hitZ )
|
||||
{
|
||||
return this.onItemUse( p.getHeldItem( hand ), p, w, pos, hand, side, hitX, hitY, hitZ );
|
||||
}
|
||||
@Override
|
||||
public ActionResultType onItemUse(PlayerEntity p, World w, BlockPos pos, Hand hand, Direction side, float hitX,
|
||||
float hitY, float hitZ) {
|
||||
return this.onItemUse(p.getHeldItem(hand), p, w, pos, hand, side, hitX, hitY, hitZ);
|
||||
}
|
||||
|
||||
@Override
|
||||
public ActionResultType onItemUse( ItemStack item, PlayerEntity p, World w, BlockPos pos, Hand hand, Direction side, float hitX, float hitY, float hitZ )
|
||||
{
|
||||
if( this.getAECurrentPower( item ) > 1600 )
|
||||
{
|
||||
if( !p.canPlayerEdit( pos, side, item ) )
|
||||
{
|
||||
return ActionResultType.FAIL;
|
||||
}
|
||||
@Override
|
||||
public ActionResultType onItemUse(ItemStack item, PlayerEntity p, World w, BlockPos pos, Hand hand, Direction side,
|
||||
float hitX, float hitY, float hitZ) {
|
||||
if (this.getAECurrentPower(item) > 1600) {
|
||||
if (!p.canPlayerEdit(pos, side, item)) {
|
||||
return ActionResultType.FAIL;
|
||||
}
|
||||
|
||||
final BlockState state = w.getBlockState( pos );
|
||||
final Block blockID = state.getBlock();
|
||||
final BlockState state = w.getBlockState(pos);
|
||||
final Block blockID = state.getBlock();
|
||||
|
||||
if( p.isCrouching() )
|
||||
{
|
||||
if( this.canCool( state ) )
|
||||
{
|
||||
this.extractAEPower( item, 1600, Actionable.MODULATE );
|
||||
this.cool( state, w, pos );
|
||||
return ActionResultType.SUCCESS;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
if( blockID instanceof TNTBlock)
|
||||
{
|
||||
w.removeBlock(pos, false);
|
||||
( (TNTBlock) blockID ).explode( w, pos );
|
||||
return ActionResultType.SUCCESS;
|
||||
}
|
||||
if (p.isCrouching()) {
|
||||
if (this.canCool(state)) {
|
||||
this.extractAEPower(item, 1600, Actionable.MODULATE);
|
||||
this.cool(state, w, pos);
|
||||
return ActionResultType.SUCCESS;
|
||||
}
|
||||
} else {
|
||||
if (blockID instanceof TNTBlock) {
|
||||
w.removeBlock(pos, false);
|
||||
((TNTBlock) blockID).explode(w, pos);
|
||||
return ActionResultType.SUCCESS;
|
||||
}
|
||||
|
||||
if( blockID instanceof BlockTinyTNT )
|
||||
{
|
||||
w.removeBlock(pos, false);
|
||||
( (BlockTinyTNT) blockID ).startFuse( w, pos, p );
|
||||
return ActionResultType.SUCCESS;
|
||||
}
|
||||
if (blockID instanceof BlockTinyTNT) {
|
||||
w.removeBlock(pos, false);
|
||||
((BlockTinyTNT) blockID).startFuse(w, pos, p);
|
||||
return ActionResultType.SUCCESS;
|
||||
}
|
||||
|
||||
if( this.canHeat( state ) )
|
||||
{
|
||||
this.extractAEPower( item, 1600, Actionable.MODULATE );
|
||||
this.heat( state, w, pos );
|
||||
return ActionResultType.SUCCESS;
|
||||
}
|
||||
if (this.canHeat(state)) {
|
||||
this.extractAEPower(item, 1600, Actionable.MODULATE);
|
||||
this.heat(state, w, pos);
|
||||
return ActionResultType.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 )
|
||||
{
|
||||
for (final ItemStack i : stack) {
|
||||
// FIXME final ItemStack result = FurnaceRecipes.instance().getSmeltingResult( i );
|
||||
// FIXME
|
||||
// FIXME if( !result.isEmpty() )
|
||||
@@ -315,53 +274,47 @@ public class ToolEntropyManipulator extends AEBasePoweredItem implements IBlockT
|
||||
// FIXME canFurnaceable = false;
|
||||
// FIXME out.add( i );
|
||||
// FIXME }
|
||||
}
|
||||
}
|
||||
|
||||
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,
|
||||
random.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,
|
||||
random.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 ActionResultType.SUCCESS;
|
||||
}
|
||||
else
|
||||
{
|
||||
final BlockPos offsetPos = pos.offset( side );
|
||||
return ActionResultType.SUCCESS;
|
||||
} else {
|
||||
final BlockPos offsetPos = pos.offset(side);
|
||||
|
||||
if( !p.canPlayerEdit( offsetPos, side, item ) )
|
||||
{
|
||||
return ActionResultType.FAIL;
|
||||
}
|
||||
if (!p.canPlayerEdit(offsetPos, side, item)) {
|
||||
return ActionResultType.FAIL;
|
||||
}
|
||||
|
||||
if( w.isAirBlock( offsetPos ) )
|
||||
{
|
||||
this.extractAEPower( item, 1600, Actionable.MODULATE );
|
||||
w.playSound( p, offsetPos.getX() + 0.5D, offsetPos.getY() + 0.5D, offsetPos.getZ() + 0.5D, SoundEvents.ITEM_FLINTANDSTEEL_USE,
|
||||
SoundCategory.PLAYERS, 1.0F, random.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,
|
||||
random.nextFloat() * 0.4F + 0.8F);
|
||||
w.setBlockState(offsetPos, Blocks.FIRE.getDefaultState());
|
||||
}
|
||||
|
||||
return ActionResultType.SUCCESS;
|
||||
}
|
||||
}
|
||||
}
|
||||
return ActionResultType.SUCCESS;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return ActionResultType.PASS;
|
||||
}
|
||||
return ActionResultType.PASS;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -18,8 +18,8 @@
|
||||
|
||||
package appeng.items.tools.powered;
|
||||
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import javax.annotation.Nullable;
|
||||
|
||||
import net.minecraft.block.BlockState;
|
||||
@@ -44,6 +44,7 @@ import appeng.api.AEApi;
|
||||
import appeng.api.config.Actionable;
|
||||
import appeng.api.config.FuzzyMode;
|
||||
import appeng.api.config.Upgrades;
|
||||
import appeng.api.features.AEFeature;
|
||||
import appeng.api.implementations.items.IStorageCell;
|
||||
import appeng.api.storage.ICellInventoryHandler;
|
||||
import appeng.api.storage.IStorageChannel;
|
||||
@@ -55,7 +56,6 @@ import appeng.api.util.DimensionalCoord;
|
||||
import appeng.core.AEConfig;
|
||||
import appeng.core.AELog;
|
||||
import appeng.core.AppEng;
|
||||
import appeng.api.features.AEFeature;
|
||||
import appeng.core.localization.PlayerMessages;
|
||||
import appeng.core.sync.network.NetworkHandler;
|
||||
import appeng.core.sync.packets.PacketMatterCannon;
|
||||
@@ -70,455 +70,389 @@ import appeng.tile.misc.TilePaint;
|
||||
import appeng.util.LookDirection;
|
||||
import appeng.util.Platform;
|
||||
|
||||
|
||||
public class ToolMatterCannon extends AEBasePoweredItem implements IStorageCell<IAEItemStack>
|
||||
{
|
||||
|
||||
public ToolMatterCannon(Item.Properties props)
|
||||
{
|
||||
super( AEConfig.instance().getMatterCannonBattery(), props );
|
||||
}
|
||||
|
||||
@OnlyIn( Dist.CLIENT )
|
||||
@Override
|
||||
public void addInformation( final ItemStack stack, final World world, final List<ITextComponent> lines, final ITooltipFlag advancedTooltips )
|
||||
{
|
||||
super.addInformation( 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 ActionResult<ItemStack> onItemRightClick( final World w, final PlayerEntity p, final @Nullable Hand 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 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<>( ActionResultType.SUCCESS, p.getHeldItem( hand ) );
|
||||
}
|
||||
|
||||
aeAmmo.setStackSize( 1 );
|
||||
final ItemStack ammo = aeAmmo.createItemStack();
|
||||
if( ammo == null )
|
||||
{
|
||||
return new ActionResult<>( ActionResultType.SUCCESS, p.getHeldItem( hand ) );
|
||||
}
|
||||
|
||||
aeAmmo = inv.extractItems( aeAmmo, Actionable.MODULATE, new PlayerSource( p, null ) );
|
||||
if( aeAmmo == null )
|
||||
{
|
||||
return new ActionResult<>( ActionResultType.SUCCESS, p.getHeldItem( hand ) );
|
||||
}
|
||||
|
||||
final LookDirection dir = Platform.getPlayerRay( p );
|
||||
|
||||
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 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<>( ActionResultType.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<>( ActionResultType.SUCCESS, p.getHeldItem( hand ) );
|
||||
}
|
||||
}
|
||||
}
|
||||
return new ActionResult<>( ActionResultType.FAIL, p.getHeldItem( hand ) );
|
||||
}
|
||||
|
||||
private void shootPaintBalls( final ItemStack type, final World w, final PlayerEntity 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;
|
||||
Vec3d entityIntersection = 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 );
|
||||
|
||||
if( !entity1.isAlive() && entity1 != p && !( entity1 instanceof ItemEntity ) )
|
||||
{
|
||||
if( entity1.isAlive() )
|
||||
{
|
||||
// prevent killing / flying of mounts.
|
||||
if( entity1.isRidingOrBeingRiddenBy( p ) )
|
||||
{
|
||||
continue;
|
||||
}
|
||||
|
||||
final float f1 = 0.3F;
|
||||
|
||||
final AxisAlignedBB boundingBox = entity1.getBoundingBox().grow( f1, f1, f1 );
|
||||
final Vec3d intersection = boundingBox.rayTrace( Vec3d, Vec3d1 ).orElse(null);
|
||||
|
||||
if( intersection != null )
|
||||
{
|
||||
final double nd = Vec3d.squareDistanceTo( intersection );
|
||||
|
||||
if( nd < closest )
|
||||
{
|
||||
entity = entity1;
|
||||
entityIntersection = intersection;
|
||||
closest = nd;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
RayTraceContext rayTraceContext = new RayTraceContext(Vec3d, Vec3d1, RayTraceContext.BlockMode.COLLIDER, RayTraceContext.FluidMode.NONE, p);
|
||||
RayTraceResult pos = w.rayTraceBlocks( rayTraceContext );
|
||||
|
||||
final Vec3d vec = new Vec3d( d0, d1, d2 );
|
||||
if( entity != null && pos.getType() != RayTraceResult.Type.MISS && pos.getHitVec().squareDistanceTo( vec ) > closest )
|
||||
{
|
||||
pos = new EntityRayTraceResult( entity, entityIntersection );
|
||||
}
|
||||
else if( entity != null && pos.getType() == RayTraceResult.Type.MISS )
|
||||
{
|
||||
pos = new EntityRayTraceResult( entity, entityIntersection );
|
||||
}
|
||||
|
||||
try
|
||||
{
|
||||
AppEng.proxy.sendToAllNearExcept( null, d0, d1, d2, 128, w, new PacketMatterCannon( d0, d1, d2, (float) direction.x, (float) direction.y, (float) direction.z, (byte) ( pos.getType() == RayTraceResult.Type.MISS ? 32 : pos.getHitVec().squareDistanceTo( vec ) + 1 ) ) );
|
||||
}
|
||||
catch( final Exception err )
|
||||
{
|
||||
AELog.debug( err );
|
||||
}
|
||||
|
||||
if( pos.getType() != RayTraceResult.Type.MISS && type != null && type.getItem() instanceof ItemPaintBall )
|
||||
{
|
||||
final ItemPaintBall ipb = (ItemPaintBall) type.getItem();
|
||||
|
||||
final AEColor col = ipb.getColor();
|
||||
// boolean lit = ipb.isLumen( type );
|
||||
|
||||
if( pos instanceof EntityRayTraceResult )
|
||||
{
|
||||
EntityRayTraceResult entityResult = (EntityRayTraceResult) pos;
|
||||
Entity entityHit = entityResult.getEntity();
|
||||
|
||||
final int id = entityHit.getEntityId();
|
||||
final PlayerColor marker = new PlayerColor( id, col, 20 * 30 );
|
||||
TickHandler.INSTANCE.getPlayerColors().put( id, marker );
|
||||
|
||||
if( entityHit instanceof SheepEntity)
|
||||
{
|
||||
final SheepEntity sh = (SheepEntity) entityHit;
|
||||
sh.setFleeceColor( col.dye );
|
||||
}
|
||||
|
||||
entityHit.attackEntityFrom( DamageSource.causePlayerDamage( p ), 0 );
|
||||
NetworkHandler.instance().sendToAll( marker.getPacket() );
|
||||
}
|
||||
else if( pos instanceof BlockRayTraceResult )
|
||||
{
|
||||
BlockRayTraceResult blockResult = (BlockRayTraceResult) pos;
|
||||
final Direction side = blockResult.getFace();
|
||||
final BlockPos hitPos = blockResult.getPos().offset( side );
|
||||
|
||||
if( !Platform.hasPermissions( new DimensionalCoord( w, hitPos ), p ) )
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
final BlockState whatsThere = w.getBlockState( hitPos );
|
||||
if( whatsThere.getMaterial().isReplaceable() && 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.getHitVec().subtract( hitPos.getX(), hitPos.getY(), hitPos.getZ() );
|
||||
( (TilePaint) te ).addBlot( type, side.getOpposite(), hp );
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private void standardAmmo( float penetration, final World w, final PlayerEntity 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 );
|
||||
|
||||
Entity entity = null;
|
||||
Vec3d entityIntersection = 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 );
|
||||
|
||||
if( entity1.isAlive() && entity1 != p && !( entity1 instanceof ItemEntity ) )
|
||||
{
|
||||
if( entity1.isAlive() )
|
||||
{
|
||||
// prevent killing / flying of mounts.
|
||||
if( entity1.isRidingOrBeingRiddenBy( p ) )
|
||||
{
|
||||
continue;
|
||||
}
|
||||
|
||||
final float f1 = 0.3F;
|
||||
|
||||
final AxisAlignedBB boundingBox = entity1.getBoundingBox().grow( f1, f1, f1 );
|
||||
final Vec3d intersection = boundingBox.rayTrace( Vec3d, Vec3d1 ).orElse(null);
|
||||
|
||||
if( intersection != null )
|
||||
{
|
||||
final double nd = Vec3d.squareDistanceTo( intersection );
|
||||
|
||||
if( nd < closest )
|
||||
{
|
||||
entity = entity1;
|
||||
entityIntersection = intersection;
|
||||
closest = nd;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
RayTraceContext rayTraceContext = new RayTraceContext(Vec3d, Vec3d1, RayTraceContext.BlockMode.COLLIDER, RayTraceContext.FluidMode.NONE, p);
|
||||
final Vec3d vec = new Vec3d( d0, d1, d2 );
|
||||
RayTraceResult pos = w.rayTraceBlocks( rayTraceContext );
|
||||
if( entity != null && pos.getType() != RayTraceResult.Type.MISS && pos.getHitVec().squareDistanceTo( vec ) > closest )
|
||||
{
|
||||
pos = new EntityRayTraceResult( entity, entityIntersection );
|
||||
}
|
||||
else if( entity != null && pos.getType() == RayTraceResult.Type.MISS )
|
||||
{
|
||||
pos = new EntityRayTraceResult( entity, entityIntersection );
|
||||
}
|
||||
|
||||
try
|
||||
{
|
||||
AppEng.proxy.sendToAllNearExcept( null, d0, d1, d2, 128, w, new PacketMatterCannon( d0, d1, d2, (float) direction.x, (float) direction.y, (float) direction.z, (byte) ( pos.getType() == RayTraceResult.Type.MISS ? 32 : pos.getHitVec().squareDistanceTo( vec ) + 1 ) ) );
|
||||
}
|
||||
catch( final Exception err )
|
||||
{
|
||||
AELog.debug( err );
|
||||
}
|
||||
|
||||
if( pos.getType() != RayTraceResult.Type.MISS )
|
||||
{
|
||||
final DamageSource dmgSrc = new EntityDamageSource( "matter_cannon", p );
|
||||
|
||||
if( pos instanceof EntityRayTraceResult )
|
||||
{
|
||||
EntityRayTraceResult entityResult = (EntityRayTraceResult) pos;
|
||||
Entity entityHit = entityResult.getEntity();
|
||||
|
||||
final int dmg = (int) Math.ceil( penetration / 20.0f );
|
||||
if( entityHit instanceof LivingEntity )
|
||||
{
|
||||
final LivingEntity el = (LivingEntity) 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.isAlive() )
|
||||
{
|
||||
hasDestroyed = true;
|
||||
}
|
||||
}
|
||||
else if( entityHit instanceof ItemEntity )
|
||||
{
|
||||
hasDestroyed = true;
|
||||
entityHit.remove();
|
||||
}
|
||||
else if( entityHit.attackEntityFrom( dmgSrc, dmg ) )
|
||||
{
|
||||
hasDestroyed = true;
|
||||
}
|
||||
}
|
||||
else if( pos instanceof BlockRayTraceResult )
|
||||
{
|
||||
BlockRayTraceResult blockResult = (BlockRayTraceResult) pos;
|
||||
|
||||
if( !AEConfig.instance().isFeatureEnabled( AEFeature.MASS_CANNON_BLOCK_DAMAGE ) )
|
||||
{
|
||||
penetration = 0;
|
||||
}
|
||||
else
|
||||
{
|
||||
BlockPos blockPos = blockResult.getPos();
|
||||
final BlockState bs = w.getBlockState(blockPos);
|
||||
|
||||
final float hardness = bs.getBlockHardness( w, blockPos) * 9.0f;
|
||||
if( hardness >= 0.0 )
|
||||
{
|
||||
if( penetration > hardness && Platform.hasPermissions( new DimensionalCoord( w, blockPos), p ) )
|
||||
{
|
||||
hasDestroyed = true;
|
||||
penetration -= hardness;
|
||||
penetration *= 0.60;
|
||||
w.destroyBlock(blockPos, 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 getConfigInventory( final ItemStack is )
|
||||
{
|
||||
return new CellConfig( is );
|
||||
}
|
||||
|
||||
@Override
|
||||
public FuzzyMode getFuzzyMode( final ItemStack is )
|
||||
{
|
||||
final String fz = is.getOrCreateTag().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 )
|
||||
{
|
||||
is.getOrCreateTag().putString( "FuzzyMode", fzMode.name() );
|
||||
}
|
||||
|
||||
@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 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;
|
||||
}
|
||||
|
||||
if( requestedAddition.getItem() instanceof ItemPaintBall )
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
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 );
|
||||
}
|
||||
public class ToolMatterCannon extends AEBasePoweredItem implements IStorageCell<IAEItemStack> {
|
||||
|
||||
public ToolMatterCannon(Item.Properties props) {
|
||||
super(AEConfig.instance().getMatterCannonBattery(), props);
|
||||
}
|
||||
|
||||
@OnlyIn(Dist.CLIENT)
|
||||
@Override
|
||||
public void addInformation(final ItemStack stack, final World world, final List<ITextComponent> lines,
|
||||
final ITooltipFlag advancedTooltips) {
|
||||
super.addInformation(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 ActionResult<ItemStack> onItemRightClick(final World w, final PlayerEntity p, final @Nullable Hand 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 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<>(ActionResultType.SUCCESS, p.getHeldItem(hand));
|
||||
}
|
||||
|
||||
aeAmmo.setStackSize(1);
|
||||
final ItemStack ammo = aeAmmo.createItemStack();
|
||||
if (ammo == null) {
|
||||
return new ActionResult<>(ActionResultType.SUCCESS, p.getHeldItem(hand));
|
||||
}
|
||||
|
||||
aeAmmo = inv.extractItems(aeAmmo, Actionable.MODULATE, new PlayerSource(p, null));
|
||||
if (aeAmmo == null) {
|
||||
return new ActionResult<>(ActionResultType.SUCCESS, p.getHeldItem(hand));
|
||||
}
|
||||
|
||||
final LookDirection dir = Platform.getPlayerRay(p);
|
||||
|
||||
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 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<>(ActionResultType.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<>(ActionResultType.SUCCESS, p.getHeldItem(hand));
|
||||
}
|
||||
}
|
||||
}
|
||||
return new ActionResult<>(ActionResultType.FAIL, p.getHeldItem(hand));
|
||||
}
|
||||
|
||||
private void shootPaintBalls(final ItemStack type, final World w, final PlayerEntity 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;
|
||||
Vec3d entityIntersection = 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);
|
||||
|
||||
if (!entity1.isAlive() && entity1 != p && !(entity1 instanceof ItemEntity)) {
|
||||
if (entity1.isAlive()) {
|
||||
// prevent killing / flying of mounts.
|
||||
if (entity1.isRidingOrBeingRiddenBy(p)) {
|
||||
continue;
|
||||
}
|
||||
|
||||
final float f1 = 0.3F;
|
||||
|
||||
final AxisAlignedBB boundingBox = entity1.getBoundingBox().grow(f1, f1, f1);
|
||||
final Vec3d intersection = boundingBox.rayTrace(Vec3d, Vec3d1).orElse(null);
|
||||
|
||||
if (intersection != null) {
|
||||
final double nd = Vec3d.squareDistanceTo(intersection);
|
||||
|
||||
if (nd < closest) {
|
||||
entity = entity1;
|
||||
entityIntersection = intersection;
|
||||
closest = nd;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
RayTraceContext rayTraceContext = new RayTraceContext(Vec3d, Vec3d1, RayTraceContext.BlockMode.COLLIDER,
|
||||
RayTraceContext.FluidMode.NONE, p);
|
||||
RayTraceResult pos = w.rayTraceBlocks(rayTraceContext);
|
||||
|
||||
final Vec3d vec = new Vec3d(d0, d1, d2);
|
||||
if (entity != null && pos.getType() != RayTraceResult.Type.MISS
|
||||
&& pos.getHitVec().squareDistanceTo(vec) > closest) {
|
||||
pos = new EntityRayTraceResult(entity, entityIntersection);
|
||||
} else if (entity != null && pos.getType() == RayTraceResult.Type.MISS) {
|
||||
pos = new EntityRayTraceResult(entity, entityIntersection);
|
||||
}
|
||||
|
||||
try {
|
||||
AppEng.proxy.sendToAllNearExcept(null, d0, d1, d2, 128, w,
|
||||
new PacketMatterCannon(d0, d1, d2, (float) direction.x, (float) direction.y, (float) direction.z,
|
||||
(byte) (pos.getType() == RayTraceResult.Type.MISS ? 32
|
||||
: pos.getHitVec().squareDistanceTo(vec) + 1)));
|
||||
} catch (final Exception err) {
|
||||
AELog.debug(err);
|
||||
}
|
||||
|
||||
if (pos.getType() != RayTraceResult.Type.MISS && type != null && type.getItem() instanceof ItemPaintBall) {
|
||||
final ItemPaintBall ipb = (ItemPaintBall) type.getItem();
|
||||
|
||||
final AEColor col = ipb.getColor();
|
||||
// boolean lit = ipb.isLumen( type );
|
||||
|
||||
if (pos instanceof EntityRayTraceResult) {
|
||||
EntityRayTraceResult entityResult = (EntityRayTraceResult) pos;
|
||||
Entity entityHit = entityResult.getEntity();
|
||||
|
||||
final int id = entityHit.getEntityId();
|
||||
final PlayerColor marker = new PlayerColor(id, col, 20 * 30);
|
||||
TickHandler.INSTANCE.getPlayerColors().put(id, marker);
|
||||
|
||||
if (entityHit instanceof SheepEntity) {
|
||||
final SheepEntity sh = (SheepEntity) entityHit;
|
||||
sh.setFleeceColor(col.dye);
|
||||
}
|
||||
|
||||
entityHit.attackEntityFrom(DamageSource.causePlayerDamage(p), 0);
|
||||
NetworkHandler.instance().sendToAll(marker.getPacket());
|
||||
} else if (pos instanceof BlockRayTraceResult) {
|
||||
BlockRayTraceResult blockResult = (BlockRayTraceResult) pos;
|
||||
final Direction side = blockResult.getFace();
|
||||
final BlockPos hitPos = blockResult.getPos().offset(side);
|
||||
|
||||
if (!Platform.hasPermissions(new DimensionalCoord(w, hitPos), p)) {
|
||||
return;
|
||||
}
|
||||
|
||||
final BlockState whatsThere = w.getBlockState(hitPos);
|
||||
if (whatsThere.getMaterial().isReplaceable() && 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.getHitVec().subtract(hitPos.getX(), hitPos.getY(), hitPos.getZ());
|
||||
((TilePaint) te).addBlot(type, side.getOpposite(), hp);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private void standardAmmo(float penetration, final World w, final PlayerEntity 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);
|
||||
|
||||
Entity entity = null;
|
||||
Vec3d entityIntersection = 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);
|
||||
|
||||
if (entity1.isAlive() && entity1 != p && !(entity1 instanceof ItemEntity)) {
|
||||
if (entity1.isAlive()) {
|
||||
// prevent killing / flying of mounts.
|
||||
if (entity1.isRidingOrBeingRiddenBy(p)) {
|
||||
continue;
|
||||
}
|
||||
|
||||
final float f1 = 0.3F;
|
||||
|
||||
final AxisAlignedBB boundingBox = entity1.getBoundingBox().grow(f1, f1, f1);
|
||||
final Vec3d intersection = boundingBox.rayTrace(Vec3d, Vec3d1).orElse(null);
|
||||
|
||||
if (intersection != null) {
|
||||
final double nd = Vec3d.squareDistanceTo(intersection);
|
||||
|
||||
if (nd < closest) {
|
||||
entity = entity1;
|
||||
entityIntersection = intersection;
|
||||
closest = nd;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
RayTraceContext rayTraceContext = new RayTraceContext(Vec3d, Vec3d1, RayTraceContext.BlockMode.COLLIDER,
|
||||
RayTraceContext.FluidMode.NONE, p);
|
||||
final Vec3d vec = new Vec3d(d0, d1, d2);
|
||||
RayTraceResult pos = w.rayTraceBlocks(rayTraceContext);
|
||||
if (entity != null && pos.getType() != RayTraceResult.Type.MISS
|
||||
&& pos.getHitVec().squareDistanceTo(vec) > closest) {
|
||||
pos = new EntityRayTraceResult(entity, entityIntersection);
|
||||
} else if (entity != null && pos.getType() == RayTraceResult.Type.MISS) {
|
||||
pos = new EntityRayTraceResult(entity, entityIntersection);
|
||||
}
|
||||
|
||||
try {
|
||||
AppEng.proxy.sendToAllNearExcept(null, d0, d1, d2, 128, w,
|
||||
new PacketMatterCannon(d0, d1, d2, (float) direction.x, (float) direction.y,
|
||||
(float) direction.z, (byte) (pos.getType() == RayTraceResult.Type.MISS ? 32
|
||||
: pos.getHitVec().squareDistanceTo(vec) + 1)));
|
||||
} catch (final Exception err) {
|
||||
AELog.debug(err);
|
||||
}
|
||||
|
||||
if (pos.getType() != RayTraceResult.Type.MISS) {
|
||||
final DamageSource dmgSrc = new EntityDamageSource("matter_cannon", p);
|
||||
|
||||
if (pos instanceof EntityRayTraceResult) {
|
||||
EntityRayTraceResult entityResult = (EntityRayTraceResult) pos;
|
||||
Entity entityHit = entityResult.getEntity();
|
||||
|
||||
final int dmg = (int) Math.ceil(penetration / 20.0f);
|
||||
if (entityHit instanceof LivingEntity) {
|
||||
final LivingEntity el = (LivingEntity) 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.isAlive()) {
|
||||
hasDestroyed = true;
|
||||
}
|
||||
} else if (entityHit instanceof ItemEntity) {
|
||||
hasDestroyed = true;
|
||||
entityHit.remove();
|
||||
} else if (entityHit.attackEntityFrom(dmgSrc, dmg)) {
|
||||
hasDestroyed = true;
|
||||
}
|
||||
} else if (pos instanceof BlockRayTraceResult) {
|
||||
BlockRayTraceResult blockResult = (BlockRayTraceResult) pos;
|
||||
|
||||
if (!AEConfig.instance().isFeatureEnabled(AEFeature.MASS_CANNON_BLOCK_DAMAGE)) {
|
||||
penetration = 0;
|
||||
} else {
|
||||
BlockPos blockPos = blockResult.getPos();
|
||||
final BlockState bs = w.getBlockState(blockPos);
|
||||
|
||||
final float hardness = bs.getBlockHardness(w, blockPos) * 9.0f;
|
||||
if (hardness >= 0.0) {
|
||||
if (penetration > hardness
|
||||
&& Platform.hasPermissions(new DimensionalCoord(w, blockPos), p)) {
|
||||
hasDestroyed = true;
|
||||
penetration -= hardness;
|
||||
penetration *= 0.60;
|
||||
w.destroyBlock(blockPos, 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 getConfigInventory(final ItemStack is) {
|
||||
return new CellConfig(is);
|
||||
}
|
||||
|
||||
@Override
|
||||
public FuzzyMode getFuzzyMode(final ItemStack is) {
|
||||
final String fz = is.getOrCreateTag().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) {
|
||||
is.getOrCreateTag().putString("FuzzyMode", fzMode.name());
|
||||
}
|
||||
|
||||
@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 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;
|
||||
}
|
||||
|
||||
if (requestedAddition.getItem() instanceof ItemPaintBall) {
|
||||
return false;
|
||||
}
|
||||
|
||||
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);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -18,20 +18,15 @@
|
||||
|
||||
package appeng.items.tools.powered;
|
||||
|
||||
|
||||
import java.util.List;
|
||||
import java.util.Set;
|
||||
|
||||
import appeng.container.ContainerLocator;
|
||||
import appeng.container.ContainerOpener;
|
||||
import appeng.container.implementations.ContainerMEPortableCell;
|
||||
import net.minecraft.client.util.ITooltipFlag;
|
||||
import net.minecraft.entity.player.PlayerEntity;
|
||||
import net.minecraft.item.Item;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.util.ActionResult;
|
||||
import net.minecraft.util.ActionResultType;
|
||||
import net.minecraft.util.ActionResultType;
|
||||
import net.minecraft.util.Hand;
|
||||
import net.minecraft.util.math.BlockPos;
|
||||
import net.minecraft.util.text.ITextComponent;
|
||||
@@ -51,146 +46,122 @@ import appeng.api.storage.IStorageChannel;
|
||||
import appeng.api.storage.channels.IItemStorageChannel;
|
||||
import appeng.api.storage.data.IAEItemStack;
|
||||
import appeng.api.util.AEPartLocation;
|
||||
import appeng.container.ContainerLocator;
|
||||
import appeng.container.ContainerOpener;
|
||||
import appeng.container.implementations.ContainerMEPortableCell;
|
||||
import appeng.core.AEConfig;
|
||||
import appeng.core.localization.GuiText;
|
||||
|
||||
import appeng.items.contents.CellConfig;
|
||||
import appeng.items.contents.CellUpgrades;
|
||||
import appeng.items.contents.PortableCellViewer;
|
||||
import appeng.items.tools.powered.powersink.AEBasePoweredItem;
|
||||
import appeng.util.Platform;
|
||||
|
||||
public class ToolPortableCell extends AEBasePoweredItem implements IStorageCell<IAEItemStack>, IGuiItem, IItemGroup {
|
||||
public ToolPortableCell(Item.Properties props) {
|
||||
super(AEConfig.instance().getPortableCellBattery(), props);
|
||||
}
|
||||
|
||||
public class ToolPortableCell extends AEBasePoweredItem implements IStorageCell<IAEItemStack>, IGuiItem, IItemGroup
|
||||
{
|
||||
public ToolPortableCell(Item.Properties props)
|
||||
{
|
||||
super( AEConfig.instance().getPortableCellBattery(), props );
|
||||
}
|
||||
@Override
|
||||
public ActionResult<ItemStack> onItemRightClick(final World w, final PlayerEntity player, final Hand hand) {
|
||||
ContainerOpener.openContainer(ContainerMEPortableCell.TYPE, player, ContainerLocator.forHand(player, hand));
|
||||
return new ActionResult<>(ActionResultType.SUCCESS, player.getHeldItem(hand));
|
||||
}
|
||||
|
||||
@Override
|
||||
public ActionResult<ItemStack> onItemRightClick( final World w, final PlayerEntity player, final Hand hand )
|
||||
{
|
||||
ContainerOpener.openContainer(ContainerMEPortableCell.TYPE, player, ContainerLocator.forHand(player, hand));
|
||||
return new ActionResult<>( ActionResultType.SUCCESS, player.getHeldItem( hand ) );
|
||||
}
|
||||
@Override
|
||||
@OnlyIn(Dist.CLIENT)
|
||||
public void addInformation(final ItemStack stack, final World world, final List<ITextComponent> lines,
|
||||
final ITooltipFlag advancedTooltips) {
|
||||
super.addInformation(stack, world, lines, advancedTooltips);
|
||||
|
||||
@Override
|
||||
@OnlyIn( Dist.CLIENT )
|
||||
public void addInformation(final ItemStack stack, final World world, final List<ITextComponent> lines, final ITooltipFlag advancedTooltips )
|
||||
{
|
||||
super.addInformation( 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.getTranslationKey();
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getUnlocalizedGroupName( final Set<ItemStack> others, final ItemStack is )
|
||||
{
|
||||
return GuiText.StorageCells.getTranslationKey();
|
||||
}
|
||||
@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 = is.getOrCreateTag().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 = is.getOrCreateTag().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 )
|
||||
{
|
||||
@Override
|
||||
public void setFuzzyMode(final ItemStack is, final FuzzyMode fzMode) {
|
||||
is.getOrCreateTag().putString("FuzzyMode", fzMode.name());
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public IGuiItemObject getGuiObject( final ItemStack is, int playerInventorySlot, final World w, final BlockPos pos )
|
||||
{
|
||||
return new PortableCellViewer( is, playerInventorySlot );
|
||||
}
|
||||
@Override
|
||||
public IGuiItemObject getGuiObject(final ItemStack is, int playerInventorySlot, final World w, final BlockPos pos) {
|
||||
return new PortableCellViewer(is, playerInventorySlot);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean shouldCauseReequipAnimation( ItemStack oldStack, ItemStack newStack, boolean slotChanged )
|
||||
{
|
||||
return slotChanged;
|
||||
}
|
||||
@Override
|
||||
public boolean shouldCauseReequipAnimation(ItemStack oldStack, ItemStack newStack, boolean slotChanged) {
|
||||
return slotChanged;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -18,7 +18,6 @@
|
||||
|
||||
package appeng.items.tools.powered;
|
||||
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import net.minecraft.client.util.ITooltipFlag;
|
||||
@@ -48,103 +47,85 @@ import appeng.core.localization.GuiText;
|
||||
import appeng.items.tools.powered.powersink.AEBasePoweredItem;
|
||||
import appeng.util.ConfigManager;
|
||||
|
||||
public class ToolWirelessTerminal extends AEBasePoweredItem implements IWirelessTermHandler {
|
||||
|
||||
public class ToolWirelessTerminal extends AEBasePoweredItem implements IWirelessTermHandler
|
||||
{
|
||||
public ToolWirelessTerminal(Item.Properties props) {
|
||||
super(AEConfig.instance().getWirelessTerminalBattery(), props);
|
||||
}
|
||||
|
||||
public ToolWirelessTerminal(Item.Properties props)
|
||||
{
|
||||
super( AEConfig.instance().getWirelessTerminalBattery(), props );
|
||||
}
|
||||
@Override
|
||||
public ActionResult<ItemStack> onItemRightClick(final World w, final PlayerEntity player, final Hand hand) {
|
||||
AEApi.instance().registries().wireless().openWirelessTerminalGui(player.getHeldItem(hand), w, player, hand);
|
||||
return new ActionResult<>(ActionResultType.SUCCESS, player.getHeldItem(hand));
|
||||
}
|
||||
|
||||
@Override
|
||||
public ActionResult<ItemStack> onItemRightClick( final World w, final PlayerEntity player, final Hand hand )
|
||||
{
|
||||
AEApi.instance().registries().wireless().openWirelessTerminalGui( player.getHeldItem( hand ), w, player, hand );
|
||||
return new ActionResult<>( ActionResultType.SUCCESS, player.getHeldItem( hand ) );
|
||||
}
|
||||
@Override
|
||||
@OnlyIn(Dist.CLIENT)
|
||||
public void addInformation(final ItemStack stack, final World world, final List<ITextComponent> lines,
|
||||
final ITooltipFlag advancedTooltips) {
|
||||
super.addInformation(stack, world, lines, advancedTooltips);
|
||||
|
||||
@Override
|
||||
@OnlyIn( Dist.CLIENT )
|
||||
public void addInformation( final ItemStack stack, final World world, final List<ITextComponent> lines, final ITooltipFlag advancedTooltips )
|
||||
{
|
||||
super.addInformation( stack, world, lines, advancedTooltips );
|
||||
if (stack.hasTag()) {
|
||||
final CompoundNBT tag = stack.getOrCreateTag();
|
||||
if (tag != null) {
|
||||
final String encKey = tag.getString("encryptionKey");
|
||||
|
||||
if( stack.hasTag() )
|
||||
{
|
||||
final CompoundNBT tag = stack.getOrCreateTag();
|
||||
if( tag != null )
|
||||
{
|
||||
final String encKey = tag.getString( "encryptionKey" );
|
||||
if (encKey == null || encKey.isEmpty()) {
|
||||
lines.add(GuiText.Unlinked.textComponent());
|
||||
} else {
|
||||
lines.add(GuiText.Linked.textComponent());
|
||||
}
|
||||
}
|
||||
} else {
|
||||
lines.add(new TranslationTextComponent("AppEng.GuiITooltip.Unlinked"));
|
||||
}
|
||||
}
|
||||
|
||||
if( encKey == null || encKey.isEmpty() )
|
||||
{
|
||||
lines.add( GuiText.Unlinked.textComponent() );
|
||||
}
|
||||
else
|
||||
{
|
||||
lines.add( GuiText.Linked.textComponent() );
|
||||
}
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
lines.add( new TranslationTextComponent( "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 PlayerEntity player, final double amount, final ItemStack is) {
|
||||
return this.extractAEPower(is, amount, Actionable.MODULATE) >= amount - 0.5;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean usePower( final PlayerEntity player, final double amount, final ItemStack is )
|
||||
{
|
||||
return this.extractAEPower( is, amount, Actionable.MODULATE ) >= amount - 0.5;
|
||||
}
|
||||
@Override
|
||||
public boolean hasPower(final PlayerEntity player, final double amt, final ItemStack is) {
|
||||
return this.getAECurrentPower(is) >= amt;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean hasPower( final PlayerEntity 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 CompoundNBT data = target.getOrCreateTag();
|
||||
manager.writeToNBT(data);
|
||||
});
|
||||
|
||||
@Override
|
||||
public IConfigManager getConfigManager( final ItemStack target )
|
||||
{
|
||||
final ConfigManager out = new ConfigManager( ( manager, settingName, newValue ) -> {
|
||||
final CompoundNBT data = target.getOrCreateTag();
|
||||
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(target.getOrCreateTag().copy());
|
||||
return out;
|
||||
}
|
||||
|
||||
out.readFromNBT( target.getOrCreateTag().copy() );
|
||||
return out;
|
||||
}
|
||||
@Override
|
||||
public String getEncryptionKey(final ItemStack item) {
|
||||
final CompoundNBT tag = item.getOrCreateTag();
|
||||
return tag.getString("encryptionKey");
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getEncryptionKey( final ItemStack item )
|
||||
{
|
||||
final CompoundNBT tag = item.getOrCreateTag();
|
||||
return tag.getString( "encryptionKey" );
|
||||
}
|
||||
@Override
|
||||
public void setEncryptionKey(final ItemStack item, final String encKey, final String name) {
|
||||
final CompoundNBT tag = item.getOrCreateTag();
|
||||
tag.putString("encryptionKey", encKey);
|
||||
tag.putString("name", name);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setEncryptionKey( final ItemStack item, final String encKey, final String name )
|
||||
{
|
||||
final CompoundNBT tag = item.getOrCreateTag();
|
||||
tag.putString( "encryptionKey", encKey );
|
||||
tag.putString( "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;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -18,7 +18,6 @@
|
||||
|
||||
package appeng.items.tools.powered.powersink;
|
||||
|
||||
|
||||
import java.text.MessageFormat;
|
||||
import java.util.List;
|
||||
import java.util.function.DoubleSupplier;
|
||||
@@ -31,9 +30,9 @@ import net.minecraft.util.NonNullList;
|
||||
import net.minecraft.util.text.ITextComponent;
|
||||
import net.minecraft.util.text.TranslationTextComponent;
|
||||
import net.minecraft.world.World;
|
||||
import net.minecraftforge.common.capabilities.ICapabilityProvider;
|
||||
import net.minecraftforge.api.distmarker.Dist;
|
||||
import net.minecraftforge.api.distmarker.OnlyIn;
|
||||
import net.minecraftforge.common.capabilities.ICapabilityProvider;
|
||||
|
||||
import appeng.api.config.AccessRestriction;
|
||||
import appeng.api.config.Actionable;
|
||||
@@ -43,137 +42,122 @@ import appeng.core.localization.GuiText;
|
||||
import appeng.items.AEBaseItem;
|
||||
import appeng.util.Platform;
|
||||
|
||||
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 DoubleSupplier 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 DoubleSupplier powerCapacity;
|
||||
|
||||
public AEBasePoweredItem(final DoubleSupplier powerCapacity, Properties props )
|
||||
{
|
||||
super(props);
|
||||
public AEBasePoweredItem(final DoubleSupplier powerCapacity, Properties props) {
|
||||
super(props);
|
||||
// FIXME this.setFull3D();
|
||||
|
||||
this.powerCapacity = powerCapacity;
|
||||
}
|
||||
this.powerCapacity = powerCapacity;
|
||||
}
|
||||
|
||||
@OnlyIn( Dist.CLIENT )
|
||||
@Override
|
||||
public void addInformation(final ItemStack stack, final World world, final List<ITextComponent> lines, final ITooltipFlag advancedTooltips )
|
||||
{
|
||||
final CompoundNBT tag = stack.getTag();
|
||||
double internalCurrentPower = 0;
|
||||
final double internalMaxPower = this.getAEMaxPower( stack );
|
||||
@OnlyIn(Dist.CLIENT)
|
||||
@Override
|
||||
public void addInformation(final ItemStack stack, final World world, final List<ITextComponent> lines,
|
||||
final ITooltipFlag advancedTooltips) {
|
||||
final CompoundNBT tag = stack.getTag();
|
||||
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.textComponent().appendText( ':' + MessageFormat.format( " {0,number,#} ", internalCurrentPower ) )
|
||||
.appendSibling( new TranslationTextComponent( PowerUnits.AE.unlocalizedName ) )
|
||||
.appendText( " - " + MessageFormat.format( " {0,number,#.##%} ", percent ) ) );
|
||||
}
|
||||
lines.add(GuiText.StoredEnergy.textComponent()
|
||||
.appendText(':' + MessageFormat.format(" {0,number,#} ", internalCurrentPower))
|
||||
.appendSibling(new TranslationTextComponent(PowerUnits.AE.unlocalizedName))
|
||||
.appendText(" - " + MessageFormat.format(" {0,number,#.##%} ", percent)));
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isDamageable()
|
||||
{
|
||||
return true;
|
||||
}
|
||||
@Override
|
||||
public boolean isDamageable() {
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void fillItemGroup(ItemGroup group, NonNullList<ItemStack> items) {
|
||||
super.fillItemGroup(group, items);
|
||||
@Override
|
||||
public void fillItemGroup(ItemGroup group, NonNullList<ItemStack> items) {
|
||||
super.fillItemGroup(group, items);
|
||||
|
||||
if (this.isInGroup(group)) {
|
||||
final ItemStack charged = new ItemStack(this, 1);
|
||||
final CompoundNBT tag = charged.getOrCreateTag();
|
||||
tag.putDouble(CURRENT_POWER_NBT_KEY, this.getAEMaxPower(charged));
|
||||
tag.putDouble(MAX_POWER_NBT_KEY, this.getAEMaxPower(charged));
|
||||
if (this.isInGroup(group)) {
|
||||
final ItemStack charged = new ItemStack(this, 1);
|
||||
final CompoundNBT tag = charged.getOrCreateTag();
|
||||
tag.putDouble(CURRENT_POWER_NBT_KEY, this.getAEMaxPower(charged));
|
||||
tag.putDouble(MAX_POWER_NBT_KEY, this.getAEMaxPower(charged));
|
||||
|
||||
items.add(charged);
|
||||
}
|
||||
}
|
||||
items.add(charged);
|
||||
}
|
||||
}
|
||||
|
||||
@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 )
|
||||
{
|
||||
if (mode == Actionable.MODULATE) {
|
||||
final CompoundNBT data = is.getOrCreateTag();
|
||||
final double toAdd = Math.min( amount, required );
|
||||
final double toAdd = Math.min(amount, required);
|
||||
|
||||
data.putDouble(CURRENT_POWER_NBT_KEY, currentStorage + toAdd);
|
||||
}
|
||||
data.putDouble(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 )
|
||||
{
|
||||
if (mode == Actionable.MODULATE) {
|
||||
final CompoundNBT data = is.getOrCreateTag();
|
||||
|
||||
data.putDouble(CURRENT_POWER_NBT_KEY, currentStorage - fulfillable);
|
||||
}
|
||||
data.putDouble(CURRENT_POWER_NBT_KEY, currentStorage - fulfillable);
|
||||
}
|
||||
|
||||
return fulfillable;
|
||||
}
|
||||
return fulfillable;
|
||||
}
|
||||
|
||||
@Override
|
||||
public double getAEMaxPower( final ItemStack is )
|
||||
{
|
||||
return this.powerCapacity.getAsDouble();
|
||||
}
|
||||
@Override
|
||||
public double getAEMaxPower(final ItemStack is) {
|
||||
return this.powerCapacity.getAsDouble();
|
||||
}
|
||||
|
||||
@Override
|
||||
public double getAECurrentPower( final ItemStack is )
|
||||
{
|
||||
@Override
|
||||
public double getAECurrentPower(final ItemStack is) {
|
||||
final CompoundNBT data = is.getOrCreateTag();
|
||||
|
||||
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, CompoundNBT nbt )
|
||||
{
|
||||
return new PoweredItemCapabilities( stack, this );
|
||||
}
|
||||
@Override
|
||||
public ICapabilityProvider initCapabilities(ItemStack stack, CompoundNBT nbt) {
|
||||
return new PoweredItemCapabilities(stack, this);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -18,7 +18,6 @@
|
||||
|
||||
package appeng.items.tools.powered.powersink;
|
||||
|
||||
|
||||
import javax.annotation.Nullable;
|
||||
|
||||
import net.minecraft.item.ItemStack;
|
||||
@@ -33,71 +32,61 @@ import appeng.api.config.PowerUnits;
|
||||
import appeng.api.implementations.items.IAEItemPowerStorage;
|
||||
import appeng.capabilities.Capabilities;
|
||||
|
||||
|
||||
/**
|
||||
* 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;
|
||||
|
||||
PoweredItemCapabilities( ItemStack is, IAEItemPowerStorage item )
|
||||
{
|
||||
this.is = is;
|
||||
this.item = item;
|
||||
}
|
||||
PoweredItemCapabilities(ItemStack is, IAEItemPowerStorage item) {
|
||||
this.is = is;
|
||||
this.item = item;
|
||||
}
|
||||
|
||||
@SuppressWarnings( "unchecked" )
|
||||
@Override
|
||||
public <T> LazyOptional<T> getCapability(Capability<T> capability, @Nullable Direction facing )
|
||||
{
|
||||
if( capability == Capabilities.FORGE_ENERGY )
|
||||
{
|
||||
return (LazyOptional<T>) LazyOptional.of(() -> this);
|
||||
}
|
||||
return LazyOptional.empty();
|
||||
}
|
||||
@SuppressWarnings("unchecked")
|
||||
@Override
|
||||
public <T> LazyOptional<T> getCapability(Capability<T> capability, @Nullable Direction facing) {
|
||||
if (capability == Capabilities.FORGE_ENERGY) {
|
||||
return (LazyOptional<T>) LazyOptional.of(() -> this);
|
||||
}
|
||||
return LazyOptional.empty();
|
||||
}
|
||||
|
||||
@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;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -18,7 +18,6 @@
|
||||
|
||||
package appeng.items.tools.quartz;
|
||||
|
||||
|
||||
import net.minecraft.item.AxeItem;
|
||||
import net.minecraft.item.Item;
|
||||
import net.minecraft.item.ItemGroup;
|
||||
@@ -28,20 +27,16 @@ import net.minecraft.item.ItemTier;
|
||||
import appeng.api.features.AEFeature;
|
||||
import appeng.util.Platform;
|
||||
|
||||
public class ToolQuartzAxe extends AxeItem {
|
||||
private final AEFeature type;
|
||||
|
||||
public class ToolQuartzAxe extends AxeItem
|
||||
{
|
||||
private final AEFeature type;
|
||||
public ToolQuartzAxe(Item.Properties props, final AEFeature type) {
|
||||
super(ItemTier.IRON, 6.0F, -3.1F, props);
|
||||
this.type = type;
|
||||
}
|
||||
|
||||
public ToolQuartzAxe( Item.Properties props, final AEFeature type )
|
||||
{
|
||||
super( ItemTier.IRON, 6.0F, -3.1F, props );
|
||||
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);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -18,16 +18,6 @@
|
||||
|
||||
package appeng.items.tools.quartz;
|
||||
|
||||
|
||||
import appeng.api.features.AEFeature;
|
||||
import appeng.api.implementations.guiobjects.IGuiItem;
|
||||
import appeng.api.implementations.guiobjects.IGuiItemObject;
|
||||
import appeng.container.ContainerLocator;
|
||||
import appeng.container.ContainerOpener;
|
||||
import appeng.container.implementations.ContainerQuartzKnife;
|
||||
import appeng.items.AEBaseItem;
|
||||
import appeng.items.contents.QuartzKnifeObj;
|
||||
import appeng.util.Platform;
|
||||
import net.minecraft.entity.player.PlayerEntity;
|
||||
import net.minecraft.item.Item;
|
||||
import net.minecraft.item.ItemStack;
|
||||
@@ -38,63 +28,64 @@ import net.minecraft.util.Hand;
|
||||
import net.minecraft.util.math.BlockPos;
|
||||
import net.minecraft.world.World;
|
||||
|
||||
import appeng.api.features.AEFeature;
|
||||
import appeng.api.implementations.guiobjects.IGuiItem;
|
||||
import appeng.api.implementations.guiobjects.IGuiItemObject;
|
||||
import appeng.container.ContainerLocator;
|
||||
import appeng.container.ContainerOpener;
|
||||
import appeng.container.implementations.ContainerQuartzKnife;
|
||||
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( Item.Properties props, final AEFeature type )
|
||||
{
|
||||
super(props);
|
||||
this.type = type;
|
||||
}
|
||||
public ToolQuartzCuttingKnife(Item.Properties props, final AEFeature type) {
|
||||
super(props);
|
||||
this.type = type;
|
||||
}
|
||||
|
||||
@Override
|
||||
public ActionResultType onItemUse(ItemUseContext context )
|
||||
{
|
||||
PlayerEntity player = context.getPlayer();
|
||||
if( Platform.isServer() && player != null )
|
||||
{
|
||||
ContainerOpener.openContainer(ContainerQuartzKnife.TYPE, context.getPlayer(), ContainerLocator.forItemUseContext(context));
|
||||
}
|
||||
return ActionResultType.SUCCESS;
|
||||
}
|
||||
@Override
|
||||
public ActionResultType onItemUse(ItemUseContext context) {
|
||||
PlayerEntity player = context.getPlayer();
|
||||
if (Platform.isServer() && player != null) {
|
||||
ContainerOpener.openContainer(ContainerQuartzKnife.TYPE, context.getPlayer(),
|
||||
ContainerLocator.forItemUseContext(context));
|
||||
}
|
||||
return ActionResultType.SUCCESS;
|
||||
}
|
||||
|
||||
@Override
|
||||
public ActionResult<ItemStack> onItemRightClick( final World w, final PlayerEntity p, final Hand hand )
|
||||
{
|
||||
if( Platform.isServer() )
|
||||
{
|
||||
ContainerOpener.openContainer(ContainerQuartzKnife.TYPE, p, ContainerLocator.forHand(p, hand));
|
||||
}
|
||||
p.swingArm( hand );
|
||||
return new ActionResult<>( ActionResultType.SUCCESS, p.getHeldItem( hand ) );
|
||||
}
|
||||
@Override
|
||||
public ActionResult<ItemStack> onItemRightClick(final World w, final PlayerEntity p, final Hand hand) {
|
||||
if (Platform.isServer()) {
|
||||
ContainerOpener.openContainer(ContainerQuartzKnife.TYPE, p, ContainerLocator.forHand(p, hand));
|
||||
}
|
||||
p.swingArm(hand);
|
||||
return new ActionResult<>(ActionResultType.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 ItemStack getContainerItem( final ItemStack itemStack )
|
||||
{
|
||||
ItemStack copy = itemStack.copy();
|
||||
copy.setDamage( itemStack.getDamage() + 1 );
|
||||
@Override
|
||||
public ItemStack getContainerItem(final ItemStack itemStack) {
|
||||
ItemStack copy = itemStack.copy();
|
||||
copy.setDamage(itemStack.getDamage() + 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, int playerInventorySlot, final World world, final BlockPos pos )
|
||||
{
|
||||
return new QuartzKnifeObj( is );
|
||||
}
|
||||
@Override
|
||||
public IGuiItemObject getGuiObject(final ItemStack is, int playerInventorySlot, final World world,
|
||||
final BlockPos pos) {
|
||||
return new QuartzKnifeObj(is);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -18,7 +18,6 @@
|
||||
|
||||
package appeng.items.tools.quartz;
|
||||
|
||||
|
||||
import net.minecraft.item.HoeItem;
|
||||
import net.minecraft.item.Item;
|
||||
import net.minecraft.item.ItemGroup;
|
||||
@@ -28,21 +27,17 @@ import net.minecraft.item.ItemTier;
|
||||
import appeng.api.features.AEFeature;
|
||||
import appeng.util.Platform;
|
||||
|
||||
public class ToolQuartzHoe extends HoeItem {
|
||||
private final AEFeature type;
|
||||
|
||||
public class ToolQuartzHoe extends HoeItem
|
||||
{
|
||||
private final AEFeature type;
|
||||
public ToolQuartzHoe(Item.Properties props, final AEFeature type) {
|
||||
super(ItemTier.IRON, -1.0F, props);
|
||||
this.type = type;
|
||||
}
|
||||
|
||||
public ToolQuartzHoe( Item.Properties props, final AEFeature type )
|
||||
{
|
||||
super( ItemTier.IRON, -1.0F, props);
|
||||
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);
|
||||
}
|
||||
|
||||
}
|
||||
@@ -18,7 +18,6 @@
|
||||
|
||||
package appeng.items.tools.quartz;
|
||||
|
||||
|
||||
import net.minecraft.item.Item;
|
||||
import net.minecraft.item.ItemGroup;
|
||||
import net.minecraft.item.ItemStack;
|
||||
@@ -28,20 +27,16 @@ import net.minecraft.item.PickaxeItem;
|
||||
import appeng.api.features.AEFeature;
|
||||
import appeng.util.Platform;
|
||||
|
||||
public class ToolQuartzPickaxe extends PickaxeItem {
|
||||
private final AEFeature type;
|
||||
|
||||
public class ToolQuartzPickaxe extends PickaxeItem
|
||||
{
|
||||
private final AEFeature type;
|
||||
public ToolQuartzPickaxe(Item.Properties props, final AEFeature type) {
|
||||
super(ItemTier.IRON, 1, -2.8F, props);
|
||||
this.type = type;
|
||||
}
|
||||
|
||||
public ToolQuartzPickaxe( Item.Properties props, final AEFeature type )
|
||||
{
|
||||
super( ItemTier.IRON, 1, -2.8F, props );
|
||||
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);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -18,7 +18,6 @@
|
||||
|
||||
package appeng.items.tools.quartz;
|
||||
|
||||
|
||||
import net.minecraft.item.Item;
|
||||
import net.minecraft.item.ItemGroup;
|
||||
import net.minecraft.item.ItemStack;
|
||||
@@ -28,20 +27,16 @@ import net.minecraft.item.ShovelItem;
|
||||
import appeng.api.features.AEFeature;
|
||||
import appeng.util.Platform;
|
||||
|
||||
public class ToolQuartzSpade extends ShovelItem {
|
||||
private final AEFeature type;
|
||||
|
||||
public class ToolQuartzSpade extends ShovelItem
|
||||
{
|
||||
private final AEFeature type;
|
||||
public ToolQuartzSpade(Item.Properties props, final AEFeature type) {
|
||||
super(ItemTier.IRON, 1.5F, -3.0F, props);
|
||||
this.type = type;
|
||||
}
|
||||
|
||||
public ToolQuartzSpade( Item.Properties props, final AEFeature type )
|
||||
{
|
||||
super( ItemTier.IRON, 1.5F, -3.0F, props );
|
||||
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);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -18,7 +18,6 @@
|
||||
|
||||
package appeng.items.tools.quartz;
|
||||
|
||||
|
||||
import net.minecraft.item.Item;
|
||||
import net.minecraft.item.ItemGroup;
|
||||
import net.minecraft.item.ItemStack;
|
||||
@@ -28,20 +27,16 @@ import net.minecraft.item.SwordItem;
|
||||
import appeng.api.features.AEFeature;
|
||||
import appeng.util.Platform;
|
||||
|
||||
public class ToolQuartzSword extends SwordItem {
|
||||
private final AEFeature type;
|
||||
|
||||
public class ToolQuartzSword extends SwordItem
|
||||
{
|
||||
private final AEFeature type;
|
||||
public ToolQuartzSword(Item.Properties props, AEFeature type) {
|
||||
super(ItemTier.IRON, 3, -2.4F, props);
|
||||
this.type = type;
|
||||
}
|
||||
|
||||
public ToolQuartzSword( Item.Properties props, AEFeature type )
|
||||
{
|
||||
super( ItemTier.IRON, 3, -2.4F, props );
|
||||
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);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -18,12 +18,6 @@
|
||||
|
||||
package appeng.items.tools.quartz;
|
||||
|
||||
|
||||
import appeng.api.implementations.items.IAEWrench;
|
||||
import appeng.api.util.DimensionalCoord;
|
||||
import appeng.block.AEBaseBlock;
|
||||
import appeng.items.AEBaseItem;
|
||||
import appeng.util.Platform;
|
||||
import net.minecraft.block.Block;
|
||||
import net.minecraft.entity.player.PlayerEntity;
|
||||
import net.minecraft.item.Item;
|
||||
@@ -32,42 +26,43 @@ import net.minecraft.item.ItemUseContext;
|
||||
import net.minecraft.util.ActionResultType;
|
||||
import net.minecraft.util.math.BlockPos;
|
||||
|
||||
import appeng.api.implementations.items.IAEWrench;
|
||||
import appeng.api.util.DimensionalCoord;
|
||||
import appeng.block.AEBaseBlock;
|
||||
import appeng.items.AEBaseItem;
|
||||
import appeng.util.Platform;
|
||||
|
||||
public class ToolQuartzWrench extends AEBaseItem implements IAEWrench
|
||||
{
|
||||
public class ToolQuartzWrench extends AEBaseItem implements IAEWrench {
|
||||
|
||||
public ToolQuartzWrench(Item.Properties props)
|
||||
{
|
||||
super( props );
|
||||
}
|
||||
public ToolQuartzWrench(Item.Properties props) {
|
||||
super(props);
|
||||
}
|
||||
|
||||
@Override
|
||||
public ActionResultType onItemUseFirst(ItemStack stack, ItemUseContext context) {
|
||||
if( !context.getPlayer().isCrouching() && Platform.hasPermissions( new DimensionalCoord( context.getWorld(), context.getPos() ),
|
||||
context.getPlayer() ) )
|
||||
{
|
||||
@Override
|
||||
public ActionResultType onItemUseFirst(ItemStack stack, ItemUseContext context) {
|
||||
if (!context.getPlayer().isCrouching() && Platform
|
||||
.hasPermissions(new DimensionalCoord(context.getWorld(), context.getPos()), context.getPlayer())) {
|
||||
|
||||
Block block = context.getWorld().getBlockState(context.getPos()).getBlock();
|
||||
if (block instanceof AEBaseBlock) {
|
||||
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 !context.getWorld().isRemote ? ActionResultType.SUCCESS : ActionResultType.PASS;
|
||||
}
|
||||
Block block = context.getWorld().getBlockState(context.getPos()).getBlock();
|
||||
if (block instanceof AEBaseBlock) {
|
||||
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 !context.getWorld().isRemote ? ActionResultType.SUCCESS : ActionResultType.PASS;
|
||||
}
|
||||
|
||||
AEBaseBlock aeBlock = (AEBaseBlock) block;
|
||||
if (aeBlock.rotateAroundFaceAxis(context.getWorld(), context.getPos(), context.getFace())) {
|
||||
context.getPlayer().swingArm(context.getHand());
|
||||
return !context.getWorld().isRemote ? ActionResultType.SUCCESS : ActionResultType.FAIL;
|
||||
}
|
||||
}
|
||||
}
|
||||
return ActionResultType.PASS;
|
||||
}
|
||||
AEBaseBlock aeBlock = (AEBaseBlock) block;
|
||||
if (aeBlock.rotateAroundFaceAxis(context.getWorld(), context.getPos(), context.getFace())) {
|
||||
context.getPlayer().swingArm(context.getHand());
|
||||
return !context.getWorld().isRemote ? ActionResultType.SUCCESS : ActionResultType.FAIL;
|
||||
}
|
||||
}
|
||||
}
|
||||
return ActionResultType.PASS;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean canWrench( final ItemStack wrench, final PlayerEntity player, final BlockPos pos )
|
||||
{
|
||||
return true;
|
||||
}
|
||||
@Override
|
||||
public boolean canWrench(final ItemStack wrench, final PlayerEntity player, final BlockPos pos) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user