use of logisticspipes.asm.ModDependentMethod in project LogisticsPipes by RS485.
the class LPMicroblockBlock method onBlockActivated.
@Override
@ModDependentMethod(modId = LPConstants.mcmpModID)
public boolean onBlockActivated(World world, BlockPos pos, IBlockState state, EntityPlayer player, EnumHand hand, EnumFacing facing, float hitX, float hitY, float hitZ) {
Pair<Vec3d, Vec3d> vectors = RayTraceHelper.getRayTraceVectors(player);
RayTraceResult hit = collisionRayTrace(getDefaultState(), world, pos, vectors.getLeft(), vectors.getRight());
if (hit != null && hit.subHit >= 0) {
return getTile(world, pos).map(t -> t.get(MCMultiPart.slotRegistry.getValue(hit.subHit)).get()).map(i -> i.getPart().onPartActivated(i, player, hand, (RayTraceResult) hit.hitInfo)).orElse(false);
}
return false;
}
use of logisticspipes.asm.ModDependentMethod in project LogisticsPipes by RS485.
the class LPMicroblockBlock method getPlayerRelativeBlockHardness.
@Override
@ModDependentMethod(modId = LPConstants.mcmpModID)
public float getPlayerRelativeBlockHardness(IBlockState state, @Nonnull EntityPlayer player, @Nonnull World world, @Nonnull BlockPos pos) {
Pair<Vec3d, Vec3d> vectors = RayTraceHelper.getRayTraceVectors(player);
RayTraceResult hit = collisionRayTrace(getDefaultState(), world, pos, vectors.getLeft(), vectors.getRight());
if (hit != null && hit.subHit >= 0) {
return getTile(world, pos).map(t -> t.get(MCMultiPart.slotRegistry.getValue(hit.subHit)).get()).map(i -> i.getPart().getPlayerRelativePartHardness(i, (RayTraceResult) hit.hitInfo, player)).orElse(0F);
}
if (hit != null) {
return super.getPlayerRelativeBlockHardness(state, player, world, pos);
}
return 0;
}
use of logisticspipes.asm.ModDependentMethod in project LogisticsPipes by RS485.
the class LPMicroblockBlock method addHitEffects.
@Override
@SideOnly(Side.CLIENT)
@ModDependentMethod(modId = LPConstants.mcmpModID)
public boolean addHitEffects(IBlockState mpState, World world, RayTraceResult hit, ParticleManager manager) {
if (hit != null && hit.subHit >= 0) {
BlockPos pos = hit.getBlockPos();
IPartInfo part = getTile(world, pos).get().get(MCMultiPart.slotRegistry.getValue(hit.subHit)).get();
if (!part.getPart().addHitEffects(part, (RayTraceResult) hit.hitInfo, manager)) {
if (part.getPart().getRenderType(part) != EnumBlockRenderType.INVISIBLE) {
int x = pos.getX(), y = pos.getY(), z = pos.getZ();
AxisAlignedBB aabb = part.getPart().getBoundingBox(part);
double pX = x + world.rand.nextDouble() * (aabb.maxX - aabb.minX - 0.2) + 0.1 + aabb.minX;
double pY = y + world.rand.nextDouble() * (aabb.maxY - aabb.minY - 0.2) + 0.1 + aabb.minY;
double pZ = z + world.rand.nextDouble() * (aabb.maxZ - aabb.minZ - 0.2) + 0.1 + aabb.minZ;
switch(hit.sideHit) {
case DOWN:
pY = y + aabb.minY - 0.1;
break;
case UP:
pY = y + aabb.maxY + 0.1;
break;
case NORTH:
pZ = z + aabb.minZ - 0.1;
break;
case SOUTH:
pZ = z + aabb.maxZ + 0.1;
break;
case WEST:
pX = x + aabb.minX - 0.1;
break;
case EAST:
pX = x + aabb.maxX + 0.1;
break;
}
manager.addEffect(new ParticleDigging(world, pX, pY, pZ, 0.0D, 0.0D, 0.0D, part.getPart().getActualState(part.getPartWorld(), pos, part)) {
}.setBlockPos(pos).multiplyVelocity(0.2F).multipleParticleScaleBy(0.6F));
}
}
return true;
}
return false;
}
use of logisticspipes.asm.ModDependentMethod in project LogisticsPipes by RS485.
the class LPMicroblockTileEntity method writeToNBT.
@Nonnull
@Override
@ModDependentMethod(modId = LPConstants.mcmpModID)
public NBTTagCompound writeToNBT(NBTTagCompound tag) {
tag = super.writeToNBT(tag);
NBTTagCompound multiPartTag = new NBTTagCompound();
if (this.getMultipartContainer() != null)
multiPartTag = this.getMultipartContainer().writeToNBT(multiPartTag);
tag.setTag("MCMultiPartData", multiPartTag);
return tag;
}
use of logisticspipes.asm.ModDependentMethod in project LogisticsPipes by RS485.
the class LPMicroblockTileEntity method getUpdatePacket.
@Override
@ModDependentMethod(modId = LPConstants.mcmpModID)
public SPacketUpdateTileEntity getUpdatePacket() {
NBTTagCompound nbt = new NBTTagCompound();
if (this.getMultipartContainer() != null) {
SPacketUpdateTileEntity packet = this.getMultipartContainer().getUpdatePacket();
nbt = ReflectionHelper.getPrivateField(SPacketUpdateTileEntity.class, packet, "nbt", "field_148860_e");
}
SPacketUpdateTileEntity superPacket = super.getUpdatePacket();
if (superPacket != null) {
nbt.setTag("LogisticsPipes:SuperUpdatePacket", superPacket.getNbtCompound());
}
return new SPacketUpdateTileEntity(this.getPartPos(), 0, nbt);
}
Aggregations