use of net.minecraft.entity.ItemEntity in project wildmod by Osmiooo.
the class AllayEntity method initGoals.
protected void initGoals() {
this.goalSelector.add(1, new LookAtEntityGoal(this, PlayerEntity.class, 8.0F));
this.goalSelector.add(3, new FlyRandomlyGoal(this));
this.setCanPickUpLoot(true);
List<ItemEntity> list = AllayEntity.this.world.getEntitiesByClass(ItemEntity.class, AllayEntity.this.getBoundingBox().expand(8.0D, 8.0D, 8.0D), AllayEntity.CAN_TAKE);
}
use of net.minecraft.entity.ItemEntity in project MCDungeonsArmors by chronosacaria.
the class EnchantmentEffects method applySurpriseGift.
public static void applySurpriseGift(PlayerEntity playerEntity) {
if (!isInstantHealthPotion(playerEntity.getMainHandStack()))
return;
int surpriseGiftLevel = EnchantmentHelper.getEquipmentLevel(EnchantsRegistry.enchants.get(SURPRISE_GIFT), playerEntity);
if (surpriseGiftLevel == 0)
return;
float surpriseGiftChance = 0.5F * surpriseGiftLevel;
while (surpriseGiftChance > 0) {
float surpriseGiftRand = playerEntity.getRandom().nextFloat();
if (surpriseGiftRand <= surpriseGiftChance) {
ItemStack potionToDrop = SURPRISE_GIFT_LIST.get(playerEntity.getRandom().nextInt(SURPRISE_GIFT_LIST.size()));
ItemEntity surpriseGift = new ItemEntity(playerEntity.world, playerEntity.getX(), playerEntity.getY(), playerEntity.getZ(), potionToDrop);
playerEntity.world.spawnEntity(surpriseGift);
}
surpriseGiftChance -= 1.0F;
}
}
use of net.minecraft.entity.ItemEntity in project FastAsyncWorldEdit by IntellectualSites.
the class FabricWorld method dropItem.
@Override
public void dropItem(Vector3 position, BaseItemStack item) {
checkNotNull(position);
checkNotNull(item);
if (item.getType() == ItemTypes.AIR) {
return;
}
ItemEntity entity = new ItemEntity(getWorld(), position.getX(), position.getY(), position.getZ(), FabricAdapter.adapt(item));
entity.setPickupDelay(10);
getWorld().spawnEntity(entity);
}
use of net.minecraft.entity.ItemEntity in project KiwiClient by TangyKiwi.
the class Nametags method onWorldRender.
@Subscribe
@AllowConcurrentEvents
public void onWorldRender(WorldRenderEvent.Post event) {
for (Entity entity : mc.world.getEntities()) {
Vec3d rPos = entity.getPos().subtract(RenderUtils.getInterpolationOffset(entity)).add(0, entity.getHeight(), 0);
double d = entity.squaredDistanceTo(mc.cameraEntity);
if (!(d > 4096.0D)) {
float scale = 1f;
if (Math.sqrt(d) > 10)
scale *= Math.sqrt(d) / 10;
if (entity instanceof ItemEntity && getSetting(3).asToggle().state) {
ItemEntity itemEntity = (ItemEntity) entity;
String name = itemEntity.getName().getString();
String customName = itemEntity.getStack().getName().getString();
String amount = "[x" + itemEntity.getStack().getCount() + "]";
if (!customName.equals(name)) {
double up = 0.7 + 0.9 * (Math.sqrt(d / 4096));
RenderUtils.drawWorldText(name + " " + getEmptyString(amount), rPos.x, rPos.y + up, rPos.z, scale, 0xFFAA00, true);
RenderUtils.drawWorldText(getEmptyString(name) + " " + amount, rPos.x, rPos.y + up, rPos.z, scale, 0xFFFF55, true);
RenderUtils.drawWorldText(customName, rPos.x, rPos.y + 0.5, rPos.z, scale, 0xFFAA00, true);
} else {
// RenderUtils.drawWorldText("\u00a76" + name + " " + "\u00a7e" + amount, rPos.x, rPos.y + 0.5, rPos.z, scale, -1, true);
RenderUtils.drawWorldText(name + " " + getEmptyString(amount), rPos.x, rPos.y + 0.5, rPos.z, scale, 0xFFAA00, true);
RenderUtils.drawWorldText(getEmptyString(name) + " " + amount, rPos.x, rPos.y + 0.5, rPos.z, scale, 0xFFFF55, true);
}
} else if (entity instanceof LivingEntity) {
if (entity == mc.player || entity.hasPassenger(mc.player) || mc.player.hasPassenger(entity)) {
continue;
}
if ((EntityUtils.isAnimal(entity) && getSetting(1).asToggle().state) || (entity instanceof Monster && getSetting(2).asToggle().state) || (entity instanceof PlayerEntity && getSetting(0).asToggle().state) || (entity instanceof ItemEntity && getSetting(3).asToggle().state)) {
LivingEntity livingEntity = (LivingEntity) entity;
String name = livingEntity.getName().getString();
String health = String.format("%.1f", livingEntity.getHealth());
RenderUtils.drawWorldText(name + " " + getEmptyString(health), rPos.x, rPos.y + 0.5, rPos.z, scale, 0xFFFFFF, true);
RenderUtils.drawWorldText(getEmptyString(name) + " " + health, rPos.x, rPos.y + 0.5, rPos.z, scale, getHealthColor(livingEntity), true);
int armorAmount = 0;
for (ItemStack i : livingEntity.getArmorItems()) {
if (!i.isEmpty()) {
armorAmount++;
}
}
double c = -3 + 0.5 * (4 - armorAmount);
double lscale = scale * 0.4;
double up = 0.7 + 0.9 * (Math.sqrt(d / 4096));
int height = 0;
height = Math.min(height, drawItem(rPos.x, rPos.y + up, rPos.z, 0.5 * (armorAmount + 1), 0, lscale, livingEntity.getEquippedStack(EquipmentSlot.MAINHAND)));
height = Math.min(height, drawItem(rPos.x, rPos.y + up, rPos.z, -0.5 * (armorAmount + 1), 0, lscale, livingEntity.getEquippedStack(EquipmentSlot.OFFHAND)));
for (ItemStack i : livingEntity.getArmorItems()) {
height = Math.min(height, drawItem(rPos.x, rPos.y + up, rPos.z, c + 1.5, 0, lscale, i));
if (!i.isEmpty()) {
c++;
}
}
}
}
}
}
}
use of net.minecraft.entity.ItemEntity in project nbt-crafting by Siphalor.
the class MixinCauldronBlock method onActivate.
@Inject(method = "onUse", at = @At("HEAD"), cancellable = true)
public void onActivate(BlockState blockState, World world, BlockPos blockPos, PlayerEntity playerEntity, Hand hand, BlockHitResult blockHitResult, CallbackInfoReturnable<ActionResult> callbackInfoReturnable) {
if (!world.isClient()) {
TemporaryCauldronInventory inventory = new TemporaryCauldronInventory(playerEntity, hand, world, blockPos);
Optional<CauldronRecipe> cauldronRecipe = world.getRecipeManager().getFirstMatch(NbtCrafting.CAULDRON_RECIPE_TYPE, inventory, world);
if (cauldronRecipe.isPresent()) {
DefaultedList<ItemStack> remainingStacks = cauldronRecipe.get().getRemainingStacks(inventory);
ItemStack itemStack = cauldronRecipe.get().craft(inventory);
itemStack.onCraft(world, playerEntity, itemStack.getCount());
if (!playerEntity.inventory.insertStack(remainingStacks.get(0))) {
ItemEntity itemEntity = playerEntity.dropItem(remainingStacks.get(0), false);
if (itemEntity != null) {
itemEntity.resetPickupDelay();
itemEntity.setOwner(playerEntity.getUuid());
}
}
if (!playerEntity.inventory.insertStack(itemStack)) {
ItemEntity itemEntity = playerEntity.dropItem(itemStack, false);
if (itemEntity != null) {
itemEntity.resetPickupDelay();
itemEntity.setOwner(playerEntity.getUuid());
}
}
callbackInfoReturnable.setReturnValue(ActionResult.SUCCESS);
}
}
}
Aggregations