net.minecraft.entity.ItemEntity Java Examples
The following examples show how to use
net.minecraft.entity.ItemEntity.
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: BasicSolarPanelBlock.java From Galacticraft-Rewoven with MIT License | 6 votes |
private void dropInventory(World world, BlockPos blockPos) { BlockEntity blockEntity = world.getBlockEntity(blockPos); if (blockEntity != null) { if (blockEntity instanceof BasicSolarPanelBlockEntity) { BasicSolarPanelBlockEntity basicSolarPanelBlockEntity = (BasicSolarPanelBlockEntity) blockEntity; for (int i = 0; i < basicSolarPanelBlockEntity.getInventory().getSize(); i++) { ItemStack itemStack = basicSolarPanelBlockEntity.getInventory().getStack(i); if (itemStack != null) { world.spawnEntity(new ItemEntity(world, blockPos.getX(), blockPos.getY() + 1, blockPos.getZ(), itemStack)); } } } } }
Example #2
Source File: OxygenCollectorBlock.java From Galacticraft-Rewoven with MIT License | 6 votes |
@Override public void onBreak(World world, BlockPos blockPos, BlockState blockState, PlayerEntity playerEntity) { super.onBreak(world, blockPos, blockState, playerEntity); BlockEntity blockEntity = world.getBlockEntity(blockPos); if (blockEntity != null) { if (blockEntity instanceof OxygenCollectorBlockEntity) { OxygenCollectorBlockEntity be = (OxygenCollectorBlockEntity) blockEntity; for (int i = 0; i < be.getInventory().getSize(); i++) { ItemStack itemStack = be.getInventory().getStack(i); if (itemStack != null) { world.spawnEntity(new ItemEntity(world, blockPos.getX(), blockPos.getY() + 1, blockPos.getZ(), itemStack)); } } } } }
Example #3
Source File: ItemEspHack.java From Wurst7 with GNU General Public License v3.0 | 6 votes |
private void renderTracers(double partialTicks) { GL11.glEnable(GL11.GL_BLEND); GL11.glDisable(GL11.GL_TEXTURE_2D); GL11.glDisable(GL11.GL_DEPTH_TEST); GL11.glColor4f(1, 1, 0, 0.5F); Vec3d start = RotationUtils.getClientLookVec().add(RenderUtils.getCameraPos()); GL11.glBegin(GL11.GL_LINES); for(ItemEntity e : items) { Vec3d end = e.getBoundingBox().getCenter() .subtract(new Vec3d(e.getX(), e.getY(), e.getZ()) .subtract(e.prevX, e.prevY, e.prevZ) .multiply(1 - partialTicks)); GL11.glVertex3d(start.x, start.y, start.z); GL11.glVertex3d(end.x, end.y, end.z); } GL11.glEnd(); }
Example #4
Source File: ColoredPumpkinBlock.java From the-hallow with MIT License | 6 votes |
@Override public ActionResult onUse(BlockState blockState, World world, BlockPos blockPos, PlayerEntity playerEntity, Hand hand, BlockHitResult blockHitResult) { ItemStack stack = playerEntity.getStackInHand(hand); if (stack.getItem() == Items.SHEARS) { if (!world.isClient) { Direction side = blockHitResult.getSide(); Direction facingTowardPlayer = side.getAxis() == Direction.Axis.Y ? playerEntity.getHorizontalFacing().getOpposite() : side; world.playSound(null, blockPos, SoundEvents.BLOCK_PUMPKIN_CARVE, SoundCategory.BLOCKS, 1.0F, 1.0F); world.setBlockState(blockPos, HallowedBlocks.CARVED_PUMPKIN_COLORS.get(this.color).getDefaultState().with(CarvedPumpkinBlock.FACING, facingTowardPlayer), 11); ItemEntity itemEntity = new ItemEntity(world, blockPos.getX() + 0.5D + facingTowardPlayer.getOffsetX() * 0.65D, blockPos.getY() + 0.1D, blockPos.getZ() + 0.5D + facingTowardPlayer.getOffsetZ() * 0.65D, new ItemStack(Items.PUMPKIN_SEEDS, 4)); itemEntity.setVelocity(0.05D * (double) facingTowardPlayer.getOffsetX() + world.random.nextDouble() * 0.02D, 0.05D, 0.05D * (double) facingTowardPlayer.getOffsetZ() + world.random.nextDouble() * 0.02D); world.spawnEntity(itemEntity); stack.damage(1, playerEntity, (playerEntityVar) -> { playerEntityVar.sendToolBreakStatus(hand); }); } return ActionResult.SUCCESS; } return super.onUse(blockState, world, blockPos, playerEntity, hand, blockHitResult); }
Example #5
Source File: BloodBlock.java From the-hallow with MIT License | 6 votes |
@Override public void onEntityCollision(BlockState blockState, World world, BlockPos pos, Entity entity) { if(!world.isClient) { if (pos.equals(entity.getBlockPos())) { if (entity instanceof ItemEntity && !((ItemEntity) entity).getStack().isEmpty()) { ItemEntity itemEntity = (ItemEntity) entity; ItemStack stack = itemEntity.getStack(); if (stack.getItem() instanceof DyeableItem) { DyeableItem item = (DyeableItem) stack.getItem(); if (item.hasColor(stack)) item.setColor(stack, 0xFF0000 | item.getColor(stack)); else item.setColor(stack, 0xFF0000); return; } } } } super.onEntityCollision(blockState, world, pos, entity); }
Example #6
Source File: OptimizedExplosion.java From fabric-carpet with MIT License | 6 votes |
private static void method_24023(ObjectArrayList<Pair<ItemStack, BlockPos>> objectArrayList, ItemStack itemStack, BlockPos blockPos) { int i = objectArrayList.size(); for(int j = 0; j < i; ++j) { Pair<ItemStack, BlockPos> pair = (Pair)objectArrayList.get(j); ItemStack itemStack2 = pair.getLeft(); if (ItemEntity.canMerge(itemStack2, itemStack)) { ItemStack itemStack3 = ItemEntity.merge(itemStack2, itemStack, 16); objectArrayList.set(j, Pair.of(itemStack3, pair.getRight())); if (itemStack.isEmpty()) { return; } } } objectArrayList.add(Pair.of(itemStack, blockPos)); }
Example #7
Source File: CoalGeneratorBlock.java From Galacticraft-Rewoven with MIT License | 6 votes |
@Override public void onBreak(World world, BlockPos blockPos, BlockState blockState, PlayerEntity playerEntity) { super.onBreak(world, blockPos, blockState, playerEntity); BlockEntity blockEntity = world.getBlockEntity(blockPos); if (blockEntity != null) { if (blockEntity instanceof CoalGeneratorBlockEntity) { CoalGeneratorBlockEntity coalGeneratorBlockEntity = (CoalGeneratorBlockEntity) blockEntity; for (int i = 0; i < coalGeneratorBlockEntity.getInventory().getSize(); i++) { ItemStack itemStack = coalGeneratorBlockEntity.getInventory().getStack(i); if (itemStack != null) { world.spawnEntity(new ItemEntity(world, blockPos.getX(), blockPos.getY() + 1, blockPos.getZ(), itemStack)); } } } } }
Example #8
Source File: EnergyStorageModuleBlock.java From Galacticraft-Rewoven with MIT License | 6 votes |
@Override public void onBreak(World world, BlockPos blockPos, BlockState blockState, PlayerEntity playerEntity) { super.onBreak(world, blockPos, blockState, playerEntity); BlockEntity blockEntity = world.getBlockEntity(blockPos); if (blockEntity != null) { if (blockEntity instanceof EnergyStorageModuleBlockEntity) { EnergyStorageModuleBlockEntity be = (EnergyStorageModuleBlockEntity) blockEntity; for (int i = 0; i < be.getInventory().getSize(); i++) { ItemStack itemStack = be.getInventory().getStack(i); if (itemStack != null) { world.spawnEntity(new ItemEntity(world, blockPos.getX(), blockPos.getY() + 1, blockPos.getZ(), itemStack)); } } } } }
Example #9
Source File: RefineryBlock.java From Galacticraft-Rewoven with MIT License | 6 votes |
@Override public void onBreak(World world, BlockPos blockPos, BlockState blockState, PlayerEntity playerEntity) { super.onBreak(world, blockPos, blockState, playerEntity); BlockEntity blockEntity = world.getBlockEntity(blockPos); if (blockEntity != null) { if (blockEntity instanceof RefineryBlockEntity) { RefineryBlockEntity refineryBlockEntity = (RefineryBlockEntity) blockEntity; for (int i = 0; i < refineryBlockEntity.getInventory().getSize(); i++) { ItemStack itemStack = refineryBlockEntity.getInventory().getStack(i); if (itemStack != null) { world.spawnEntity(new ItemEntity(world, blockPos.getX(), blockPos.getY() + 1, blockPos.getZ(), itemStack)); } } } } }
Example #10
Source File: ElectricCompressorBlock.java From Galacticraft-Rewoven with MIT License | 6 votes |
@Override public void onBreak(World world, BlockPos blockPos, BlockState blockState, PlayerEntity playerEntity) { super.onBreak(world, blockPos, blockState, playerEntity); BlockEntity blockEntity = world.getBlockEntity(blockPos); if (blockEntity != null) { if (blockEntity instanceof ElectricCompressorBlockEntity) { ElectricCompressorBlockEntity be = (ElectricCompressorBlockEntity) blockEntity; for (int i = 0; i < be.getInventory().getSize(); i++) { ItemStack itemStack = be.getInventory().getStack(i); if (!itemStack.isEmpty()) { world.spawnEntity(new ItemEntity(world, blockPos.getX(), blockPos.getY() + 1, blockPos.getZ(), itemStack.copy())); } } } } }
Example #11
Source File: CompressorBlock.java From Galacticraft-Rewoven with MIT License | 6 votes |
@Override public void onBreak(World world, BlockPos blockPos, BlockState blockState, PlayerEntity playerEntity) { super.onBreak(world, blockPos, blockState, playerEntity); BlockEntity blockEntity = world.getBlockEntity(blockPos); if (blockEntity != null) { if (blockEntity instanceof CompressorBlockEntity) { CompressorBlockEntity be = (CompressorBlockEntity) blockEntity; for (int i = 0; i < be.getInventory().getSize(); i++) { ItemStack itemStack = be.getInventory().getStack(i); if (!itemStack.isEmpty()) { world.spawnEntity(new ItemEntity(world, blockPos.getX(), blockPos.getY() + 1, blockPos.getZ(), itemStack.copy())); } } } } }
Example #12
Source File: CircuitFabricatorBlock.java From Galacticraft-Rewoven with MIT License | 6 votes |
@Override public void onBreak(World world, BlockPos blockPos, BlockState blockState, PlayerEntity playerEntity) { super.onBreak(world, blockPos, blockState, playerEntity); BlockEntity blockEntity = world.getBlockEntity(blockPos); if (blockEntity != null) { if (blockEntity instanceof CircuitFabricatorBlockEntity) { CircuitFabricatorBlockEntity circuitFabricatorBlockEntity = (CircuitFabricatorBlockEntity) blockEntity; for (int i = 0; i < circuitFabricatorBlockEntity.getInventory().getSize(); i++) { ItemStack itemStack = circuitFabricatorBlockEntity.getInventory().getStack(i); if (itemStack != null) { world.spawnEntity(new ItemEntity(world, blockPos.getX(), blockPos.getY() + 1, blockPos.getZ(), itemStack)); } } } } }
Example #13
Source File: ItemEntityMixin.java From fabric-carpet with MIT License | 5 votes |
@Inject( method = "tryMerge(Lnet/minecraft/entity/ItemEntity;)V", at = @At("HEAD"), cancellable = true ) private void tryStackShulkerBoxes(ItemEntity other, CallbackInfo ci) { ItemEntity self = (ItemEntity)(Object)this; ItemStack selfStack = self.getStack(); if (!CarpetSettings.stackableShulkerBoxes || !(selfStack.getItem() instanceof BlockItem) || !(((BlockItem)selfStack.getItem()).getBlock() instanceof ShulkerBoxBlock)) { return; } ItemStack otherStack = other.getStack(); if (selfStack.getItem() == otherStack.getItem() && !InventoryHelper.shulkerBoxHasItems(selfStack) && !InventoryHelper.shulkerBoxHasItems(otherStack) && selfStack.hasTag() == otherStack.hasTag() && selfStack.getCount() + otherStack.getCount() <= SHULKERBOX_MAX_STACK_AMOUNT) { int amount = Math.min(otherStack.getCount(), SHULKERBOX_MAX_STACK_AMOUNT - selfStack.getCount()); selfStack.increment(amount); self.setStack(selfStack); this.pickupDelay = Math.max(((ItemEntityInterface)other).getPickupDelayCM(), this.pickupDelay); this.age = Math.min(((ItemEntityInterface)other).getAgeCM(), this.age); otherStack.decrement(amount); if (otherStack.isEmpty()) { other.remove(); } else { other.setStack(otherStack); } ci.cancel(); } }
Example #14
Source File: ItemEntityMixin.java From fabric-carpet with MIT License | 5 votes |
@Inject(method="<init>(Lnet/minecraft/world/World;DDDLnet/minecraft/item/ItemStack;)V", at = @At("RETURN")) private void removeEmptyShulkerBoxTags(World worldIn, double x, double y, double z, ItemStack stack, CallbackInfo ci) { if (CarpetSettings.stackableShulkerBoxes && stack.getItem() instanceof BlockItem && ((BlockItem)stack.getItem()).getBlock() instanceof ShulkerBoxBlock) { if (InventoryHelper.cleanUpShulkerBoxTag(stack)) { ((ItemEntity) (Object) this).setStack(stack); } } }
Example #15
Source File: Tracers.java From bleachhack-1.14 with GNU General Public License v3.0 | 5 votes |
@Subscribe public void onRender(Event3DRender event) { final float thick = (float) getSettings().get(6).toSlider().getValue(); for (Entity e: mc.world.getEntities()) { Vec3d vec = e.getPos(); Vec3d vec2 = new Vec3d(0, 0, 75).rotateX(-(float) Math.toRadians(mc.cameraEntity.pitch)) .rotateY(-(float) Math.toRadians(mc.cameraEntity.yaw)) .add(mc.cameraEntity.getPos().add(0, mc.cameraEntity.getEyeHeight(mc.cameraEntity.getPose()), 0)); if (e instanceof PlayerEntity && e != mc.player && e != mc.cameraEntity && getSettings().get(0).toToggle().state) { RenderUtils.drawLine(vec2.x,vec2.y,vec2.z,vec.x,vec.y,vec.z,1f,0f,0f,thick); RenderUtils.drawLine(vec.x,vec.y,vec.z, vec.x,vec.y+(e.getHeight()/1.1),vec.z,1f,0f,0f,thick); } else if (e instanceof Monster && getSettings().get(1).toToggle().state) { RenderUtils.drawLine(vec2.x,vec2.y,vec2.z,vec.x,vec.y,vec.z,0f,0f,0f,thick); RenderUtils.drawLine(vec.x,vec.y,vec.z, vec.x,vec.y+(e.getHeight()/1.1),vec.z,0f,0f,0f,thick); } else if (EntityUtils.isAnimal(e) && getSettings().get(2).toToggle().state) { RenderUtils.drawLine(vec2.x,vec2.y,vec2.z,vec.x,vec.y,vec.z,0f,1f,0f,thick); RenderUtils.drawLine(vec.x,vec.y,vec.z, vec.x,vec.y+(e.getHeight()/1.1),vec.z,0f,1f,0f,thick); } else if (e instanceof ItemEntity && getSettings().get(3).toToggle().state) { RenderUtils.drawLine(vec2.x,vec2.y,vec2.z,vec.x,vec.y,vec.z,1f,0.7f,0f,thick); RenderUtils.drawLine(vec.x,vec.y,vec.z, vec.x,vec.y+(e.getHeight()/1.1),vec.z,1f,0.7f,0f,thick); } else if (e instanceof EnderCrystalEntity && getSettings().get(4).toToggle().state) { RenderUtils.drawLine(vec2.x,vec2.y,vec2.z,vec.x,vec.y,vec.z,1f, 0f, 1f,thick); RenderUtils.drawLine(vec.x,vec.y,vec.z, vec.x,vec.y+(e.getHeight()/1.1),vec.z,1f, 0f, 1f,thick); } else if ((e instanceof BoatEntity || e instanceof AbstractMinecartEntity) && getSettings().get(5).toToggle().state) { RenderUtils.drawLine(vec2.x,vec2.y,vec2.z,vec.x,vec.y,vec.z,0.5f, 0.5f, 0.5f,thick); RenderUtils.drawLine(vec.x,vec.y,vec.z, vec.x,vec.y+(e.getHeight()/1.1),vec.z,0.5f, 0.5f, 0.5f,thick); } } }
Example #16
Source File: ESP.java From bleachhack-1.14 with GNU General Public License v3.0 | 5 votes |
@Subscribe public void onTick(EventTick event) { for (Entity e: mc.world.getEntities()) { if (e instanceof PlayerEntity && e != mc.player && getSettings().get(0).toToggle().state) { EntityUtils.setGlowing(e, Formatting.RED, "players"); } else if (e instanceof Monster && getSettings().get(1).toToggle().state) { EntityUtils.setGlowing(e, Formatting.DARK_BLUE, "mobs"); } else if (EntityUtils.isAnimal(e) && getSettings().get(2).toToggle().state) { EntityUtils.setGlowing(e, Formatting.GREEN, "passive"); } else if (e instanceof ItemEntity && getSettings().get(3).toToggle().state) { EntityUtils.setGlowing(e, Formatting.GOLD, "items"); } else if (e instanceof EnderCrystalEntity && getSettings().get(4).toToggle().state) { EntityUtils.setGlowing(e, Formatting.LIGHT_PURPLE, "crystals"); } else if ((e instanceof BoatEntity || e instanceof AbstractMinecartEntity) && getSettings().get(5).toToggle().state) { EntityUtils.setGlowing(e, Formatting.GRAY, "vehicles"); } else { e.setGlowing(false); } } }
Example #17
Source File: Tracers.java From bleachhack-1.14 with GNU General Public License v3.0 | 5 votes |
@Subscribe public void onRender(Event3DRender event) { final float thick = (float) getSettings().get(6).toSlider().getValue(); for (Entity e: mc.world.getEntities()) { Vec3d vec = e.getPos(); Vec3d vec2 = new Vec3d(0, 0, 75).rotateX(-(float) Math.toRadians(mc.cameraEntity.pitch)) .rotateY(-(float) Math.toRadians(mc.cameraEntity.yaw)) .add(mc.cameraEntity.getPos().add(0, mc.cameraEntity.getEyeHeight(mc.cameraEntity.getPose()), 0)); if (e instanceof PlayerEntity && e != mc.player && e != mc.cameraEntity && getSettings().get(0).toToggle().state) { RenderUtils.drawLine(vec2.x,vec2.y,vec2.z,vec.x,vec.y,vec.z,1f,0f,0f,thick); RenderUtils.drawLine(vec.x,vec.y,vec.z, vec.x,vec.y+(e.getHeight()/1.1),vec.z,1f,0f,0f,thick); } else if (e instanceof Monster && getSettings().get(1).toToggle().state) { RenderUtils.drawLine(vec2.x,vec2.y,vec2.z,vec.x,vec.y,vec.z,0f,0f,0f,thick); RenderUtils.drawLine(vec.x,vec.y,vec.z, vec.x,vec.y+(e.getHeight()/1.1),vec.z,0f,0f,0f,thick); } else if (EntityUtils.isAnimal(e) && getSettings().get(2).toToggle().state) { RenderUtils.drawLine(vec2.x,vec2.y,vec2.z,vec.x,vec.y,vec.z,0f,1f,0f,thick); RenderUtils.drawLine(vec.x,vec.y,vec.z, vec.x,vec.y+(e.getHeight()/1.1),vec.z,0f,1f,0f,thick); } else if (e instanceof ItemEntity && getSettings().get(3).toToggle().state) { RenderUtils.drawLine(vec2.x,vec2.y,vec2.z,vec.x,vec.y,vec.z,1f,0.7f,0f,thick); RenderUtils.drawLine(vec.x,vec.y,vec.z, vec.x,vec.y+(e.getHeight()/1.1),vec.z,1f,0.7f,0f,thick); } else if (e instanceof EndCrystalEntity && getSettings().get(4).toToggle().state) { RenderUtils.drawLine(vec2.x,vec2.y,vec2.z,vec.x,vec.y,vec.z,1f, 0f, 1f,thick); RenderUtils.drawLine(vec.x,vec.y,vec.z, vec.x,vec.y+(e.getHeight()/1.1),vec.z,1f, 0f, 1f,thick); } else if ((e instanceof BoatEntity || e instanceof AbstractMinecartEntity) && getSettings().get(5).toToggle().state) { RenderUtils.drawLine(vec2.x,vec2.y,vec2.z,vec.x,vec.y,vec.z,0.5f, 0.5f, 0.5f,thick); RenderUtils.drawLine(vec.x,vec.y,vec.z, vec.x,vec.y+(e.getHeight()/1.1),vec.z,0.5f, 0.5f, 0.5f,thick); } } }
Example #18
Source File: ESP.java From bleachhack-1.14 with GNU General Public License v3.0 | 5 votes |
@Subscribe public void onTick(EventTick event) { for (Entity e: mc.world.getEntities()) { if (e instanceof PlayerEntity && e != mc.player && getSettings().get(0).toToggle().state) { EntityUtils.setGlowing(e, Formatting.RED, "players"); } else if (e instanceof Monster && getSettings().get(1).toToggle().state) { EntityUtils.setGlowing(e, Formatting.DARK_BLUE, "mobs"); } else if (EntityUtils.isAnimal(e) && getSettings().get(2).toToggle().state) { EntityUtils.setGlowing(e, Formatting.GREEN, "passive"); } else if (e instanceof ItemEntity && getSettings().get(3).toToggle().state) { EntityUtils.setGlowing(e, Formatting.GOLD, "items"); } else if (e instanceof EndCrystalEntity && getSettings().get(4).toToggle().state) { EntityUtils.setGlowing(e, Formatting.LIGHT_PURPLE, "crystals"); } else if ((e instanceof BoatEntity || e instanceof AbstractMinecartEntity) && getSettings().get(5).toToggle().state) { EntityUtils.setGlowing(e, Formatting.GRAY, "vehicles"); } else { e.setGlowing(false); } } }
Example #19
Source File: Tracers.java From bleachhack-1.14 with GNU General Public License v3.0 | 5 votes |
@Subscribe public void onRender(Event3DRender event) { final float thick = (float) getSettings().get(6).toSlider().getValue(); for (Entity e: mc.world.getEntities()) { Vec3d vec = e.getPos(); Vec3d vec2 = new Vec3d(0, 0, 75).rotateX(-(float) Math.toRadians(mc.cameraEntity.pitch)) .rotateY(-(float) Math.toRadians(mc.cameraEntity.yaw)) .add(mc.cameraEntity.getPos().add(0, mc.cameraEntity.getEyeHeight(mc.cameraEntity.getPose()), 0)); if (e instanceof PlayerEntity && e != mc.player && e != mc.cameraEntity && getSettings().get(0).toToggle().state) { RenderUtils.drawLine(vec2.x,vec2.y,vec2.z,vec.x,vec.y,vec.z,1f,0f,0f,thick); RenderUtils.drawLine(vec.x,vec.y,vec.z, vec.x,vec.y+(e.getHeight()/1.1),vec.z,1f,0f,0f,thick); } else if (e instanceof Monster && getSettings().get(1).toToggle().state) { RenderUtils.drawLine(vec2.x,vec2.y,vec2.z,vec.x,vec.y,vec.z,0f,0f,0f,thick); RenderUtils.drawLine(vec.x,vec.y,vec.z, vec.x,vec.y+(e.getHeight()/1.1),vec.z,0f,0f,0f,thick); } else if (EntityUtils.isAnimal(e) && getSettings().get(2).toToggle().state) { RenderUtils.drawLine(vec2.x,vec2.y,vec2.z,vec.x,vec.y,vec.z,0f,1f,0f,thick); RenderUtils.drawLine(vec.x,vec.y,vec.z, vec.x,vec.y+(e.getHeight()/1.1),vec.z,0f,1f,0f,thick); } else if (e instanceof ItemEntity && getSettings().get(3).toToggle().state) { RenderUtils.drawLine(vec2.x,vec2.y,vec2.z,vec.x,vec.y,vec.z,1f,0.7f,0f,thick); RenderUtils.drawLine(vec.x,vec.y,vec.z, vec.x,vec.y+(e.getHeight()/1.1),vec.z,1f,0.7f,0f,thick); } else if (e instanceof EnderCrystalEntity && getSettings().get(4).toToggle().state) { RenderUtils.drawLine(vec2.x,vec2.y,vec2.z,vec.x,vec.y,vec.z,1f, 0f, 1f,thick); RenderUtils.drawLine(vec.x,vec.y,vec.z, vec.x,vec.y+(e.getHeight()/1.1),vec.z,1f, 0f, 1f,thick); } else if ((e instanceof BoatEntity || e instanceof AbstractMinecartEntity) && getSettings().get(5).toToggle().state) { RenderUtils.drawLine(vec2.x,vec2.y,vec2.z,vec.x,vec.y,vec.z,0.5f, 0.5f, 0.5f,thick); RenderUtils.drawLine(vec.x,vec.y,vec.z, vec.x,vec.y+(e.getHeight()/1.1),vec.z,0.5f, 0.5f, 0.5f,thick); } } }
Example #20
Source File: ESP.java From bleachhack-1.14 with GNU General Public License v3.0 | 5 votes |
@Subscribe public void onTick(EventTick event) { for (Entity e: mc.world.getEntities()) { if (e instanceof PlayerEntity && e != mc.player && getSettings().get(0).toToggle().state) { EntityUtils.setGlowing(e, Formatting.RED, "players"); } else if (e instanceof Monster && getSettings().get(1).toToggle().state) { EntityUtils.setGlowing(e, Formatting.DARK_BLUE, "mobs"); } else if (EntityUtils.isAnimal(e) && getSettings().get(2).toToggle().state) { EntityUtils.setGlowing(e, Formatting.GREEN, "passive"); } else if (e instanceof ItemEntity && getSettings().get(3).toToggle().state) { EntityUtils.setGlowing(e, Formatting.GOLD, "items"); } else if (e instanceof EnderCrystalEntity && getSettings().get(4).toToggle().state) { EntityUtils.setGlowing(e, Formatting.LIGHT_PURPLE, "crystals"); } else if ((e instanceof BoatEntity || e instanceof AbstractMinecartEntity) && getSettings().get(5).toToggle().state) { EntityUtils.setGlowing(e, Formatting.GRAY, "vehicles"); } else { e.setGlowing(false); } } }
Example #21
Source File: LivingDropsEvent.java From patchwork-api with GNU Lesser General Public License v2.1 | 5 votes |
public LivingDropsEvent(LivingEntity entity, DamageSource source, Collection<ItemEntity> drops, int lootingLevel, boolean recentlyHit) { super(entity); this.source = source; this.drops = drops; this.lootingLevel = lootingLevel; this.recentlyHit = recentlyHit; }
Example #22
Source File: MixinEntity.java From patchwork-api with GNU Lesser General Public License v2.1 | 5 votes |
@Redirect(method = "dropStack(Lnet/minecraft/item/ItemStack;F)Lnet/minecraft/entity/ItemEntity;", at = @At(value = "INVOKE", target = "Lnet/minecraft/world/World;spawnEntity(Lnet/minecraft/entity/Entity;)Z")) private boolean hookDropStackForCapture(World world, Entity entity) { ItemEntity itemEntity = (ItemEntity) entity; if (captureDrops() != null) { captureDrops().add(itemEntity); return true; } else { return world.spawnEntity(itemEntity); } }
Example #23
Source File: MixinServerPlayerEntity.java From patchwork-api with GNU Lesser General Public License v2.1 | 5 votes |
@Redirect(method = "dropItem(Lnet/minecraft/item/ItemStack;ZZ)Lnet/minecraft/entity/ItemEntity;", at = @At(value = "INVOKE", target = "Lnet/minecraft/world/World;spawnEntity(Lnet/minecraft/entity/Entity;)Z")) private boolean hookDropItemForCapture(World world, Entity entity) { ItemEntity itemEntity = (ItemEntity) entity; IForgeEntity forgeEntity = (IForgeEntity) this; if (forgeEntity.captureDrops() != null) { forgeEntity.captureDrops().add(itemEntity); return true; } else { return world.spawnEntity(itemEntity); } }
Example #24
Source File: MixinLivingEntity.java From patchwork-api with GNU Lesser General Public License v2.1 | 5 votes |
@Inject(method = "drop", at = @At("TAIL")) private void hookDropForDropsEvent(DamageSource src, CallbackInfo info) { LivingEntity entity = (LivingEntity) (Object) this; IForgeEntity forgeEntity = (IForgeEntity) this; Collection<ItemEntity> drops = forgeEntity.captureDrops(null); if (!MinecraftForge.EVENT_BUS.post(new LivingDropsEvent(entity, src, drops, dropLootingLevel.get(), playerHitTimer > 0))) { for (ItemEntity item : drops) { forgeEntity.getEntity().world.spawnEntity(item); } } dropLootingLevel.remove(); }
Example #25
Source File: CraftingFluidBlock.java From the-hallow with MIT License | 5 votes |
@Override public void onEntityCollision(BlockState blockState, World world, BlockPos pos, Entity entity) { super.onEntityCollision(blockState, world, pos, entity); if(entity instanceof ItemEntity) { List<ItemEntity> entities = world.getEntities(ItemEntity.class, new Box(pos), e -> true); BasicInventory inventory = new BasicInventory(entities.size()); entities.forEach(itemEntity -> { //required for multi-input recipes ItemStack stack = itemEntity.getStack(); inventory.add(stack); }); Optional<FluidRecipe> match = world.getRecipeManager() .getFirstMatch(recipeType, inventory, world); if (match.isPresent()) { spawnCraftingResult(world, pos, match.get().craft(inventory)); for (Ingredient ingredient : match.get().getIngredients()) { for (ItemEntity testEntity : entities) { if (ingredient.test(testEntity.getStack())) { testEntity.getStack().decrement(1); break; } } } } } }
Example #26
Source File: Shearables.java From patchwork-api with GNU Lesser General Public License v2.1 | 5 votes |
public static void shearEntity(ItemStack stack, IWorld world, BlockPos pos, IShearable target) { if (!(target instanceof Entity)) { throw new IllegalArgumentException("Tried to call shearEntity on something that was not an entity!"); } Entity entity = (Entity) target; List<ItemStack> drops = target.onSheared(stack, world, pos, EnchantmentHelper.getLevel(Enchantments.FORTUNE, stack)); Random rand = world.getRandom(); for (ItemStack drop : drops) { ItemEntity item = entity.dropStack(drop, 1.0F); if (item == null) { continue; } float accelerationX = (rand.nextFloat() - rand.nextFloat()) * 0.1F; float accelerationY = rand.nextFloat() * 0.05F; float accelerationZ = (rand.nextFloat() - rand.nextFloat()) * 0.1F; item.setVelocity(item.getVelocity().add(accelerationX, accelerationY, accelerationZ)); } if (stack.damage(1, world.getRandom(), null)) { stack.setCount(0); } }
Example #27
Source File: ItemEntityMixin.java From patchwork-api with GNU Lesser General Public License v2.1 | 5 votes |
@Inject(method = "merge", at = @At("HEAD"), cancellable = true) private static void merge(ItemEntity targetEntity, ItemStack targetStack, ItemEntity sourceEntity, ItemStack sourceStack, CallbackInfo callbackInfo) { CapabilityProviderHolder source = (CapabilityProviderHolder) (Object) sourceStack; CapabilityProviderHolder target = (CapabilityProviderHolder) (Object) targetStack; if (!source.areCapsCompatible(target.getCapabilityProvider())) { callbackInfo.cancel(); } }
Example #28
Source File: DropperBlock_craftingMixin.java From carpet-extra with GNU Lesser General Public License v3.0 | 5 votes |
private void spawn(World world_1, double double_1, double double_2, double double_3, ItemStack itemStack_1) { while(!itemStack_1.isEmpty()) { ItemEntity itemEntity_1 = new ItemEntity(world_1, double_1, double_2, double_3, itemStack_1.split(CarpetServer.rand.nextInt(21) + 10)); itemEntity_1.setVelocity( (CarpetServer.rand.nextDouble()-CarpetServer.rand.nextDouble()) * 0.05, CarpetServer.rand.nextDouble() * 0.05, (CarpetServer.rand.nextDouble()-CarpetServer.rand.nextDouble()) * 0.05 ); world_1.spawnEntity(itemEntity_1); } }
Example #29
Source File: HopperMinecartEntity_cooldownFixMixin.java From carpet-extra with GNU Lesser General Public License v3.0 | 5 votes |
@Inject(method = "canOperate", at = @At(value = "INVOKE", target = "Lnet/minecraft/block/entity/HopperBlockEntity;extract(Lnet/minecraft/inventory/Inventory;Lnet/minecraft/entity/ItemEntity;)Z", shift = At.Shift.BEFORE),cancellable = true, locals = LocalCapture.CAPTURE_FAILHARD) private void extractAndReturnSuccess(CallbackInfoReturnable<Boolean> cir, List list_1) { if (CarpetExtraSettings.hopperMinecart8gtCooldown) { boolean result = HopperBlockEntity.extract(this, (ItemEntity) list_1.get(0)); cir.setReturnValue(result); cir.cancel(); } }
Example #30
Source File: ItemEspHack.java From Wurst7 with GNU General Public License v3.0 | 5 votes |
private void renderBoxes(double partialTicks) { double extraSize = boxSize.getSelected().extraSize; for(ItemEntity e : items) { GL11.glPushMatrix(); GL11.glTranslated(e.prevX + (e.getX() - e.prevX) * partialTicks, e.prevY + (e.getY() - e.prevY) * partialTicks, e.prevZ + (e.getZ() - e.prevZ) * partialTicks); if(style.getSelected().boxes) { GL11.glPushMatrix(); GL11.glScaled(e.getWidth() + extraSize, e.getHeight() + extraSize, e.getWidth() + extraSize); GL11.glCallList(itemBox); GL11.glPopMatrix(); } if(names.isChecked()) { // ItemStack stack = e.getStack(); // GameRenderer.renderFloatingText(MC.textRenderer, // stack.getCount() + "x " // + stack.getName().asFormattedString(), // 0, 1, 0, 0, MC.getEntityRenderManager().cameraYaw, // MC.getEntityRenderManager().cameraPitch, false); // GL11.glDisable(GL11.GL_LIGHTING); } GL11.glPopMatrix(); } }