Search in sources :

Example 11 with ItemEntity

use of net.minecraft.entity.ItemEntity in project Biome-Makeover by Lemonszz.

the class EctoplasmComposterBlock method emptyFullComposter.

public static void emptyFullComposter(World world, BlockPos pos) {
    if (!world.isClient) {
        float offset = 0.7F;
        double offsetX = (double) (world.random.nextFloat() * offset) + 0.15D;
        double offsetY = (double) (world.random.nextFloat() * offset) + 0.06D + 0.6D;
        double offsetZ = (double) (world.random.nextFloat() * offset) + 0.15D;
        ItemEntity itemEntity = new ItemEntity(world, (double) pos.getX() + offsetX, (double) pos.getY() + offsetY, (double) pos.getZ() + offsetZ, new ItemStack(Blocks.SOUL_SOIL));
        itemEntity.setToDefaultPickupDelay();
        world.spawnEntity(itemEntity);
    }
    BlockState originalState = Blocks.COMPOSTER.getDefaultState();
    world.setBlockState(pos, originalState);
    world.playSound(null, pos, SoundEvents.BLOCK_COMPOSTER_EMPTY, SoundCategory.BLOCKS, 1.0F, 1.0F);
}
Also used : ItemEntity(net.minecraft.entity.ItemEntity) BlockState(net.minecraft.block.BlockState) ItemStack(net.minecraft.item.ItemStack)

Example 12 with ItemEntity

use of net.minecraft.entity.ItemEntity in project Terracraft by SimplyCmd.

the class PotBlock method dropCoins.

private void dropCoins(World world, BlockPos pos) {
    // Spawn silver coins from 0-3
    for (int i = 0; i < RANDOM.nextInt(3); i++) {
        ItemEntity coin = new ItemEntity(world, pos.getX(), pos.getY(), pos.getZ(), ItemRegistry.silver_coin.getItem().getDefaultStack());
        world.spawnEntity(coin);
    }
    // Spawn copper coins from 0-64
    ItemStack copper_coins = ItemRegistry.copper_coin.getItem().getDefaultStack();
    copper_coins.setCount(RANDOM.nextInt(64));
    ItemEntity coin = new ItemEntity(world, pos.getX(), pos.getY(), pos.getZ(), copper_coins);
    world.spawnEntity(coin);
}
Also used : ItemEntity(net.minecraft.entity.ItemEntity) ItemStack(net.minecraft.item.ItemStack)

Example 13 with ItemEntity

use of net.minecraft.entity.ItemEntity in project Hypnotic-Client by Hypnotic-Development.

the class RenderUtils method drawEntityBox.

public static void drawEntityBox(MatrixStack matrixstack, Entity entity, double x, double y, double z, Color color) {
    setup3DRender(true);
    matrixstack.translate(x, y, z);
    matrixstack.multiply(new Quaternion(new Vec3f(0, -1, 0), 0, true));
    matrixstack.translate(-x, -y, -z);
    Box bb = new Box(x - entity.getWidth() + 0.25, y, z - entity.getWidth() + 0.25, x + entity.getWidth() - 0.25, y + entity.getHeight() + 0.1, z + entity.getWidth() - 0.25);
    if (entity instanceof ItemEntity)
        bb = new Box(x - 0.15, y + 0.1f, z - 0.15, x + 0.15, y + 0.5, z + 0.15);
    drawFilledBox(matrixstack, bb, new Color(color.getRed(), color.getGreen(), color.getBlue(), 130), true);
    RenderSystem.lineWidth(1.5f);
    drawOutlineBox(matrixstack, bb, color, true);
    end3DRender();
    matrixstack.translate(x, y, z);
    matrixstack.multiply(new Quaternion(new Vec3f(0, 1, 0), 0, true));
    matrixstack.translate(-x, -y, -z);
}
Also used : ItemEntity(net.minecraft.entity.ItemEntity) Quaternion(net.minecraft.util.math.Quaternion) Color(java.awt.Color) Box(net.minecraft.util.math.Box) Vec3f(net.minecraft.util.math.Vec3f)

Example 14 with ItemEntity

use of net.minecraft.entity.ItemEntity in project Hypnotic-Client by Hypnotic-Development.

the class Nametags method getNameString.

public String getNameString(Entity entity) {
    String name = entity.getDisplayName().asString();
    PlayerListEntry playerListEntry = mc.getNetworkHandler().getPlayerListEntry(entity.getUuid());
    String gameModeText = gamemode.isEnabled() ? (playerListEntry != null ? ColorUtils.aqua + playerListEntry.getGameMode().getName().substring(0, 1).toUpperCase() + " " + ColorUtils.reset : "") : "";
    String pingText = ping.isEnabled() ? (playerListEntry != null ? playerListEntry.getLatency() : "0") + "ms " : "";
    String distanceText = distance.isEnabled() ? Math.round(mc.player.distanceTo(entity)) + "m " : " ";
    String devText = (Arrays.asList(Hypnotic.INSTANCE.devUUIDs).contains(entity.getUuidAsString()) ? ColorUtils.purple + " DEV" + ColorUtils.reset : "");
    if (name.trim().isEmpty())
        name = entity.getName().getString();
    if (entity instanceof ItemEntity) {
        ItemEntity itemEntity = (ItemEntity) entity;
        if (itemEntity.getStack().getCount() > 1)
            name += " \247fx" + itemEntity.getStack().getCount();
    }
    String displayName = "";
    if (entity instanceof LivingEntity)
        displayName = gameModeText + ColorUtils.white + name.replaceAll(ColorUtils.colorChar, "&") + devText + " " + pingText + distanceText + getHealthString((LivingEntity) entity) + (entity.getName().asString().equalsIgnoreCase("BadGamesInc") ? ColorUtils.purple + " Swag" : "");
    return displayName;
}
Also used : LivingEntity(net.minecraft.entity.LivingEntity) ItemEntity(net.minecraft.entity.ItemEntity) PlayerListEntry(net.minecraft.client.network.PlayerListEntry)

Example 15 with ItemEntity

use of net.minecraft.entity.ItemEntity in project Neutrino by FrostWizard4.

the class WitherlingEntity method dropEquipment.

protected void dropEquipment(DamageSource source, int lootingMultiplier, boolean allowDrops) {
    super.dropEquipment(source, lootingMultiplier, allowDrops);
    ItemEntity itemEntity = this.dropItem(ItemRegistry.WITHERING_HEART);
    if (itemEntity != null) {
        itemEntity.setCovetedItem();
    }
}
Also used : ItemEntity(net.minecraft.entity.ItemEntity)

Aggregations

ItemEntity (net.minecraft.entity.ItemEntity)32 ItemStack (net.minecraft.item.ItemStack)15 PlayerEntity (net.minecraft.entity.player.PlayerEntity)7 Inject (org.spongepowered.asm.mixin.injection.Inject)6 Entity (net.minecraft.entity.Entity)5 LivingEntity (net.minecraft.entity.LivingEntity)5 Box (net.minecraft.util.math.Box)4 Monster (net.minecraft.entity.mob.Monster)3 Vec3d (net.minecraft.util.math.Vec3d)3 Item (net.minecraft.item.Item)2 ServerPlayerEntity (net.minecraft.server.network.ServerPlayerEntity)2 World (net.minecraft.world.World)2 AllowConcurrentEvents (com.google.common.eventbus.AllowConcurrentEvents)1 Subscribe (com.google.common.eventbus.Subscribe)1 CapeItem (com.jab125.thonkutil.api.CapeItem)1 CauldronRecipe (de.siphalor.nbtcrafting.recipe.cauldron.CauldronRecipe)1 TemporaryCauldronInventory (de.siphalor.nbtcrafting.recipe.cauldron.TemporaryCauldronInventory)1 FlyRandomlyGoal (frozenblock.wild.mod.liukrastapi.FlyRandomlyGoal)1 Color (java.awt.Color)1 Iterator (java.util.Iterator)1