use of gregtech.api.cover.CoverBehavior in project GregTech by GregTechCE.
the class MetaTileEntity method writeInitialSyncData.
public void writeInitialSyncData(PacketBuffer buf) {
buf.writeByte(this.frontFacing.getIndex());
buf.writeInt(this.paintingColor);
buf.writeShort(mteTraits.size());
for (MTETrait trait : mteTraits) {
buf.writeVarInt(trait.getNetworkID());
trait.writeInitialData(buf);
}
for (EnumFacing coverSide : EnumFacing.VALUES) {
CoverBehavior coverBehavior = getCoverAtSide(coverSide);
if (coverBehavior != null) {
int coverId = CoverDefinition.getNetworkIdForCover(coverBehavior.getCoverDefinition());
buf.writeVarInt(coverId);
coverBehavior.writeInitialSyncData(buf);
} else {
buf.writeVarInt(-1);
}
}
buf.writeBoolean(isFragile);
}
use of gregtech.api.cover.CoverBehavior in project GregTech by GregTechCE.
the class MetaTileEntity method onCoverScrewdriverClick.
public final boolean onCoverScrewdriverClick(EntityPlayer playerIn, EnumHand hand, CuboidRayTraceResult result) {
EnumFacing hitFacing = ICoverable.determineGridSideHit(result);
boolean accessingActiveOutputSide = false;
if (this.getCapability(GregtechTileCapabilities.CAPABILITY_ACTIVE_OUTPUT_SIDE, hitFacing) != null) {
accessingActiveOutputSide = playerIn.isSneaking();
}
EnumFacing coverSide = ICoverable.traceCoverSide(result);
CoverBehavior coverBehavior = coverSide == null ? null : getCoverAtSide(coverSide);
EnumActionResult coverResult = coverBehavior == null ? EnumActionResult.PASS : accessingActiveOutputSide ? EnumActionResult.PASS : coverBehavior.onScrewdriverClick(playerIn, hand, result);
if (coverResult != EnumActionResult.PASS) {
return coverResult == EnumActionResult.SUCCESS;
}
return onScrewdriverClick(playerIn, hand, result.sideHit, result);
}
use of gregtech.api.cover.CoverBehavior in project GregTech by GregTechCE.
the class MetaTileEntity method getCoverCapability.
public final <T> T getCoverCapability(Capability<T> capability, EnumFacing side) {
boolean isCoverable = capability == GregtechTileCapabilities.CAPABILITY_COVERABLE;
CoverBehavior coverBehavior = side == null ? null : getCoverAtSide(side);
T originalCapability = getCapability(capability, side);
if (coverBehavior != null && !isCoverable) {
return coverBehavior.getCapability(capability, originalCapability);
}
return originalCapability;
}
use of gregtech.api.cover.CoverBehavior in project GregTech by GregTechCE.
the class MetaTileEntity method dropAllCovers.
public final void dropAllCovers() {
for (EnumFacing coverSide : EnumFacing.VALUES) {
CoverBehavior coverBehavior = coverBehaviors[coverSide.getIndex()];
if (coverBehavior == null)
continue;
List<ItemStack> drops = coverBehavior.getDrops();
coverBehavior.onRemoved();
for (ItemStack dropStack : drops) {
Block.spawnAsEntity(getWorld(), getPos(), dropStack);
}
}
}
use of gregtech.api.cover.CoverBehavior in project GregTech by GregTechCE.
the class CoverMachineController method updateDisplayInventory.
private void updateDisplayInventory() {
EnumFacing controlledSide = getControllerMode().side;
ItemStack resultStack = ItemStack.EMPTY;
if (controlledSide != null) {
CoverBehavior coverBehavior = coverHolder.getCoverAtSide(controlledSide);
if (coverBehavior != null) {
resultStack = coverBehavior.getCoverDefinition().getDropItemStack();
}
}
this.displayInventory.setStackInSlot(0, resultStack);
}
Aggregations