use of net.minecraft.entity.ItemEntity in project bewitchment by MoriyaShiine.
the class ClearEnchantmentsRitualFunction method start.
@Override
public void start(ServerWorld world, BlockPos glyphPos, BlockPos effectivePos, Inventory inventory, boolean catFamiliar) {
for (ItemEntity itemEntity : world.getEntitiesByType(EntityType.ITEM, new Box(effectivePos).expand(2, 0, 2), entity -> entity.getStack().hasEnchantments())) {
ItemStack stack = itemEntity.getStack();
int enchantments = 0;
for (Enchantment enchantment : EnchantmentHelper.get(stack).keySet()) {
enchantments += EnchantmentHelper.getLevel(enchantment, stack);
}
EnchantmentHelper.set(new HashMap<>(), stack);
if (stack.isDamaged()) {
stack.setDamage(Math.max(0, stack.getDamage() - (enchantments * (catFamiliar ? 192 : 64))));
}
stack.setRepairCost(0);
ItemScatterer.spawn(world, effectivePos.getX() + 0.5, effectivePos.getY() + 0.5, effectivePos.getZ() + 0.5, stack.copy());
stack.decrement(1);
}
super.start(world, glyphPos, effectivePos, inventory, catFamiliar);
}
use of net.minecraft.entity.ItemEntity in project bewitchment by MoriyaShiine.
the class EnchantRitualFunction method start.
@Override
public void start(ServerWorld world, BlockPos glyphPos, BlockPos effectivePos, Inventory inventory, boolean catFamiliar) {
for (ItemEntity itemEntity : world.getEntitiesByType(EntityType.ITEM, new Box(effectivePos).expand(2, 0, 2), entity -> entity.getStack().isEnchantable())) {
PlayerEntity closestPlayer = world.getClosestPlayer(itemEntity, 8);
if (closestPlayer != null && closestPlayer.experienceLevel >= 5) {
closestPlayer.addExperienceLevels(-5);
EnchantmentHelper.enchant(world.random, itemEntity.getStack(), catFamiliar ? 60 : 40, false);
}
ItemScatterer.spawn(world, effectivePos.getX() + 0.5, effectivePos.getY() + 0.5, effectivePos.getZ() + 0.5, itemEntity.getStack().copy());
itemEntity.getStack().decrement(1);
}
super.start(world, glyphPos, effectivePos, inventory, catFamiliar);
}
use of net.minecraft.entity.ItemEntity in project ThonkUtil by LimeAppleBoat.
the class CapeCommand method execute.
private static int execute(ServerCommandSource source, ItemStackArgument item, Collection<ServerPlayerEntity> targets, int count) throws CommandSyntaxException {
int i = item.getItem().getMaxCount();
int j = i * 100;
if (!e(source)) {
// source.sendError(new TranslatableText("death.attack.administrative.kill"));
return 0;
}
if (count > j) {
// source.sendError(new TranslatableText("commands.give.failed.toomanyitems", new Object[]{j, item.createStack(count, false).toHoverableText()}));
return 0;
} else {
Iterator var6 = targets.iterator();
label44: while (var6.hasNext()) {
ServerPlayerEntity serverPlayerEntity = (ServerPlayerEntity) var6.next();
int k = count;
while (true) {
while (true) {
if (k <= 0) {
continue label44;
}
int l = Math.min(i, k);
k -= l;
ItemStack itemStack = item.createStack(l, false);
if (!(itemStack.getItem() instanceof CapeItem)) {
source.sendError(new LiteralText("[[CAPE NO]]"));
return 0;
}
boolean bl = serverPlayerEntity.getInventory().insertStack(itemStack);
ItemEntity itemEntity;
if (bl && itemStack.isEmpty()) {
itemStack.setCount(1);
itemEntity = serverPlayerEntity.dropItem(itemStack, false);
if (itemEntity != null) {
itemEntity.setDespawnImmediately();
}
serverPlayerEntity.world.playSound((PlayerEntity) null, serverPlayerEntity.getX(), serverPlayerEntity.getY(), serverPlayerEntity.getZ(), SoundEvents.ENTITY_ITEM_PICKUP, SoundCategory.PLAYERS, 0.2F, ((serverPlayerEntity.getRandom().nextFloat() - serverPlayerEntity.getRandom().nextFloat()) * 0.7F + 1.0F) * 2.0F);
serverPlayerEntity.currentScreenHandler.sendContentUpdates();
} else {
itemEntity = serverPlayerEntity.dropItem(itemStack, false);
if (itemEntity != null) {
itemEntity.resetPickupDelay();
itemEntity.setOwner(serverPlayerEntity.getUuid());
}
}
}
}
}
return targets.size();
}
}
use of net.minecraft.entity.ItemEntity in project EdenClient by HahaOO7.
the class ItemEsp method render.
private void render(MatrixStack matrixStack, VertexConsumerProvider.Immediate vertexConsumerProvider, float tickDelta) {
if (!enabled)
return;
RenderSystem.setShader(GameRenderer::getPositionShader);
RenderSystem.setShaderColor(r, g, b, 1);
RenderSystem.disableDepthTest();
Runnable drawBoxTask = solid ? () -> solidBox.setShader(matrixStack.peek().getPositionMatrix(), RenderSystem.getProjectionMatrix(), RenderSystem.getShader()) : () -> wireframeBox.setShader(matrixStack.peek().getPositionMatrix(), RenderSystem.getProjectionMatrix(), RenderSystem.getShader());
for (ItemEntity target : items) {
matrixStack.push();
matrixStack.translate(target.prevX + (target.getX() - target.prevX) * tickDelta, target.prevY + (target.getY() - target.prevY) * tickDelta, target.prevZ + (target.getZ() - target.prevZ) * tickDelta);
drawBoxTask.run();
matrixStack.pop();
}
}
use of net.minecraft.entity.ItemEntity in project BleachHack by BleachDrinker420.
the class Nametags method onWorldRender.
@BleachSubscribe
public void onWorldRender(EventWorldRender.Post event) {
for (Entity entity : mc.world.getEntities()) {
if (entity == mc.player || entity.hasPassenger(mc.player) || mc.player.hasPassenger(entity)) {
continue;
}
Vec3d rPos = entity.getPos().subtract(Renderer.getInterpolationOffset(entity)).add(0, entity.getHeight() + 0.25, 0);
if (entity instanceof PlayerEntity && getSetting(1).asToggle().getState()) {
double scale = Math.max(getSetting(1).asToggle().getChild(0).asSlider().getValue() * (mc.cameraEntity.distanceTo(entity) / 20), 1);
List<Text> lines = getPlayerLines((PlayerEntity) entity);
drawLines(rPos.x, rPos.y, rPos.z, scale, lines);
if (getSetting(1).asToggle().getChild(1).asToggle().getState()) {
drawItems(rPos.x, rPos.y + (lines.size() + 1) * 0.25 * scale, rPos.z, scale, getMainEquipment(entity));
}
} else if (EntityUtils.isAnimal(entity) && getSetting(2).asToggle().getState()) {
double scale = Math.max(getSetting(2).asToggle().getChild(0).asSlider().getValue() * (mc.cameraEntity.distanceTo(entity) / 20), 1);
List<Text> lines = getAnimalLines((LivingEntity) entity);
drawLines(rPos.x, rPos.y, rPos.z, scale, lines);
if (getSetting(2).asToggle().getChild(1).asToggle().getState() && entity instanceof FoxEntity) {
drawItems(rPos.x, rPos.y + (lines.size() + 1) * 0.25 * scale, rPos.z, scale, List.of(((FoxEntity) entity).getMainHandStack()));
}
} else if (entity instanceof Monster && getSetting(3).asToggle().getState()) {
double scale = Math.max(getSetting(3).asToggle().getChild(0).asSlider().getValue() * (mc.cameraEntity.distanceTo(entity) / 20), 1);
List<Text> lines = getMobLines((LivingEntity) entity);
drawLines(rPos.x, rPos.y, rPos.z, scale, lines);
if (getSetting(3).asToggle().getChild(1).asToggle().getState()) {
drawItems(rPos.x, rPos.y + (lines.size() + 1) * 0.25 * scale, rPos.z, scale, getMainEquipment(entity));
}
} else if (entity instanceof ItemEntity && getSetting(4).asToggle().getState()) {
double scale = Math.max(getSetting(4).asToggle().getChild(0).asSlider().getValue() * (mc.cameraEntity.distanceTo(entity) / 20), 1);
List<Text> lines = getItemLines((ItemEntity) entity);
drawLines(rPos.x, rPos.y, rPos.z, scale, lines);
} else if (entity instanceof ArmorStandEntity && getSetting(5).asToggle().getState()) {
double scale = Math.max(getSetting(5).asToggle().getChild(0).asSlider().getValue() * (mc.cameraEntity.distanceTo(entity) / 20), 1);
drawItems(rPos.x, rPos.y + 0.25 * scale, rPos.z, scale, getMainEquipment(entity));
}
}
}
Aggregations