use of gregtech.api.cover.CoverBehavior in project GregTech by GregTechCE.
the class MetaTileEntity method writeToNBT.
public NBTTagCompound writeToNBT(NBTTagCompound data) {
data.setInteger("FrontFacing", frontFacing.getIndex());
data.setInteger(TAG_KEY_PAINTING_COLOR, paintingColor);
data.setInteger("CachedLightValue", cachedLightValue);
if (shouldSerializeInventories()) {
GTUtility.writeItems(importItems, "ImportInventory", data);
GTUtility.writeItems(exportItems, "ExportInventory", data);
data.setTag("ImportFluidInventory", importFluids.serializeNBT());
data.setTag("ExportFluidInventory", exportFluids.serializeNBT());
}
for (MTETrait mteTrait : this.mteTraits) {
data.setTag(mteTrait.getName(), mteTrait.serializeNBT());
}
NBTTagList coversList = new NBTTagList();
for (EnumFacing coverSide : EnumFacing.VALUES) {
CoverBehavior coverBehavior = coverBehaviors[coverSide.getIndex()];
if (coverBehavior != null) {
NBTTagCompound tagCompound = new NBTTagCompound();
ResourceLocation coverId = coverBehavior.getCoverDefinition().getCoverId();
tagCompound.setString("CoverId", coverId.toString());
tagCompound.setByte("Side", (byte) coverSide.getIndex());
coverBehavior.writeToNBT(tagCompound);
coversList.appendTag(tagCompound);
}
}
data.setTag("Covers", coversList);
data.setBoolean(TAG_KEY_FRAGILE, isFragile);
return data;
}
use of gregtech.api.cover.CoverBehavior in project GregTech by GregTechCE.
the class MetaTileEntity method getOutputRedstoneSignal.
public final int getOutputRedstoneSignal(@Nullable EnumFacing side) {
if (side == null) {
return getHighestOutputRedstoneSignal();
}
CoverBehavior behavior = getCoverAtSide(side);
int sidedOutput = sidedRedstoneOutput[side.getIndex()];
return behavior == null ? sidedOutput : behavior.getRedstoneSignalOutput();
}
use of gregtech.api.cover.CoverBehavior in project GregTech by GregTechCE.
the class TileEntityPipeBase method getCapability.
@Nullable
@Override
public final <T> T getCapability(Capability<T> capability, @Nullable EnumFacing facing) {
boolean isCoverable = capability == GregtechTileCapabilities.CAPABILITY_COVERABLE;
CoverBehavior coverBehavior = facing == null ? null : coverableImplementation.getCoverAtSide(facing);
T defaultValue = getCapabilityInternal(capability, facing);
if (isCoverable) {
return defaultValue;
}
if (coverBehavior == null && facing != null) {
boolean isBlocked = (getBlockedConnections() & 1 << facing.getIndex()) > 0;
return isBlocked ? null : defaultValue;
}
if (coverBehavior != null) {
return coverBehavior.getCapability(capability, defaultValue);
}
return defaultValue;
}
use of gregtech.api.cover.CoverBehavior in project GregTech by GregTechCE.
the class BlockPipe method onBlockClicked.
@Override
public void onBlockClicked(World worldIn, BlockPos pos, EntityPlayer playerIn) {
IPipeTile<PipeType, NodeDataType> pipeTile = getPipeTileEntity(worldIn, pos);
CuboidRayTraceResult rayTraceResult = (CuboidRayTraceResult) RayTracer.retraceBlock(worldIn, playerIn, pos);
if (pipeTile == null || rayTraceResult == null) {
return;
}
EnumFacing coverSide = ICoverable.traceCoverSide(rayTraceResult);
CoverBehavior coverBehavior = coverSide == null ? null : pipeTile.getCoverableImplementation().getCoverAtSide(coverSide);
if (coverBehavior != null) {
coverBehavior.onLeftClick(playerIn, rayTraceResult);
}
}
use of gregtech.api.cover.CoverBehavior in project GregTech by GregTechCE.
the class MetaTileEntityTank method recheckBlockedSides.
private void recheckBlockedSides() {
this.blockedSides = 0;
for (EnumFacing side : EnumFacing.VALUES) {
CoverBehavior coverBehavior = getCoverAtSide(side);
if (coverBehavior == null)
continue;
if (coverBehavior.canPipePassThrough())
continue;
this.blockedSides |= 1 << side.getIndex();
}
}
Aggregations