Start of part registration.
This commit is contained in:
@@ -32,6 +32,7 @@ import net.minecraft.crash.CrashReportCategory;
|
||||
import net.minecraft.entity.Entity;
|
||||
import net.minecraft.entity.LivingEntity;
|
||||
import net.minecraft.entity.player.PlayerEntity;
|
||||
import net.minecraft.item.Item;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.nbt.CompoundNBT;
|
||||
import net.minecraft.network.PacketBuffer;
|
||||
@@ -102,7 +103,12 @@ public abstract class AEBasePart implements IPart, IGridProxyable, IActionHost,
|
||||
|
||||
public PartType getType()
|
||||
{
|
||||
return ItemPart.instance.getTypeByStack( this.is );
|
||||
Item item = this.is.getItem();
|
||||
if (!(item instanceof ItemPart)) {
|
||||
return PartType.INVALID_TYPE;
|
||||
}
|
||||
|
||||
return ((ItemPart<?>) item).getType();
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -138,12 +138,12 @@ public class CableBusContainer extends CableBusStorage implements AEMultiTile, I
|
||||
|
||||
if( is.getItem() instanceof IPartItem )
|
||||
{
|
||||
final IPartItem bi = (IPartItem) is.getItem();
|
||||
final IPartItem<?> bi = (IPartItem<?>) is.getItem();
|
||||
|
||||
is = is.copy();
|
||||
is.setCount( 1 );
|
||||
|
||||
final IPart bp = bi.createPartFromItemStack( is );
|
||||
final IPart bp = bi.createPart(is);
|
||||
if( bp != null )
|
||||
{
|
||||
if( bp instanceof IPartCable )
|
||||
@@ -186,12 +186,12 @@ public class CableBusContainer extends CableBusStorage implements AEMultiTile, I
|
||||
{
|
||||
if( is.getItem() instanceof IPartItem )
|
||||
{
|
||||
final IPartItem bi = (IPartItem) is.getItem();
|
||||
final IPartItem<?> bi = (IPartItem<?>) is.getItem();
|
||||
|
||||
is = is.copy();
|
||||
is.setCount( 1 );
|
||||
|
||||
final IPart bp = bi.createPartFromItemStack( is );
|
||||
final IPart bp = bi.createPart(is);
|
||||
if( bp instanceof IPartCable )
|
||||
{
|
||||
boolean canPlace = true;
|
||||
|
||||
@@ -19,17 +19,6 @@
|
||||
package appeng.parts.networking;
|
||||
|
||||
|
||||
import java.io.IOException;
|
||||
import java.util.EnumSet;
|
||||
|
||||
import com.google.common.collect.ImmutableSet;
|
||||
|
||||
import net.minecraft.entity.player.PlayerEntity;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.nbt.CompoundNBT;
|
||||
import net.minecraft.network.PacketBuffer;
|
||||
import net.minecraft.util.Direction;
|
||||
|
||||
import appeng.api.AEApi;
|
||||
import appeng.api.config.SecurityPermissions;
|
||||
import appeng.api.definitions.IParts;
|
||||
@@ -46,10 +35,19 @@ import appeng.api.util.AECableType;
|
||||
import appeng.api.util.AEColor;
|
||||
import appeng.api.util.AEPartLocation;
|
||||
import appeng.api.util.IReadOnlyCollection;
|
||||
import appeng.items.parts.ItemPart;
|
||||
import appeng.items.parts.ColoredPartItem;
|
||||
import appeng.me.GridAccessException;
|
||||
import appeng.parts.AEBasePart;
|
||||
import appeng.util.Platform;
|
||||
import com.google.common.collect.ImmutableSet;
|
||||
import net.minecraft.entity.player.PlayerEntity;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.nbt.CompoundNBT;
|
||||
import net.minecraft.network.PacketBuffer;
|
||||
import net.minecraft.util.Direction;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.util.EnumSet;
|
||||
|
||||
|
||||
public class PartCable extends AEBasePart implements IPartCable
|
||||
@@ -68,7 +66,10 @@ public class PartCable extends AEBasePart implements IPartCable
|
||||
super( is );
|
||||
this.getProxy().setFlags( GridFlags.PREFERRED );
|
||||
this.getProxy().setIdlePowerUsage( 0.0 );
|
||||
this.getProxy().setColor( AEColor.values()[( (ItemPart) is.getItem() ).variantOf( is.getDamage() )] );
|
||||
if (is.getItem() instanceof ColoredPartItem) {
|
||||
ColoredPartItem<?> coloredPartItem = (ColoredPartItem<?>) is.getItem();
|
||||
this.getProxy().setColor(coloredPartItem.getColor());
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -207,7 +207,7 @@ public abstract class PartP2PTunnel<T extends PartP2PTunnel> extends PartBasicSt
|
||||
{
|
||||
if( newType.getItem() instanceof IPartItem )
|
||||
{
|
||||
final IPart testPart = ( (IPartItem) newType.getItem() ).createPartFromItemStack( newType );
|
||||
final IPart testPart = ( (IPartItem<?>) newType.getItem() ).createPart( newType );
|
||||
if( testPart instanceof PartP2PTunnel )
|
||||
{
|
||||
this.getHost().removePart( this.getSide(), true );
|
||||
@@ -216,7 +216,7 @@ public abstract class PartP2PTunnel<T extends PartP2PTunnel> extends PartBasicSt
|
||||
|
||||
if( newBus instanceof PartP2PTunnel )
|
||||
{
|
||||
final PartP2PTunnel newTunnel = (PartP2PTunnel) newBus;
|
||||
final PartP2PTunnel<?> newTunnel = (PartP2PTunnel<?>) newBus;
|
||||
newTunnel.setOutput( true );
|
||||
|
||||
try
|
||||
|
||||
Reference in New Issue
Block a user