codechicken.multipart.TMultiPart Java Examples

The following examples show how to use codechicken.multipart.TMultiPart. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: PartFrame.java    From Framez with GNU General Public License v3.0 6 votes vote down vote up
@Override
public int getMicroblock(ForgeDirection face) {

    if (tile() != null) {
        for (TMultiPart p : tile().jPartList()) {
            if (p instanceof FaceMicroblock || p instanceof HollowMicroblock) {
                int pos = ((CommonMicroblock) p).getShape();
                if (pos != face.ordinal())
                    continue;
                if (((CommonMicroblock) p).getSize() == 2)
                    return 2;
                else
                    return 1;
            }
        }
    }

    return 0;
}
 
Example #2
Source File: ItemPartFrame.java    From Framez with GNU General Public License v3.0 6 votes vote down vote up
@Override
public TMultiPart newPart(ItemStack item, EntityPlayer player, World world, BlockCoord loc, int side, Vector3 hit) {

    NBTTagCompound tag = item.getTagCompound();

    if (tag == null)
        return null;
    if (!tag.hasKey("modifiers"))
        return null;

    NBTTagList l = tag.getTagList("modifiers", new NBTTagString().getId());
    List<IFrameModifier> mods = new ArrayList<IFrameModifier>();
    for (int i = 0; i < l.tagCount(); i++) {
        IFrameModifier mod = FrameModifierRegistry.instance().findModifier(l.getStringTagAt(i));
        if (mod != null)
            mods.add(mod);
    }

    return FrameFactory.createFrame(PartFrame.class, mods);
}
 
Example #3
Source File: FrameMovementRegistry.java    From Framez with GNU General Public License v3.0 6 votes vote down vote up
@Override
public List<IFrame> findFrames(World world, int x, int y, int z) {

    if (world == null)
        return null;

    List<IFrame> l = new ArrayList<IFrame>();

    Block b = world.getBlock(x, y, z);
    if (b instanceof IFrame)
        l.add((IFrame) b);

    TileEntity te = world.getTileEntity(x, y, z);
    if (te != null && te instanceof IFrame)
        l.add((IFrame) te);

    TileMultipart tmp = TileMultipart.getTile(world, new BlockCoord(x, y, z));
    if (tmp != null)
        for (TMultiPart p : tmp.jPartList())
            if (p instanceof IFrame)
                l.add((IFrame) p);// FIXME actual multipart handling

    return l;
}
 
Example #4
Source File: MovementHandlerFMP.java    From Framez with GNU General Public License v3.0 6 votes vote down vote up
@Override
@Priority(PriorityEnum.OVERRIDE)
public BlockMovementType getMovementType(World world, int x, int y, int z, ForgeDirection side, IMovement movement) {

    TileMultipart tmp = TileMultipart.getTile(world, new BlockCoord(x, y, z));
    if (tmp == null)
        return null;

    for (TMultiPart p : tmp.jPartList()) {
        if (p instanceof TSlottedPart) {
            int slot = ((TSlottedPart) p).getSlotMask();
            if (slot == PartMap.face(side.ordinal()).mask && (p instanceof FaceMicroblock || p instanceof HollowMicroblock)) {
                if (((CommonMicroblock) p).getSize() == 1)
                    return BlockMovementType.UNMOVABLE;
            }
        }
    }

    return null;
}
 
Example #5
Source File: ItemBlockChiselTorchPart.java    From Chisel-2 with GNU General Public License v2.0 6 votes vote down vote up
public boolean placePart(World world, BlockCoord pos, ItemStack item, int side, boolean doPlace) {
	TileMultipart tile = TileMultipart.getOrConvertTile(world, pos);
	if (tile == null) {
		return false;
	}
	TMultiPart part = createMultiPart(world, pos, item, side);
	if (part == null) {
		return false;
	}
	if (tile.canAddPart(part)) {
		if (doPlace) {
			TileMultipart.addPart(world, pos, part);
		}
		return true;
	}
	return false;
}
 
Example #6
Source File: WRLogicProxy.java    From WirelessRedstone with MIT License 5 votes vote down vote up
@Override
public TMultiPart createPart(String name, boolean client)
{
    if(name.equals("wrcbe-tran"))
        return new TransmitterPart();
    if(name.equals("wrcbe-recv"))
        return new ReceiverPart();
    if(name.equals("wrcbe-jamm"))
        return new JammerPart();
    return null;
}
 
Example #7
Source File: FMP.java    From PneumaticCraft with GNU General Public License v3.0 5 votes vote down vote up
public static <T> Iterable<T> getMultiParts(TileMultipart t, Class<T> searchedClass){
    List<T> parts = new ArrayList<T>();
    for(TMultiPart part : t.jPartList()) {
        if(searchedClass.isAssignableFrom(part.getClass())) parts.add((T)part);
    }
    return parts;
}
 
Example #8
Source File: FMP.java    From PneumaticCraft with GNU General Public License v3.0 5 votes vote down vote up
@Override
public TMultiPart createPart(String id, boolean client){
    try {
        return multiparts.get(id).newInstance();
    } catch(Exception e) {
        Log.error("Failed to instantiate the multipart with id " + id + ". Is the constructor a parameterless one?");
        return null;
    }
}
 
Example #9
Source File: FMP.java    From PneumaticCraft with GNU General Public License v3.0 5 votes vote down vote up
@Override
public TMultiPart convert(World world, BlockCoord pos){
    if(!Config.convertMultipartsToBlocks) {
        if(world.getBlock(pos.x, pos.y, pos.z) == Blockss.pressureTube) return new PartPressureTube((TileEntityPressureTube)world.getTileEntity(pos.x, pos.y, pos.z));
        if(world.getBlock(pos.x, pos.y, pos.z) == Blockss.advancedPressureTube) return new PartAdvancedPressureTube((TileEntityPressureTube)world.getTileEntity(pos.x, pos.y, pos.z));
    }
    return null;
}
 
Example #10
Source File: ThirdPartyManager.java    From PneumaticCraft with GNU General Public License v3.0 5 votes vote down vote up
@Optional.Method(modid = ModIds.FMP)
public void registerPart(String partName, Class<? extends TMultiPart> multipart){
    for(IThirdParty thirdParty : thirdPartyMods) {
        if(thirdParty instanceof FMPLoader) {
            ((FMPLoader)thirdParty).fmp.registerPart(partName, multipart);
            return;
        }
    }
    throw new IllegalStateException("No FMP found!");
}
 
Example #11
Source File: ThirdPartyManager.java    From PneumaticCraft with GNU General Public License v3.0 5 votes vote down vote up
@Optional.Method(modid = ModIds.FMP)
public TMultiPart getPart(String partName){
    for(IThirdParty thirdParty : thirdPartyMods) {
        if(thirdParty instanceof FMPLoader) {
            return ((FMPLoader)thirdParty).fmp.createPart(partName, false);
        }
    }
    return null;
}
 
Example #12
Source File: ModInteractionUtilImplementation.java    From PneumaticCraft with GNU General Public License v3.0 5 votes vote down vote up
@Override
@Optional.Method(modid = ModIds.FMP)
public void sendDescriptionPacket(IPneumaticPosProvider te){
    if(te instanceof TMultiPart) {
        ((TMultiPart)te).sendDescUpdate();
    } else {
        super.sendDescriptionPacket(te);
    }
}
 
Example #13
Source File: HydraulicBaseClassSupplier.java    From PneumaticCraft with GNU General Public License v3.0 5 votes vote down vote up
public static IBaseClass getBaseClass(TMultiPart target, PressureTier pTier, int maxStorage){
	IBaseClass baseClassEntity = null;
    try {
        if(multipartConstructor == null) multipartConstructor = Class.forName("k4unl.minecraft.Hydraulicraft.tileEntities.TileHydraulicBase").getConstructor(PressureTier.class, int.class);
        baseClassEntity = (IBaseClass)multipartConstructor.newInstance(pTier, maxStorage);
        baseClassEntity.init(target);
    } catch(Exception e){
    	System.err.println("[Hydraulicraft API] An error has occured whilst trying to get a base class. Here's a stacktrace:");
        e.printStackTrace();
    }
    return baseClassEntity;
}
 
Example #14
Source File: ItemWirelessPart.java    From WirelessRedstone with MIT License 5 votes vote down vote up
@Override
public TMultiPart newPart(ItemStack item, EntityPlayer player, World world, BlockCoord pos, int side, Vector3 vhit) {
    BlockCoord onPos = pos.copy().offset(side ^ 1);
    if (!world.isSideSolid(onPos.x, onPos.y, onPos.z, ForgeDirection.getOrientation(side)))
        return null;

    WirelessPart part = getPart(item.getItemDamage());
    part.setupPlacement(player, side);
    return part;
}
 
Example #15
Source File: WirelessPart.java    From WirelessRedstone with MIT License 5 votes vote down vote up
@Override
public void onPartChanged(TMultiPart part) {
    if (world().isRemote) {
        recalcBounds();
    } else {
        onNeighborChanged();
    }
}
 
Example #16
Source File: WirelessPart.java    From WirelessRedstone with MIT License 5 votes vote down vote up
public int getInternalPower() {
    TMultiPart part = tile().partMap(Rotation.rotateSide(side(), rotation()));
    if (part instanceof IRedstonePart) {
        IRedstonePart rp = (IRedstonePart) part;
        return Math.max(rp.strongPowerLevel(side()), rp.weakPowerLevel(side())) << 4;
    }

    return 0;
}
 
Example #17
Source File: FMPCompat.java    From Chisel-2 with GNU General Public License v2.0 5 votes vote down vote up
@Override
public TMultiPart createPart(String type, boolean client) {
	if (type.equals("chisel_torch")) {
		return new PartChiselTorch();
	}
	return null;
}
 
Example #18
Source File: FMPCompat.java    From Chisel-2 with GNU General Public License v2.0 5 votes vote down vote up
@Override
public TMultiPart convert(World world, BlockCoord bc) {
	Block block = world.getBlock(bc.x, bc.y, bc.z);
	for (int i = 0; i < ChiselBlocks.torches.length; i++) {
		if (block == ChiselBlocks.torches[i]) {
			return new PartChiselTorch(i, world.getBlockMetadata(bc.x, bc.y, bc.z));
		}
	}
	return null;
}
 
Example #19
Source File: StickyHandlerFMP.java    From Framez with GNU General Public License v3.0 5 votes vote down vote up
@Override
public boolean isSideSticky(World world, int x, int y, int z, ForgeDirection side, IMovement movement) {

    TileMultipart tmp = TileMultipart.getTile(world, new BlockCoord(x, y, z));
    if (tmp == null)
        return false;

    boolean is = false;

    for (TMultiPart p : tmp.jPartList()) {
        if (p instanceof TSlottedPart) {
            int slot = ((TSlottedPart) p).getSlotMask();
            if (PartMap.face(side.ordinal()).mask == slot) {
                if (p instanceof ISticky) {
                    return ((ISticky) p).isSideSticky(world, x, y, z, side, movement);
                } else if (p instanceof FaceMicroblock || p instanceof HollowMicroblock) {
                    if (((CommonMicroblock) p).getSize() == 1)
                        return false;
                }
            } else if (slot == PartMap.CENTER.mask && p instanceof ISticky)
                return ((ISticky) p).isSideSticky(world, x, y, z, side, movement);
        } else if (p instanceof ISticky)
            is |= ((ISticky) p).isSideSticky(world, x, y, z, side, movement);
    }

    return is;
}
 
Example #20
Source File: GTMultipartFactory.java    From GregTech with GNU Lesser General Public License v3.0 5 votes vote down vote up
public TMultiPart createPart(ResourceLocation identifier) {
    if (partRegistry.containsKey(identifier)) {
        Supplier<TMultiPart> supplier = partRegistry.get(identifier);
        return supplier.get();

    }
    return null;
}
 
Example #21
Source File: PartFactory.java    From Framez with GNU General Public License v3.0 5 votes vote down vote up
@Override
public TMultiPart createPart(String type, boolean client) {

    if (type.equals(References.FRAME_PART_ID))
        type = References.FRAME_PART_ID + "_" + References.Modifier.MATERIAL_WOOD;

    if (type.startsWith(References.FRAME_PART_ID))
        return FrameFactory.createFrame(PartFrame.class, type);

    return null;
}
 
Example #22
Source File: PartFrame.java    From Framez with GNU General Public License v3.0 5 votes vote down vote up
@Override
public boolean occlusionTest(TMultiPart part) {

    if (part instanceof CommonMicroblock) {
        if (!(part instanceof FaceMicroblock) && !(part instanceof HollowMicroblock))
            return false;
        if (((CommonMicroblock) part).getSize() > 2)
            return false;
    }

    return !(part instanceof PartFrame) && super.occlusionTest(part);
}
 
Example #23
Source File: FluidPipeNet.java    From GregTech with GNU Lesser General Public License v3.0 5 votes vote down vote up
@Method(modid = GTValues.MODID_FMP)
private static void removeMultipartPipePartFromTile(TileEntity tileEntity) {
    if (tileEntity instanceof TileMultipart) {
        TileMultipart tileMultipart = (TileMultipart) tileEntity;
        List<TMultiPart> partList = tileMultipart.jPartList();
        for (TMultiPart tMultiPart : partList) {
            if (tMultiPart instanceof IPipeTile) {
                tileMultipart.remPart(tMultiPart);
            }
        }
    }
}
 
Example #24
Source File: GTMultipartFactory.java    From GregTech with GNU Lesser General Public License v3.0 4 votes vote down vote up
@Override
public TMultiPart createPartServer(ResourceLocation identifier, NBTTagCompound compound) {
    return createPart(identifier);
}
 
Example #25
Source File: FMP.java    From PneumaticCraft with GNU General Public License v3.0 4 votes vote down vote up
public static <T> T getMultiPart(TileMultipart t, Class<T> searchedClass){
    for(TMultiPart part : t.jPartList()) {
        if(searchedClass.isAssignableFrom(part.getClass())) return (T)part;
    }
    return null;
}
 
Example #26
Source File: GTMultipartFactory.java    From GregTech with GNU Lesser General Public License v3.0 4 votes vote down vote up
@Override
public TMultiPart createPartClient(ResourceLocation identifier, MCDataInput packet) {
    return createPart(identifier);
}
 
Example #27
Source File: FMP.java    From PneumaticCraft with GNU General Public License v3.0 4 votes vote down vote up
public void registerPart(String partName, Class<? extends TMultiPart> part){
    multiparts.put(partName, part);
}
 
Example #28
Source File: PartPressureTube.java    From PneumaticCraft with GNU General Public License v3.0 4 votes vote down vote up
@Override
public boolean occlusionTest(TMultiPart npart){
    return NormalOcclusionTest.apply(this, npart);
}
 
Example #29
Source File: PartPressureTube.java    From PneumaticCraft with GNU General Public License v3.0 4 votes vote down vote up
@Override
public void onPartChanged(TMultiPart part){
    onNeighborChanged();
}
 
Example #30
Source File: PartFactory.java    From Framez with GNU General Public License v3.0 4 votes vote down vote up
@Override
public TMultiPart convert(World world, BlockCoord location) {

    return null;
}