diff --git a/src/main/java/de/ellpeck/naturesaura/Helper.java b/src/main/java/de/ellpeck/naturesaura/Helper.java index da51b5b4..9c0df454 100644 --- a/src/main/java/de/ellpeck/naturesaura/Helper.java +++ b/src/main/java/de/ellpeck/naturesaura/Helper.java @@ -5,6 +5,7 @@ import de.ellpeck.naturesaura.api.NaturesAuraAPI; import de.ellpeck.naturesaura.api.aura.item.IAuraRecharge; import de.ellpeck.naturesaura.blocks.tiles.TileEntityImpl; import de.ellpeck.naturesaura.chunk.AuraChunk; +import net.minecraft.advancements.Advancement; import net.minecraft.block.Block; import net.minecraft.block.BlockState; import net.minecraft.block.Blocks; @@ -255,11 +256,11 @@ public final class Helper { public static void addAdvancement(PlayerEntity player, ResourceLocation advancement, String criterion) { if (!(player instanceof ServerPlayerEntity)) - return;/* TODO add advancements + return; ServerPlayerEntity playerMp = (ServerPlayerEntity) player; - Advancement adv = playerMp.getServerWorld().getAdvancementManager().getAdvancement(advancement); + Advancement adv = playerMp.getServerWorld().getServer().getAdvancementManager().getAdvancement(advancement); if (adv != null) - playerMp.getAdvancements().grantCriterion(adv, criterion);*/ + playerMp.getAdvancements().grantCriterion(adv, criterion); } public static int getIngredientAmount(Ingredient ingredient) { diff --git a/src/main/java/de/ellpeck/naturesaura/ModConfig.java b/src/main/java/de/ellpeck/naturesaura/ModConfig.java index 71ba4368..5f24b16d 100644 --- a/src/main/java/de/ellpeck/naturesaura/ModConfig.java +++ b/src/main/java/de/ellpeck/naturesaura/ModConfig.java @@ -5,6 +5,9 @@ import de.ellpeck.naturesaura.api.aura.type.BasicAuraType; import de.ellpeck.naturesaura.api.aura.type.IAuraType; import de.ellpeck.naturesaura.api.recipes.WeightedOre; import de.ellpeck.naturesaura.chunk.effect.OreSpawnEffect; +import net.minecraft.block.Block; +import net.minecraft.tags.BlockTags; +import net.minecraft.tags.Tag; import net.minecraft.util.ResourceLocation; import net.minecraft.world.dimension.DimensionType; @@ -121,7 +124,8 @@ public final class ModConfig { try { for (String s : general.additionalOres) { String[] split = s.split(":"); - WeightedOre ore = new WeightedOre(split[0], Integer.parseInt(split[1])); + Tag tag = BlockTags.getCollection().get(new ResourceLocation(split[0])); + WeightedOre ore = new WeightedOre(tag, Integer.parseInt(split[1])); String dimension = split[2]; if ("nether".equalsIgnoreCase(dimension)) NaturesAuraAPI.NETHER_ORES.add(ore); diff --git a/src/main/java/de/ellpeck/naturesaura/api/recipes/AnimalSpawnerRecipe.java b/src/main/java/de/ellpeck/naturesaura/api/recipes/AnimalSpawnerRecipe.java index 86dc8d2c..46221b44 100644 --- a/src/main/java/de/ellpeck/naturesaura/api/recipes/AnimalSpawnerRecipe.java +++ b/src/main/java/de/ellpeck/naturesaura/api/recipes/AnimalSpawnerRecipe.java @@ -39,7 +39,7 @@ public class AnimalSpawnerRecipe { MobEntity living = (MobEntity) entity; living.rotationYawHead = entity.rotationYaw; living.renderYawOffset = entity.rotationYaw; - living.onInitialSpawn(world, world.getDifficultyForLocation(living.getPosition()), SpawnReason.SPAWNER, null, null); // TODO test if null is okay here + living.onInitialSpawn(world, world.getDifficultyForLocation(living.getPosition()), SpawnReason.SPAWNER, null, null); } return entity; } diff --git a/src/main/java/de/ellpeck/naturesaura/api/recipes/WeightedOre.java b/src/main/java/de/ellpeck/naturesaura/api/recipes/WeightedOre.java index 7c427e5d..8f5bbdb2 100644 --- a/src/main/java/de/ellpeck/naturesaura/api/recipes/WeightedOre.java +++ b/src/main/java/de/ellpeck/naturesaura/api/recipes/WeightedOre.java @@ -1,13 +1,15 @@ package de.ellpeck.naturesaura.api.recipes; +import net.minecraft.block.Block; +import net.minecraft.tags.Tag; import net.minecraft.util.WeightedRandom; public class WeightedOre extends WeightedRandom.Item { - public final String name; + public final Tag tag; - public WeightedOre(String name, int weight) { + public WeightedOre(Tag tag, int weight) { super(weight); - this.name = name; + this.tag = tag; } } diff --git a/src/main/java/de/ellpeck/naturesaura/blocks/tiles/TileEntityAutoCrafter.java b/src/main/java/de/ellpeck/naturesaura/blocks/tiles/TileEntityAutoCrafter.java index 94b4a3cc..f5ce3448 100644 --- a/src/main/java/de/ellpeck/naturesaura/blocks/tiles/TileEntityAutoCrafter.java +++ b/src/main/java/de/ellpeck/naturesaura/blocks/tiles/TileEntityAutoCrafter.java @@ -11,6 +11,7 @@ import net.minecraft.inventory.CraftingInventory; import net.minecraft.inventory.container.Container; import net.minecraft.item.ItemStack; import net.minecraft.item.crafting.IRecipe; +import net.minecraft.item.crafting.IRecipeType; import net.minecraft.tileentity.ITickableTileEntity; import net.minecraft.util.Direction; import net.minecraft.util.EntityPredicates; @@ -76,8 +77,7 @@ public class TileEntityAutoCrafter extends TileEntityImpl implements ITickableTi this.crafting.setInventorySlotContents(i, stack.copy()); } - // TODO get recipes from the recipe registry?? - IRecipe recipe = /*CraftingManager.findMatchingRecipe(this.crafting, this.world);*/null; + IRecipe recipe = this.world.getRecipeManager().getRecipe(IRecipeType.CRAFTING, this.crafting, this.world).orElse(null); if (recipe == null) return; @@ -109,7 +109,7 @@ public class TileEntityAutoCrafter extends TileEntityImpl implements ITickableTi this.world.addEntity(remItem); } - PacketHandler.sendToAllAround(this.world, this.pos, 32, + PacketHandler.sendToAllAround(this.world, this.pos, 32, new PacketParticles((float) item.posX, (float) item.posY, (float) item.posZ, 19)); } } diff --git a/src/main/java/de/ellpeck/naturesaura/blocks/tiles/TileEntityPlacer.java b/src/main/java/de/ellpeck/naturesaura/blocks/tiles/TileEntityPlacer.java index 963638a9..7d254355 100644 --- a/src/main/java/de/ellpeck/naturesaura/blocks/tiles/TileEntityPlacer.java +++ b/src/main/java/de/ellpeck/naturesaura/blocks/tiles/TileEntityPlacer.java @@ -59,8 +59,7 @@ public class TileEntityPlacer extends TileEntityImpl implements ITickableTileEnt BlockPos up = pos.up(); BlockState state = this.world.getBlockState(up); - // TODO maybe allow the placer to place on more than air? - if (state.isAir(this.world, up)) + if (state.getMaterial().isReplaceable()) validPositions.add(up); } if (validPositions.isEmpty()) @@ -106,44 +105,12 @@ public class TileEntityPlacer extends TileEntityImpl implements ITickableTileEnt } private ItemStack tryPlace(ItemStack stack, BlockPos pos) { - if (this.handleSpecialCases(stack, pos)) - return stack; - if (!(this.world instanceof ServerWorld)) return stack; - FakePlayer fake = FakePlayerFactory.getMinecraft((ServerWorld) this.world); fake.inventory.mainInventory.set(fake.inventory.currentItem, stack); BlockRayTraceResult ray = new BlockRayTraceResult(new Vec3d(pos).add(0.5F, 0.5F, 0.5F), Direction.UP, pos, false); ForgeHooks.onPlaceItemIntoWorld(new ItemUseContext(fake, Hand.MAIN_HAND, ray)); return fake.getHeldItemMainhand().copy(); } - - private boolean handleSpecialCases(ItemStack stack, BlockPos pos) { - // TODO placer special cases - /* if (stack.getItem() == Items.REDSTONE) - if (Blocks.REDSTONE_WIRE.canPlaceBlockAt(this.world, pos)) - this.world.setBlockState(pos, Blocks.REDSTONE_WIRE.getDefaultState()); - else - return false; - else if (stack.getItem() == Item.getItemFromBlock(ModBlocks.GOLD_POWDER)) - if (ModBlocks.GOLD_POWDER.canPlaceBlockAt(this.world, pos)) - this.world.setBlockState(pos, ModBlocks.GOLD_POWDER.getDefaultState()); - else - return false; - else if (stack.getItem() instanceof IPlantable) { - IPlantable plantable = (IPlantable) stack.getItem(); - BlockState plant = plantable.getPlant(this.world, pos); - if (!plant.getBlock().canPlaceBlockAt(this.world, pos)) - return false; - BlockState state = this.world.getBlockState(pos); - if (!state.getBlock().isAir(state, this.world, pos)) - return false; - this.world.setBlockState(pos, plant); - } else*/ - return false; - - /*stack.shrink(1); - return true;*/ - } } diff --git a/src/main/java/de/ellpeck/naturesaura/chunk/effect/OreSpawnEffect.java b/src/main/java/de/ellpeck/naturesaura/chunk/effect/OreSpawnEffect.java index 800a504b..de82b7da 100644 --- a/src/main/java/de/ellpeck/naturesaura/chunk/effect/OreSpawnEffect.java +++ b/src/main/java/de/ellpeck/naturesaura/chunk/effect/OreSpawnEffect.java @@ -11,17 +11,18 @@ import net.minecraft.block.Block; import net.minecraft.block.BlockState; import net.minecraft.block.Blocks; import net.minecraft.entity.player.PlayerEntity; +import net.minecraft.item.BlockItemUseContext; import net.minecraft.item.ItemStack; -import net.minecraft.util.ResourceLocation; -import net.minecraft.util.Tuple; -import net.minecraft.util.WeightedRandom; -import net.minecraft.util.math.AxisAlignedBB; -import net.minecraft.util.math.BlockPos; -import net.minecraft.util.math.MathHelper; -import net.minecraft.util.math.Vec3d; +import net.minecraft.item.ItemUseContext; +import net.minecraft.util.*; +import net.minecraft.util.math.*; import net.minecraft.world.World; import net.minecraft.world.chunk.Chunk; +import net.minecraft.world.server.ServerWorld; +import net.minecraftforge.common.util.FakePlayer; +import net.minecraftforge.common.util.FakePlayerFactory; +import java.util.Collection; import java.util.HashSet; import java.util.List; import java.util.Set; @@ -96,24 +97,21 @@ public class OreSpawnEffect implements IDrainSpotEffect { if (orePos.distanceSq(powderPos.x, powderPos.y, powderPos.z, true) <= range * range && orePos.distanceSq(pos) <= this.dist * this.dist && world.isBlockLoaded(orePos)) { BlockState state = world.getBlockState(orePos); - Block block = state.getBlock(); - if (block != requiredBlock) + if (state.getBlock() != requiredBlock) continue; - // TODO place ores - /*outer: + outer: while (true) { WeightedOre ore = WeightedRandom.getRandomItem(world.rand, ores, totalWeight); - List stacks = OreDictionary.getOres(ore.name, false); - for (ItemStack stack : stacks) { - if (stack.isEmpty()) - continue; - Block toPlace = Block.getBlockFromItem(stack.getItem()); - if (toPlace == Blocks.AIR) + for (Block toPlace : ore.tag.getAllElements()) { + if (toPlace == null || toPlace == Blocks.AIR) continue; FakePlayer player = FakePlayerFactory.getMinecraft((ServerWorld) world); - BlockState stateToPlace = toPlace.getStateForPlacement(world, pos, Direction.UP, 0, 0, 0, stack.getDamage(), player, EnumHand.MAIN_HAND); + player.setHeldItem(Hand.MAIN_HAND, ItemStack.EMPTY); + BlockRayTraceResult ray = new BlockRayTraceResult(new Vec3d(pos).add(0.5F, 0.5F, 0.5F), Direction.UP, pos, false); + BlockItemUseContext context = new BlockItemUseContext(new ItemUseContext(player, Hand.MAIN_HAND, ray)); + BlockState stateToPlace = toPlace.getStateForPlacement(context); if (SPAWN_EXCEPTIONS.contains(stateToPlace)) continue; @@ -125,7 +123,7 @@ public class OreSpawnEffect implements IDrainSpotEffect { IAuraChunk.getAuraChunk(world, highestSpot).drainAura(highestSpot, toDrain); break outer; } - }*/ + } } } } diff --git a/src/main/java/de/ellpeck/naturesaura/potion/PotionImpl.java b/src/main/java/de/ellpeck/naturesaura/potion/PotionImpl.java index e2b7f778..fb843d40 100644 --- a/src/main/java/de/ellpeck/naturesaura/potion/PotionImpl.java +++ b/src/main/java/de/ellpeck/naturesaura/potion/PotionImpl.java @@ -1,15 +1,12 @@ package de.ellpeck.naturesaura.potion; -import de.ellpeck.naturesaura.NaturesAura; import de.ellpeck.naturesaura.reg.IModItem; import de.ellpeck.naturesaura.reg.ModRegistry; import net.minecraft.potion.Effect; import net.minecraft.potion.EffectType; -import net.minecraft.util.ResourceLocation; public class PotionImpl extends Effect implements IModItem { - private static final ResourceLocation TEXTURE = new ResourceLocation(NaturesAura.MOD_ID, "textures/gui/potions.png"); protected final String baseName; protected PotionImpl(String baseName, EffectType type, int liquidColorIn) { @@ -19,20 +16,6 @@ public class PotionImpl extends Effect implements IModItem { ModRegistry.add(this); } - /* TODO potion textures - - @Override - public Effect setIconIndex(int x, int y) { - return super.setIconIndex(x, y); - } - - @Override - @OnlyIn(Dist.CLIENT) - public int getStatusIconIndex() { - Minecraft.getMinecraft().renderEngine.bindTexture(TEXTURE); - return super.getStatusIconIndex(); - }*/ - @Override public String getBaseName() { return this.baseName; diff --git a/src/main/java/de/ellpeck/naturesaura/recipes/ModRecipes.java b/src/main/java/de/ellpeck/naturesaura/recipes/ModRecipes.java index bccc30f5..1c730b9e 100644 --- a/src/main/java/de/ellpeck/naturesaura/recipes/ModRecipes.java +++ b/src/main/java/de/ellpeck/naturesaura/recipes/ModRecipes.java @@ -30,6 +30,7 @@ import net.minecraft.tags.ItemTags; import net.minecraft.tags.Tag; import net.minecraft.util.ResourceLocation; import net.minecraft.world.World; +import net.minecraftforge.common.Tags; import net.minecraftforge.registries.ForgeRegistries; import java.util.Arrays; @@ -267,22 +268,17 @@ public final class ModRecipes { spawner("wolf", "minecraft:wolf", 50000, 60, ing(Items.LEATHER), ing(Items.BONE)); spawner("zombie", "minecraft:zombie", 100000, 100, ing(Items.ROTTEN_FLESH)); - NaturesAuraAPI.OVERWORLD_ORES.add(new WeightedOre("oreCoal", 5000)); - NaturesAuraAPI.NETHER_ORES.add(new WeightedOre("oreNetherCoal", 5000)); - NaturesAuraAPI.OVERWORLD_ORES.add(new WeightedOre("oreIron", 3000)); - NaturesAuraAPI.NETHER_ORES.add(new WeightedOre("oreNetherIron", 3000)); - NaturesAuraAPI.OVERWORLD_ORES.add(new WeightedOre("oreGold", 500)); - NaturesAuraAPI.NETHER_ORES.add(new WeightedOre("oreNetherGold", 500)); - NaturesAuraAPI.OVERWORLD_ORES.add(new WeightedOre("oreDiamond", 50)); - NaturesAuraAPI.NETHER_ORES.add(new WeightedOre("oreNetherDiamond", 50)); - NaturesAuraAPI.OVERWORLD_ORES.add(new WeightedOre("oreLapis", 250)); - NaturesAuraAPI.NETHER_ORES.add(new WeightedOre("oreNetherLapis", 250)); - NaturesAuraAPI.OVERWORLD_ORES.add(new WeightedOre("oreRedstone", 200)); - NaturesAuraAPI.NETHER_ORES.add(new WeightedOre("oreNetherRedstone", 200)); - NaturesAuraAPI.OVERWORLD_ORES.add(new WeightedOre("oreEmerald", 30)); - NaturesAuraAPI.NETHER_ORES.add(new WeightedOre("oreQuartz", 3000)); + NaturesAuraAPI.OVERWORLD_ORES.add(new WeightedOre(Tags.Blocks.ORES_COAL, 5000)); + NaturesAuraAPI.OVERWORLD_ORES.add(new WeightedOre(Tags.Blocks.ORES_IRON, 3000)); + NaturesAuraAPI.OVERWORLD_ORES.add(new WeightedOre(Tags.Blocks.ORES_GOLD, 500)); + NaturesAuraAPI.OVERWORLD_ORES.add(new WeightedOre(Tags.Blocks.ORES_DIAMOND, 50)); + NaturesAuraAPI.OVERWORLD_ORES.add(new WeightedOre(Tags.Blocks.ORES_LAPIS, 250)); + NaturesAuraAPI.OVERWORLD_ORES.add(new WeightedOre(Tags.Blocks.ORES_REDSTONE, 200)); + NaturesAuraAPI.OVERWORLD_ORES.add(new WeightedOre(Tags.Blocks.ORES_EMERALD, 30)); + NaturesAuraAPI.NETHER_ORES.add(new WeightedOre(Tags.Blocks.ORES_QUARTZ, 3000)); - NaturesAuraAPI.OVERWORLD_ORES.add(new WeightedOre("oreCopper", 2000)); + // TODO figure out how to deal with foreign ore tags + /*NaturesAuraAPI.OVERWORLD_ORES.add(new WeightedOre("oreCopper", 2000)); NaturesAuraAPI.NETHER_ORES.add(new WeightedOre("oreNetherCopper", 2000)); NaturesAuraAPI.OVERWORLD_ORES.add(new WeightedOre("oreTin", 1800)); NaturesAuraAPI.NETHER_ORES.add(new WeightedOre("oreNetherTin", 1800)); @@ -325,7 +321,7 @@ public final class ModRecipes { NaturesAuraAPI.OVERWORLD_ORES.add(new WeightedOre("orePoorSilver", 1000)); NaturesAuraAPI.NETHER_ORES.add(new WeightedOre("oreCobalt", 50)); - NaturesAuraAPI.NETHER_ORES.add(new WeightedOre("oreArdite", 50)); + NaturesAuraAPI.NETHER_ORES.add(new WeightedOre("oreArdite", 50));*/ NaturesAuraAPI.PROJECTILE_GENERATIONS.put(new ResourceLocation("egg"), 2500); NaturesAuraAPI.PROJECTILE_GENERATIONS.put(new ResourceLocation("snowball"), 3500); diff --git a/src/main/resources/assets/naturesaura/lang/en_us.json b/src/main/resources/assets/naturesaura/lang/en_us.json index 8ffd61bc..1d0cabae 100644 --- a/src/main/resources/assets/naturesaura/lang/en_us.json +++ b/src/main/resources/assets/naturesaura/lang/en_us.json @@ -165,7 +165,7 @@ "advancement.naturesaura.range_visualizer": "I Spy With my Little Eye", "advancement.naturesaura.range_visualizer.desc": "Create a Mystical Magnifier to see the range of your devices", "command.naturesaura.aura.usage": "/naaura store|drain [range] OR /naaura reset ", - "potion.naturesaura.breathless": "Breathless", + "effect.naturesaura.breathless": "Breathless", "entity.naturesaura.effect_inhibitor": "Effect Powder", "entity.naturesaura.mover_cart": "Aura Attraction Cart" } \ No newline at end of file diff --git a/src/main/resources/assets/naturesaura/textures/mob_effect/breathless.png b/src/main/resources/assets/naturesaura/textures/mob_effect/breathless.png new file mode 100644 index 00000000..44262843 Binary files /dev/null and b/src/main/resources/assets/naturesaura/textures/mob_effect/breathless.png differ