use of gregapi.tileentity.ITileEntityFoamable in project gregtech6 by GregTech6.
the class MultiTileEntityItemInternal method getOreDictItemData.
@Override
public OreDictItemData getOreDictItemData(ItemStack aStack) {
List<OreDictItemData> rList = new ArrayListNoNulls<>(F, OM.data(aStack));
MultiTileEntityContainer tTileEntityContainer = mBlock.mMultiTileEntityRegistry.getNewTileEntityContainer(aStack);
// Yes I keep Covers a special case, less chances for fuck ups.
if (tTileEntityContainer != null && tTileEntityContainer.mTileEntity instanceof ITileEntityCoverable) {
CoverData tCoverData = ((ITileEntityCoverable) tTileEntityContainer.mTileEntity).getCoverData();
if (tCoverData != null)
for (byte tSide : ALL_SIDES_VALID) rList.add(OM.anydata(tCoverData.getCoverItem(tSide)));
}
// Same for foamed Blocks.
if (tTileEntityContainer != null && tTileEntityContainer.mTileEntity instanceof ITileEntityFoamable && ((ITileEntityFoamable) tTileEntityContainer.mTileEntity).hasFoam(SIDE_ANY)) {
rList.add(new OreDictItemData(MT.ConstructionFoam, U));
if (((ITileEntityFoamable) tTileEntityContainer.mTileEntity).ownedFoam(SIDE_ANY))
rList.add(new OreDictItemData(MT.Pd, U4));
}
// General case for Custom additional OreDictItemData.
if (tTileEntityContainer != null && tTileEntityContainer.mTileEntity instanceof IMTE_GetOreDictItemData) {
rList = ((IMTE_GetOreDictItemData) tTileEntityContainer.mTileEntity).getOreDictItemData(rList);
}
return rList.isEmpty() ? null : rList.size() > 1 ? new OreDictItemData(rList) : rList.get(0);
}
use of gregapi.tileentity.ITileEntityFoamable in project gregtech6 by GregTech6.
the class Behavior_Spray_Foam method foam.
public long foam(World aWorld, int aX, int aY, int aZ, byte aSide, long aUses, EntityPlayer aPlayer, ItemStack aStack) {
if (aUses < 1)
return 0;
long rUses = 0;
DelegatorTileEntity<TileEntity> aDelegator = WD.te(aWorld, aX, aY, aZ, aSide, T);
if (aDelegator.mTileEntity instanceof ITileEntityFoamable && !((ITileEntityFoamable) aDelegator.mTileEntity).hasFoam(aDelegator.mSideOfTileEntity))
return ((ITileEntityFoamable) aDelegator.mTileEntity).applyFoam(aDelegator.mSideOfTileEntity, aPlayer, DYES[mColor], mColor, mOwned) ? 10 : 0;
Block aBlock = aDelegator.getBlock();
aWorld = aDelegator.mWorld;
aX = aDelegator.mX;
aY = aDelegator.mY;
aZ = aDelegator.mZ;
if (aBlock instanceof IBlockFoamable && !((IBlockFoamable) aBlock).hasFoam(aWorld, aX, aY, aZ, aDelegator.mSideOfTileEntity))
return ((IBlockFoamable) aBlock).applyFoam(aWorld, aX, aY, aZ, aDelegator.mSideOfTileEntity, DYES[mColor], mColor) ? 10 : 0;
try {
if (UT.Reflection.getClassName(aDelegator.mTileEntity).startsWith("TileEntityCable") && UT.Reflection.getPublicField(aDelegator.mTileEntity, "foamed").getByte(aDelegator.mTileEntity) == 0) {
if (aUses >= 10) {
UT.Reflection.callPublicMethod(aDelegator.mTileEntity, "changeFoam", (byte) 1);
return 10;
}
return 0;
}
} catch (Throwable e) {
e.printStackTrace(ERR);
}
if (IL.IC2_Scaffold.equal(aBlock))
return aUses >= 10 && MultiTileEntityCFoam.setBlock(aWorld, aX, aY, aZ, aDelegator.mSideOfTileEntity, aPlayer, aStack, DYES[mColor], mOwned) ? 10 : 0;
if (IL.IC2_Scaffold_Iron.equal(aBlock))
return aUses >= 10 && aWorld.setBlock(aX, aY, aZ, IL.IC2_Foam_Reinforced.block(), 0, 3) ? 10 : 0;
aX += OFFX[aSide];
aY += OFFY[aSide];
aZ += OFFZ[aSide];
if (BlocksGT.CFoamFresh != null) {
byte tSide = UT.Code.getSideForPlayerPlacing(aPlayer);
switch((int) getMode(aStack)) {
case 0:
if (aUses >= 10 && WD.air(aWorld, aX, aY, aZ) && (mOwned ? MultiTileEntityCFoam.setBlock(aWorld, aX, aY, aZ, aSide, aPlayer, aStack, DYES[mColor], mOwned) : aWorld.setBlock(aX, aY, aZ, BlocksGT.CFoamFresh, mColor, 3))) {
aUses -= 10;
rUses += 10;
}
return rUses;
case 1:
for (byte i = 0; i < 4; i++) {
if (aUses >= 10 && WD.air(aWorld, aX, aY, aZ) && (mOwned ? MultiTileEntityCFoam.setBlock(aWorld, aX, aY, aZ, aSide, aPlayer, aStack, DYES[mColor], mOwned) : aWorld.setBlock(aX, aY, aZ, BlocksGT.CFoamFresh, mColor, 3))) {
aUses -= 10;
rUses += 10;
} else
break;
aX -= OFFX[tSide];
aY -= OFFY[tSide];
aZ -= OFFZ[tSide];
}
return rUses;
case 2:
aX -= (SIDES_AXIS_X[tSide] ? 0 : 1);
aY -= (SIDES_AXIS_Y[tSide] ? 0 : 1);
aZ -= (SIDES_AXIS_Z[tSide] ? 0 : 1);
for (byte i = 0; i < 3; i++) for (byte j = 0; j < 3; j++) {
if (aUses >= 10) {
if (WD.air(aWorld, aX + (SIDES_AXIS_X[tSide] ? 0 : i), aY + (SIDES_AXIS_X[tSide] ? i : 0) + (SIDES_AXIS_Z[tSide] ? j : 0), aZ + (SIDES_AXIS_Z[tSide] ? 0 : j))) {
if (mOwned ? MultiTileEntityCFoam.setBlock(aWorld, aX + (SIDES_AXIS_X[tSide] ? 0 : i), aY + (SIDES_AXIS_X[tSide] ? i : 0) + (SIDES_AXIS_Z[tSide] ? j : 0), aZ + (SIDES_AXIS_Z[tSide] ? 0 : j), aSide, aPlayer, aStack, DYES[mColor], mOwned) : aWorld.setBlock(aX + (SIDES_AXIS_X[tSide] ? 0 : i), aY + (SIDES_AXIS_X[tSide] ? i : 0) + (SIDES_AXIS_Z[tSide] ? j : 0), aZ + (SIDES_AXIS_Z[tSide] ? 0 : j), BlocksGT.CFoamFresh, mColor, 3)) {
aUses -= 10;
rUses += 10;
}
}
} else
break;
}
return rUses;
case 3:
if (aUses >= 5 && WD.air(aWorld, aX, aY, aZ) && aWorld.setBlock(aX, aY, aZ, ((BlockCFoamFresh) BlocksGT.CFoamFresh).mSlabs[OPOS[aSide]], mColor, 3)) {
aUses -= 5;
rUses += 5;
}
return rUses;
case 4:
aX -= (SIDES_AXIS_X[tSide] ? 0 : 1);
aY -= (SIDES_AXIS_Y[tSide] ? 0 : 1);
aZ -= (SIDES_AXIS_Z[tSide] ? 0 : 1);
for (byte i = 0; i < 3; i++) for (byte j = 0; j < 3; j++) {
if (aUses >= 5) {
if (WD.air(aWorld, aX + (SIDES_AXIS_X[tSide] ? 0 : i), aY + (SIDES_AXIS_X[tSide] ? i : 0) + (SIDES_AXIS_Z[tSide] ? j : 0), aZ + (SIDES_AXIS_Z[tSide] ? 0 : j))) {
if (aWorld.setBlock(aX + (SIDES_AXIS_X[tSide] ? 0 : i), aY + (SIDES_AXIS_X[tSide] ? i : 0) + (SIDES_AXIS_Z[tSide] ? j : 0), aZ + (SIDES_AXIS_Z[tSide] ? 0 : j), ((BlockCFoamFresh) BlocksGT.CFoamFresh).mSlabs[OPOS[tSide]], mColor, 3)) {
aUses -= 5;
rUses += 5;
}
}
} else
break;
}
return rUses;
}
}
return rUses;
}
use of gregapi.tileentity.ITileEntityFoamable in project gregtech6 by GregTech6.
the class Behavior_Spray_Foam_Hardener method harden.
public long harden(World aWorld, int aX, int aY, int aZ, byte aSide, long aUses, EntityPlayer aPlayer, ItemStack aStack) {
if (aUses < 1)
return 0;
DelegatorTileEntity<TileEntity> aTileEntity = WD.te(aWorld, aX, aY, aZ, aSide, T);
if (aTileEntity.mTileEntity instanceof ITileEntityFoamable)
return ((ITileEntityFoamable) aTileEntity.mTileEntity).dryFoam(aTileEntity.mSideOfTileEntity, aPlayer) ? 10 : 0;
Block aBlock = aTileEntity.getBlock();
aWorld = aTileEntity.mWorld;
aX = aTileEntity.mX;
aY = aTileEntity.mY;
aZ = aTileEntity.mZ;
if (aBlock instanceof IBlockFoamable)
return ((IBlockFoamable) aBlock).dryFoam(aWorld, aX, aY, aZ, aTileEntity.mSideOfTileEntity) ? aBlock instanceof BlockCFoamFresh && SIDES_VALID[((BlockMetaType) aBlock).mSide] ? 5 : 10 : 0;
try {
if (UT.Reflection.getClassName(aTileEntity.mTileEntity).startsWith("TileEntityCable")) {
if (aUses >= 10 && UT.Reflection.getPublicField(aTileEntity.mTileEntity, "foamed").getByte(aTileEntity.mTileEntity) == 1) {
UT.Reflection.callPublicMethod(aTileEntity.mTileEntity, "changeFoam", (byte) 2);
return 10;
}
return 0;
}
} catch (Throwable e) {
e.printStackTrace(ERR);
}
if (IL.IC2_Foam.block() == aBlock)
return aUses >= 10 && aWorld.setBlock(aX, aY, aZ, IL.IC2_Wall.block(), 7, 3) ? 10 : 0;
if (IL.IC2_Foam_Reinforced.block() == aBlock)
return aUses >= 10 && aWorld.setBlock(aX, aY, aZ, IL.IC2_Wall_Reinforced.block(), 0, 3) ? 10 : 0;
return 0;
}
use of gregapi.tileentity.ITileEntityFoamable in project gregtech6 by GregTech6.
the class Behavior_Spray_Foam_Remover method remove.
public long remove(World aWorld, int aX, int aY, int aZ, byte aSide, long aUses, EntityPlayer aPlayer, ItemStack aStack) {
if (aUses < 1)
return 0;
DelegatorTileEntity<TileEntity> aTileEntity = WD.te(aWorld, aX, aY, aZ, aSide, T);
if (aTileEntity.mTileEntity instanceof ITileEntityFoamable)
return ((ITileEntityFoamable) aTileEntity.mTileEntity).removeFoam(aTileEntity.mSideOfTileEntity, aPlayer) ? 10 : 0;
Block aBlock = aTileEntity.getBlock();
aWorld = aTileEntity.mWorld;
aX = aTileEntity.mX;
aY = aTileEntity.mY;
aZ = aTileEntity.mZ;
if (aBlock instanceof IBlockFoamable)
return ((IBlockFoamable) aBlock).removeFoam(aWorld, aX, aY, aZ, aTileEntity.mSideOfTileEntity) ? aBlock instanceof BlockCFoamFresh && SIDES_VALID[((BlockMetaType) aBlock).mSide] ? 5 : 10 : 0;
try {
if (UT.Reflection.getClassName(aTileEntity.mTileEntity).startsWith("TileEntityCable")) {
if (aUses >= 10 && UT.Reflection.getPublicField(aTileEntity.mTileEntity, "foamed").getByte(aTileEntity.mTileEntity) >= 1) {
UT.Reflection.callPublicMethod(aTileEntity.mTileEntity, "changeFoam", (byte) 0);
return 10;
}
return 0;
}
} catch (Throwable e) {
e.printStackTrace(ERR);
}
if (IL.IC2_Foam.block() == aBlock || IL.IC2_Wall.block() == aBlock)
return aUses >= 10 && aWorld.setBlock(aX, aY, aZ, NB, 0, 3) ? 10 : 0;
return 0;
}
Aggregations