use of gregtech.api.cover.CoverBehavior in project GregTech by GregTechCE.
the class MetaTileEntity method removeCover.
public final boolean removeCover(EnumFacing side) {
Preconditions.checkNotNull(side, "side");
CoverBehavior coverBehavior = getCoverAtSide(side);
if (coverBehavior == null) {
return false;
}
List<ItemStack> drops = coverBehavior.getDrops();
coverBehavior.onRemoved();
this.coverBehaviors[side.getIndex()] = null;
for (ItemStack dropStack : drops) {
Block.spawnAsEntity(getWorld(), getPos(), dropStack);
}
writeCustomData(-6, buffer -> buffer.writeByte(side.getIndex()));
if (getHolder() != null) {
getHolder().notifyBlockUpdate();
getHolder().markDirty();
}
onCoverPlacementUpdate();
return true;
}
use of gregtech.api.cover.CoverBehavior in project GregTech by GregTechCE.
the class MetaTileEntity method updateInputRedstoneSignals.
public void updateInputRedstoneSignals() {
for (EnumFacing side : EnumFacing.VALUES) {
int redstoneValue = GTUtility.getRedstonePower(getWorld(), getPos(), side);
int currentValue = sidedRedstoneInput[side.getIndex()];
if (redstoneValue != currentValue) {
this.sidedRedstoneInput[side.getIndex()] = redstoneValue;
CoverBehavior coverBehavior = getCoverAtSide(side);
if (coverBehavior != null) {
coverBehavior.onRedstoneInputSignalChange(redstoneValue);
}
}
}
}
use of gregtech.api.cover.CoverBehavior in project GregTech by GregTechCE.
the class MetaTileEntity method onCoverRightClick.
public final boolean onCoverRightClick(EntityPlayer playerIn, EnumHand hand, CuboidRayTraceResult result) {
CoverBehavior coverBehavior = getCoverAtSide(result.sideHit);
EnumActionResult coverResult = coverBehavior == null ? EnumActionResult.PASS : coverBehavior.onRightClick(playerIn, hand, result);
if (coverResult != EnumActionResult.PASS) {
return coverResult == EnumActionResult.SUCCESS;
}
return onRightClick(playerIn, hand, result.sideHit, result);
}
use of gregtech.api.cover.CoverBehavior in project GregTech by GregTechCE.
the class MetaTileEntity method readFromNBT.
public void readFromNBT(NBTTagCompound data) {
this.frontFacing = EnumFacing.VALUES[data.getInteger("FrontFacing")];
this.paintingColor = data.getInteger(TAG_KEY_PAINTING_COLOR);
this.cachedLightValue = data.getInteger("CachedLightValue");
if (shouldSerializeInventories()) {
GTUtility.readItems(importItems, "ImportInventory", data);
GTUtility.readItems(exportItems, "ExportInventory", data);
importFluids.deserializeNBT(data.getCompoundTag("ImportFluidInventory"));
exportFluids.deserializeNBT(data.getCompoundTag("ExportFluidInventory"));
}
for (MTETrait mteTrait : this.mteTraits) {
NBTTagCompound traitCompound = data.getCompoundTag(mteTrait.getName());
mteTrait.deserializeNBT(traitCompound);
}
NBTTagList coversList = data.getTagList("Covers", NBT.TAG_COMPOUND);
for (int index = 0; index < coversList.tagCount(); index++) {
NBTTagCompound tagCompound = coversList.getCompoundTagAt(index);
if (tagCompound.hasKey("CoverId", NBT.TAG_STRING)) {
EnumFacing coverSide = EnumFacing.VALUES[tagCompound.getByte("Side")];
ResourceLocation coverId = new ResourceLocation(tagCompound.getString("CoverId"));
CoverDefinition coverDefinition = CoverDefinition.getCoverById(coverId);
CoverBehavior coverBehavior = coverDefinition.createCoverBehavior(this, coverSide);
coverBehavior.readFromNBT(tagCompound);
this.coverBehaviors[coverSide.getIndex()] = coverBehavior;
}
}
this.isFragile = data.getBoolean(TAG_KEY_FRAGILE);
}
use of gregtech.api.cover.CoverBehavior in project GregTech by GregTechCE.
the class MetaTileEntity method getHighestOutputRedstoneSignal.
public final int getHighestOutputRedstoneSignal() {
int highestSignal = 0;
for (EnumFacing side : EnumFacing.VALUES) {
CoverBehavior behavior = getCoverAtSide(side);
int sidedOutput = sidedRedstoneOutput[side.getIndex()];
int sideResult = behavior == null ? sidedOutput : behavior.getRedstoneSignalOutput();
highestSignal = Math.max(highestSignal, sideResult);
}
return highestSignal;
}
Aggregations