use of net.minecraft.entity.ItemEntity in project MasaGadget by plusls.
the class MixinRenderUtils method modifyInv.
@ModifyVariable(method = "renderInventoryOverlay", at = @At(value = "INVOKE", target = "Lfi/dy/masa/malilib/util/GuiUtils;getScaledWindowWidth()I", ordinal = 0, remap = false), ordinal = 0)
private static Inventory modifyInv(Inventory inv) {
Inventory ret = inv;
Entity traceEntity = TraceUtil.getTraceEntity();
if (Configs.Tweakeroo.INVENTORY_PREVIEW_SUPPORT_SHULKER_BOX_ITEM_ENTITY.getBooleanValue() && ret == null && traceEntity instanceof ItemEntity) {
ItemStack itemStack = ((ItemEntity) traceEntity).getStack();
Item item = itemStack.getItem();
NbtCompound invNbt = itemStack.getSubNbt("BlockEntityTag");
DefaultedList<ItemStack> stacks = DefaultedList.ofSize(27, ItemStack.EMPTY);
if (item instanceof BlockItem && ((BlockItem) item).getBlock() instanceof ShulkerBoxBlock) {
ret = new SimpleInventory(27);
if (invNbt != null) {
Inventories.readNbt(invNbt, stacks);
}
for (int i = 0; i < 27; ++i) {
ret.setStack(i, stacks.get(i));
}
}
}
return ret;
}
use of net.minecraft.entity.ItemEntity in project bewitchment by MoriyaShiine.
the class SmeltItemsRitualFunction method tick.
@Override
public void tick(World world, BlockPos glyphPos, BlockPos effectivePos, boolean catFamiliar) {
int radius = catFamiliar ? 9 : 3;
if (!world.isClient) {
if (world.getTime() % 20 == 0) {
for (ItemEntity itemEntity : world.getEntitiesByType(EntityType.ITEM, new Box(effectivePos).expand(radius, 0, radius), entity -> true)) {
if (world.random.nextFloat() < 1 / 4f) {
world.getRecipeManager().listAllOfType(RecipeType.SMELTING).forEach(smeltingRecipe -> {
for (Ingredient ingredient : smeltingRecipe.getIngredients()) {
if (ingredient.test(itemEntity.getStack())) {
world.playSound(null, itemEntity.getBlockPos(), SoundEvents.BLOCK_FURNACE_FIRE_CRACKLE, SoundCategory.BLOCKS, 1, 1);
ItemScatterer.spawn(world, itemEntity.getX(), itemEntity.getY(), itemEntity.getZ(), smeltingRecipe.getOutput().copy());
world.spawnEntity(new ExperienceOrbEntity(world, itemEntity.getX(), itemEntity.getY(), itemEntity.getZ(), 1));
itemEntity.getStack().decrement(1);
}
}
});
}
}
}
} else {
world.addParticle(ParticleTypes.FLAME, effectivePos.getX() + MathHelper.nextDouble(world.random, -radius, radius), effectivePos.getY() + 0.5, effectivePos.getZ() + MathHelper.nextDouble(world.random, -radius, radius), 0, 0, 0);
}
}
use of net.minecraft.entity.ItemEntity in project MCDungeonsArmors by chronosacaria.
the class EnchantmentEffects method applyLuckyExplorer.
public static void applyLuckyExplorer(LivingEntity livingEntity) {
World world = livingEntity.getWorld();
if (livingEntity.isOnGround() && world.getTime() % 50 == 0) {
int luckyExplorerLevel = EnchantmentHelper.getEquipmentLevel(EnchantsRegistry.enchants.get(LUCKY_EXPLORER), livingEntity);
if (luckyExplorerLevel == 0)
return;
float luckyExplorerThreshold = luckyExplorerLevel * 0.10f;
float luckyExplorerRand = livingEntity.getRandom().nextFloat();
if (luckyExplorerRand <= luckyExplorerThreshold) {
ItemStack feetStack = livingEntity.getEquippedStack(EquipmentSlot.FEET);
double currentXCoord = livingEntity.getPos().getX();
double currentZCoord = livingEntity.getPos().getZ();
if (feetStack.getNbt().get("x-coord") == null) {
feetStack.getOrCreateNbt().putDouble("x-coord", currentXCoord);
feetStack.getOrCreateNbt().putDouble("z-coord", currentZCoord);
return;
}
double storedXCoord = feetStack.getNbt().getDouble("x-coord");
double storedZCoord = feetStack.getNbt().getDouble("z-coord");
Vec3d vec3d = new Vec3d(storedXCoord, 0, storedZCoord);
double distanceBetween = Math.sqrt(vec3d.squaredDistanceTo(currentXCoord, 0, currentZCoord));
if (distanceBetween >= 20) {
ItemEntity emerald = new ItemEntity(livingEntity.world, currentXCoord, livingEntity.getY(), currentZCoord, Items.EMERALD.getDefaultStack());
livingEntity.world.spawnEntity(emerald);
feetStack.getOrCreateNbt().putDouble("x-coord", currentXCoord);
feetStack.getOrCreateNbt().putDouble("z-coord", currentZCoord);
}
}
}
}
use of net.minecraft.entity.ItemEntity in project MCDungeonsArmors by chronosacaria.
the class EnchantmentEffects method applyFoodReserves.
public static void applyFoodReserves(PlayerEntity playerEntity) {
if (!isInstantHealthPotion(playerEntity.getMainHandStack()))
return;
int foodReserveLevel = EnchantmentHelper.getEquipmentLevel(EnchantsRegistry.enchants.get(FOOD_RESERVES), playerEntity);
while (foodReserveLevel > 0) {
Item foodToDrop = FOOD_RESERVE_LIST.get(playerEntity.getRandom().nextInt(FOOD_RESERVE_LIST.size()));
ItemEntity foodDrop = new ItemEntity(playerEntity.world, playerEntity.getX(), playerEntity.getY(), playerEntity.getZ(), new ItemStack(foodToDrop));
playerEntity.world.spawnEntity(foodDrop);
foodReserveLevel--;
}
}
use of net.minecraft.entity.ItemEntity in project MCDungeonsArmors by chronosacaria.
the class RecyclerEnchantment method onUserDamaged.
@Override
public void onUserDamaged(LivingEntity user, Entity attacker, int level) {
DamageSource damageSource = user.getRecentDamageSource();
if (damageSource != null && damageSource.isProjectile()) {
float recyclerRand = user.getRandom().nextFloat();
float recyclerChance = level * 0.1F;
if (recyclerRand <= recyclerChance) {
ItemEntity arrowDrop = new ItemEntity(user.world, user.getX(), user.getY(), user.getZ(), new ItemStack(Items.ARROW));
user.world.spawnEntity(arrowDrop);
}
}
}
Aggregations