mirror of
https://github.com/Ellpeck/NaturesAura.git
synced 2024-12-22 14:59:22 +01:00
added bottled vacuum
This commit is contained in:
parent
cf275cfc09
commit
7d23cafc77
9 changed files with 87 additions and 72 deletions
|
@ -0,0 +1,6 @@
|
|||
{
|
||||
"parent": "minecraft:item/generated",
|
||||
"textures": {
|
||||
"layer0": "naturesaura:item/vacuum_bottle"
|
||||
}
|
||||
}
|
|
@ -1,15 +1,15 @@
|
|||
{
|
||||
"values": [
|
||||
"naturesaura:flower_generator",
|
||||
"naturesaura:ancient_log",
|
||||
"naturesaura:offering_table",
|
||||
"naturesaura:ancient_planks",
|
||||
"naturesaura:ancient_slab",
|
||||
"naturesaura:ancient_stairs",
|
||||
"naturesaura:oak_generator",
|
||||
"naturesaura:auto_crafter",
|
||||
"naturesaura:flower_generator",
|
||||
"naturesaura:wood_stand",
|
||||
"naturesaura:ancient_bark",
|
||||
"naturesaura:ancient_slab",
|
||||
"naturesaura:ancient_planks",
|
||||
"naturesaura:nether_wart_mushroom",
|
||||
"naturesaura:auto_crafter"
|
||||
"naturesaura:offering_table",
|
||||
"naturesaura:ancient_log"
|
||||
]
|
||||
}
|
|
@ -1,46 +1,46 @@
|
|||
{
|
||||
"values": [
|
||||
"naturesaura:spring",
|
||||
"naturesaura:aura_detector",
|
||||
"naturesaura:nature_altar",
|
||||
"naturesaura:animal_spawner",
|
||||
"naturesaura:chorus_generator",
|
||||
"naturesaura:animal_container",
|
||||
"naturesaura:infused_slab",
|
||||
"naturesaura:tainted_gold_block",
|
||||
"naturesaura:potion_generator",
|
||||
"naturesaura:grated_chute",
|
||||
"naturesaura:snow_creator",
|
||||
"naturesaura:infused_brick",
|
||||
"naturesaura:weather_changer",
|
||||
"naturesaura:ender_crate",
|
||||
"naturesaura:generator_limit_remover",
|
||||
"naturesaura:infused_stairs",
|
||||
"naturesaura:aura_detector",
|
||||
"naturesaura:spawn_lamp",
|
||||
"naturesaura:hopper_upgrade",
|
||||
"naturesaura:pickup_stopper",
|
||||
"naturesaura:infused_brick_slab",
|
||||
"naturesaura:field_creator",
|
||||
"naturesaura:infused_stone",
|
||||
"naturesaura:time_changer",
|
||||
"naturesaura:nature_altar",
|
||||
"naturesaura:placer",
|
||||
"naturesaura:firework_generator",
|
||||
"naturesaura:infused_stairs",
|
||||
"naturesaura:projectile_generator",
|
||||
"naturesaura:item_distributor",
|
||||
"naturesaura:moss_generator",
|
||||
"naturesaura:spring",
|
||||
"naturesaura:conversion_catalyst",
|
||||
"naturesaura:firework_generator",
|
||||
"naturesaura:aura_timer",
|
||||
"naturesaura:powder_placer",
|
||||
"naturesaura:infused_iron_block",
|
||||
"naturesaura:weather_changer",
|
||||
"naturesaura:gold_nether_brick",
|
||||
"naturesaura:snow_creator",
|
||||
"naturesaura:infused_stone",
|
||||
"naturesaura:furnace_heater",
|
||||
"naturesaura:nether_grass",
|
||||
"naturesaura:projectile_generator",
|
||||
"naturesaura:animal_generator",
|
||||
"naturesaura:infused_brick_stairs",
|
||||
"naturesaura:crushing_catalyst",
|
||||
"naturesaura:infused_brick",
|
||||
"naturesaura:chunk_loader",
|
||||
"naturesaura:rf_converter",
|
||||
"naturesaura:spawn_lamp",
|
||||
"naturesaura:blast_furnace_booster",
|
||||
"naturesaura:nether_grass",
|
||||
"naturesaura:animal_container",
|
||||
"naturesaura:moss_generator",
|
||||
"naturesaura:generator_limit_remover",
|
||||
"naturesaura:pickup_stopper",
|
||||
"naturesaura:aura_timer",
|
||||
"naturesaura:animal_spawner",
|
||||
"naturesaura:ender_crate",
|
||||
"naturesaura:animal_generator",
|
||||
"naturesaura:chorus_generator",
|
||||
"naturesaura:hopper_upgrade",
|
||||
"naturesaura:furnace_heater",
|
||||
"naturesaura:potion_generator",
|
||||
"naturesaura:infused_brick_stairs",
|
||||
"naturesaura:infused_iron_block",
|
||||
"naturesaura:powder_placer",
|
||||
"naturesaura:crushing_catalyst",
|
||||
"naturesaura:conversion_catalyst",
|
||||
"naturesaura:gold_nether_brick",
|
||||
"naturesaura:placer",
|
||||
"naturesaura:time_changer",
|
||||
"naturesaura:tainted_gold_block",
|
||||
"naturesaura:gold_brick"
|
||||
]
|
||||
}
|
|
@ -17,7 +17,7 @@ public class SpreadEffect implements IDrainSpotEffect {
|
|||
|
||||
@Override
|
||||
public void update(Level level, LevelChunk chunk, IAuraChunk auraChunk, BlockPos pos, Integer spot) {
|
||||
if (Math.abs(spot) < 500000 || Math.abs(IAuraChunk.getAuraInArea(level, pos, 25)) < 2000000)
|
||||
if (Math.abs(spot) < 500000 || Math.abs(IAuraChunk.getAuraInArea(level, pos, 25) - IAuraChunk.DEFAULT_AURA) < 1000000)
|
||||
return;
|
||||
var drain = spot > 0;
|
||||
var toMove = Mth.ceil(Math.abs(spot) * 0.72F);
|
||||
|
|
|
@ -7,6 +7,7 @@ import de.ellpeck.naturesaura.data.ItemModelGenerator;
|
|||
import de.ellpeck.naturesaura.reg.IColorProvidingItem;
|
||||
import de.ellpeck.naturesaura.reg.ICustomItemModel;
|
||||
import net.minecraft.client.color.item.ItemColor;
|
||||
import net.minecraft.core.BlockPos;
|
||||
import net.minecraft.core.NonNullList;
|
||||
import net.minecraft.core.dispenser.DefaultDispenseItemBehavior;
|
||||
import net.minecraft.network.chat.Component;
|
||||
|
@ -42,33 +43,15 @@ public class ItemAuraBottle extends ItemImpl implements IColorProvidingItem, ICu
|
|||
|
||||
var dispense = stack.split(1);
|
||||
if (offsetState.isAir()) {
|
||||
if (IAuraChunk.getAuraInArea(level, offset, 30) >= 100000) {
|
||||
dispense = ItemAuraBottle.setType(new ItemStack(ItemAuraBottle.this), IAuraType.forLevel(level));
|
||||
|
||||
var spot = IAuraChunk.getHighestSpot(level, offset, 30, offset);
|
||||
IAuraChunk.getAuraChunk(level, spot).drainAura(spot, 20000);
|
||||
}
|
||||
var bottle = ItemAuraBottle.create(level, offset);
|
||||
if (!bottle.isEmpty())
|
||||
dispense = bottle;
|
||||
}
|
||||
|
||||
DefaultDispenseItemBehavior.spawnItem(level, dispense, 6, facing, DispenserBlock.getDispensePosition(source));
|
||||
return stack;
|
||||
});
|
||||
}
|
||||
|
||||
public static IAuraType getType(ItemStack stack) {
|
||||
if (!stack.hasTag())
|
||||
return NaturesAuraAPI.TYPE_OTHER;
|
||||
var type = stack.getTag().getString("stored_type");
|
||||
if (type.isEmpty())
|
||||
return NaturesAuraAPI.TYPE_OTHER;
|
||||
return NaturesAuraAPI.AURA_TYPES.get(new ResourceLocation(type));
|
||||
}
|
||||
|
||||
public static ItemStack setType(ItemStack stack, IAuraType type) {
|
||||
stack.getOrCreateTag().putString("stored_type", type.getName().toString());
|
||||
return stack;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void fillItemCategory(CreativeModeTab tab, NonNullList<ItemStack> items) {
|
||||
if (this.allowedIn(tab)) {
|
||||
|
@ -98,7 +81,34 @@ public class ItemAuraBottle extends ItemImpl implements IColorProvidingItem, ICu
|
|||
.texture("layer1", "item/" + this.getBaseName() + "_overlay");
|
||||
}
|
||||
|
||||
private class EventHandler {
|
||||
public static IAuraType getType(ItemStack stack) {
|
||||
if (!stack.hasTag())
|
||||
return NaturesAuraAPI.TYPE_OTHER;
|
||||
var type = stack.getTag().getString("stored_type");
|
||||
if (type.isEmpty())
|
||||
return NaturesAuraAPI.TYPE_OTHER;
|
||||
return NaturesAuraAPI.AURA_TYPES.get(new ResourceLocation(type));
|
||||
}
|
||||
|
||||
public static ItemStack setType(ItemStack stack, IAuraType type) {
|
||||
stack.getOrCreateTag().putString("stored_type", type.getName().toString());
|
||||
return stack;
|
||||
}
|
||||
|
||||
private static ItemStack create(Level level, BlockPos pos) {
|
||||
var aura = IAuraChunk.getAuraInArea(level, pos, 30);
|
||||
if (aura <= -100000) {
|
||||
return new ItemStack(ModItems.VACUUM_BOTTLE);
|
||||
} else if (aura >= 100000) {
|
||||
var spot = IAuraChunk.getHighestSpot(level, pos, 30, pos);
|
||||
IAuraChunk.getAuraChunk(level, spot).drainAura(spot, 20000);
|
||||
return ItemAuraBottle.setType(new ItemStack(ModItems.AURA_BOTTLE), IAuraType.forLevel(level));
|
||||
} else {
|
||||
return ItemStack.EMPTY;
|
||||
}
|
||||
}
|
||||
|
||||
private static class EventHandler {
|
||||
|
||||
@SubscribeEvent
|
||||
public void onRightClick(PlayerInteractEvent.RightClickItem event) {
|
||||
|
@ -109,23 +119,19 @@ public class ItemAuraBottle extends ItemImpl implements IColorProvidingItem, ICu
|
|||
HitResult ray = Item.getPlayerPOVHitResult(player.level, player, ClipContext.Fluid.NONE);
|
||||
if (ray.getType() == HitResult.Type.BLOCK)
|
||||
return;
|
||||
var pos = player.blockPosition();
|
||||
if (IAuraChunk.getAuraInArea(player.level, pos, 30) < 100000)
|
||||
var bottle = ItemAuraBottle.create(player.level, player.blockPosition());
|
||||
if (bottle.isEmpty())
|
||||
return;
|
||||
|
||||
if (!player.level.isClientSide) {
|
||||
held.shrink(1);
|
||||
|
||||
var stack = ItemAuraBottle.setType(new ItemStack(ItemAuraBottle.this), IAuraType.forLevel(player.level));
|
||||
if (!player.addItem(stack))
|
||||
player.level.addFreshEntity(new ItemEntity(player.level, player.getX(), player.getY(), player.getZ(), stack));
|
||||
|
||||
var spot = IAuraChunk.getHighestSpot(player.level, pos, 30, pos);
|
||||
IAuraChunk.getAuraChunk(player.level, spot).drainAura(spot, 20000);
|
||||
if (!player.addItem(bottle))
|
||||
player.level.addFreshEntity(new ItemEntity(player.level, player.getX(), player.getY(), player.getZ(), bottle));
|
||||
|
||||
player.level.playSound(null, player.getX(), player.getY(), player.getZ(),
|
||||
SoundEvents.BOTTLE_FILL_DRAGONBREATH, SoundSource.PLAYERS, 1F, 1F);
|
||||
}
|
||||
|
||||
player.swing(event.getHand());
|
||||
}
|
||||
|
||||
|
|
|
@ -64,4 +64,5 @@ public final class ModItems {
|
|||
public static Item BREAK_PREVENTION;
|
||||
public static Item PET_REVIVER;
|
||||
public static Item NETHERITE_FINDER;
|
||||
public static Item VACUUM_BOTTLE;
|
||||
}
|
||||
|
|
|
@ -206,7 +206,8 @@ public final class ModRegistry {
|
|||
new ItemStructureFinder("outpost_finder", BuiltinStructures.PILLAGER_OUTPOST, 0xab9f98, 2048),
|
||||
new ItemBreakPrevention(),
|
||||
new ItemPetReviver(),
|
||||
new ItemNetheriteFinder()
|
||||
new ItemNetheriteFinder(),
|
||||
new ItemImpl("vacuum_bottle")
|
||||
);
|
||||
Helper.populateObjectHolders(ModItems.class, event.getForgeRegistry());
|
||||
});
|
||||
|
|
|
@ -94,6 +94,7 @@
|
|||
"item.naturesaura.book.name": "Book of Natural Aura",
|
||||
"item.naturesaura.shockwave_creator": "Amulet of Wrath",
|
||||
"item.naturesaura.multiblock_maker": "Multiblock Maker",
|
||||
"item.naturesaura.vacuum_bottle": "Bottled Vacuum",
|
||||
"item.naturesaura.aura_bottle.naturesaura:overworld": "Bottled Sunlight",
|
||||
"item.naturesaura.aura_bottle.naturesaura:nether": "Bottled Ghosts",
|
||||
"item.naturesaura.aura_bottle.naturesaura:end": "Bottled Darkness",
|
||||
|
|
Binary file not shown.
After Width: | Height: | Size: 270 B |
Loading…
Reference in a new issue