Custom Model Loader

This commit is contained in:
Sebastian Hartte
2020-06-01 04:02:37 +02:00
parent 077ff17078
commit 5cdeff01be
202 changed files with 942 additions and 1017 deletions
@@ -19,10 +19,10 @@
package appeng.items.contents;
import appeng.core.Api;
import net.minecraft.item.ItemStack;
import net.minecraft.nbt.CompoundNBT;
import appeng.api.AEApi;
import appeng.api.config.Actionable;
import appeng.api.config.PowerMultiplier;
import appeng.api.config.Settings;
@@ -51,7 +51,7 @@ public class PortableCellViewer extends MEMonitorHandler<IAEItemStack> implement
public PortableCellViewer( final ItemStack is, final int slot )
{
super( AEApi.instance().registries().cell().getCellInventory( is, null, AEApi.instance().storage().getStorageChannel( IItemStorageChannel.class ) ) );
super( Api.INSTANCE.registries().cell().getCellInventory( is, null, Api.INSTANCE.storage().getStorageChannel( IItemStorageChannel.class ) ) );
this.ips = (IAEItemPowerStorage) is.getItem();
this.target = is;
this.inventorySlot = slot;
@@ -85,7 +85,7 @@ public class PortableCellViewer extends MEMonitorHandler<IAEItemStack> implement
@Override
public <T extends IAEStack<T>> IMEMonitor<T> getInventory( IStorageChannel<T> channel )
{
if( channel == AEApi.instance().storage().getStorageChannel( IItemStorageChannel.class ) )
if( channel == Api.INSTANCE.storage().getStorageChannel( IItemStorageChannel.class ) )
{
return (IMEMonitor<T>) this;
}
@@ -66,7 +66,7 @@ public class ItemCrystalSeed extends AEBaseItem implements IGrowableCrystal
public static ResolverResult getResolver( final int certus2 )
{
return AEApi.instance()
return Api.INSTANCE
.definitions()
.items()
.crystalSeed()
@@ -109,7 +109,7 @@ public class ItemCrystalSeed extends AEBaseItem implements IGrowableCrystal
public ItemStack triggerGrowth( final ItemStack is )
{
final int newDamage = getProgress( is ) + 1;
final IMaterials materials = AEApi.instance().definitions().materials();
final IMaterials materials = Api.INSTANCE.definitions().materials();
final int size = is.getCount();
if( newDamage == CERTUS + SINGLE_OFFSET )
@@ -85,7 +85,7 @@ public class ItemEncodedPattern extends AEBaseItem implements ICraftingPatternIt
final PlayerInventory inv = player.inventory;
ItemStack is = AEApi.instance().definitions().materials().blankPattern().maybeStack( stack.getCount() ).orElse( ItemStack.EMPTY );
ItemStack is = Api.INSTANCE.definitions().materials().blankPattern().maybeStack( stack.getCount() ).orElse( ItemStack.EMPTY );
if( !is.isEmpty() )
{
for( int s = 0; s < player.inventory.getSizeInventory(); s++ )
@@ -69,7 +69,7 @@ public class ItemFacade extends AEBaseItem implements IFacadeItem, IAlphaPassIte
@Override
public EnumActionResult onItemUseFirst( final PlayerEntity player, final World world, final BlockPos pos, final Direction side, final float hitX, final float hitY, final float hitZ, final Hand hand )
{
return AEApi.instance().partHelper().placeBus( player.getHeldItem( hand ), pos, side, player, hand, world );
return Api.INSTANCE.partHelper().placeBus( player.getHeldItem( hand ), pos, side, player, hand, world );
}
@Override
@@ -308,7 +308,7 @@ public class ItemFacade extends AEBaseItem implements IFacadeItem, IAlphaPassIte
public ItemStack createFromIDs( final int[] ids )
{
ItemStack facadeStack = AEApi.instance()
ItemStack facadeStack = Api.INSTANCE
.definitions()
.items()
.facade()
@@ -159,7 +159,7 @@ public final class ItemPart extends AEBaseItem implements IPartItem, IItemGroup
return EnumActionResult.FAIL;
}
return AEApi.instance().partHelper().placeBus( player.getHeldItem( hand ), pos, side, player, hand, w );
return Api.INSTANCE.partHelper().placeBus( player.getHeldItem( hand ), pos, side, player, hand, w );
}
@Override
@@ -79,9 +79,9 @@ public abstract class AbstractStorageCell<T extends IAEStack<T>> extends AEBaseI
@Override
public void addInformation(final ItemStack stack, final World world, final List<ITextComponent> lines, final ITooltipFlag advancedTooltips )
{
AEApi.instance()
Api.INSTANCE
.client()
.addCellInformation( AEApi.instance().registries().cell().getCellInventory( stack, null, this.getChannel() ), lines );
.addCellInformation( Api.INSTANCE.registries().cell().getCellInventory( stack, null, this.getChannel() ), lines );
}
@Override
@@ -175,7 +175,7 @@ public abstract class AbstractStorageCell<T extends IAEStack<T>> extends AEBaseI
}
final PlayerInventory playerInventory = player.inventory;
final IMEInventoryHandler inv = AEApi.instance().registries().cell().getCellInventory( stack, null, this.getChannel() );
final IMEInventoryHandler inv = Api.INSTANCE.registries().cell().getCellInventory( stack, null, this.getChannel() );
if( inv != null && playerInventory.getCurrentItem() == stack )
{
final InventoryAdaptor ia = InventoryAdaptor.getAdaptor( player );
@@ -229,7 +229,7 @@ public abstract class AbstractStorageCell<T extends IAEStack<T>> extends AEBaseI
@Override
public ItemStack getContainerItem( final ItemStack itemStack )
{
return AEApi.instance()
return Api.INSTANCE
.definitions()
.materials()
.emptyStorageCell()
@@ -79,13 +79,13 @@ public final class BasicItemStorageCell extends AbstractStorageCell<IAEItemStack
@Override
public IStorageChannel<IAEItemStack> getChannel()
{
return AEApi.instance().storage().getStorageChannel( IItemStorageChannel.class );
return Api.INSTANCE.storage().getStorageChannel( IItemStorageChannel.class );
}
@Override
protected void dropEmptyStorageCellCase( final InventoryAdaptor ia, final PlayerEntity player )
{
AEApi.instance().definitions().materials().emptyStorageCell().maybeStack( 1 ).ifPresent( is ->
Api.INSTANCE.definitions().materials().emptyStorageCell().maybeStack( 1 ).ifPresent( is ->
{
final ItemStack extraA = ia.addItems( is );
if( !extraA.isEmpty() )
@@ -81,11 +81,11 @@ public class ItemCreativeStorageCell extends AEBaseItem implements ICellWorkbenc
@Override
public void addInformation(final ItemStack stack, final World world, final List<ITextComponent> lines, final ITooltipFlag advancedTooltips )
{
final IMEInventoryHandler<?> inventory = AEApi.instance()
final IMEInventoryHandler<?> inventory = Api.INSTANCE
.registries()
.cell()
.getCellInventory( stack, null,
AEApi.instance().storage().getStorageChannel( IItemStorageChannel.class ) );
Api.INSTANCE.storage().getStorageChannel( IItemStorageChannel.class ) );
if( inventory instanceof ICellInventoryHandler )
{
@@ -62,7 +62,7 @@ public class ItemViewCell extends AEBaseItem implements ICellWorkbenchItem
if( ( currentViewCell.getItem() instanceof ItemViewCell ) )
{
final IItemList<IAEItemStack> priorityList = AEApi.instance().storage().getStorageChannel( IItemStorageChannel.class ).createList();
final IItemList<IAEItemStack> priorityList = Api.INSTANCE.storage().getStorageChannel( IItemStorageChannel.class ).createList();
final ICellWorkbenchItem vc = (ICellWorkbenchItem) currentViewCell.getItem();
final IItemHandler upgrades = vc.getUpgradesInventory( currentViewCell );
@@ -117,11 +117,11 @@ public class ToolColorApplicator extends AEBasePoweredItem implements IStorageCe
ItemStack paintBall = this.getColor( is );
final IMEInventory<IAEItemStack> inv = AEApi.instance()
final IMEInventory<IAEItemStack> inv = Api.INSTANCE
.registries()
.cell()
.getCellInventory( is, null,
AEApi.instance().storage().getStorageChannel( IItemStorageChannel.class ) );
Api.INSTANCE.storage().getStorageChannel( IItemStorageChannel.class ) );
if( inv != null )
{
final IAEItemStack option = inv.extractItems( AEItemStack.fromItemStack( paintBall ), Actionable.SIMULATE, new BaseActionSource() );
@@ -267,15 +267,15 @@ public class ToolColorApplicator extends AEBasePoweredItem implements IStorageCe
{
ItemStack newColor = ItemStack.EMPTY;
final IMEInventory<IAEItemStack> inv = AEApi.instance()
final IMEInventory<IAEItemStack> inv = Api.INSTANCE
.registries()
.cell()
.getCellInventory( is, null,
AEApi.instance().storage().getStorageChannel( IItemStorageChannel.class ) );
Api.INSTANCE.storage().getStorageChannel( IItemStorageChannel.class ) );
if( inv != null )
{
final IItemList<IAEItemStack> itemList = inv
.getAvailableItems( AEApi.instance().storage().getStorageChannel( IItemStorageChannel.class ).createList() );
.getAvailableItems( Api.INSTANCE.storage().getStorageChannel( IItemStorageChannel.class ).createList() );
if( anchor.isEmpty() )
{
final IAEItemStack firstItem = itemList.getFirstItem();
@@ -428,13 +428,13 @@ public class ToolColorApplicator extends AEBasePoweredItem implements IStorageCe
{
super.addInformation( stack, world, lines, advancedTooltips );
final ICellInventoryHandler<IAEItemStack> cdi = AEApi.instance()
final ICellInventoryHandler<IAEItemStack> cdi = Api.INSTANCE
.registries()
.cell()
.getCellInventory( stack, null,
AEApi.instance().storage().getStorageChannel( IItemStorageChannel.class ) );
Api.INSTANCE.storage().getStorageChannel( IItemStorageChannel.class ) );
AEApi.instance().client().addCellInformation( cdi, lines );
Api.INSTANCE.client().addCellInformation( cdi, lines );
}
@Override
@@ -501,7 +501,7 @@ public class ToolColorApplicator extends AEBasePoweredItem implements IStorageCe
@Override
public IStorageChannel<IAEItemStack> getChannel()
{
return AEApi.instance().storage().getStorageChannel( IItemStorageChannel.class );
return Api.INSTANCE.storage().getStorageChannel( IItemStorageChannel.class );
}
@Override
@@ -93,13 +93,13 @@ public class ToolMatterCannon extends AEBasePoweredItem implements IStorageCell<
{
super.addInformation( stack, world, lines, advancedTooltips );
final ICellInventoryHandler<IAEItemStack> cdi = AEApi.instance()
final ICellInventoryHandler<IAEItemStack> cdi = Api.INSTANCE
.registries()
.cell()
.getCellInventory( stack, null,
AEApi.instance().storage().getStorageChannel( IItemStorageChannel.class ) );
Api.INSTANCE.storage().getStorageChannel( IItemStorageChannel.class ) );
AEApi.instance().client().addCellInformation( cdi, lines );
Api.INSTANCE.client().addCellInformation( cdi, lines );
}
@Override
@@ -115,15 +115,15 @@ public class ToolMatterCannon extends AEBasePoweredItem implements IStorageCell<
shots += cu.getInstalledUpgrades( Upgrades.SPEED );
}
final ICellInventoryHandler<IAEItemStack> inv = AEApi.instance()
final ICellInventoryHandler<IAEItemStack> inv = Api.INSTANCE
.registries()
.cell()
.getCellInventory( p.getHeldItem( hand ), null,
AEApi.instance().storage().getStorageChannel( IItemStorageChannel.class ) );
Api.INSTANCE.storage().getStorageChannel( IItemStorageChannel.class ) );
if( inv != null )
{
final IItemList<IAEItemStack> itemList = inv
.getAvailableItems( AEApi.instance().storage().getStorageChannel( IItemStorageChannel.class ).createList() );
.getAvailableItems( Api.INSTANCE.storage().getStorageChannel( IItemStorageChannel.class ).createList() );
IAEItemStack req = itemList.getFirstItem();
if( req instanceof IAEItemStack )
{
@@ -162,7 +162,7 @@ public class ToolMatterCannon extends AEBasePoweredItem implements IStorageCell<
final double d1 = Vec3d.y;
final double d2 = Vec3d.z;
final float penetration = AEApi.instance().registries().matterCannon().getPenetration( ammo ); // 196.96655f;
final float penetration = Api.INSTANCE.registries().matterCannon().getPenetration( ammo ); // 196.96655f;
if( penetration <= 0 )
{
final ItemStack type = aeAmmo.asItemStackRepresentation();
@@ -291,7 +291,7 @@ public class ToolMatterCannon extends AEBasePoweredItem implements IStorageCell<
final Block whatsThere = w.getBlockState( hitPos ).getBlock();
if( whatsThere.isReplaceable( w, hitPos ) && w.isAirBlock( hitPos ) )
{
AEApi.instance().definitions().blocks().paint().maybeBlock().ifPresent( paintBlock ->
Api.INSTANCE.definitions().blocks().paint().maybeBlock().ifPresent( paintBlock ->
{
w.setBlockState( hitPos, paintBlock.getDefaultState(), 3 );
} );
@@ -495,7 +495,7 @@ public class ToolMatterCannon extends AEBasePoweredItem implements IStorageCell<
@Override
public boolean isBlackListed( final ItemStack cellItem, final IAEItemStack requestedAddition )
{
final float pen = AEApi.instance().registries().matterCannon().getPenetration( requestedAddition.createItemStack() );
final float pen = Api.INSTANCE.registries().matterCannon().getPenetration( requestedAddition.createItemStack() );
if( pen > 0 )
{
return false;
@@ -530,6 +530,6 @@ public class ToolMatterCannon extends AEBasePoweredItem implements IStorageCell<
@Override
public IStorageChannel<IAEItemStack> getChannel()
{
return AEApi.instance().storage().getStorageChannel( IItemStorageChannel.class );
return Api.INSTANCE.storage().getStorageChannel( IItemStorageChannel.class );
}
}
@@ -83,13 +83,13 @@ public class ToolPortableCell extends AEBasePoweredItem implements IStorageCell<
{
super.addInformation( stack, world, lines, advancedTooltips );
final ICellInventoryHandler<IAEItemStack> cdi = AEApi.instance()
final ICellInventoryHandler<IAEItemStack> cdi = Api.INSTANCE
.registries()
.cell()
.getCellInventory( stack, null,
AEApi.instance().storage().getStorageChannel( IItemStorageChannel.class ) );
Api.INSTANCE.storage().getStorageChannel( IItemStorageChannel.class ) );
AEApi.instance().client().addCellInformation( cdi, lines );
Api.INSTANCE.client().addCellInformation( cdi, lines );
}
@Override
@@ -137,7 +137,7 @@ public class ToolPortableCell extends AEBasePoweredItem implements IStorageCell<
@Override
public IStorageChannel<IAEItemStack> getChannel()
{
return AEApi.instance().storage().getStorageChannel( IItemStorageChannel.class );
return Api.INSTANCE.storage().getStorageChannel( IItemStorageChannel.class );
}
@Override
@@ -58,7 +58,7 @@ public class ToolWirelessTerminal extends AEBasePoweredItem implements IWireless
@Override
public ActionResult<ItemStack> onItemRightClick( final World w, final PlayerEntity player, final Hand hand )
{
AEApi.instance().registries().wireless().openWirelessTerminalGui( player.getHeldItem( hand ), w, player );
Api.INSTANCE.registries().wireless().openWirelessTerminalGui( player.getHeldItem( hand ), w, player );
return new ActionResult<>( EnumActionResult.SUCCESS, player.getHeldItem( hand ) );
}
@@ -101,7 +101,7 @@ public class ToolWirelessTerminal extends AEBasePoweredItem implements IWireless
@Override
public boolean canHandle( final ItemStack is )
{
return AEApi.instance().definitions().items().wirelessTerminal().isSameAs( is );
return Api.INSTANCE.definitions().items().wirelessTerminal().isSameAs( is );
}
@Override
@@ -20,19 +20,19 @@ package appeng.items.tools.quartz;
import net.minecraft.entity.player.PlayerEntity;
import net.minecraft.item.Item;
import net.minecraft.item.ItemGroup;
import net.minecraft.item.ItemStack;
import net.minecraft.item.ItemUseContext;
import net.minecraft.util.ActionResult;
import net.minecraft.util.EnumActionResult;
import net.minecraft.util.Direction;
import net.minecraft.util.ActionResultType;
import net.minecraft.util.Hand;
import net.minecraft.util.math.BlockPos;
import net.minecraft.world.World;
import appeng.api.implementations.guiobjects.IGuiItem;
import appeng.api.implementations.guiobjects.IGuiItemObject;
import appeng.api.util.AEPartLocation;
import appeng.core.features.AEFeature;
import appeng.core.sync.GuiBridge;
import appeng.items.AEBaseItem;
import appeng.items.contents.QuartzKnifeObj;
import appeng.util.Platform;
@@ -44,19 +44,22 @@ public class ToolQuartzCuttingKnife extends AEBaseItem implements IGuiItem
public ToolQuartzCuttingKnife( final AEFeature type )
{
super(new Item.Properties()
.group(ItemGroup.TOOLS)
.maxStackSize(1)
.maxDamage(50)
.setNoRepair());
this.type = type;
this.setMaxDamage( 50 );
this.setMaxStackSize( 1 );
}
@Override
public EnumActionResult onItemUse( final PlayerEntity p, final World worldIn, final BlockPos pos, final Hand hand, final Direction side, final float hitX, final float hitY, final float hitZ )
public ActionResultType onItemUse(ItemUseContext context )
{
if( Platform.isServer() )
{
Platform.openGUI( p, null, AEPartLocation.INTERNAL, GuiBridge.GUI_QUARTZ_KNIFE );
// FIXME Platform.openGUI( p, null, AEPartLocation.INTERNAL, GuiBridge.GUI_QUARTZ_KNIFE );
}
return EnumActionResult.SUCCESS;
return ActionResultType.SUCCESS;
}
@Override
@@ -64,10 +67,10 @@ public class ToolQuartzCuttingKnife extends AEBaseItem implements IGuiItem
{
if( Platform.isServer() )
{
Platform.openGUI( p, null, AEPartLocation.INTERNAL, GuiBridge.GUI_QUARTZ_KNIFE );
// FIXME Platform.openGUI( p, null, AEPartLocation.INTERNAL, GuiBridge.GUI_QUARTZ_KNIFE );
}
p.swingArm( hand );
return new ActionResult<>( EnumActionResult.SUCCESS, p.getHeldItem( hand ) );
return new ActionResult<>( ActionResultType.SUCCESS, p.getHeldItem( hand ) );
}
@Override
@@ -76,17 +79,11 @@ public class ToolQuartzCuttingKnife extends AEBaseItem implements IGuiItem
return Platform.canRepair( this.type, a, b );
}
@Override
public boolean isRepairable()
{
return false;
}
@Override
public ItemStack getContainerItem( final ItemStack itemStack )
{
ItemStack copy = itemStack.copy();
copy.setItemDamage( itemStack.getDamage() + 1 );
copy.setDamage( itemStack.getDamage() + 1 );
return copy;
}
@@ -19,8 +19,10 @@
package appeng.items.tools.quartz;
import appeng.core.CreativeTab;
import net.minecraft.block.Block;
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;
@@ -38,20 +40,21 @@ public class ToolQuartzWrench extends AEBaseItem implements IAEWrench
public ToolQuartzWrench()
{
super( new Properties().maxStackSize( 1 ) );
super( new Properties()
.group(ItemGroup.TOOLS)
.maxStackSize( 1 ) );
}
@Override
public ActionResultType onItemUse( ItemUseContext context )
{
final Block b = context.getWorld().getBlockState( context.getPos() ).getBlock();
if( b != null && !context.getPlayer().isShiftKeyDown() && Platform.hasPermissions( new DimensionalCoord( context.getWorld(), context.getPos() ),
if( !context.getPlayer().isCrouching() && Platform.hasPermissions( new DimensionalCoord( context.getWorld(), context.getPos() ),
context.getPlayer() ) )
{
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.
// 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;
}