use of net.minecraft.util.EnumHand in project Spark-Client by Spark-Client-Development.
the class ShulkerAura method openShulk.
private void openShulk(BlockPos shulkPos) {
Vec3d pos = new Vec3d(shulkPos).add(0.5, 0.5, 0.5);
List<Vec3d> vecs = RaytraceUtil.getVisiblePointsForBox(mc.world.getBlockState(shulkPos).getBoundingBox(mc.world, shulkPos));
if (!vecs.isEmpty())
pos = PlayerUtil.getClosestPoint(vecs);
final RayTraceResult result = mc.world.rayTraceBlocks(PlayerUtil.getEyePos(), pos, false, true, false);
EnumFacing facing = (result == null || !shulkPos.equals(result.getBlockPos()) || result.sideHit == null) ? EnumFacing.UP : result.sideHit;
// rotate if needed
if (!Spark.rotationManager.rotate(RotationUtil.getViewRotations(pos, mc.player), AntiCheatConfig.INSTANCE.getCrystalRotStep(), 2, false)) {
return;
}
// send packet
EnumHand hand = EnumHand.OFF_HAND;
if (mc.player.getHeldItemOffhand().getItem() instanceof ItemEndCrystal && !(mc.player.getHeldItemMainhand().getItem() instanceof ItemEndCrystal))
hand = EnumHand.MAIN_HAND;
mc.player.connection.sendPacket(new CPacketPlayerTryUseItemOnBlock(shulkPos, facing, hand, (float) pos.x, (float) pos.y, (float) pos.z));
flag = true;
}
use of net.minecraft.util.EnumHand in project Spark-Client by Spark-Client-Development.
the class TntAura method OnUpdate.
@SubscribeEvent
void OnUpdate(PlayerUpdateEvent event) {
BlockPos newPos = GetTntBlock();
if (newPos == null || (targetFloorPos != null && !targetFloorPos.equals(newPos))) {
if (targetFloorPos == null)
Spark.sendInfo("TntAura has no target!");
else
Spark.sendInfo("TntAura has lost target!");
targetFloorPos = null;
disable();
return;
}
targetFloorPos = newPos;
if (cooldown > 0) {
cooldown--;
return;
}
if (pause.isOn()) {
// pause if tnt is exploding
List<Entity> l = mc.world.getEntitiesWithinAABBExcludingEntity(null, new AxisAlignedBB(targetFloorPos));
for (Entity e : l) {
if (e instanceof EntityTNTPrimed) {
EntityTNTPrimed tnt = (EntityTNTPrimed) e;
if (tnt.ticksExisted > 60)
return;
}
}
}
BlockPos targetPos = targetFloorPos.add(0, getH(), 0);
ArrayList<BlockPos> toPlace = new ArrayList<BlockPos>();
for (BlockPos s : WorldUtils.getSurroundBlocks(targetPos)) {
toPlace.add(s.add(0, 0, 0));
toPlace.add(s.add(0, -1, 0));
toPlace.add(s.add(0, -2, 0));
}
// sort by distance
Collections.sort(toPlace, new Comparator<BlockPos>() {
@Override
public int compare(BlockPos fruit2, BlockPos fruit1) {
return (int) ((PlayerUtil.getDistance(fruit1) - PlayerUtil.getDistance(fruit2)) * 5);
}
});
for (BlockPos pos : toPlace) {
if (mc.world.getBlockState(pos).getBlock().material.isReplaceable()) {
BlockInteractUtil.BlockPlaceResult res = place(pos, new HardSolidBlockSwitchItem());
if (res != BlockInteractUtil.BlockPlaceResult.FAILED) {
return;
}
}
}
if (mc.world.getBlockState(targetPos).getBlock() == Blocks.TNT) {
if (closeTop.isOn()) {
if (mc.world.getBlockState(targetPos.add(0, 1, 0)).getBlock().material.isReplaceable()) {
place(targetPos.add(0, 1, 0), new HardSolidBlockSwitchItem());
return;
}
}
Vec3d pos = PlayerUtil.getClosestPoint(RaytraceUtil.getPointToLookAtBlock(targetPos));
EnumFacing facing = EnumFacing.UP;
if (pos == null)
pos = new Vec3d(targetPos.getX() + 0.5, targetPos.getY() + 0.5, targetPos.getZ() + 0.5);
else
facing = mc.world.rayTraceBlocks(new Vec3d(mc.player.posX, mc.player.posY + (double) mc.player.getEyeHeight(), mc.player.posZ), pos, false).sideHit;
if (AntiCheatConfig.INSTANCE.getBlockRotate())
if (!Spark.rotationManager.rotate(Spark.rotationManager.getLegitRotations(pos), AntiCheatConfig.getInstance().getBlockRotStep(), 6, false, true))
return;
EnumHand hand = Spark.switchManager.Switch(new SpecItemSwitchItem(Items.FLINT_AND_STEEL), ItemSwitcher.usedHand.Both);
if (hand == null)
return;
BlockInteractUtil.processRightClickBlock(targetPos, facing, true, hand, pos);
cooldown = delay.getValue();
} else
place(targetPos, new SpecBlockSwitchItem(Blocks.TNT));
}
use of net.minecraft.util.EnumHand in project pnc-repressurized by TeamPneumatic.
the class RenderPressureTubeModule method render.
@Override
public void render(TileEntityPressureTube tile, double x, double y, double z, float partialTicks, int destroyStage, float alpha) {
if (tile.getCamouflage() != null) {
return;
}
Minecraft mc = Minecraft.getMinecraft();
EnumHand holdingModule = null;
if (mc.player.getHeldItem(EnumHand.MAIN_HAND).getItem() instanceof ItemTubeModule) {
holdingModule = EnumHand.MAIN_HAND;
} else if (mc.player.getHeldItem(EnumHand.OFF_HAND).getItem() instanceof ItemTubeModule) {
holdingModule = EnumHand.OFF_HAND;
}
boolean render = false;
for (int i = 0; i < tile.modules.length; i++) {
if (tile.modules[i] != null)
render = true;
}
if (!render && holdingModule == null)
return;
GlStateManager.pushMatrix();
mc.getTextureManager().bindTexture(TextureMap.LOCATION_BLOCKS_TEXTURE);
GlStateManager.enableTexture2D();
GlStateManager.disableAlpha();
GlStateManager.color(1, 1, 1);
GlStateManager.translate((float) x + 0.5F, (float) y + 1.5F, (float) z + 0.5F);
GlStateManager.scale(1.0F, -1F, -1F);
// "fake" module is for showing a preview of where the module would be placed
if (holdingModule != null)
attachFakeModule(mc, tile, holdingModule);
for (int i = 0; i < tile.modules.length; i++) {
TubeModule module = tile.modules[i];
if (module != null) {
if (module.isFake()) {
GlStateManager.enableBlend();
GlStateManager.blendFunc(GlStateManager.SourceFactor.SRC_ALPHA, GlStateManager.DestFactor.ONE_MINUS_SRC_ALPHA);
GlStateManager.color(1, 1, 1, 0.5f);
}
module.getModel().renderModel(0.0625f, module, partialTicks);
module.doExtraRendering();
if (module.isFake()) {
tile.modules[i] = null;
GlStateManager.disableBlend();
}
GlStateManager.color(1, 1, 1, 1);
}
}
GlStateManager.enableAlpha();
GlStateManager.popMatrix();
}
use of net.minecraft.util.EnumHand in project QuarryPlus by Kotori316.
the class BlockController method onBlockActivated.
@Override
public boolean onBlockActivated(World worldIn, BlockPos pos, IBlockState state, EntityPlayer playerIn, EnumHand hand, EnumFacing facing, float hitX, float hitY, float hitZ) {
if (InvUtils.isDebugItem(playerIn, hand))
return true;
if (!playerIn.isSneaking()) {
if (!worldIn.isRemote) {
if (!Config.content().disableMapJ().get(SYMBOL)) {
List<EntityEntry> entries = ForgeRegistries.ENTITIES.getValues().stream().filter(entity -> entity.getEntityClass() != null && !Modifier.isAbstract(entity.getEntityClass().getModifiers()) && !Config.content().spawnerBlacklist().contains(entity.getRegistryName())).collect(Collectors.toList());
PacketHandler.sendToClient(AvailableEntities.create(pos, worldIn.provider.getDimension(), entries), (EntityPlayerMP) playerIn);
} else {
VersionUtil.sendMessage(playerIn, new TextComponentString("Spawner Controller is disabled."), true);
}
}
return true;
}
return super.onBlockActivated(worldIn, pos, state, playerIn, hand, facing, hitX, hitY, hitZ);
}
use of net.minecraft.util.EnumHand in project aquaacrobatics by Fuzss.
the class ModelBipedMixin method setRotationAnglesPre.
@Inject(method = "setRotationAngles", at = @At(value = "FIELD", target = "Lnet/minecraft/client/model/ModelBiped;swingProgress:F"))
public void setRotationAnglesPre(float limbSwing, float limbSwingAmount, float ageInTicks, float netHeadYaw, float headPitch, float scaleFactor, Entity entityIn, CallbackInfo callbackInfo) {
if (!ConfigHandler.MiscellaneousConfig.eatingAnimation || !(entityIn instanceof EntityLivingBase)) {
return;
}
EntityLivingBase livingEntityIn = (EntityLivingBase) entityIn;
int inUseCount = livingEntityIn.getItemInUseCount();
if (livingEntityIn.isHandActive() && inUseCount > 0) {
EnumHand hand = livingEntityIn.getActiveHand();
ItemStack stack = livingEntityIn.getHeldItem(hand);
EnumHandSide handSide = livingEntityIn.getPrimaryHand();
if (stack.getItemUseAction() == EnumAction.EAT || stack.getItemUseAction() == EnumAction.DRINK) {
boolean isRight = (hand == EnumHand.MAIN_HAND ? handSide : handSide.opposite()) == EnumHandSide.RIGHT;
float partialTicks = (float) MathHelper.frac(ageInTicks);
float animationCount = inUseCount - partialTicks + 1.0F;
float useRatio = animationCount / (float) stack.getMaxItemUseDuration();
float f = 1.0F - (float) Math.pow(useRatio, 27.0D);
if (useRatio < 0.8F) {
f += MathHelper.abs(MathHelper.cos(animationCount / 4.0F * (float) Math.PI) * 0.1F);
}
ModelRenderer bipedArm = isRight ? this.bipedRightArm : this.bipedLeftArm;
bipedArm.rotateAngleX = f * (bipedArm.rotateAngleX * 0.5F - ((float) Math.PI * 4.0F / 10.0F));
bipedArm.rotateAngleY = f * (float) Math.PI / 6F * (isRight ? -1.0F : 1.0F);
}
}
}
Aggregations