diff --git a/build.gradle b/build.gradle index 520eb6cd..81b6d481 100644 --- a/build.gradle +++ b/build.gradle @@ -1,6 +1,6 @@ plugins { id 'java-library' - id 'fabric-loom' version '0.2.6-SNAPSHOT' + id 'fabric-loom' version '0.4-SNAPSHOT' id 'maven-publish' } diff --git a/gradle.properties b/gradle.properties index d323240f..852bac6c 100644 --- a/gradle.properties +++ b/gradle.properties @@ -2,21 +2,21 @@ org.gradle.jvmargs=-Xmx3G org.gradle.daemon=false # Fabric Properties - # check these on https://fabricmc.net/use - minecraft_version=1.15.2 - yarn_mappings=1.15.2+build.7:v2 - loader_version=0.7.6+build.180 + # check these on https://modmuss50.me/fabric.html + minecraft_version=1.16-rc1 + yarn_mappings=1.16-rc1+build.4:v2 + loader_version=0.8.8+build.202 + fabric_version=0.12.5+build.367-1.16 # Mod Properties group=com.minelittlepony displayname=Unicopia authors=Sollace description=Magical Abilities for Mine Little Pony! - version=0.3.1 + version=0.4 release=SNAPSHOT # Dependencies - fabric_version=0.4.29+ - modmenu_version=1.8.+ - minelp_version=4.0.7-1.15.2 - kirin_version=1.5.2-1.15.2 + modmenu_version=1.12.+ + minelp_version=4.1-1.16-rc1-1.16 + kirin_version=1.6.4-1.16-rc1-1.16 diff --git a/src/external/java/com/minelittlepony/model/anim/BasicEasingInterpolator.java b/src/external/java/com/minelittlepony/model/anim/BasicEasingInterpolator.java deleted file mode 100644 index 27d72da0..00000000 --- a/src/external/java/com/minelittlepony/model/anim/BasicEasingInterpolator.java +++ /dev/null @@ -1,57 +0,0 @@ -package com.minelittlepony.model.anim; - -import java.util.HashMap; -import java.util.Map; -import java.util.UUID; - -import com.minelittlepony.util.chron.ChronicCache; -import com.minelittlepony.util.chron.Touchable; - -//#MineLittlePony# -public class BasicEasingInterpolator extends Touchable implements IInterpolator { - - private static ChronicCache instanceCache = new ChronicCache<>(); - - /** - * Gets or creates a new basic, linear interpolator for the provided id. - */ - public static IInterpolator getInstance(UUID id) { - return instanceCache.retrieve(id, BasicEasingInterpolator::new); - } - - public BasicEasingInterpolator() { - - } - - private BasicEasingInterpolator(UUID id) { - - } - - private final Map properties = new HashMap(); - - private float getLast(String key, float to) { - if (properties.containsKey(key)) { - return properties.get(key); - } - - return to; - } - - @Override - public float interpolate(String key, float to, float scalingFactor) { - float from = getLast(key, to); - - from += (to - from) / scalingFactor; - - if (Float.isNaN(from) || Float.isInfinite(from)) { - System.err.println("Error: Animation frame for " + key + " is NaN or Infinite."); - from = to; - } - - properties.put(key, from); - - return from; - - } - -} diff --git a/src/external/java/com/minelittlepony/model/anim/IInterpolator.java b/src/external/java/com/minelittlepony/model/anim/IInterpolator.java deleted file mode 100644 index dea22f74..00000000 --- a/src/external/java/com/minelittlepony/model/anim/IInterpolator.java +++ /dev/null @@ -1,7 +0,0 @@ -package com.minelittlepony.model.anim; - -// #MineLittlePony# -@FunctionalInterface -public interface IInterpolator { - float interpolate(String key, float to, float scalingFactor); -} diff --git a/src/external/java/com/minelittlepony/transform/MotionCompositor.java b/src/external/java/com/minelittlepony/transform/MotionCompositor.java deleted file mode 100644 index de80c34e..00000000 --- a/src/external/java/com/minelittlepony/transform/MotionCompositor.java +++ /dev/null @@ -1,48 +0,0 @@ -package com.minelittlepony.transform; - -import net.minecraft.entity.player.PlayerEntity; -import net.minecraft.util.math.MathHelper; - -import com.minelittlepony.util.math.MathUtil; - -//#MineLittlePony# -public abstract class MotionCompositor { - - protected double calculateRoll(PlayerEntity player, double motionX, double motionY, double motionZ) { - - // since model roll should probably be calculated from model rotation rather than entity rotation... - double roll = MathUtil.sensibleAngle(player.prevRenderYawOffset - player.renderYawOffset); - double horMotion = Math.sqrt(motionX * motionX + motionZ * motionZ); - float modelYaw = MathUtil.sensibleAngle(player.renderYawOffset); - - // detecting that we're flying backwards and roll must be inverted - if (Math.abs(MathUtil.sensibleAngle((float) Math.toDegrees(Math.atan2(motionX, motionZ)) + modelYaw)) > 90) { - roll *= -1; - } - - // ayyy magic numbers (after 5 - an approximation of nice looking coefficients calculated by hand) - - // roll might be zero, in which case Math.pow produces +Infinity. Anything x Infinity = NaN. - double pow = roll != 0 ? Math.pow(Math.abs(roll), -0.191) : 0; - - roll *= horMotion * 5 * (3.6884f * pow); - - assert !Float.isNaN((float)roll); - - return MathHelper.clamp(roll, -54, 54); - } - - protected double calculateIncline(PlayerEntity player, double motionX, double motionY, double motionZ) { - double dist = Math.sqrt(motionX * motionX + motionZ * motionZ); - double angle = Math.atan2(motionY, dist); - - if (!player.capabilities.isFlying) { - angle /= 2; - } - - angle = MathUtil.clampLimit(angle, Math.PI / 3); - - return Math.toDegrees(angle); - } - -} diff --git a/src/external/java/com/minelittlepony/util/chron/ChronicCache.java b/src/external/java/com/minelittlepony/util/chron/ChronicCache.java deleted file mode 100644 index dc132852..00000000 --- a/src/external/java/com/minelittlepony/util/chron/ChronicCache.java +++ /dev/null @@ -1,18 +0,0 @@ -package com.minelittlepony.util.chron; - -import java.util.HashMap; -import java.util.function.Function; - -//#MineLittlePony# -public class ChronicCache> extends HashMap { - private static final long serialVersionUID = 6454924015818181978L; - - public V retrieve(K key, Function mappingFunction) { - V result = computeIfAbsent(key, mappingFunction).touch(); - - entrySet().removeIf(entry -> entry.getValue().hasExpired()); - - return result; - } - -} diff --git a/src/external/java/com/minelittlepony/util/chron/Touchable.java b/src/external/java/com/minelittlepony/util/chron/Touchable.java deleted file mode 100644 index 6a50c3e5..00000000 --- a/src/external/java/com/minelittlepony/util/chron/Touchable.java +++ /dev/null @@ -1,17 +0,0 @@ -package com.minelittlepony.util.chron; - -//#MineLittlePony# -public abstract class Touchable> { - - private long expirationPeriod; - - public boolean hasExpired() { - return expirationPeriod <= System.currentTimeMillis(); - } - - @SuppressWarnings("unchecked") - public T touch() { - expirationPeriod = System.currentTimeMillis() + 30000; - return (T)this; - } -} diff --git a/src/external/java/com/minelittlepony/util/math/MathUtil.java b/src/external/java/com/minelittlepony/util/math/MathUtil.java deleted file mode 100644 index 2a97c1d8..00000000 --- a/src/external/java/com/minelittlepony/util/math/MathUtil.java +++ /dev/null @@ -1,33 +0,0 @@ -package com.minelittlepony.util.math; - -import net.minecraft.util.math.MathHelper; - -//#MineLittlePony# -public class MathUtil { - - public static double clampLimit(double num, double limit) { - return MathHelper.clamp(num, -limit, limit); - } - - public static float sensibleAngle(float angle) { - angle %= 360; - - if (angle > 180) angle -= 360; - if (angle < -180) angle += 360; - - return angle; - } - - public static float interpolateDegress(float prev, float current, float partialTicks) { - float difference = current - prev; - - while (difference < -180) difference += 360; - while (difference >= 180) difference -= 360; - - return prev + partialTicks * difference; - } - - public static float interpolateRadians(float prev, float current, float partialTicks) { - return (float)Math.toRadians(interpolateDegress(prev, current, partialTicks)); - } -} diff --git a/src/external/java/com/minelittlepony/util/render/Box.java b/src/external/java/com/minelittlepony/util/render/Box.java deleted file mode 100644 index 0c9a1c69..00000000 --- a/src/external/java/com/minelittlepony/util/render/Box.java +++ /dev/null @@ -1,37 +0,0 @@ -package com.minelittlepony.util.render; - -import net.minecraft.client.model.ModelBox; -import net.minecraft.client.model.ModelRenderer; - -//#MineLittlePony# -public abstract class Box extends ModelBox { - - protected final T parent; - - public Box(T renderer, int texU, int texV, float x, float y, float z, int dx, int dy, int dz, float delta) { - super(renderer, texU, texV, x, y, z, dx, dy, dz, delta); - parent = renderer; - } - - public Box(T renderer, int texU, int texV, float x, float y, float z, int dx, int dy, int dz, float delta, boolean mirror) { - super(renderer, texU, texV, x, y, z, dx, dy, dz, delta, mirror); - parent = renderer; - } - - /** - * Creates a new vertex mapping the given (x, y, z) coordinates to a texture offset. - */ - protected Vertex vert(float x, float y, float z, int texX, int texY) { - return new Vertex(x, y, z, texX, texY); - } - - /** - * Creates a new quad with the given spacial vertices. - */ - protected Quad quad(int startX, int width, int startY, int height, Vertex ...verts) { - return new Quad(verts, - startX, startY, - startX + width, startY + height, - parent.textureWidth, parent.textureHeight); - } -} \ No newline at end of file diff --git a/src/external/java/com/minelittlepony/util/render/Color.java b/src/external/java/com/minelittlepony/util/render/Color.java deleted file mode 100644 index dc04a79e..00000000 --- a/src/external/java/com/minelittlepony/util/render/Color.java +++ /dev/null @@ -1,22 +0,0 @@ -package com.minelittlepony.util.render; - -import net.minecraft.client.renderer.GlStateManager; - -//#MineLittlePony# -public interface Color { - static float r(int color) { - return (color >> 16 & 255) / 255F; - } - - static float g(int color) { - return (color >> 8 & 255) / 255F; - } - - static float b(int color) { - return (color & 255) / 255F; - } - - static void glColor(int color, float alpha) { - GlStateManager.color(Color.r(color), Color.g(color), Color.b(color), alpha); - } -} diff --git a/src/external/java/com/minelittlepony/util/render/Quad.java b/src/external/java/com/minelittlepony/util/render/Quad.java deleted file mode 100644 index c6020942..00000000 --- a/src/external/java/com/minelittlepony/util/render/Quad.java +++ /dev/null @@ -1,10 +0,0 @@ -package com.minelittlepony.util.render; - -import net.minecraft.client.model.TexturedQuad; - -//#MineLittlePony# -public class Quad extends TexturedQuad { - Quad(Vertex[] vertices, int texcoordU1, int texcoordV1, int texcoordU2, int texcoordV2, float textureWidth, float textureHeight) { - super(vertices, texcoordU1, texcoordV1, texcoordU2, texcoordV2, textureWidth, textureHeight); - } -} \ No newline at end of file diff --git a/src/external/java/com/minelittlepony/util/render/Vertex.java b/src/external/java/com/minelittlepony/util/render/Vertex.java deleted file mode 100644 index 08052332..00000000 --- a/src/external/java/com/minelittlepony/util/render/Vertex.java +++ /dev/null @@ -1,20 +0,0 @@ -package com.minelittlepony.util.render; - -import net.minecraft.client.model.PositionTextureVertex; - -//#MineLittlePony# -public class Vertex extends PositionTextureVertex { - - public Vertex(float x, float y, float z, float texX, float texY) { - super(x, y, z, texX, texY); - } - - private Vertex(Vertex old, float texX, float texY) { - super(old, texX, texY); - } - - @Override - public Vertex setTexturePosition(float texX, float texY) { - return new Vertex(this, texX, texY); - } -} diff --git a/src/main/java/com/minelittlepony/unicopia/EquinePredicates.java b/src/main/java/com/minelittlepony/unicopia/EquinePredicates.java index f548e6e0..23da6658 100644 --- a/src/main/java/com/minelittlepony/unicopia/EquinePredicates.java +++ b/src/main/java/com/minelittlepony/unicopia/EquinePredicates.java @@ -2,9 +2,9 @@ package com.minelittlepony.unicopia; import java.util.function.Predicate; -import com.minelittlepony.unicopia.entity.CloudEntity; -import com.minelittlepony.unicopia.entity.Ponylike; -import com.minelittlepony.unicopia.gas.Gas; +import com.minelittlepony.unicopia.equine.Ponylike; +import com.minelittlepony.unicopia.world.block.gas.Gas; +import com.minelittlepony.unicopia.world.entity.CloudEntity; import net.minecraft.entity.Entity; import net.minecraft.entity.ItemEntity; diff --git a/src/main/java/com/minelittlepony/unicopia/entity/InAnimate.java b/src/main/java/com/minelittlepony/unicopia/InAnimate.java similarity index 76% rename from src/main/java/com/minelittlepony/unicopia/entity/InAnimate.java rename to src/main/java/com/minelittlepony/unicopia/InAnimate.java index 7393f46b..bb118483 100644 --- a/src/main/java/com/minelittlepony/unicopia/entity/InAnimate.java +++ b/src/main/java/com/minelittlepony/unicopia/InAnimate.java @@ -1,6 +1,4 @@ -package com.minelittlepony.unicopia.entity; - -import com.minelittlepony.unicopia.Race; +package com.minelittlepony.unicopia; /** * This interface is for any entities that are categorised as inanimated, diff --git a/src/main/java/com/minelittlepony/unicopia/entity/Owned.java b/src/main/java/com/minelittlepony/unicopia/Owned.java similarity index 87% rename from src/main/java/com/minelittlepony/unicopia/entity/Owned.java rename to src/main/java/com/minelittlepony/unicopia/Owned.java index 510c5469..a8b84697 100644 --- a/src/main/java/com/minelittlepony/unicopia/entity/Owned.java +++ b/src/main/java/com/minelittlepony/unicopia/Owned.java @@ -1,4 +1,4 @@ -package com.minelittlepony.unicopia.entity; +package com.minelittlepony.unicopia; /** * Interface for things that can be owned. diff --git a/src/main/java/com/minelittlepony/unicopia/TreeTraverser.java b/src/main/java/com/minelittlepony/unicopia/TreeTraverser.java index f8ad527e..8a0d93c6 100644 --- a/src/main/java/com/minelittlepony/unicopia/TreeTraverser.java +++ b/src/main/java/com/minelittlepony/unicopia/TreeTraverser.java @@ -46,7 +46,8 @@ public class TreeTraverser { if (level < 3 && !done.contains(pos)) { done.add(pos); - BlockPos.Mutable result = new BlockPos.Mutable(ascendTree(w, log, pos, true)); + BlockPos.Mutable result = new BlockPos.Mutable(); + result.set(ascendTree(w, log, pos, true)); PosHelper.all(pos, p -> { if (variantAndBlockEquals(w.getBlockState(pos.east()), log)) { @@ -84,7 +85,7 @@ public class TreeTraverser { } public static Optional descendTree(World w, BlockState log, BlockPos pos) { - return descendTreePart(new HashSet(), w, log, new BlockPos.Mutable(pos)); + return descendTreePart(new HashSet(), w, log, new BlockPos.Mutable(pos.getX(), pos.getY(), pos.getZ())); } private static Optional descendTreePart(Set done, World w, BlockState log, BlockPos.Mutable pos) { @@ -94,12 +95,11 @@ public class TreeTraverser { done.add(pos.toImmutable()); while (variantAndBlockEquals(w.getBlockState(pos.down()), log)) { - pos.setOffset(Direction.DOWN); - done.add(pos.toImmutable()); + done.add(pos.move(Direction.DOWN).toImmutable()); } PosHelper.all(pos.toImmutable(), p -> { - descendTreePart(done, w, log, new BlockPos.Mutable(p)).filter(a -> a.getY() < pos.getY()).ifPresent(pos::set); + descendTreePart(done, w, log, new BlockPos.Mutable(p.getX(), p.getY(), p.getZ())).filter(a -> a.getY() < pos.getY()).ifPresent(pos::set); }, Direction.NORTH, Direction.SOUTH, Direction.EAST, Direction.WEST); done.add(pos.toImmutable()); diff --git a/src/main/java/com/minelittlepony/unicopia/TreeType.java b/src/main/java/com/minelittlepony/unicopia/TreeType.java index 643fa8bc..a1e4cf80 100644 --- a/src/main/java/com/minelittlepony/unicopia/TreeType.java +++ b/src/main/java/com/minelittlepony/unicopia/TreeType.java @@ -2,8 +2,8 @@ package com.minelittlepony.unicopia; import java.util.stream.Collectors; -import com.minelittlepony.unicopia.item.UItems; import com.minelittlepony.unicopia.util.Weighted; +import com.minelittlepony.unicopia.world.item.UItems; import java.util.Arrays; import java.util.HashSet; @@ -19,35 +19,42 @@ import net.minecraft.util.Identifier; import net.minecraft.util.registry.Registry; public final class TreeType { - // XXX: move to datapack + // TODO: move to datapack private static final Set REGISTRY = new HashSet<>(); + private static final Supplier ROTTEN = () -> new ItemStack(UItems.ROTTEN_APPLE); + private static final Supplier SWEET = () -> new ItemStack(UItems.SWEET_APPLE); + private static final Supplier GREEN = () -> new ItemStack(UItems.GREEN_APPLE); + private static final Supplier ZAP = () -> new ItemStack(UItems.ZAP_APPLE); + private static final Supplier SOUR = () -> new ItemStack(UItems.SOUR_APPLE); + private static final Supplier RED = () -> new ItemStack(Items.APPLE); + public static final TreeType NONE = new TreeType("none", new Weighted>()); public static final TreeType OAK = new TreeType("oak", new Weighted>() - .put(1, () -> new ItemStack(UItems.ROTTEN_APPLE)) - .put(2, () -> new ItemStack(UItems.GREEN_APPLE)) - .put(3, () -> new ItemStack(Items.APPLE)), Blocks.OAK_LOG, Blocks.OAK_LEAVES); + .put(1, ROTTEN) + .put(2, GREEN) + .put(3, RED), Blocks.OAK_LOG, Blocks.OAK_LEAVES); public static final TreeType BIRCH = new TreeType("birch", new Weighted>() - .put(1, () -> new ItemStack(UItems.ROTTEN_APPLE)) - .put(2, () -> new ItemStack(UItems.SWEET_APPLE)) - .put(5, () -> new ItemStack(UItems.GREEN_APPLE)), Blocks.BIRCH_LOG, Blocks.BIRCH_LEAVES); + .put(1, ROTTEN) + .put(2, SWEET) + .put(5, GREEN), Blocks.BIRCH_LOG, Blocks.BIRCH_LEAVES); public static final TreeType SPRUCE = new TreeType("spruce", new Weighted>() - .put(1, () -> new ItemStack(UItems.SOUR_APPLE)) - .put(2, () -> new ItemStack(UItems.GREEN_APPLE)) - .put(3, () -> new ItemStack(UItems.SWEET_APPLE)) - .put(4, () -> new ItemStack(UItems.ROTTEN_APPLE)), Blocks.SPRUCE_LOG, Blocks.SPRUCE_LEAVES); + .put(1, SOUR) + .put(2, GREEN) + .put(3, SWEET) + .put(4, ROTTEN), Blocks.SPRUCE_LOG, Blocks.SPRUCE_LEAVES); public static final TreeType ACACIA = new TreeType("acacia", new Weighted>() - .put(1, () -> new ItemStack(UItems.ROTTEN_APPLE)) - .put(2, () -> new ItemStack(UItems.SWEET_APPLE)) - .put(5, () -> new ItemStack(UItems.GREEN_APPLE)), Blocks.ACACIA_LOG, Blocks.ACACIA_LEAVES); + .put(1, ROTTEN) + .put(2, SWEET) + .put(5, GREEN), Blocks.ACACIA_LOG, Blocks.ACACIA_LEAVES); public static final TreeType JUNGLE = new TreeType("jungle", new Weighted>() - .put(5, () -> new ItemStack(UItems.GREEN_APPLE)) - .put(2, () -> new ItemStack(UItems.SWEET_APPLE)) - .put(1, () -> new ItemStack(UItems.SOUR_APPLE)), Blocks.JUNGLE_LOG, Blocks.JUNGLE_LEAVES); + .put(5, GREEN) + .put(2, SWEET) + .put(1, ZAP), Blocks.JUNGLE_LOG, Blocks.JUNGLE_LEAVES); public static final TreeType DARK_OAK = new TreeType("dark_oak", new Weighted>() - .put(1, () -> new ItemStack(UItems.ROTTEN_APPLE)) - .put(2, () -> new ItemStack(UItems.SWEET_APPLE)) - .put(5, () -> new ItemStack(UItems.ZAP_APPLE)), Blocks.DARK_OAK_LOG, Blocks.DARK_OAK_LEAVES); + .put(1, ROTTEN) + .put(2, SWEET) + .put(5, ZAP), Blocks.DARK_OAK_LOG, Blocks.DARK_OAK_LEAVES); private final String name; private final Set blocks; diff --git a/src/main/java/com/minelittlepony/unicopia/Unicopia.java b/src/main/java/com/minelittlepony/unicopia/Unicopia.java index b6b804ce..5b7127b1 100644 --- a/src/main/java/com/minelittlepony/unicopia/Unicopia.java +++ b/src/main/java/com/minelittlepony/unicopia/Unicopia.java @@ -2,26 +2,12 @@ package com.minelittlepony.unicopia; import net.fabricmc.api.ModInitializer; import net.fabricmc.fabric.api.event.world.WorldTickCallback; -import net.fabricmc.fabric.api.loot.v1.FabricLootSupplier; -import net.fabricmc.fabric.api.loot.v1.event.LootTableLoadingCallback; -import net.fabricmc.fabric.api.resource.ResourceManagerHelper; -import net.minecraft.loot.LootTable; -import net.minecraft.resource.ResourceType; -import net.minecraft.util.Identifier; - import org.apache.logging.log4j.LogManager; import org.apache.logging.log4j.Logger; -import com.minelittlepony.unicopia.advancement.BOHDeathCriterion; -import com.minelittlepony.unicopia.block.UBlocks; import com.minelittlepony.unicopia.command.Commands; -import com.minelittlepony.unicopia.container.UContainers; -import com.minelittlepony.unicopia.enchanting.Pages; -import com.minelittlepony.unicopia.item.UItems; -import com.minelittlepony.unicopia.mixin.CriterionsRegistry; import com.minelittlepony.unicopia.network.Channel; -import com.minelittlepony.unicopia.recipe.URecipes; -import com.minelittlepony.unicopia.structure.UStructures; +import com.minelittlepony.unicopia.world.UnicopiaWorld; public class Unicopia implements ModInitializer { @@ -45,26 +31,9 @@ public class Unicopia implements ModInitializer { Channel.bootstrap(); UTags.bootstrap(); Commands.bootstrap(); - UBlocks.bootstrap(); - UItems.bootstrap(); - UContainers.bootstrap(); - UStructures.bootstrap(); - URecipes.bootstrap(); - CriterionsRegistry.register(BOHDeathCriterion.INSTANCE); - ResourceManagerHelper.get(ResourceType.SERVER_DATA).registerReloadListener(Pages.instance()); WorldTickCallback.EVENT.register(AwaitTickQueue::tick); - LootTableLoadingCallback.EVENT.register((res, manager, id, supplier, setter) -> { - if (!"minecraft".contentEquals(id.getNamespace())) { - return; - } - - Identifier modId = new Identifier("unicopiamc", id.getPath()); - LootTable table = manager.getSupplier(modId); - if (table != LootTable.EMPTY) { - supplier.withPools(((FabricLootSupplier)table).getPools()); - } - }); + UnicopiaWorld.bootstrap(); } } diff --git a/src/main/java/com/minelittlepony/unicopia/ability/Abilities.java b/src/main/java/com/minelittlepony/unicopia/ability/Abilities.java index abdfe6f0..a0766682 100644 --- a/src/main/java/com/minelittlepony/unicopia/ability/Abilities.java +++ b/src/main/java/com/minelittlepony/unicopia/ability/Abilities.java @@ -5,13 +5,14 @@ import java.util.HashSet; import java.util.Map; import java.util.Set; +import com.minelittlepony.unicopia.util.Registries; + import net.minecraft.util.Identifier; -import net.minecraft.util.registry.MutableRegistry; -import net.minecraft.util.registry.SimpleRegistry; +import net.minecraft.util.registry.Registry; public interface Abilities { Map>> BY_SLOT = new EnumMap<>(AbilitySlot.class); - MutableRegistry> REGISTRY = new SimpleRegistry<>(); + Registry> REGISTRY = Registries.createSimple(new Identifier("unicopia", "abilities")); // unicorn / alicorn Ability TELEPORT = register(new UnicornTeleportAbility(), "teleport", AbilitySlot.SECONDARY); @@ -35,6 +36,6 @@ public interface Abilities { static > T register(T power, String name, AbilitySlot slot) { Identifier id = new Identifier("unicopia", name); BY_SLOT.computeIfAbsent(slot, s -> new HashSet<>()).add(power); - return REGISTRY.add(id, power); + return Registry.register(REGISTRY, id, power); } } diff --git a/src/main/java/com/minelittlepony/unicopia/ability/Ability.java b/src/main/java/com/minelittlepony/unicopia/ability/Ability.java index c6428de8..64410d5d 100644 --- a/src/main/java/com/minelittlepony/unicopia/ability/Ability.java +++ b/src/main/java/com/minelittlepony/unicopia/ability/Ability.java @@ -4,7 +4,7 @@ import javax.annotation.Nullable; import com.minelittlepony.unicopia.Race; import com.minelittlepony.unicopia.ability.data.Hit; -import com.minelittlepony.unicopia.entity.player.Pony; +import com.minelittlepony.unicopia.equine.player.Pony; import net.minecraft.world.World; diff --git a/src/main/java/com/minelittlepony/unicopia/ability/AbilityDispatcher.java b/src/main/java/com/minelittlepony/unicopia/ability/AbilityDispatcher.java index d6b8db40..1c55cf0e 100644 --- a/src/main/java/com/minelittlepony/unicopia/ability/AbilityDispatcher.java +++ b/src/main/java/com/minelittlepony/unicopia/ability/AbilityDispatcher.java @@ -6,7 +6,7 @@ import java.util.Optional; import com.minelittlepony.unicopia.Race; import com.minelittlepony.unicopia.ability.data.Hit; -import com.minelittlepony.unicopia.entity.player.Pony; +import com.minelittlepony.unicopia.equine.player.Pony; import com.minelittlepony.unicopia.network.MsgPlayerAbility; import com.minelittlepony.unicopia.network.Channel; import com.minelittlepony.unicopia.util.NbtSerialisable; diff --git a/src/main/java/com/minelittlepony/unicopia/ability/CarryAbility.java b/src/main/java/com/minelittlepony/unicopia/ability/CarryAbility.java index 580c9c80..15dd457a 100644 --- a/src/main/java/com/minelittlepony/unicopia/ability/CarryAbility.java +++ b/src/main/java/com/minelittlepony/unicopia/ability/CarryAbility.java @@ -2,13 +2,13 @@ package com.minelittlepony.unicopia.ability; import com.minelittlepony.unicopia.Race; import com.minelittlepony.unicopia.ability.data.Hit; -import com.minelittlepony.unicopia.entity.player.Pony; +import com.minelittlepony.unicopia.equine.player.Pony; import com.minelittlepony.unicopia.util.VecHelper; -import net.minecraft.client.network.packet.EntityPassengersSetS2CPacket; import net.minecraft.entity.Entity; import net.minecraft.entity.LivingEntity; import net.minecraft.entity.player.PlayerEntity; +import net.minecraft.network.packet.s2c.play.EntityPassengersSetS2CPacket; import net.minecraft.server.network.ServerPlayerEntity; import net.minecraft.world.World; diff --git a/src/main/java/com/minelittlepony/unicopia/ability/ChangelingDisguiseAbility.java b/src/main/java/com/minelittlepony/unicopia/ability/ChangelingDisguiseAbility.java index 60a96975..9b732fb0 100644 --- a/src/main/java/com/minelittlepony/unicopia/ability/ChangelingDisguiseAbility.java +++ b/src/main/java/com/minelittlepony/unicopia/ability/ChangelingDisguiseAbility.java @@ -3,10 +3,10 @@ package com.minelittlepony.unicopia.ability; import javax.annotation.Nullable; +import com.minelittlepony.unicopia.InAnimate; import com.minelittlepony.unicopia.Race; import com.minelittlepony.unicopia.ability.data.Hit; -import com.minelittlepony.unicopia.entity.InAnimate; -import com.minelittlepony.unicopia.entity.player.Pony; +import com.minelittlepony.unicopia.equine.player.Pony; import com.minelittlepony.unicopia.magic.spell.DisguiseSpell; import com.minelittlepony.unicopia.particles.UParticles; import com.minelittlepony.unicopia.util.VecHelper; diff --git a/src/main/java/com/minelittlepony/unicopia/ability/ChangelingFeedAbility.java b/src/main/java/com/minelittlepony/unicopia/ability/ChangelingFeedAbility.java index e29fe103..5d944ba0 100644 --- a/src/main/java/com/minelittlepony/unicopia/ability/ChangelingFeedAbility.java +++ b/src/main/java/com/minelittlepony/unicopia/ability/ChangelingFeedAbility.java @@ -7,7 +7,7 @@ import javax.annotation.Nullable; import com.minelittlepony.unicopia.Race; import com.minelittlepony.unicopia.ability.data.Hit; -import com.minelittlepony.unicopia.entity.player.Pony; +import com.minelittlepony.unicopia.equine.player.Pony; import com.minelittlepony.unicopia.particles.ParticleUtils; import com.minelittlepony.unicopia.particles.UParticles; import com.minelittlepony.unicopia.util.MagicalDamageSource; @@ -59,7 +59,7 @@ public class ChangelingFeedAbility implements Ability { } private boolean canFeed(Pony player) { - return player.getOwner().getHealth() < player.getOwner().getMaximumHealth() || player.getOwner().canConsume(false); + return player.getOwner().getHealth() < player.getOwner().getMaxHealth() || player.getOwner().canConsume(false); } private boolean canDrain(Entity e) { @@ -92,7 +92,7 @@ public class ChangelingFeedAbility implements Ability { public void apply(Pony iplayer, Hit data) { PlayerEntity player = iplayer.getOwner(); - float maximumHealthGain = player.getMaximumHealth() - player.getHealth(); + float maximumHealthGain = player.getMaxHealth() - player.getHealth(); int maximumFoodGain = player.canConsume(false) ? (20 - player.getHungerManager().getFoodLevel()) : 0; if (maximumHealthGain > 0 || maximumFoodGain > 0) { diff --git a/src/main/java/com/minelittlepony/unicopia/ability/ChangelingTrapAbility.java b/src/main/java/com/minelittlepony/unicopia/ability/ChangelingTrapAbility.java deleted file mode 100644 index 9489464a..00000000 --- a/src/main/java/com/minelittlepony/unicopia/ability/ChangelingTrapAbility.java +++ /dev/null @@ -1,54 +0,0 @@ -package com.minelittlepony.unicopia.ability; - -import javax.annotation.Nullable; - -import com.minelittlepony.unicopia.Race; -import com.minelittlepony.unicopia.ability.data.Hit; -import com.minelittlepony.unicopia.entity.player.Pony; -import com.minelittlepony.unicopia.magic.spell.ChangelingTrapSpell; - -// TODO: Make this a throwable item instead -@Deprecated -public class ChangelingTrapAbility implements Ability { - - @Override - public int getWarmupTime(Pony player) { - return 0; - } - - @Override - public int getCooldownTime(Pony player) { - return 30; - } - - @Override - public boolean canUse(Race playerSpecies) { - return playerSpecies == Race.CHANGELING; - } - - @Nullable - @Override - public Hit tryActivate(Pony player) { - return Hit.INSTANCE; - } - - @Override - public Hit.Serializer getSerializer() { - return Hit.SERIALIZER; - } - - @Override - public void apply(Pony player, Hit data) { - new ChangelingTrapSpell().toss(player); - } - - @Override - public void preApply(Pony player, AbilitySlot slot) { - - } - - @Override - public void postApply(Pony player, AbilitySlot slot) { - - } -} diff --git a/src/main/java/com/minelittlepony/unicopia/ability/EarthPonyGrowAbility.java b/src/main/java/com/minelittlepony/unicopia/ability/EarthPonyGrowAbility.java index 9e7f815c..2614ecb3 100644 --- a/src/main/java/com/minelittlepony/unicopia/ability/EarthPonyGrowAbility.java +++ b/src/main/java/com/minelittlepony/unicopia/ability/EarthPonyGrowAbility.java @@ -3,7 +3,7 @@ package com.minelittlepony.unicopia.ability; import com.minelittlepony.unicopia.Race; import com.minelittlepony.unicopia.ability.data.Hit; import com.minelittlepony.unicopia.ability.data.Pos; -import com.minelittlepony.unicopia.entity.player.Pony; +import com.minelittlepony.unicopia.equine.player.Pony; import com.minelittlepony.unicopia.particles.MagicParticleEffect; import com.minelittlepony.unicopia.util.VecHelper; diff --git a/src/main/java/com/minelittlepony/unicopia/ability/EarthPonyStompAbility.java b/src/main/java/com/minelittlepony/unicopia/ability/EarthPonyStompAbility.java index 9383da22..3c664f76 100644 --- a/src/main/java/com/minelittlepony/unicopia/ability/EarthPonyStompAbility.java +++ b/src/main/java/com/minelittlepony/unicopia/ability/EarthPonyStompAbility.java @@ -11,7 +11,7 @@ import com.minelittlepony.unicopia.TreeTraverser; import com.minelittlepony.unicopia.TreeType; import com.minelittlepony.unicopia.ability.data.Hit; import com.minelittlepony.unicopia.ability.data.Multi; -import com.minelittlepony.unicopia.entity.player.Pony; +import com.minelittlepony.unicopia.equine.player.Pony; import com.minelittlepony.unicopia.util.MagicalDamageSource; import com.minelittlepony.unicopia.util.PosHelper; import com.minelittlepony.unicopia.util.VecHelper; @@ -23,14 +23,14 @@ import net.minecraft.block.Block; import net.minecraft.block.BlockState; import net.minecraft.block.Blocks; import net.minecraft.block.LeavesBlock; -import net.minecraft.block.LogBlock; -import net.minecraft.entity.EntityContext; +import net.minecraft.block.ShapeContext; import net.minecraft.entity.ItemEntity; import net.minecraft.entity.attribute.EntityAttributes; import net.minecraft.entity.damage.DamageSource; import net.minecraft.entity.player.PlayerEntity; import net.minecraft.particle.BlockStateParticleEffect; import net.minecraft.particle.ParticleTypes; +import net.minecraft.tag.BlockTags; import net.minecraft.util.hit.BlockHitResult; import net.minecraft.util.hit.HitResult; import net.minecraft.util.math.BlockPos; @@ -76,7 +76,7 @@ public class EarthPonyStompAbility implements Ability { BlockPos pos = ((BlockHitResult)mop).getBlockPos(); BlockState state = player.getWorld().getBlockState(pos); - if (state.getBlock() instanceof LogBlock) { + if (state.getBlock().isIn(BlockTags.LOGS)) { pos = TreeTraverser.descendTree(player.getWorld(), state, pos).get(); if (TreeTraverser.measureTree(player.getWorld(), state, pos) > 0) { return new Multi(pos, 1); @@ -84,7 +84,7 @@ public class EarthPonyStompAbility implements Ability { } } - if (!player.getOwner().onGround && !player.getOwner().abilities.flying) { + if (!player.getOwner().isOnGround() && !player.getOwner().abilities.flying) { player.getOwner().addVelocity(0, -6, 0); return new Multi(Vec3i.ZERO, 0); } @@ -121,7 +121,7 @@ public class EarthPonyStompAbility implements Ability { DamageSource damage = MagicalDamageSource.causePlayerDamage("smash", player); - double amount = (4 * player.getAttributeInstance(EntityAttributes.ATTACK_DAMAGE).getValue()) / (float)dist; + double amount = (4 * player.getAttributeInstance(EntityAttributes.GENERIC_ATTACK_DAMAGE).getValue()) / (float)dist; if (i instanceof PlayerEntity) { Race race = Pony.of((PlayerEntity)i).getSpecies(); @@ -151,7 +151,7 @@ public class EarthPonyStompAbility implements Ability { iplayer.subtractEnergyCost(rad); } else if (data.hitType == 1) { - boolean harmed = player.getHealth() < player.getMaximumHealth(); + boolean harmed = player.getHealth() < player.getMaxHealth(); if (harmed && player.world.random.nextInt(30) == 0) { iplayer.subtractEnergyCost(3); @@ -179,14 +179,13 @@ public class EarthPonyStompAbility implements Ability { BlockState state = w.getBlockState(pos); if (!state.isAir() && w.getBlockState(pos.up()).isAir()) { - WorldEvent.DESTROY_BLOCK.play(w, pos, state); + WorldEvent.play(WorldEvent.DESTROY_BLOCK, w, pos, state); } } @Override public void preApply(Pony player, AbilitySlot slot) { player.getMagicalReserves().addExertion(40); - player.getOwner().attemptSprintingParticles(); } @Override @@ -247,7 +246,7 @@ public class EarthPonyStompAbility implements Ability { BlockState state = w.getBlockState(pos); if (state.getBlock() instanceof LeavesBlock && w.getBlockState(pos.down()).isAir()) { - WorldEvent.DESTROY_BLOCK.play(w, pos, state); + WorldEvent.play(WorldEvent.DESTROY_BLOCK, w, pos, state); drops.add(new ItemEntity(w, pos.getX() + w.random.nextFloat(), pos.getY() - 0.5, @@ -264,10 +263,10 @@ public class EarthPonyStompAbility implements Ability { } private static BlockPos getSolidBlockBelow(BlockPos pos, World w) { - while (World.isValid(pos)) { + while (!World.isHeightInvalid(pos)) { pos = pos.down(); - if (Block.isFaceFullSquare(w.getBlockState(pos).getCollisionShape(w, pos, EntityContext.absent()), Direction.UP)) { + if (Block.isFaceFullSquare(w.getBlockState(pos).getCollisionShape(w, pos, ShapeContext.absent()), Direction.UP)) { return pos; } } diff --git a/src/main/java/com/minelittlepony/unicopia/ability/FlightPredicate.java b/src/main/java/com/minelittlepony/unicopia/ability/FlightPredicate.java index ac635a5e..fb96ece0 100644 --- a/src/main/java/com/minelittlepony/unicopia/ability/FlightPredicate.java +++ b/src/main/java/com/minelittlepony/unicopia/ability/FlightPredicate.java @@ -1,6 +1,6 @@ package com.minelittlepony.unicopia.ability; -import com.minelittlepony.unicopia.entity.player.Pony; +import com.minelittlepony.unicopia.equine.player.Pony; /** * Predicate for abilities to control whether a player can fly. diff --git a/src/main/java/com/minelittlepony/unicopia/ability/HeightPredicate.java b/src/main/java/com/minelittlepony/unicopia/ability/HeightPredicate.java index 12aa6c9e..c3fe5420 100644 --- a/src/main/java/com/minelittlepony/unicopia/ability/HeightPredicate.java +++ b/src/main/java/com/minelittlepony/unicopia/ability/HeightPredicate.java @@ -1,6 +1,6 @@ package com.minelittlepony.unicopia.ability; -import com.minelittlepony.unicopia.entity.player.Pony; +import com.minelittlepony.unicopia.equine.player.Pony; /** * Predicate for abilities to control what the player's physical height is. diff --git a/src/main/java/com/minelittlepony/unicopia/ability/PegasusCloudInteractionAbility.java b/src/main/java/com/minelittlepony/unicopia/ability/PegasusCloudInteractionAbility.java index 5b2b343c..4555ded5 100644 --- a/src/main/java/com/minelittlepony/unicopia/ability/PegasusCloudInteractionAbility.java +++ b/src/main/java/com/minelittlepony/unicopia/ability/PegasusCloudInteractionAbility.java @@ -5,7 +5,7 @@ import java.util.Optional; import com.minelittlepony.unicopia.Race; import com.minelittlepony.unicopia.ability.data.Hit; import com.minelittlepony.unicopia.ability.data.Numeric; -import com.minelittlepony.unicopia.entity.player.Pony; +import com.minelittlepony.unicopia.equine.player.Pony; import com.minelittlepony.unicopia.particles.MagicParticleEffect; import com.minelittlepony.unicopia.particles.UParticles; import com.minelittlepony.unicopia.util.VecHelper; @@ -51,15 +51,15 @@ public class PegasusCloudInteractionAbility implements Ability { }); } - protected Optional findTarget(Pony player) { - if (player.getOwner().hasVehicle() && player.getOwner().getVehicle() instanceof ICloudEntity) { - return Optional.ofNullable((ICloudEntity)player.getOwner().getVehicle()); + protected Optional findTarget(Pony player) { + if (player.getOwner().hasVehicle() && player.getOwner().getVehicle() instanceof Interactable) { + return Optional.ofNullable((Interactable)player.getOwner().getVehicle()); } Entity e = VecHelper.getLookedAtEntity(player.getOwner(), 18); - if (e instanceof ICloudEntity) { - return Optional.of((ICloudEntity)e); + if (e instanceof Interactable) { + return Optional.of((Interactable)e); } return Optional.empty(); @@ -75,7 +75,7 @@ public class PegasusCloudInteractionAbility implements Ability { player.spawnParticles(UParticles.RAIN_DROPS, 5); } - public interface ICloudEntity { + public interface Interactable { void handlePegasusInteration(int interationType); } } diff --git a/src/main/java/com/minelittlepony/unicopia/ability/UnicornCastingAbility.java b/src/main/java/com/minelittlepony/unicopia/ability/UnicornCastingAbility.java index 744349c4..8bfaf966 100644 --- a/src/main/java/com/minelittlepony/unicopia/ability/UnicornCastingAbility.java +++ b/src/main/java/com/minelittlepony/unicopia/ability/UnicornCastingAbility.java @@ -3,7 +3,7 @@ package com.minelittlepony.unicopia.ability; import com.google.common.collect.Streams; import com.minelittlepony.unicopia.Race; import com.minelittlepony.unicopia.ability.data.Hit; -import com.minelittlepony.unicopia.entity.player.Pony; +import com.minelittlepony.unicopia.equine.player.Pony; import com.minelittlepony.unicopia.magic.spell.ShieldSpell; import com.minelittlepony.unicopia.magic.spell.SpellRegistry; import com.minelittlepony.unicopia.particles.MagicParticleEffect; diff --git a/src/main/java/com/minelittlepony/unicopia/ability/UnicornTeleportAbility.java b/src/main/java/com/minelittlepony/unicopia/ability/UnicornTeleportAbility.java index 59d021f5..8d5ade01 100644 --- a/src/main/java/com/minelittlepony/unicopia/ability/UnicornTeleportAbility.java +++ b/src/main/java/com/minelittlepony/unicopia/ability/UnicornTeleportAbility.java @@ -3,7 +3,7 @@ package com.minelittlepony.unicopia.ability; import com.minelittlepony.unicopia.Race; import com.minelittlepony.unicopia.ability.data.Hit; import com.minelittlepony.unicopia.ability.data.Pos; -import com.minelittlepony.unicopia.entity.player.Pony; +import com.minelittlepony.unicopia.equine.player.Pony; import com.minelittlepony.unicopia.particles.MagicParticleEffect; import com.minelittlepony.unicopia.util.VecHelper; @@ -12,9 +12,9 @@ import net.minecraft.block.BlockState; import net.minecraft.block.FenceBlock; import net.minecraft.block.LeavesBlock; import net.minecraft.block.WallBlock; -import net.minecraft.client.network.packet.EntityPassengersSetS2CPacket; import net.minecraft.entity.Entity; import net.minecraft.entity.player.PlayerEntity; +import net.minecraft.network.packet.s2c.play.EntityPassengersSetS2CPacket; import net.minecraft.server.network.ServerPlayerEntity; import net.minecraft.sound.SoundCategory; import net.minecraft.sound.SoundEvents; diff --git a/src/main/java/com/minelittlepony/unicopia/ability/data/Hit.java b/src/main/java/com/minelittlepony/unicopia/ability/data/Hit.java index f8beede9..454b50c9 100644 --- a/src/main/java/com/minelittlepony/unicopia/ability/data/Hit.java +++ b/src/main/java/com/minelittlepony/unicopia/ability/data/Hit.java @@ -1,6 +1,6 @@ package com.minelittlepony.unicopia.ability.data; -import net.minecraft.util.PacketByteBuf; +import net.minecraft.network.PacketByteBuf; public class Hit { diff --git a/src/main/java/com/minelittlepony/unicopia/ability/data/Multi.java b/src/main/java/com/minelittlepony/unicopia/ability/data/Multi.java index 1defe557..98ac3fe6 100644 --- a/src/main/java/com/minelittlepony/unicopia/ability/data/Multi.java +++ b/src/main/java/com/minelittlepony/unicopia/ability/data/Multi.java @@ -1,6 +1,6 @@ package com.minelittlepony.unicopia.ability.data; -import net.minecraft.util.PacketByteBuf; +import net.minecraft.network.PacketByteBuf; import net.minecraft.util.math.Vec3i; public class Multi extends Pos { diff --git a/src/main/java/com/minelittlepony/unicopia/ability/data/Numeric.java b/src/main/java/com/minelittlepony/unicopia/ability/data/Numeric.java index 4f9d69ba..30334814 100644 --- a/src/main/java/com/minelittlepony/unicopia/ability/data/Numeric.java +++ b/src/main/java/com/minelittlepony/unicopia/ability/data/Numeric.java @@ -2,7 +2,7 @@ package com.minelittlepony.unicopia.ability.data; import com.google.gson.annotations.Expose; -import net.minecraft.util.PacketByteBuf; +import net.minecraft.network.PacketByteBuf; public class Numeric extends Hit { public static final Serializer SERIALIZER = Numeric::new; diff --git a/src/main/java/com/minelittlepony/unicopia/ability/data/Pos.java b/src/main/java/com/minelittlepony/unicopia/ability/data/Pos.java index 6c85c249..412ddb54 100644 --- a/src/main/java/com/minelittlepony/unicopia/ability/data/Pos.java +++ b/src/main/java/com/minelittlepony/unicopia/ability/data/Pos.java @@ -1,6 +1,6 @@ package com.minelittlepony.unicopia.ability.data; -import net.minecraft.util.PacketByteBuf; +import net.minecraft.network.PacketByteBuf; import net.minecraft.util.math.BlockPos; public class Pos extends Hit { diff --git a/src/main/java/com/minelittlepony/unicopia/client/ClientInteractionManager.java b/src/main/java/com/minelittlepony/unicopia/client/ClientInteractionManager.java index 194855fb..d5bfb429 100644 --- a/src/main/java/com/minelittlepony/unicopia/client/ClientInteractionManager.java +++ b/src/main/java/com/minelittlepony/unicopia/client/ClientInteractionManager.java @@ -6,7 +6,7 @@ import javax.annotation.Nullable; import com.minelittlepony.unicopia.InteractionManager; import com.minelittlepony.unicopia.Race; import com.minelittlepony.unicopia.Unicopia; -import com.minelittlepony.unicopia.entity.player.Pony; +import com.minelittlepony.unicopia.equine.player.Pony; import com.minelittlepony.unicopia.util.dummy.DummyClientPlayerEntity; import com.mojang.authlib.GameProfile; diff --git a/src/main/java/com/minelittlepony/unicopia/client/KeyBindingsHandler.java b/src/main/java/com/minelittlepony/unicopia/client/KeyBindingsHandler.java index d3b4899c..9195e3ec 100644 --- a/src/main/java/com/minelittlepony/unicopia/client/KeyBindingsHandler.java +++ b/src/main/java/com/minelittlepony/unicopia/client/KeyBindingsHandler.java @@ -8,14 +8,11 @@ import java.util.Set; import org.lwjgl.glfw.GLFW; import com.minelittlepony.unicopia.ability.AbilitySlot; -import com.minelittlepony.unicopia.entity.player.Pony; +import com.minelittlepony.unicopia.equine.player.Pony; -import net.fabricmc.fabric.api.client.keybinding.FabricKeyBinding; -import net.fabricmc.fabric.api.client.keybinding.KeyBindingRegistry; +import net.fabricmc.fabric.api.client.keybinding.v1.KeyBindingHelper; import net.minecraft.client.MinecraftClient; import net.minecraft.client.options.KeyBinding; -import net.minecraft.client.util.InputUtil; -import net.minecraft.util.Identifier; class KeyBindingsHandler { private final String KEY_CATEGORY = "unicopia.category.name"; @@ -25,20 +22,13 @@ class KeyBindingsHandler { private final Set pressed = new HashSet<>(); public KeyBindingsHandler() { - KeyBindingRegistry.INSTANCE.addCategory(KEY_CATEGORY); - addKeybind(GLFW.GLFW_KEY_O, AbilitySlot.PRIMARY); addKeybind(GLFW.GLFW_KEY_P, AbilitySlot.SECONDARY); addKeybind(GLFW.GLFW_KEY_L, AbilitySlot.TERTIARY); } public void addKeybind(int code, AbilitySlot slot) { - KeyBindingRegistry.INSTANCE.addCategory(KEY_CATEGORY); - - FabricKeyBinding b = FabricKeyBinding.Builder.create(new Identifier("unicopia", slot.name().toLowerCase()), InputUtil.Type.KEYSYM, code, KEY_CATEGORY).build(); - KeyBindingRegistry.INSTANCE.register(b); - - keys.put(b, slot); + keys.put(KeyBindingHelper.registerKeyBinding(new KeyBinding("key.unicopia" + slot.name().toLowerCase(), code, KEY_CATEGORY)), slot); } public void tick(MinecraftClient client) { diff --git a/src/main/java/com/minelittlepony/unicopia/client/URenderers.java b/src/main/java/com/minelittlepony/unicopia/client/URenderers.java index 7f010312..58a1e710 100644 --- a/src/main/java/com/minelittlepony/unicopia/client/URenderers.java +++ b/src/main/java/com/minelittlepony/unicopia/client/URenderers.java @@ -1,65 +1,22 @@ package com.minelittlepony.unicopia.client; -import com.minelittlepony.unicopia.block.UBlocks; -import com.minelittlepony.unicopia.client.gui.UScreens; import com.minelittlepony.unicopia.client.particle.ChangelingMagicParticle; import com.minelittlepony.unicopia.client.particle.DiskParticle; import com.minelittlepony.unicopia.client.particle.MagicParticle; import com.minelittlepony.unicopia.client.particle.RaindropsParticle; import com.minelittlepony.unicopia.client.particle.SphereParticle; -import com.minelittlepony.unicopia.client.render.ButterflyEntityRenderer; -import com.minelittlepony.unicopia.client.render.CloudEntityRenderer; -import com.minelittlepony.unicopia.client.render.CucoonEntityRenderer; -import com.minelittlepony.unicopia.client.render.RainbowEntityRenderer; -import com.minelittlepony.unicopia.client.render.SpearEntityRenderer; -import com.minelittlepony.unicopia.client.render.SpellbookEntityRender; -import com.minelittlepony.unicopia.client.render.SpellcastEntityRenderer; -import com.minelittlepony.unicopia.entity.UEntities; import com.minelittlepony.unicopia.particles.UParticles; - -import net.fabricmc.fabric.api.blockrenderlayer.v1.BlockRenderLayerMap; +import com.minelittlepony.unicopia.world.client.UWorldClient; import net.fabricmc.fabric.api.client.particle.v1.ParticleFactoryRegistry; -import net.fabricmc.fabric.api.client.rendereregistry.v1.EntityRendererRegistry; -import net.minecraft.client.render.RenderLayer; -import net.minecraft.client.render.entity.FlyingItemEntityRenderer; public interface URenderers { static void bootstrap() { - EntityRendererRegistry.INSTANCE.register(UEntities.CLOUD, CloudEntityRenderer::new); - EntityRendererRegistry.INSTANCE.register(UEntities.WILD_CLOUD, CloudEntityRenderer::new); - EntityRendererRegistry.INSTANCE.register(UEntities.CONSTRUCTION_CLOUD, CloudEntityRenderer::new); - EntityRendererRegistry.INSTANCE.register(UEntities.RACING_CLOUD, CloudEntityRenderer::new); - EntityRendererRegistry.INSTANCE.register(UEntities.MAGIC_SPELL, SpellcastEntityRenderer::new); - EntityRendererRegistry.INSTANCE.register(UEntities.THROWN_ITEM, (manager, context) -> new FlyingItemEntityRenderer<>(manager, context.getItemRenderer())); - EntityRendererRegistry.INSTANCE.register(UEntities.SPELLBOOK, SpellbookEntityRender::new); - EntityRendererRegistry.INSTANCE.register(UEntities.RAINBOW, RainbowEntityRenderer::new); - EntityRendererRegistry.INSTANCE.register(UEntities.BUTTERFLY, ButterflyEntityRenderer::new); - EntityRendererRegistry.INSTANCE.register(UEntities.CUCOON, CucoonEntityRenderer::new); - EntityRendererRegistry.INSTANCE.register(UEntities.THROWN_SPEAR, SpearEntityRenderer::new); - ParticleFactoryRegistry.getInstance().register(UParticles.UNICORN_MAGIC, MagicParticle.Factory::new); ParticleFactoryRegistry.getInstance().register(UParticles.CHANGELING_MAGIC, ChangelingMagicParticle.Factory::new); ParticleFactoryRegistry.getInstance().register(UParticles.RAIN_DROPS, RaindropsParticle.Factory::new); ParticleFactoryRegistry.getInstance().register(UParticles.SPHERE, SphereParticle::new); ParticleFactoryRegistry.getInstance().register(UParticles.DISK, DiskParticle::new); - BlockRenderLayerMap.INSTANCE.putBlocks(RenderLayer.getCutout(), - UBlocks.ENCHANTED_TORCH, UBlocks.ENCHANTED_WALL_TORCH, - UBlocks.BAKERY_DOOR, UBlocks.LIBRARY_DOOR, UBlocks.MISTED_GLASS_DOOR, UBlocks.DIAMOND_DOOR, - UBlocks.APPLE_SAPLING, UBlocks.ALFALFA_CROPS, - UBlocks.TOMATO_PLANT, UBlocks.CLOUDSDALE_TOMATO_PLANT - ); - BlockRenderLayerMap.INSTANCE.putBlocks(RenderLayer.getTranslucent(), - UBlocks.CLOUD_ANVIL, UBlocks.CLOUD_FARMLAND, - UBlocks.CLOUD_BLOCK, UBlocks.CLOUD_SLAB, UBlocks.CLOUD_STAIRS, - UBlocks.ENCHANTED_CLOUD_BLOCK, UBlocks.ENCHANTED_CLOUD_SLAB, UBlocks.ENCHANTED_CLOUD_STAIRS, - - UBlocks.SLIME_DRIP, UBlocks.SLIME_LAYER - ); - BlockRenderLayerMap.INSTANCE.putBlocks(RenderLayer.getCutoutMipped(), - UBlocks.APPLE_LEAVES - ); - - UScreens.bootstrap(); + UWorldClient.bootstrap(); } } diff --git a/src/main/java/com/minelittlepony/unicopia/client/UnicopiaClient.java b/src/main/java/com/minelittlepony/unicopia/client/UnicopiaClient.java index 80450867..fe532216 100644 --- a/src/main/java/com/minelittlepony/unicopia/client/UnicopiaClient.java +++ b/src/main/java/com/minelittlepony/unicopia/client/UnicopiaClient.java @@ -6,14 +6,15 @@ import javax.annotation.Nullable; import com.minelittlepony.unicopia.InteractionManager; import com.minelittlepony.unicopia.Race; -import com.minelittlepony.unicopia.block.UBlocks; -import com.minelittlepony.unicopia.container.SpellbookResultSlot; import com.minelittlepony.unicopia.ducks.Colourful; -import com.minelittlepony.unicopia.item.UItems; import com.minelittlepony.unicopia.magic.spell.SpellRegistry; import com.minelittlepony.unicopia.mixin.client.DefaultTexturesRegistry; import com.minelittlepony.unicopia.network.Channel; import com.minelittlepony.unicopia.network.MsgRequestCapabilities; +import com.minelittlepony.unicopia.world.block.UBlocks; +import com.minelittlepony.unicopia.world.container.SpellbookResultSlot; +import com.minelittlepony.unicopia.world.item.UItems; + import net.fabricmc.api.ClientModInitializer; import net.fabricmc.fabric.api.client.rendering.v1.ColorProviderRegistry; import net.fabricmc.fabric.api.event.client.ClientTickCallback; diff --git a/src/main/java/com/minelittlepony/unicopia/client/gui/BagOfHoldingScreen.java b/src/main/java/com/minelittlepony/unicopia/client/gui/BagOfHoldingScreen.java deleted file mode 100644 index c67535fc..00000000 --- a/src/main/java/com/minelittlepony/unicopia/client/gui/BagOfHoldingScreen.java +++ /dev/null @@ -1,107 +0,0 @@ -package com.minelittlepony.unicopia.client.gui; - -import com.minelittlepony.common.client.gui.element.Scrollbar; -import com.minelittlepony.unicopia.container.BagOfHoldingContainer; -import com.mojang.blaze3d.platform.GlStateManager; - -import net.minecraft.client.gui.screen.ingame.ContainerScreen; -import net.minecraft.entity.player.PlayerEntity; -import net.minecraft.sound.SoundEvents; -import net.minecraft.util.Identifier; -import net.minecraft.util.PacketByteBuf; - -public class BagOfHoldingScreen extends ContainerScreen { - private static final Identifier CHEST_GUI_TEXTURE = new Identifier("textures/gui/container/generic_54.png"); - - private final int inventoryRows; - private final int playerRows; - - private final Scrollbar scrollbar = new Scrollbar(); - - public BagOfHoldingScreen(int sync, Identifier id, PlayerEntity player, PacketByteBuf buf) { - super(new BagOfHoldingContainer(sync, id, player, buf), player.inventory, buf.readText()); - - playerRows = playerInventory.getInvSize() / 9; - inventoryRows = (container.slots.size() / 9) - 1; - } - - @Override - public void init() { - super.init(); - scrollbar.reposition( - x + containerWidth, - y, - containerHeight, - (inventoryRows + 1) * 18 + 17); - children.add(scrollbar); - } - - @Override - public void onClose() { - super.onClose(); - minecraft.player.playSound(SoundEvents.BLOCK_ENDER_CHEST_OPEN, 0.5F, 0.5F); - } - - @Override - public void render(int mouseX, int mouseY, float partialTicks) { - renderBackground(); - - scrollbar.render(mouseX, mouseY, partialTicks); - - int scroll = -scrollbar.getScrollAmount(); - - GlStateManager.pushMatrix(); - GlStateManager.translatef(0, scroll, 0); - - super.render(mouseX, mouseY - scroll, partialTicks); - - int h = height; - height = Integer.MAX_VALUE; - drawMouseoverTooltip(mouseX, mouseY - scroll); - height = h; - - GlStateManager.popMatrix(); - } - - @Override - public boolean mouseClicked(double x, double y, int button) { - return super.mouseClicked(x, y + scrollbar.getScrollAmount(), button); - } - - @Override - public boolean mouseDragged(double x, double y, int button, double dx, double dy) { - - if (scrollbar.isMouseOver(x, y)) { - return scrollbar.mouseDragged(x, y + scrollbar.getScrollAmount(), button, dx, dy); - } - - return super.mouseDragged(x, y + scrollbar.getScrollAmount(), button, dx, dy); - } - - @Override - public boolean mouseReleased(double x, double y, int button) { - return super.mouseReleased(x, y + scrollbar.getScrollAmount(), button); - } - - @Override - protected void drawForeground(int mouseX, int mouseY) { - font.draw(title.asString(), 8, 6, 0x404040); - } - - @Override - protected void drawBackground(float partialTicks, int mouseX, int mouseY) { - GlStateManager.color4f(1, 1, 1, 1); - - minecraft.getTextureManager().bindTexture(CHEST_GUI_TEXTURE); - - int midX = (width - containerWidth) / 2; - int midY = (height - containerHeight) / 2; - - blit(midX, midY, 0, 0, containerWidth, 18); - for (int i = 0; i < inventoryRows - (playerRows - 1); i++) { - blit(midX, midY + (18 * (i + 1)), 0, 18, containerWidth, 18); - } - - blit(midX, midY + (18 * (inventoryRows - (playerRows - 2))) - 1, 0, 131, containerWidth, 98); - } -} diff --git a/src/main/java/com/minelittlepony/unicopia/client/gui/UScreens.java b/src/main/java/com/minelittlepony/unicopia/client/gui/UScreens.java deleted file mode 100644 index 3cbff9fa..00000000 --- a/src/main/java/com/minelittlepony/unicopia/client/gui/UScreens.java +++ /dev/null @@ -1,13 +0,0 @@ -package com.minelittlepony.unicopia.client.gui; - -import com.minelittlepony.unicopia.container.UContainers; - -import net.fabricmc.fabric.api.client.screen.ScreenProviderRegistry; - -public interface UScreens { - - static void bootstrap() { - ScreenProviderRegistry.INSTANCE.registerFactory(UContainers.BAG_OF_HOLDING, BagOfHoldingScreen::new); - ScreenProviderRegistry.INSTANCE.registerFactory(UContainers.SPELL_BOOK, SpellBookScreen::new); - } -} diff --git a/src/main/java/com/minelittlepony/unicopia/client/particle/ChangelingMagicParticle.java b/src/main/java/com/minelittlepony/unicopia/client/particle/ChangelingMagicParticle.java index 4515c7e5..9a08ee99 100644 --- a/src/main/java/com/minelittlepony/unicopia/client/particle/ChangelingMagicParticle.java +++ b/src/main/java/com/minelittlepony/unicopia/client/particle/ChangelingMagicParticle.java @@ -5,14 +5,14 @@ import net.fabricmc.api.Environment; import net.minecraft.client.particle.Particle; import net.minecraft.client.particle.ParticleFactory; import net.minecraft.client.particle.SpriteProvider; +import net.minecraft.client.world.ClientWorld; import net.minecraft.particle.DefaultParticleType; -import net.minecraft.world.World; public class ChangelingMagicParticle extends MagicParticle { private final SpriteProvider provider; - public ChangelingMagicParticle(SpriteProvider provider, World world, double x, double y, double z, double dx, double dy, double dz) { + public ChangelingMagicParticle(SpriteProvider provider, ClientWorld world, double x, double y, double z, double dx, double dy, double dz) { super(world, x, y, z, dx, dy, dz, 1, 1, 1); this.provider = provider; @@ -39,7 +39,7 @@ public class ChangelingMagicParticle extends MagicParticle { } @Override - public Particle createParticle(DefaultParticleType effect, World world, double x, double y, double z, double dx, double dy, double dz) { + public Particle createParticle(DefaultParticleType effect, ClientWorld world, double x, double y, double z, double dx, double dy, double dz) { MagicParticle particle = new MagicParticle(world, x, y, z, dx, dy, dz); particle.setSprite(provider); return particle; diff --git a/src/main/java/com/minelittlepony/unicopia/client/render/model/DiskModel.java b/src/main/java/com/minelittlepony/unicopia/client/particle/DiskModel.java similarity index 86% rename from src/main/java/com/minelittlepony/unicopia/client/render/model/DiskModel.java rename to src/main/java/com/minelittlepony/unicopia/client/particle/DiskModel.java index 84bb6fdd..51bb8521 100644 --- a/src/main/java/com/minelittlepony/unicopia/client/render/model/DiskModel.java +++ b/src/main/java/com/minelittlepony/unicopia/client/particle/DiskModel.java @@ -1,8 +1,8 @@ -package com.minelittlepony.unicopia.client.render.model; +package com.minelittlepony.unicopia.client.particle; import net.minecraft.client.render.VertexConsumer; -import net.minecraft.client.util.math.Matrix4f; import net.minecraft.client.util.math.MatrixStack; +import net.minecraft.util.math.Matrix4f; public class DiskModel extends SphereModel { diff --git a/src/main/java/com/minelittlepony/unicopia/client/particle/DiskParticle.java b/src/main/java/com/minelittlepony/unicopia/client/particle/DiskParticle.java index e75ea34d..c966a202 100644 --- a/src/main/java/com/minelittlepony/unicopia/client/particle/DiskParticle.java +++ b/src/main/java/com/minelittlepony/unicopia/client/particle/DiskParticle.java @@ -1,6 +1,5 @@ package com.minelittlepony.unicopia.client.particle; -import com.minelittlepony.unicopia.client.render.model.DiskModel; import com.minelittlepony.unicopia.particles.SphereParticleEffect; import net.minecraft.client.MinecraftClient; @@ -9,7 +8,7 @@ import net.minecraft.client.render.RenderLayer; import net.minecraft.client.render.VertexConsumer; import net.minecraft.client.render.VertexConsumerProvider; import net.minecraft.client.util.math.MatrixStack; -import net.minecraft.world.World; +import net.minecraft.client.world.ClientWorld; public class DiskParticle extends SphereParticle { @@ -19,7 +18,7 @@ public class DiskParticle extends SphereParticle { protected float rotY; protected float rotZ; - public DiskParticle(SphereParticleEffect effect, World w, double x, double y, double z, double rX, double rY, double rZ) { + public DiskParticle(SphereParticleEffect effect, ClientWorld w, double x, double y, double z, double rX, double rY, double rZ) { super(effect, w, x, y, z, 0, 0, 0); rotX = (float)rX; diff --git a/src/main/java/com/minelittlepony/unicopia/client/particle/MagicParticle.java b/src/main/java/com/minelittlepony/unicopia/client/particle/MagicParticle.java index e42595b3..92ffd84f 100644 --- a/src/main/java/com/minelittlepony/unicopia/client/particle/MagicParticle.java +++ b/src/main/java/com/minelittlepony/unicopia/client/particle/MagicParticle.java @@ -9,14 +9,14 @@ import net.minecraft.client.particle.Particle; import net.minecraft.client.particle.ParticleFactory; import net.minecraft.client.particle.ParticleTextureSheet; import net.minecraft.client.particle.SpriteBillboardParticle; -import net.minecraft.world.World; +import net.minecraft.client.world.ClientWorld; public class MagicParticle extends SpriteBillboardParticle { private double startX; private double startY; private double startZ; - MagicParticle(World w, double x, double y, double z, double vX, double vY, double vZ, float r, float g, float b) { + MagicParticle(ClientWorld w, double x, double y, double z, double vX, double vY, double vZ, float r, float g, float b) { super(w, x, y, z); velocityX = vX; velocityY = vY; @@ -32,7 +32,7 @@ public class MagicParticle extends SpriteBillboardParticle { colorBlue = b; } - MagicParticle(World w, double x, double y, double z, double vX, double vY, double vZ) { + MagicParticle(ClientWorld w, double x, double y, double z, double vX, double vY, double vZ) { this(w, x, y, z, vX, vY, vZ, 1, 1, 1); colorAlpha = 0.7F; @@ -106,7 +106,7 @@ public class MagicParticle extends SpriteBillboardParticle { } @Override - public Particle createParticle(MagicParticleEffect effect, World world, double x, double y, double z, double dx, double dy, double dz) { + public Particle createParticle(MagicParticleEffect effect, ClientWorld world, double x, double y, double z, double dx, double dy, double dz) { MagicParticle particle = effect.hasTint() ? new MagicParticle(world, x, y, z, dx, dy, dz, effect.getRed(), effect.getGreen(), effect.getBlue()) : new MagicParticle(world, x, y, z, dx, dy, dz); diff --git a/src/main/java/com/minelittlepony/unicopia/client/particle/RaindropsParticle.java b/src/main/java/com/minelittlepony/unicopia/client/particle/RaindropsParticle.java index 86a76668..c82277e3 100644 --- a/src/main/java/com/minelittlepony/unicopia/client/particle/RaindropsParticle.java +++ b/src/main/java/com/minelittlepony/unicopia/client/particle/RaindropsParticle.java @@ -4,12 +4,12 @@ import net.minecraft.client.particle.Particle; import net.minecraft.client.particle.ParticleFactory; import net.minecraft.client.particle.RainSplashParticle; import net.minecraft.client.particle.SpriteProvider; +import net.minecraft.client.world.ClientWorld; import net.minecraft.particle.DefaultParticleType; -import net.minecraft.world.World; public class RaindropsParticle extends RainSplashParticle { - public RaindropsParticle(World world, double x, double y, double z, double dx, double dy, double dz) { + public RaindropsParticle(ClientWorld world, double x, double y, double z, double dx, double dy, double dz) { super(world, x, y, z); velocityY = -0.1; maxAge += 19; @@ -34,7 +34,7 @@ public class RaindropsParticle extends RainSplashParticle { } @Override - public Particle createParticle(DefaultParticleType defaultParticleType_1, World world, double x, double y, double z, double dx, double dy, double dz) { + public Particle createParticle(DefaultParticleType defaultParticleType_1, ClientWorld world, double x, double y, double z, double dx, double dy, double dz) { RaindropsParticle particle = new RaindropsParticle(world, x, y, z, dx, dy, dz); particle.setSprite(provider); return particle; diff --git a/src/main/java/com/minelittlepony/unicopia/client/render/model/SphereModel.java b/src/main/java/com/minelittlepony/unicopia/client/particle/SphereModel.java similarity index 97% rename from src/main/java/com/minelittlepony/unicopia/client/render/model/SphereModel.java rename to src/main/java/com/minelittlepony/unicopia/client/particle/SphereModel.java index 484f7942..a036008d 100644 --- a/src/main/java/com/minelittlepony/unicopia/client/render/model/SphereModel.java +++ b/src/main/java/com/minelittlepony/unicopia/client/particle/SphereModel.java @@ -1,7 +1,7 @@ -package com.minelittlepony.unicopia.client.render.model; +package com.minelittlepony.unicopia.client.particle; import net.minecraft.client.render.VertexConsumer; -import net.minecraft.client.util.math.Matrix4f; +import net.minecraft.util.math.Matrix4f; import net.minecraft.client.util.math.MatrixStack; import net.minecraft.client.util.math.Vector3f; import net.minecraft.client.util.math.Vector4f; diff --git a/src/main/java/com/minelittlepony/unicopia/client/particle/SphereParticle.java b/src/main/java/com/minelittlepony/unicopia/client/particle/SphereParticle.java index cbae1835..958c519b 100644 --- a/src/main/java/com/minelittlepony/unicopia/client/particle/SphereParticle.java +++ b/src/main/java/com/minelittlepony/unicopia/client/particle/SphereParticle.java @@ -7,16 +7,15 @@ import net.minecraft.client.render.Camera; import net.minecraft.client.render.VertexConsumer; import net.minecraft.client.render.VertexConsumerProvider; import net.minecraft.client.util.math.MatrixStack; +import net.minecraft.client.world.ClientWorld; import net.minecraft.util.math.MathHelper; -import net.minecraft.world.World; -import com.minelittlepony.unicopia.client.render.RenderLayers; -import com.minelittlepony.unicopia.client.render.model.SphereModel; import com.minelittlepony.unicopia.magic.Caster; import com.minelittlepony.unicopia.particles.ParticleHandle.Attachment; import com.minelittlepony.unicopia.particles.ParticleHandle.Link; +import com.minelittlepony.unicopia.world.client.render.RenderLayers; import com.minelittlepony.unicopia.particles.SphereParticleEffect; -import com.minelittlepony.util.Color; +import com.minelittlepony.common.util.Color; public class SphereParticle extends Particle implements Attachment { @@ -36,7 +35,7 @@ public class SphereParticle extends Particle implements Attachment { private static final SphereModel model = new SphereModel(); - public SphereParticle(SphereParticleEffect effect, World w, double x, double y, double z, double vX, double vY, double vZ) { + public SphereParticle(SphereParticleEffect effect, ClientWorld w, double x, double y, double z, double vX, double vY, double vZ) { this(effect, w, x, y, z); this.velocityX = vX; @@ -44,7 +43,7 @@ public class SphereParticle extends Particle implements Attachment { this.velocityZ = vZ; } - public SphereParticle(SphereParticleEffect effect, World w, double x, double y, double z) { + public SphereParticle(SphereParticleEffect effect, ClientWorld w, double x, double y, double z) { super(w, x, y, z); this.radius = effect.getRadius(); diff --git a/src/main/java/com/minelittlepony/unicopia/command/Commands.java b/src/main/java/com/minelittlepony/unicopia/command/Commands.java index 5e4ca17e..87ea6387 100644 --- a/src/main/java/com/minelittlepony/unicopia/command/Commands.java +++ b/src/main/java/com/minelittlepony/unicopia/command/Commands.java @@ -1,16 +1,17 @@ package com.minelittlepony.unicopia.command; -import net.fabricmc.fabric.api.registry.CommandRegistry; +import net.fabricmc.fabric.api.command.v1.CommandRegistrationCallback; import net.fabricmc.loader.api.FabricLoader; import net.minecraft.server.MinecraftServer; public class Commands { public static void bootstrap() { - CommandRegistry.INSTANCE.register(false, SpeciesCommand::register); - CommandRegistry.INSTANCE.register(false, RacelistCommand::register); - CommandRegistry.INSTANCE.register(false, GravityCommand::register); - CommandRegistry.INSTANCE.register(false, DisguiseCommand::register); - + CommandRegistrationCallback.EVENT.register((dispatcher, dedicated) -> { + SpeciesCommand.register(dispatcher); + RacelistCommand.register(dispatcher); + GravityCommand.register(dispatcher); + DisguiseCommand.register(dispatcher); + }); Object game = FabricLoader.getInstance().getGameInstance(); if (game instanceof MinecraftServer) { ((MinecraftServer)game).setFlightEnabled(true); diff --git a/src/main/java/com/minelittlepony/unicopia/command/DisguiseCommand.java b/src/main/java/com/minelittlepony/unicopia/command/DisguiseCommand.java index f75ec99e..42e0cc5e 100644 --- a/src/main/java/com/minelittlepony/unicopia/command/DisguiseCommand.java +++ b/src/main/java/com/minelittlepony/unicopia/command/DisguiseCommand.java @@ -2,7 +2,7 @@ package com.minelittlepony.unicopia.command; import java.util.function.Function; -import com.minelittlepony.unicopia.entity.player.Pony; +import com.minelittlepony.unicopia.equine.player.Pony; import com.minelittlepony.unicopia.magic.spell.DisguiseSpell; import com.mojang.brigadier.CommandDispatcher; import com.mojang.brigadier.builder.LiteralArgumentBuilder; @@ -72,7 +72,7 @@ public class DisguiseCommand { source.sendFeedback(new TranslatableText("commands.disguise.success.other", player.getName(), entity.getName()), true); } else { if (player.getEntityWorld().getGameRules().getBoolean(GameRules.SEND_COMMAND_FEEDBACK)) { - player.sendMessage(new TranslatableText("commands.disguise.success.self", entity.getName())); + player.sendMessage(new TranslatableText("commands.disguise.success.self", entity.getName()), false); } source.sendFeedback(new TranslatableText("commands.disguise.success.otherself", player.getName(), entity.getName()), true); } @@ -87,7 +87,7 @@ public class DisguiseCommand { }); if (player.getEntityWorld().getGameRules().getBoolean(GameRules.SEND_COMMAND_FEEDBACK)) { - player.sendMessage(new TranslatableText("commands.disguise.removed")); + player.sendMessage(new TranslatableText("commands.disguise.removed"), false); } return 0; diff --git a/src/main/java/com/minelittlepony/unicopia/command/GravityCommand.java b/src/main/java/com/minelittlepony/unicopia/command/GravityCommand.java index cc6569fc..6ac7408c 100644 --- a/src/main/java/com/minelittlepony/unicopia/command/GravityCommand.java +++ b/src/main/java/com/minelittlepony/unicopia/command/GravityCommand.java @@ -1,6 +1,6 @@ package com.minelittlepony.unicopia.command; -import com.minelittlepony.unicopia.entity.player.Pony; +import com.minelittlepony.unicopia.equine.player.Pony; import com.mojang.brigadier.CommandDispatcher; import com.mojang.brigadier.arguments.FloatArgumentType; import com.mojang.brigadier.builder.LiteralArgumentBuilder; @@ -44,7 +44,7 @@ class GravityCommand { if (source.getPlayer() != player) { translationKey += ".other"; } - player.sendMessage(new TranslatableText(translationKey, player.getName(), gravity)); + player.sendMessage(new TranslatableText(translationKey, player.getName(), gravity), false); return 0; } @@ -58,7 +58,7 @@ class GravityCommand { iplayer.setDirty(); if (isSelf) { - player.sendMessage(new TranslatableText(translationKey, gravity)); + player.sendMessage(new TranslatableText(translationKey, gravity), false); } source.sendFeedback(new TranslatableText(translationKey + ".other", player.getName(), gravity), true); diff --git a/src/main/java/com/minelittlepony/unicopia/command/RacelistCommand.java b/src/main/java/com/minelittlepony/unicopia/command/RacelistCommand.java index 74e1a931..b11a2173 100644 --- a/src/main/java/com/minelittlepony/unicopia/command/RacelistCommand.java +++ b/src/main/java/com/minelittlepony/unicopia/command/RacelistCommand.java @@ -50,14 +50,9 @@ class RacelistCommand { translationKey += ".failed"; } - Text formattedName = new TranslatableText(race.name().toLowerCase()); - formattedName.getStyle().setColor(Formatting.GOLD); - - Text comp = new TranslatableText(translationKey, formattedName); - comp.getStyle().setColor(Formatting.GREEN); - - player.sendMessage(comp); + Text formattedName = new TranslatableText(race.name().toLowerCase()).styled(s -> s.withColor(Formatting.GOLD)); + player.sendMessage(new TranslatableText(translationKey, formattedName).styled(s -> s.withColor(Formatting.GREEN)), false); source.sendFeedback(new TranslatableText(translationKey + ".other", player.getName(), formattedName), true); return 0; diff --git a/src/main/java/com/minelittlepony/unicopia/command/SpeciesCommand.java b/src/main/java/com/minelittlepony/unicopia/command/SpeciesCommand.java index 5d392ea7..98e778f9 100644 --- a/src/main/java/com/minelittlepony/unicopia/command/SpeciesCommand.java +++ b/src/main/java/com/minelittlepony/unicopia/command/SpeciesCommand.java @@ -1,7 +1,7 @@ package com.minelittlepony.unicopia.command; import com.minelittlepony.unicopia.Race; -import com.minelittlepony.unicopia.entity.player.Pony; +import com.minelittlepony.unicopia.equine.player.Pony; import com.mojang.brigadier.CommandDispatcher; import com.mojang.brigadier.builder.LiteralArgumentBuilder; @@ -10,6 +10,7 @@ import net.minecraft.entity.player.PlayerEntity; import net.minecraft.server.command.CommandManager; import net.minecraft.server.command.ServerCommandSource; import net.minecraft.text.LiteralText; +import net.minecraft.text.MutableText; import net.minecraft.text.Text; import net.minecraft.text.TranslatableText; import net.minecraft.util.Formatting; @@ -57,12 +58,12 @@ class SpeciesCommand { source.sendFeedback(new TranslatableText("commands.race.success.other", player.getName(), formattedName), true); } else { if (player.getEntityWorld().getGameRules().getBoolean(GameRules.SEND_COMMAND_FEEDBACK)) { - player.sendMessage(new TranslatableText("commands.race.success.self")); + player.sendMessage(new TranslatableText("commands.race.success.self"), false); } source.sendFeedback(new TranslatableText("commands.race.success.otherself", player.getName(), formattedName), true); } } else if (player.getEntityWorld().getGameRules().getBoolean(GameRules.SEND_COMMAND_FEEDBACK)) { - player.sendMessage(new TranslatableText("commands.race.permission")); + player.sendMessage(new TranslatableText("commands.race.permission"), false); } return 0; @@ -74,22 +75,17 @@ class SpeciesCommand { String name = "commands.race.tell."; name += isSelf ? "self" : "other"; - Text race = new TranslatableText(spec.getTranslationKey()); - Text message = new TranslatableText(name); - - race.getStyle().setColor(Formatting.GOLD); - - message.append(race); - - player.sendMessage(message); + player.sendMessage(new TranslatableText(name) + .append(new TranslatableText(spec.getTranslationKey()) + .styled(s -> s.withColor(Formatting.GOLD))), false); return 0; } static int list(PlayerEntity player) { - player.sendMessage(new TranslatableText("commands.race.list")); + player.sendMessage(new TranslatableText("commands.race.list"), false); - Text message = new LiteralText(""); + MutableText message = new LiteralText(""); boolean first = true; for (Race i : Race.values()) { @@ -99,9 +95,7 @@ class SpeciesCommand { } } - message.getStyle().setColor(Formatting.GOLD); - - player.sendMessage(message); + player.sendMessage(message.styled(s -> s.withColor(Formatting.GOLD)), false); return 0; } @@ -109,17 +103,9 @@ class SpeciesCommand { static int describe(PlayerEntity player, Race species) { String name = species.name().toLowerCase(); - Text line1 = new TranslatableText(String.format("commands.race.describe.%s.1", name)); - line1.getStyle().setColor(Formatting.YELLOW); - - player.sendMessage(line1); - - player.sendMessage(new TranslatableText(String.format("commands.race.describe.%s.2", name))); - - Text line3 = new TranslatableText(String.format("commands.race.describe.%s.3", name)); - line3.getStyle().setColor(Formatting.RED); - - player.sendMessage(line3); + player.sendMessage(new TranslatableText(String.format("commands.race.describe.%s.1", name)).styled(s -> s.withColor(Formatting.YELLOW)), false); + player.sendMessage(new TranslatableText(String.format("commands.race.describe.%s.2", name)), false); + player.sendMessage(new TranslatableText(String.format("commands.race.describe.%s.3", name)).styled(s -> s.withColor(Formatting.RED)), false); return 0; } diff --git a/src/main/java/com/minelittlepony/unicopia/container/SpellBookInventory.java b/src/main/java/com/minelittlepony/unicopia/container/SpellBookInventory.java deleted file mode 100644 index bcca40c0..00000000 --- a/src/main/java/com/minelittlepony/unicopia/container/SpellBookInventory.java +++ /dev/null @@ -1,19 +0,0 @@ -package com.minelittlepony.unicopia.container; - -import net.minecraft.container.Container; -import net.minecraft.inventory.CraftingInventory; -import net.minecraft.inventory.Inventory; - -public class SpellBookInventory extends CraftingInventory { - - private final Inventory craftResult; - - public SpellBookInventory(Inventory resultMatrix, Container eventHandler, int width, int height) { - super(eventHandler, width, height); - craftResult = resultMatrix; - } - - public Inventory getCraftResultMatrix() { - return craftResult; - } -} diff --git a/src/main/java/com/minelittlepony/unicopia/container/UContainers.java b/src/main/java/com/minelittlepony/unicopia/container/UContainers.java deleted file mode 100644 index 36eee219..00000000 --- a/src/main/java/com/minelittlepony/unicopia/container/UContainers.java +++ /dev/null @@ -1,20 +0,0 @@ -package com.minelittlepony.unicopia.container; - -import net.fabricmc.fabric.api.container.ContainerFactory; -import net.fabricmc.fabric.api.container.ContainerProviderRegistry; -import net.minecraft.container.Container; -import net.minecraft.util.Identifier; - -public interface UContainers { - - Identifier BAG_OF_HOLDING = register("bag_of_holding", BagOfHoldingContainer::new); - Identifier SPELL_BOOK = register("spell_book", SpellBookContainer::new); - - static Identifier register(String name, ContainerFactory factory) { - Identifier id = new Identifier("unicopia", name); - ContainerProviderRegistry.INSTANCE.registerFactory(id, factory); - return id; - } - - static void bootstrap() { } -} diff --git a/src/main/java/com/minelittlepony/unicopia/ducks/Climbable.java b/src/main/java/com/minelittlepony/unicopia/ducks/Climbable.java deleted file mode 100644 index 54e1c63b..00000000 --- a/src/main/java/com/minelittlepony/unicopia/ducks/Climbable.java +++ /dev/null @@ -1,7 +0,0 @@ -package com.minelittlepony.unicopia.ducks; - -@Deprecated -// XXX: 1.16 Use the vanilla BlockTag once mojang adds it -public interface Climbable { - -} diff --git a/src/main/java/com/minelittlepony/unicopia/ducks/IItemEntity.java b/src/main/java/com/minelittlepony/unicopia/ducks/IItemEntity.java index 94bbaefa..1b5af94f 100644 --- a/src/main/java/com/minelittlepony/unicopia/ducks/IItemEntity.java +++ b/src/main/java/com/minelittlepony/unicopia/ducks/IItemEntity.java @@ -1,6 +1,6 @@ package com.minelittlepony.unicopia.ducks; -import com.minelittlepony.unicopia.entity.ItemImpl; +import com.minelittlepony.unicopia.equine.ItemImpl; public interface IItemEntity extends PonyContainer { diff --git a/src/main/java/com/minelittlepony/unicopia/ducks/PonyContainer.java b/src/main/java/com/minelittlepony/unicopia/ducks/PonyContainer.java index 9d68338e..2437dd4b 100644 --- a/src/main/java/com/minelittlepony/unicopia/ducks/PonyContainer.java +++ b/src/main/java/com/minelittlepony/unicopia/ducks/PonyContainer.java @@ -4,7 +4,7 @@ import java.util.Optional; import javax.annotation.Nullable; -import com.minelittlepony.unicopia.entity.Ponylike; +import com.minelittlepony.unicopia.equine.Ponylike; import com.minelittlepony.unicopia.magic.Caster; import net.minecraft.entity.Entity; diff --git a/src/main/java/com/minelittlepony/unicopia/enchanting/IUnlockEvent.java b/src/main/java/com/minelittlepony/unicopia/enchanting/IUnlockEvent.java deleted file mode 100644 index abcc5214..00000000 --- a/src/main/java/com/minelittlepony/unicopia/enchanting/IUnlockEvent.java +++ /dev/null @@ -1,5 +0,0 @@ -package com.minelittlepony.unicopia.enchanting; - -public interface IUnlockEvent { - -} diff --git a/src/main/java/com/minelittlepony/unicopia/entity/UEntities.java b/src/main/java/com/minelittlepony/unicopia/entity/UEntities.java deleted file mode 100644 index e21c481b..00000000 --- a/src/main/java/com/minelittlepony/unicopia/entity/UEntities.java +++ /dev/null @@ -1,75 +0,0 @@ -package com.minelittlepony.unicopia.entity; - -import java.util.List; - -import net.fabricmc.fabric.api.entity.FabricEntityTypeBuilder; -import net.minecraft.entity.Entity; -import net.minecraft.entity.EntityCategory; -import net.minecraft.entity.EntityDimensions; -import net.minecraft.entity.EntityType; -import net.minecraft.util.Identifier; -import net.minecraft.util.registry.Registry; -import net.minecraft.world.biome.EndBiome; -import net.minecraft.world.biome.ForestBiome; -import net.minecraft.world.biome.MountainsBiome; -import net.minecraft.world.biome.NetherBiome; -import net.minecraft.world.biome.OceanBiome; -import net.minecraft.world.biome.PlainsBiome; -import net.minecraft.world.biome.RiverBiome; - -public interface UEntities { - EntityType SPELLBOOK = register("spellbook", FabricEntityTypeBuilder.create(EntityCategory.MISC, SpellbookEntity::new) - .size(EntityDimensions.changing(0.6F, 0.6F))); - EntityType MAGIC_SPELL = register("magic_spell", FabricEntityTypeBuilder.create(EntityCategory.MISC, SpellcastEntity::new) - .size(EntityDimensions.changing(0.6F, 0.25F))); - EntityType CLOUD = register("cloud", FabricEntityTypeBuilder.create(EntityCategory.CREATURE, CloudEntity::new) - .size(CloudEntity.BASE_DIMENSIONS)); - EntityType WILD_CLOUD = register("wild_cloud", FabricEntityTypeBuilder.create(EntityCategory.CREATURE, WildCloudEntity::new) - .size(CloudEntity.BASE_DIMENSIONS)); - EntityType RACING_CLOUD = register("racing_cloud", FabricEntityTypeBuilder.create(EntityCategory.CREATURE, RacingCloudEntity::new) - .size(CloudEntity.BASE_DIMENSIONS)); - EntityType CONSTRUCTION_CLOUD = register("construction_cloud", FabricEntityTypeBuilder.create(EntityCategory.CREATURE, ConstructionCloudEntity::new) - .size(CloudEntity.BASE_DIMENSIONS)); - - EntityType RAINBOW = register("rainbow", FabricEntityTypeBuilder.create(EntityCategory.AMBIENT, RainbowEntity::new) - .size(EntityDimensions.fixed(1, 1))); - - EntityType CUCOON = register("cucoon", FabricEntityTypeBuilder.create(EntityCategory.MISC, CucoonEntity::new) - .size(EntityDimensions.changing(1.5F, 1.6F))); - - EntityType BUTTERFLY = register("butterfly", FabricEntityTypeBuilder.create(EntityCategory.AMBIENT, ButterflyEntity::new) - .size(EntityDimensions.fixed(1, 1))); - - EntityType THROWN_ITEM = register("thrown_item", FabricEntityTypeBuilder.create(EntityCategory.MISC, ProjectileEntity::new) - .trackable(100, 2) - .size(EntityDimensions.fixed(0.25F, 0.25F))); - EntityType THROWN_SPEAR = register("thrown_spear", FabricEntityTypeBuilder.create(EntityCategory.MISC, SpearEntity::new) - .trackable(100, 2) - .size(EntityDimensions.fixed(0.6F, 0.6F))); - - static EntityType register(String name, FabricEntityTypeBuilder builder) { - return Registry.register(Registry.ENTITY_TYPE, new Identifier("unicopia", name), builder.build()); - } - - static void bootstrap() { - Registry.BIOME.forEach(biome -> { - if (!(biome instanceof NetherBiome || biome instanceof EndBiome)) { - addifAbsent(biome.getEntitySpawnList(EntityCategory.AMBIENT), biome instanceof OceanBiome ? WildCloudEntity.SPAWN_ENTRY_OCEAN : WildCloudEntity.SPAWN_ENTRY_LAND); - addifAbsent(biome.getEntitySpawnList(EntityCategory.CREATURE), RainbowEntity.SPAWN_ENTRY); - } - - if (biome instanceof PlainsBiome - || biome instanceof RiverBiome - || biome instanceof MountainsBiome - || biome instanceof ForestBiome) { - addifAbsent(biome.getEntitySpawnList(EntityCategory.AMBIENT), ButterflyEntity.SPAWN_ENTRY); - } - }); - } - - static void addifAbsent(List entries, T entry) { - if (!entries.contains(entry)) { - entries.add(entry); - } - } -} diff --git a/src/main/java/com/minelittlepony/unicopia/entity/Creature.java b/src/main/java/com/minelittlepony/unicopia/equine/Creature.java similarity index 98% rename from src/main/java/com/minelittlepony/unicopia/entity/Creature.java rename to src/main/java/com/minelittlepony/unicopia/equine/Creature.java index 01c8b498..a8208f46 100644 --- a/src/main/java/com/minelittlepony/unicopia/entity/Creature.java +++ b/src/main/java/com/minelittlepony/unicopia/equine/Creature.java @@ -1,4 +1,4 @@ -package com.minelittlepony.unicopia.entity; +package com.minelittlepony.unicopia.equine; import com.minelittlepony.unicopia.Race; import com.minelittlepony.unicopia.magic.Affinity; diff --git a/src/main/java/com/minelittlepony/unicopia/entity/EntityPhysics.java b/src/main/java/com/minelittlepony/unicopia/equine/EntityPhysics.java similarity index 90% rename from src/main/java/com/minelittlepony/unicopia/entity/EntityPhysics.java rename to src/main/java/com/minelittlepony/unicopia/equine/EntityPhysics.java index e354bc79..3a4177e3 100644 --- a/src/main/java/com/minelittlepony/unicopia/entity/EntityPhysics.java +++ b/src/main/java/com/minelittlepony/unicopia/equine/EntityPhysics.java @@ -1,5 +1,6 @@ -package com.minelittlepony.unicopia.entity; +package com.minelittlepony.unicopia.equine; +import com.minelittlepony.unicopia.Owned; import com.minelittlepony.unicopia.util.Copieable; import net.minecraft.block.Block; @@ -40,7 +41,7 @@ public class EntityPhysics & Owned> impl Entity entity = pony.getOwner(); - entity.onGround = false; + entity.setOnGround(false); BlockPos pos = new BlockPos( MathHelper.floor(entity.getX()), @@ -51,12 +52,12 @@ public class EntityPhysics & Owned> impl if (entity.world.getBlockState(pos).isAir()) { BlockPos below = pos.down(); Block block = entity.world.getBlockState(below).getBlock(); - if (block.matches(BlockTags.FENCES) || block.matches(BlockTags.WALLS) || block instanceof FenceGateBlock) { - entity.onGround = true; + if (block.isIn(BlockTags.FENCES) || block.isIn(BlockTags.WALLS) || block instanceof FenceGateBlock) { + entity.setOnGround(true); return below; } } else { - pony.getOwner().onGround = true; + pony.getOwner().setOnGround(true); } return pos; diff --git a/src/main/java/com/minelittlepony/unicopia/entity/ItemImpl.java b/src/main/java/com/minelittlepony/unicopia/equine/ItemImpl.java similarity index 96% rename from src/main/java/com/minelittlepony/unicopia/entity/ItemImpl.java rename to src/main/java/com/minelittlepony/unicopia/equine/ItemImpl.java index de35af6a..b670b7f5 100644 --- a/src/main/java/com/minelittlepony/unicopia/entity/ItemImpl.java +++ b/src/main/java/com/minelittlepony/unicopia/equine/ItemImpl.java @@ -1,5 +1,6 @@ -package com.minelittlepony.unicopia.entity; +package com.minelittlepony.unicopia.equine; +import com.minelittlepony.unicopia.Owned; import com.minelittlepony.unicopia.Race; import com.minelittlepony.unicopia.ducks.IItemEntity; diff --git a/src/main/java/com/minelittlepony/unicopia/entity/Physics.java b/src/main/java/com/minelittlepony/unicopia/equine/Physics.java similarity index 92% rename from src/main/java/com/minelittlepony/unicopia/entity/Physics.java rename to src/main/java/com/minelittlepony/unicopia/equine/Physics.java index 4439c049..08d5923d 100644 --- a/src/main/java/com/minelittlepony/unicopia/entity/Physics.java +++ b/src/main/java/com/minelittlepony/unicopia/equine/Physics.java @@ -1,4 +1,4 @@ -package com.minelittlepony.unicopia.entity; +package com.minelittlepony.unicopia.equine; import com.minelittlepony.unicopia.util.NbtSerialisable; diff --git a/src/main/java/com/minelittlepony/unicopia/entity/Ponylike.java b/src/main/java/com/minelittlepony/unicopia/equine/Ponylike.java similarity index 96% rename from src/main/java/com/minelittlepony/unicopia/entity/Ponylike.java rename to src/main/java/com/minelittlepony/unicopia/equine/Ponylike.java index 39a077c3..44ea620a 100644 --- a/src/main/java/com/minelittlepony/unicopia/entity/Ponylike.java +++ b/src/main/java/com/minelittlepony/unicopia/equine/Ponylike.java @@ -1,4 +1,4 @@ -package com.minelittlepony.unicopia.entity; +package com.minelittlepony.unicopia.equine; import javax.annotation.Nullable; diff --git a/src/main/java/com/minelittlepony/unicopia/entity/Trap.java b/src/main/java/com/minelittlepony/unicopia/equine/Trap.java similarity index 71% rename from src/main/java/com/minelittlepony/unicopia/entity/Trap.java rename to src/main/java/com/minelittlepony/unicopia/equine/Trap.java index 56ad9f1b..6c3ea867 100644 --- a/src/main/java/com/minelittlepony/unicopia/entity/Trap.java +++ b/src/main/java/com/minelittlepony/unicopia/equine/Trap.java @@ -1,4 +1,4 @@ -package com.minelittlepony.unicopia.entity; +package com.minelittlepony.unicopia.equine; import net.minecraft.entity.Entity; diff --git a/src/main/java/com/minelittlepony/unicopia/entity/player/Aeronautics.java b/src/main/java/com/minelittlepony/unicopia/equine/player/Aeronautics.java similarity index 96% rename from src/main/java/com/minelittlepony/unicopia/entity/player/Aeronautics.java rename to src/main/java/com/minelittlepony/unicopia/equine/player/Aeronautics.java index 494171f5..6363f8fd 100644 --- a/src/main/java/com/minelittlepony/unicopia/entity/player/Aeronautics.java +++ b/src/main/java/com/minelittlepony/unicopia/equine/player/Aeronautics.java @@ -1,4 +1,4 @@ -package com.minelittlepony.unicopia.entity.player; +package com.minelittlepony.unicopia.equine.player; import net.minecraft.util.math.Vec3d; diff --git a/src/main/java/com/minelittlepony/unicopia/entity/player/MagicReserves.java b/src/main/java/com/minelittlepony/unicopia/equine/player/MagicReserves.java similarity index 94% rename from src/main/java/com/minelittlepony/unicopia/entity/player/MagicReserves.java rename to src/main/java/com/minelittlepony/unicopia/equine/player/MagicReserves.java index 8aa04df0..fea2c3a0 100644 --- a/src/main/java/com/minelittlepony/unicopia/entity/player/MagicReserves.java +++ b/src/main/java/com/minelittlepony/unicopia/equine/player/MagicReserves.java @@ -1,4 +1,4 @@ -package com.minelittlepony.unicopia.entity.player; +package com.minelittlepony.unicopia.equine.player; public interface MagicReserves { /** diff --git a/src/main/java/com/minelittlepony/unicopia/entity/player/ManaContainer.java b/src/main/java/com/minelittlepony/unicopia/equine/player/ManaContainer.java similarity index 94% rename from src/main/java/com/minelittlepony/unicopia/entity/player/ManaContainer.java rename to src/main/java/com/minelittlepony/unicopia/equine/player/ManaContainer.java index 088a5675..38364a96 100644 --- a/src/main/java/com/minelittlepony/unicopia/entity/player/ManaContainer.java +++ b/src/main/java/com/minelittlepony/unicopia/equine/player/ManaContainer.java @@ -1,4 +1,4 @@ -package com.minelittlepony.unicopia.entity.player; +package com.minelittlepony.unicopia.equine.player; public class ManaContainer implements MagicReserves { private final Pony pony; diff --git a/src/main/java/com/minelittlepony/unicopia/entity/player/Motion.java b/src/main/java/com/minelittlepony/unicopia/equine/player/Motion.java similarity index 85% rename from src/main/java/com/minelittlepony/unicopia/entity/player/Motion.java rename to src/main/java/com/minelittlepony/unicopia/equine/player/Motion.java index d56af216..cc5808f3 100644 --- a/src/main/java/com/minelittlepony/unicopia/entity/player/Motion.java +++ b/src/main/java/com/minelittlepony/unicopia/equine/player/Motion.java @@ -1,4 +1,4 @@ -package com.minelittlepony.unicopia.entity.player; +package com.minelittlepony.unicopia.equine.player; /** * Interface for controlling flight. diff --git a/src/main/java/com/minelittlepony/unicopia/entity/player/PlayerAttributes.java b/src/main/java/com/minelittlepony/unicopia/equine/player/PlayerAttributes.java similarity index 73% rename from src/main/java/com/minelittlepony/unicopia/entity/player/PlayerAttributes.java rename to src/main/java/com/minelittlepony/unicopia/equine/player/PlayerAttributes.java index 5edd7b2a..b130f2c2 100644 --- a/src/main/java/com/minelittlepony/unicopia/entity/player/PlayerAttributes.java +++ b/src/main/java/com/minelittlepony/unicopia/equine/player/PlayerAttributes.java @@ -1,4 +1,4 @@ -package com.minelittlepony.unicopia.entity.player; +package com.minelittlepony.unicopia.equine.player; import java.util.UUID; @@ -15,7 +15,7 @@ import net.minecraft.entity.player.PlayerEntity; class PlayerAttributes { - static final EntityAttribute EXTENDED_REACH_DISTANCE = new ClampedEntityAttribute(null, "player.reachDistance", 0, 0, 10); + static final EntityAttribute EXTENDED_REACH_DISTANCE = new ClampedEntityAttribute("player.reachDistance", 0, 0, 10); private static final EntityAttributeModifier EARTH_PONY_STRENGTH = new EntityAttributeModifier(UUID.fromString("777a5505-521e-480b-b9d5-6ea54f259564"), "Earth Pony Strength", 0.6, Operation.MULTIPLY_TOTAL); @@ -30,10 +30,10 @@ class PlayerAttributes { ((Walker)entity.abilities).setWalkSpeed(0.1F - (float)pony.getInventory().getCarryingWeight()); - toggleAttribute(entity, EntityAttributes.ATTACK_DAMAGE, EARTH_PONY_STRENGTH, race.canUseEarth()); - toggleAttribute(entity, EntityAttributes.KNOCKBACK_RESISTANCE, EARTH_PONY_STRENGTH, race.canUseEarth()); - toggleAttribute(entity, EntityAttributes.MOVEMENT_SPEED, PEGASUS_SPEED, race.canFly()); - toggleAttribute(entity, EntityAttributes.ATTACK_SPEED, PEGASUS_SPEED, race.canFly()); + toggleAttribute(entity, EntityAttributes.GENERIC_ATTACK_DAMAGE, EARTH_PONY_STRENGTH, race.canUseEarth()); + toggleAttribute(entity, EntityAttributes.GENERIC_KNOCKBACK_RESISTANCE, EARTH_PONY_STRENGTH, race.canUseEarth()); + toggleAttribute(entity, EntityAttributes.GENERIC_MOVEMENT_SPEED, PEGASUS_SPEED, race.canFly()); + toggleAttribute(entity, EntityAttributes.GENERIC_ATTACK_SPEED, PEGASUS_SPEED, race.canFly()); toggleAttribute(entity, EXTENDED_REACH_DISTANCE, PEGASUS_REACH, race.canFly()); } @@ -43,12 +43,10 @@ class PlayerAttributes { if (enable) { if (!instance.hasModifier(modifier)) { - instance.addModifier(modifier); + instance.addPersistentModifier(modifier); } } else { - if (instance.hasModifier(modifier)) { - instance.removeModifier(modifier); - } + instance.tryRemoveModifier(modifier.getId()); } } } diff --git a/src/main/java/com/minelittlepony/unicopia/entity/player/PlayerCamera.java b/src/main/java/com/minelittlepony/unicopia/equine/player/PlayerCamera.java similarity index 93% rename from src/main/java/com/minelittlepony/unicopia/entity/player/PlayerCamera.java rename to src/main/java/com/minelittlepony/unicopia/equine/player/PlayerCamera.java index ecc78856..17f6748e 100644 --- a/src/main/java/com/minelittlepony/unicopia/entity/player/PlayerCamera.java +++ b/src/main/java/com/minelittlepony/unicopia/equine/player/PlayerCamera.java @@ -1,6 +1,6 @@ -package com.minelittlepony.unicopia.entity.player; +package com.minelittlepony.unicopia.equine.player; -import com.minelittlepony.util.MotionCompositor; +import com.minelittlepony.common.util.animation.MotionCompositor; import net.minecraft.util.math.Vec3d; diff --git a/src/main/java/com/minelittlepony/unicopia/entity/player/PlayerDimensions.java b/src/main/java/com/minelittlepony/unicopia/equine/player/PlayerDimensions.java similarity index 98% rename from src/main/java/com/minelittlepony/unicopia/entity/player/PlayerDimensions.java rename to src/main/java/com/minelittlepony/unicopia/equine/player/PlayerDimensions.java index bfe1e1a5..de9ccff4 100644 --- a/src/main/java/com/minelittlepony/unicopia/entity/player/PlayerDimensions.java +++ b/src/main/java/com/minelittlepony/unicopia/equine/player/PlayerDimensions.java @@ -1,4 +1,4 @@ -package com.minelittlepony.unicopia.entity.player; +package com.minelittlepony.unicopia.equine.player; import com.minelittlepony.unicopia.ability.HeightPredicate; import com.minelittlepony.unicopia.magic.Spell; diff --git a/src/main/java/com/minelittlepony/unicopia/entity/player/PlayerInventory.java b/src/main/java/com/minelittlepony/unicopia/equine/player/PlayerInventory.java similarity index 81% rename from src/main/java/com/minelittlepony/unicopia/entity/player/PlayerInventory.java rename to src/main/java/com/minelittlepony/unicopia/equine/player/PlayerInventory.java index e4873ff7..2689bdf9 100644 --- a/src/main/java/com/minelittlepony/unicopia/entity/player/PlayerInventory.java +++ b/src/main/java/com/minelittlepony/unicopia/equine/player/PlayerInventory.java @@ -1,14 +1,12 @@ -package com.minelittlepony.unicopia.entity.player; +package com.minelittlepony.unicopia.equine.player; import java.util.Iterator; import java.util.Map; import com.google.common.collect.Maps; -import com.minelittlepony.unicopia.container.HeavyInventory; -import com.minelittlepony.unicopia.item.MagicGemItem; -import com.minelittlepony.unicopia.magic.item.AddictiveMagicitem; -import com.minelittlepony.unicopia.magic.item.MagicItem; +import com.minelittlepony.unicopia.magic.AffineItem; import com.minelittlepony.unicopia.util.NbtSerialisable; +import com.minelittlepony.unicopia.world.container.HeavyInventory; import net.minecraft.item.Item; import net.minecraft.item.ItemStack; @@ -20,7 +18,7 @@ import net.minecraft.util.Tickable; import net.minecraft.util.registry.Registry; public class PlayerInventory implements Tickable, NbtSerialisable { - private final Map dependencies = Maps.newHashMap(); + private final Map dependencies = Maps.newHashMap(); private final Pony player; @@ -36,7 +34,7 @@ public class PlayerInventory implements Tickable, NbtSerialisable { * * Bad things might happen when it's removed. */ - public synchronized void enforceDependency(AddictiveMagicitem item) { + public synchronized void enforceDependency(AffineItem item) { if (dependencies.containsKey(item)) { dependencies.get(item).reinforce(); } else { @@ -47,7 +45,7 @@ public class PlayerInventory implements Tickable, NbtSerialisable { /** * Returns how long the player has been wearing the given item. */ - public synchronized int getTicksAttached(AddictiveMagicitem item) { + public synchronized int getTicksAttached(AffineItem item) { if (dependencies.containsKey(item)) { return dependencies.get(item).ticksAttached; } @@ -60,7 +58,7 @@ public class PlayerInventory implements Tickable, NbtSerialisable { * * Zero means not dependent at all / not wearing. */ - public synchronized float getNeedfulness(AddictiveMagicitem item) { + public synchronized float getNeedfulness(AffineItem item) { if (dependencies.containsKey(item)) { return dependencies.get(item).needfulness; } @@ -72,10 +70,10 @@ public class PlayerInventory implements Tickable, NbtSerialisable { public synchronized void tick() { carryingWeight = HeavyInventory.getContentsTotalWorth(player.getOwner().inventory, false); - Iterator> iterator = dependencies.entrySet().iterator(); + Iterator> iterator = dependencies.entrySet().iterator(); while (iterator.hasNext()) { - Map.Entry entry = iterator.next(); + Map.Entry entry = iterator.next(); Entry item = entry.getValue(); @@ -90,14 +88,14 @@ public class PlayerInventory implements Tickable, NbtSerialisable { /** * Checks if the player is wearing the specified magical artifact. */ - public boolean isWearing(MagicItem item) { + public boolean isWearing(AffineItem item) { for (ItemStack i : player.getOwner().getArmorItems()) { if (!i.isEmpty() && i.getItem() == item) { return true; } } - return item instanceof MagicGemItem; + return item.alwaysActive(); } public boolean matches(Tag tag) { @@ -147,13 +145,13 @@ public class PlayerInventory implements Tickable, NbtSerialisable { float needfulness = 1; - AddictiveMagicitem item; + AffineItem item; Entry() { } - Entry(AddictiveMagicitem key) { + Entry(AffineItem key) { this.item = key; } @@ -186,7 +184,7 @@ public class PlayerInventory implements Tickable, NbtSerialisable { Item item = Registry.ITEM.get(new Identifier(compound.getString("item"))); - this.item = item instanceof AddictiveMagicitem ? (AddictiveMagicitem)item : null; + this.item = item instanceof AffineItem ? (AffineItem)item : null; } } } diff --git a/src/main/java/com/minelittlepony/unicopia/entity/player/PlayerPageStats.java b/src/main/java/com/minelittlepony/unicopia/equine/player/PlayerPageStats.java similarity index 91% rename from src/main/java/com/minelittlepony/unicopia/entity/player/PlayerPageStats.java rename to src/main/java/com/minelittlepony/unicopia/equine/player/PlayerPageStats.java index 48ce6796..e92491ba 100644 --- a/src/main/java/com/minelittlepony/unicopia/entity/player/PlayerPageStats.java +++ b/src/main/java/com/minelittlepony/unicopia/equine/player/PlayerPageStats.java @@ -1,12 +1,12 @@ -package com.minelittlepony.unicopia.entity.player; +package com.minelittlepony.unicopia.equine.player; import java.util.HashMap; import java.util.Map; -import com.minelittlepony.unicopia.enchanting.PageOwner; -import com.minelittlepony.unicopia.enchanting.PageState; import com.minelittlepony.unicopia.util.Copieable; import com.minelittlepony.unicopia.util.NbtSerialisable; +import com.minelittlepony.unicopia.world.recipe.enchanting.PageOwner; +import com.minelittlepony.unicopia.world.recipe.enchanting.PageState; import net.minecraft.nbt.CompoundTag; import net.minecraft.util.Identifier; diff --git a/src/main/java/com/minelittlepony/unicopia/entity/player/PlayerPhysics.java b/src/main/java/com/minelittlepony/unicopia/equine/player/PlayerPhysics.java similarity index 96% rename from src/main/java/com/minelittlepony/unicopia/entity/player/PlayerPhysics.java rename to src/main/java/com/minelittlepony/unicopia/equine/player/PlayerPhysics.java index 50bafdf7..66140588 100644 --- a/src/main/java/com/minelittlepony/unicopia/entity/player/PlayerPhysics.java +++ b/src/main/java/com/minelittlepony/unicopia/equine/player/PlayerPhysics.java @@ -1,11 +1,11 @@ -package com.minelittlepony.unicopia.entity.player; +package com.minelittlepony.unicopia.equine.player; import java.util.Random; import com.minelittlepony.unicopia.Race; import com.minelittlepony.unicopia.USounds; import com.minelittlepony.unicopia.ability.FlightPredicate; -import com.minelittlepony.unicopia.entity.EntityPhysics; +import com.minelittlepony.unicopia.equine.EntityPhysics; import com.minelittlepony.unicopia.magic.Spell; import com.minelittlepony.unicopia.particles.MagicParticleEffect; import com.minelittlepony.unicopia.util.NbtSerialisable; @@ -105,7 +105,7 @@ public class PlayerPhysics extends EntityPhysics implements Tickable, Moti entity.abilities.allowFlying = checkCanFly(); if (!creative) { - entity.abilities.flying |= entity.abilities.allowFlying && isFlying && !entity.onGround && !entity.isTouchingWater(); + entity.abilities.flying |= entity.abilities.allowFlying && isFlying && !entity.isOnGround() && !entity.isTouchingWater(); } isFlying = entity.abilities.flying && !creative; @@ -174,9 +174,9 @@ public class PlayerPhysics extends EntityPhysics implements Tickable, Moti } if (pony.getPhysics().isGravityNegative()) { - entity.onGround = !entity.world.isAir(new BlockPos(entity.getX(), entity.getY() + entity.getHeight() + 0.5F, entity.getZ())); + entity.setOnGround(!entity.world.isAir(new BlockPos(entity.getX(), entity.getY() + entity.getHeight() + 0.5F, entity.getZ()))); - if (entity.onGround) { + if (entity.isOnGround()) { entity.abilities.flying = false; isFlying = false; } diff --git a/src/main/java/com/minelittlepony/unicopia/entity/player/Pony.java b/src/main/java/com/minelittlepony/unicopia/equine/player/Pony.java similarity index 91% rename from src/main/java/com/minelittlepony/unicopia/entity/player/Pony.java rename to src/main/java/com/minelittlepony/unicopia/equine/player/Pony.java index 71a62ae9..1d00ac4a 100644 --- a/src/main/java/com/minelittlepony/unicopia/entity/player/Pony.java +++ b/src/main/java/com/minelittlepony/unicopia/equine/player/Pony.java @@ -1,4 +1,4 @@ -package com.minelittlepony.unicopia.entity.player; +package com.minelittlepony.unicopia.equine.player; import javax.annotation.Nullable; @@ -7,16 +7,15 @@ import com.minelittlepony.unicopia.Race; import com.minelittlepony.unicopia.UTags; import com.minelittlepony.unicopia.ability.AbilityDispatcher; import com.minelittlepony.unicopia.ducks.PonyContainer; -import com.minelittlepony.unicopia.enchanting.PageOwner; -import com.minelittlepony.unicopia.entity.Physics; -import com.minelittlepony.unicopia.entity.Ponylike; -import com.minelittlepony.unicopia.entity.Trap; +import com.minelittlepony.unicopia.equine.Physics; +import com.minelittlepony.unicopia.equine.Ponylike; +import com.minelittlepony.unicopia.equine.Trap; +import com.minelittlepony.unicopia.magic.AffineItem; import com.minelittlepony.unicopia.magic.Affinity; import com.minelittlepony.unicopia.magic.AttachableSpell; import com.minelittlepony.unicopia.magic.Caster; import com.minelittlepony.unicopia.magic.HeldSpell; import com.minelittlepony.unicopia.magic.Spell; -import com.minelittlepony.unicopia.magic.item.MagicItem; import com.minelittlepony.unicopia.magic.spell.SpellRegistry; import com.minelittlepony.unicopia.network.Channel; import com.minelittlepony.unicopia.network.EffectSync; @@ -25,13 +24,14 @@ import com.minelittlepony.unicopia.network.Transmittable; import com.minelittlepony.unicopia.toxin.Toxicity; import com.minelittlepony.unicopia.toxin.Toxin; import com.minelittlepony.unicopia.util.Copieable; -import com.minelittlepony.util.BasicEasingInterpolator; -import com.minelittlepony.util.IInterpolator; +import com.minelittlepony.unicopia.world.recipe.enchanting.PageOwner; +import com.minelittlepony.common.util.animation.LinearInterpolator; +import com.minelittlepony.common.util.animation.Interpolator; import com.mojang.authlib.GameProfile; import com.mojang.datafixers.util.Either; -import net.minecraft.client.network.packet.EntityPassengersSetS2CPacket; import net.minecraft.entity.Entity; +import net.minecraft.entity.attribute.DefaultAttributeContainer; import net.minecraft.entity.damage.DamageSource; import net.minecraft.entity.data.DataTracker; import net.minecraft.entity.data.TrackedData; @@ -41,6 +41,7 @@ import net.minecraft.entity.player.PlayerEntity.SleepFailureReason; import net.minecraft.entity.projectile.ProjectileEntity; import net.minecraft.item.ItemStack; import net.minecraft.nbt.CompoundTag; +import net.minecraft.network.packet.s2c.play.EntityPassengersSetS2CPacket; import net.minecraft.server.network.ServerPlayerEntity; import net.minecraft.text.TranslatableText; import net.minecraft.util.Hand; @@ -67,7 +68,7 @@ public class Pony implements Caster, Ponylike, Trans private final EffectSync effectDelegate = new EffectSync(this, EFFECT); private final EffectSync heldEffectDelegate = new EffectSync(this, HELD_EFFECT); - private final IInterpolator interpolator = new BasicEasingInterpolator(); + private final Interpolator interpolator = new LinearInterpolator(); private float nextStepDistance = 1; @@ -84,8 +85,10 @@ public class Pony implements Caster, Ponylike, Trans player.getDataTracker().startTracking(RACE, Race.EARTH.ordinal()); player.getDataTracker().startTracking(EFFECT, new CompoundTag()); player.getDataTracker().startTracking(HELD_EFFECT, new CompoundTag()); + } - player.getAttributes().register(PlayerAttributes.EXTENDED_REACH_DISTANCE); + public static void registerAttributes(DefaultAttributeContainer.Builder builder) { + builder.add(PlayerAttributes.EXTENDED_REACH_DISTANCE); } @Override @@ -183,7 +186,7 @@ public class Pony implements Caster, Ponylike, Trans return camera; } - public IInterpolator getInterpolator() { + public Interpolator getInterpolator() { return interpolator; } @@ -239,7 +242,7 @@ public class Pony implements Caster, Ponylike, Trans HeldSpell effect = getHeldSpell(stack); if (effect != null) { - Affinity affinity = stack.getItem() instanceof MagicItem ? ((MagicItem)stack.getItem()).getAffinity(stack) : Affinity.NEUTRAL; + Affinity affinity = stack.getItem() instanceof AffineItem ? ((AffineItem)stack.getItem()).getAffinity(stack) : Affinity.NEUTRAL; effect.updateInHand(this, affinity); } @@ -312,7 +315,7 @@ public class Pony implements Caster, Ponylike, Trans if (getInventory().matches(UTags.CURSED_ARTEFACTS)) { if (!isClient()) { - entity.addChatMessage(new TranslatableText("tile.bed.youAreAMonster"), true); + entity.sendMessage(new TranslatableText("tile.bed.youAreAMonster"), true); } return Either.left(SleepFailureReason.OTHER_PROBLEM); } diff --git a/src/main/java/com/minelittlepony/unicopia/magic/item/MagicItem.java b/src/main/java/com/minelittlepony/unicopia/magic/AffineItem.java similarity index 56% rename from src/main/java/com/minelittlepony/unicopia/magic/item/MagicItem.java rename to src/main/java/com/minelittlepony/unicopia/magic/AffineItem.java index fd9d7b3a..225bbe9f 100644 --- a/src/main/java/com/minelittlepony/unicopia/magic/item/MagicItem.java +++ b/src/main/java/com/minelittlepony/unicopia/magic/AffineItem.java @@ -1,11 +1,10 @@ -package com.minelittlepony.unicopia.magic.item; +package com.minelittlepony.unicopia.magic; -import com.minelittlepony.unicopia.magic.Affine; -import com.minelittlepony.unicopia.magic.Affinity; +import com.minelittlepony.unicopia.equine.player.Pony; import net.minecraft.item.ItemStack; -public interface MagicItem extends Affine { +public interface AffineItem extends Affine { /** * Gets the affinity of this magical artifact. Either good, bad, or unaligned. * What this returns may have effects on the behaviour of certain spells and effects. @@ -13,4 +12,10 @@ public interface MagicItem extends Affine { default Affinity getAffinity(ItemStack stack) { return getAffinity(); } + + default void onRemoved(Pony player, float needfulness) { + + } + + boolean alwaysActive(); } diff --git a/src/main/java/com/minelittlepony/unicopia/magic/Affinity.java b/src/main/java/com/minelittlepony/unicopia/magic/Affinity.java index 3de9a03e..2e1e7369 100644 --- a/src/main/java/com/minelittlepony/unicopia/magic/Affinity.java +++ b/src/main/java/com/minelittlepony/unicopia/magic/Affinity.java @@ -29,9 +29,7 @@ public enum Affinity { } public Text getName() { - Text text = new TranslatableText("affinity." + getTranslationKey()); - text.getStyle().setColor(getColourCode()); - return text; + return new TranslatableText("affinity." + getTranslationKey()).styled(s -> s.withColor(getColourCode())); } public int getCorruption() { diff --git a/src/main/java/com/minelittlepony/unicopia/magic/Caster.java b/src/main/java/com/minelittlepony/unicopia/magic/Caster.java index 1c238057..e8ab5801 100644 --- a/src/main/java/com/minelittlepony/unicopia/magic/Caster.java +++ b/src/main/java/com/minelittlepony/unicopia/magic/Caster.java @@ -7,8 +7,7 @@ import java.util.stream.Stream; import javax.annotation.Nullable; import com.minelittlepony.unicopia.AwaitTickQueue; -import com.minelittlepony.unicopia.entity.IMagicals; -import com.minelittlepony.unicopia.entity.Owned; +import com.minelittlepony.unicopia.Owned; import com.minelittlepony.unicopia.network.EffectSync; import com.minelittlepony.unicopia.particles.ParticleSource; import com.minelittlepony.unicopia.util.VecHelper; @@ -24,7 +23,7 @@ import net.minecraft.world.World; /** * Interface for any magically capable entities that can cast and persist spells. */ -public interface Caster extends Owned, Levelled, Affine, IMagicals, ParticleSource { +public interface Caster extends Owned, Levelled, Affine, Magical, ParticleSource { EffectSync getPrimarySpellSlot(); diff --git a/src/main/java/com/minelittlepony/unicopia/magic/CasterUtils.java b/src/main/java/com/minelittlepony/unicopia/magic/CasterUtils.java index 42564e03..57686623 100644 --- a/src/main/java/com/minelittlepony/unicopia/magic/CasterUtils.java +++ b/src/main/java/com/minelittlepony/unicopia/magic/CasterUtils.java @@ -8,7 +8,6 @@ import javax.annotation.Nullable; import com.google.common.collect.Streams; import com.minelittlepony.unicopia.EquinePredicates; import com.minelittlepony.unicopia.ducks.PonyContainer; -import com.minelittlepony.unicopia.entity.IMagicals; import com.minelittlepony.unicopia.magic.spell.SpellRegistry; import net.minecraft.entity.Entity; @@ -75,7 +74,7 @@ public class CasterUtils { return Optional.of((Caster)entity); } - if (entity instanceof LivingEntity && !(entity instanceof IMagicals)) { + if (entity instanceof LivingEntity && !(entity instanceof Magical)) { return PonyContainer.of(entity).map(PonyContainer::getCaster); } diff --git a/src/main/java/com/minelittlepony/unicopia/magic/HeldSpell.java b/src/main/java/com/minelittlepony/unicopia/magic/HeldSpell.java index 1726cb7b..6e5dacf6 100644 --- a/src/main/java/com/minelittlepony/unicopia/magic/HeldSpell.java +++ b/src/main/java/com/minelittlepony/unicopia/magic/HeldSpell.java @@ -1,6 +1,6 @@ package com.minelittlepony.unicopia.magic; -import com.minelittlepony.unicopia.entity.player.Pony; +import com.minelittlepony.unicopia.equine.player.Pony; /** * Represents a passive spell that does something when held in the player's hand. diff --git a/src/main/java/com/minelittlepony/unicopia/entity/IMagicals.java b/src/main/java/com/minelittlepony/unicopia/magic/Magical.java similarity index 62% rename from src/main/java/com/minelittlepony/unicopia/entity/IMagicals.java rename to src/main/java/com/minelittlepony/unicopia/magic/Magical.java index fdf6dc79..52d85551 100644 --- a/src/main/java/com/minelittlepony/unicopia/entity/IMagicals.java +++ b/src/main/java/com/minelittlepony/unicopia/magic/Magical.java @@ -1,9 +1,9 @@ -package com.minelittlepony.unicopia.entity; +package com.minelittlepony.unicopia.magic; /** * Any entities with magical abilities. * Casters are automatically considered magic, for obvious reasons. */ -public interface IMagicals { +public interface Magical { } diff --git a/src/main/java/com/minelittlepony/unicopia/magic/ThrowableSpell.java b/src/main/java/com/minelittlepony/unicopia/magic/ThrowableSpell.java index 3f1277ae..0dc1955f 100644 --- a/src/main/java/com/minelittlepony/unicopia/magic/ThrowableSpell.java +++ b/src/main/java/com/minelittlepony/unicopia/magic/ThrowableSpell.java @@ -2,12 +2,12 @@ package com.minelittlepony.unicopia.magic; import javax.annotation.Nullable; -import com.minelittlepony.unicopia.entity.ProjectileEntity; -import com.minelittlepony.unicopia.entity.UEntities; -import com.minelittlepony.unicopia.item.UItems; import com.minelittlepony.unicopia.magic.spell.SpellRegistry; -import com.minelittlepony.unicopia.util.projectile.AdvancedProjectile; +import com.minelittlepony.unicopia.util.projectile.Projectile; import com.minelittlepony.unicopia.util.projectile.Tossable; +import com.minelittlepony.unicopia.world.entity.MagicProjectileEntity; +import com.minelittlepony.unicopia.world.entity.UEntities; +import com.minelittlepony.unicopia.world.item.UItems; import net.minecraft.entity.Entity; import net.minecraft.item.Item; @@ -42,7 +42,7 @@ public interface ThrowableSpell extends Spell, Tossable> { * Returns the resulting projectile entity for customization (or null if on the client). */ @Nullable - default AdvancedProjectile toss(Caster caster) { + default Projectile toss(Caster caster) { World world = caster.getWorld(); Entity entity = caster.getOwner(); @@ -50,7 +50,7 @@ public interface ThrowableSpell extends Spell, Tossable> { world.playSound(null, entity.getX(), entity.getY(), entity.getZ(), getThrowSound(caster), SoundCategory.NEUTRAL, 0.7F, 0.4F / (world.random.nextFloat() * 0.4F + 0.8F)); if (caster.isLocal()) { - AdvancedProjectile projectile = new ProjectileEntity(UEntities.THROWN_ITEM, world, caster.getOwner()); + Projectile projectile = new MagicProjectileEntity(UEntities.THROWN_ITEM, world, caster.getOwner()); projectile.setItem(getCastAppearance(caster)); projectile.setThrowDamage(getThrowDamage(caster)); diff --git a/src/main/java/com/minelittlepony/unicopia/magic/item/AddictiveMagicitem.java b/src/main/java/com/minelittlepony/unicopia/magic/item/AddictiveMagicitem.java deleted file mode 100644 index 9dce27cf..00000000 --- a/src/main/java/com/minelittlepony/unicopia/magic/item/AddictiveMagicitem.java +++ /dev/null @@ -1,10 +0,0 @@ -package com.minelittlepony.unicopia.magic.item; - -import com.minelittlepony.unicopia.entity.player.Pony; - -/** - * A magical item with addictive properties. - */ -public interface AddictiveMagicitem extends MagicItem { - void onRemoved(Pony player, float needfulness); -} diff --git a/src/main/java/com/minelittlepony/unicopia/magic/spell/AbstractLinkedSpell.java b/src/main/java/com/minelittlepony/unicopia/magic/spell/AbstractLinkedSpell.java index 33c96110..3e60c1e3 100644 --- a/src/main/java/com/minelittlepony/unicopia/magic/spell/AbstractLinkedSpell.java +++ b/src/main/java/com/minelittlepony/unicopia/magic/spell/AbstractLinkedSpell.java @@ -5,8 +5,9 @@ import java.util.UUID; import javax.annotation.Nonnull; import javax.annotation.Nullable; -import com.minelittlepony.unicopia.entity.SpellcastEntity; import com.minelittlepony.unicopia.magic.Caster; +import com.minelittlepony.unicopia.world.entity.SpellcastEntity; + import net.minecraft.entity.Entity; import net.minecraft.nbt.CompoundTag; import net.minecraft.server.world.ServerWorld; diff --git a/src/main/java/com/minelittlepony/unicopia/magic/spell/AttractiveSpell.java b/src/main/java/com/minelittlepony/unicopia/magic/spell/AttractiveSpell.java index 14441512..654a2ff6 100644 --- a/src/main/java/com/minelittlepony/unicopia/magic/spell/AttractiveSpell.java +++ b/src/main/java/com/minelittlepony/unicopia/magic/spell/AttractiveSpell.java @@ -5,7 +5,7 @@ import java.util.stream.Collectors; import javax.annotation.Nullable; -import com.minelittlepony.unicopia.entity.player.Pony; +import com.minelittlepony.unicopia.equine.player.Pony; import com.minelittlepony.unicopia.magic.Affinity; import com.minelittlepony.unicopia.magic.Caster; import com.minelittlepony.unicopia.magic.EtherialListener; @@ -73,7 +73,7 @@ public class AttractiveSpell extends ShieldSpell implements EtherialListener { @Override protected void applyRadialEffect(Caster source, Entity target, double distance, double radius) { - Vec3d pos = homingPos == null ? source.getOriginVector() : new Vec3d(homingPos); + Vec3d pos = homingPos == null ? source.getOriginVector() : Vec3d.of(homingPos); double force = 2.5F / distance; diff --git a/src/main/java/com/minelittlepony/unicopia/magic/spell/ChangelingTrapSpell.java b/src/main/java/com/minelittlepony/unicopia/magic/spell/ChangelingTrapSpell.java index cb8780b9..a32c2dab 100644 --- a/src/main/java/com/minelittlepony/unicopia/magic/spell/ChangelingTrapSpell.java +++ b/src/main/java/com/minelittlepony/unicopia/magic/spell/ChangelingTrapSpell.java @@ -3,16 +3,16 @@ package com.minelittlepony.unicopia.magic.spell; import java.util.Optional; import com.minelittlepony.unicopia.USounds; -import com.minelittlepony.unicopia.block.UBlocks; -import com.minelittlepony.unicopia.entity.CucoonEntity; -import com.minelittlepony.unicopia.entity.IMagicals; -import com.minelittlepony.unicopia.entity.UEntities; import com.minelittlepony.unicopia.magic.Affinity; import com.minelittlepony.unicopia.magic.CasterUtils; +import com.minelittlepony.unicopia.magic.Magical; import com.minelittlepony.unicopia.magic.AttachableSpell; import com.minelittlepony.unicopia.magic.Caster; import com.minelittlepony.unicopia.magic.ThrowableSpell; import com.minelittlepony.unicopia.util.WorldEvent; +import com.minelittlepony.unicopia.world.block.UBlocks; +import com.minelittlepony.unicopia.world.entity.CucoonEntity; +import com.minelittlepony.unicopia.world.entity.UEntities; import net.minecraft.block.BlockState; import net.minecraft.block.Blocks; @@ -88,7 +88,7 @@ public class ChangelingTrapSpell extends AbstractSpell implements ThrowableSpell if (checkStruggleCondition(caster)) { previousTrappedPosition = origin; struggleCounter--; - WorldEvent.DESTROY_BLOCK.play(caster.getWorld(), origin, Blocks.SLIME_BLOCK.getDefaultState()); + WorldEvent.play(WorldEvent.DESTROY_BLOCK, caster.getWorld(), origin, Blocks.SLIME_BLOCK.getDefaultState()); setDirty(true); } @@ -105,7 +105,7 @@ public class ChangelingTrapSpell extends AbstractSpell implements ThrowableSpell double yMotion = entity.getVelocity().y; - if (!entity.onGround && yMotion > 0) { + if (!entity.isOnGround() && yMotion > 0) { yMotion = 0; } entity.setVelocity(0, yMotion, 0); @@ -120,7 +120,7 @@ public class ChangelingTrapSpell extends AbstractSpell implements ThrowableSpell entity.hurtTime = 2; entity.horizontalCollision = true; - entity.collided = true; + entity.verticalCollision = true; if (entity instanceof PlayerEntity) { ((PlayerEntity)entity).abilities.flying = false; @@ -135,7 +135,7 @@ public class ChangelingTrapSpell extends AbstractSpell implements ThrowableSpell onDestroyed(caster); setDirty(true); - WorldEvent.DESTROY_BLOCK.play(caster.getWorld(), origin, Blocks.SLIME_BLOCK.getDefaultState()); + WorldEvent.play(WorldEvent.DESTROY_BLOCK, caster.getWorld(), origin, Blocks.SLIME_BLOCK.getDefaultState()); } } @@ -191,7 +191,7 @@ public class ChangelingTrapSpell extends AbstractSpell implements ThrowableSpell } protected boolean canAffect(Entity e) { - return !(e instanceof IMagicals) + return !(e instanceof Magical) && e instanceof LivingEntity && !e.hasVehicle(); } diff --git a/src/main/java/com/minelittlepony/unicopia/magic/spell/ChargingSpell.java b/src/main/java/com/minelittlepony/unicopia/magic/spell/ChargingSpell.java index 455864dd..98c97f67 100644 --- a/src/main/java/com/minelittlepony/unicopia/magic/spell/ChargingSpell.java +++ b/src/main/java/com/minelittlepony/unicopia/magic/spell/ChargingSpell.java @@ -1,12 +1,12 @@ package com.minelittlepony.unicopia.magic.spell; -import com.minelittlepony.unicopia.entity.SpellcastEntity; import com.minelittlepony.unicopia.magic.Affinity; import com.minelittlepony.unicopia.magic.Caster; import com.minelittlepony.unicopia.magic.EtherialListener; import com.minelittlepony.unicopia.magic.Spell; import com.minelittlepony.unicopia.particles.MagicParticleEffect; import com.minelittlepony.unicopia.util.shape.Shape; +import com.minelittlepony.unicopia.world.entity.SpellcastEntity; import com.minelittlepony.unicopia.util.shape.Line; import net.minecraft.util.math.Box; diff --git a/src/main/java/com/minelittlepony/unicopia/magic/spell/DarknessSpell.java b/src/main/java/com/minelittlepony/unicopia/magic/spell/DarknessSpell.java index 43f0d31e..2f5f43ca 100644 --- a/src/main/java/com/minelittlepony/unicopia/magic/spell/DarknessSpell.java +++ b/src/main/java/com/minelittlepony/unicopia/magic/spell/DarknessSpell.java @@ -3,7 +3,6 @@ package com.minelittlepony.unicopia.magic.spell; import java.util.Random; import java.util.function.Consumer; -import com.minelittlepony.unicopia.entity.SpellcastEntity; import com.minelittlepony.unicopia.magic.Affinity; import com.minelittlepony.unicopia.magic.CasterUtils; import com.minelittlepony.unicopia.particles.SphereParticleEffect; @@ -12,6 +11,7 @@ import com.minelittlepony.unicopia.util.MagicalDamageSource; import com.minelittlepony.unicopia.util.PosHelper; import com.minelittlepony.unicopia.util.shape.Shape; import com.minelittlepony.unicopia.util.shape.Sphere; +import com.minelittlepony.unicopia.world.entity.SpellcastEntity; import net.minecraft.block.BlockState; import net.minecraft.block.Fertilizable; @@ -129,14 +129,14 @@ public class DarknessSpell extends AbstractLinkedSpell { } private void applyLight(Caster source, LivingEntity entity) { - if (entity.getHealth() < entity.getMaximumHealth()) { + if (entity.getHealth() < entity.getMaxHealth()) { entity.heal(1); } } private void applyDark(Caster source, LivingEntity entity) { - if (isAreaOccupied(source, entity.getPosVector())) { + if (isAreaOccupied(source, entity.getPos())) { return; } @@ -144,8 +144,8 @@ public class DarknessSpell extends AbstractLinkedSpell { entity.addStatusEffect(new StatusEffectInstance(StatusEffects.BLINDNESS, 100, 3)); Vec3d origin = source.getOriginVector(); - Vec3d to = entity.getPosVector(); - double distance = origin.distanceTo(entity.getPosVector()); + Vec3d to = entity.getPos(); + double distance = origin.distanceTo(to); if (entity.world.random.nextInt(30) == 0) { double appliedForce = distance / 10 + entity.world.random.nextInt(3); @@ -193,7 +193,7 @@ public class DarknessSpell extends AbstractLinkedSpell { }); source.findAllEntitiesInRange(radius * 1.5F).filter(this::isLightholder).forEach(e -> { - Vec3d pos = shape.computePoint(source.getWorld().random).add(e.getPosVector().add(0, e.getEyeHeight(e.getPose()), 0)); + Vec3d pos = shape.computePoint(source.getWorld().random).add(e.getPos().add(0, e.getEyeHeight(e.getPose()), 0)); spawnSphere(source, pos, 0xFFFFFF, 1); }); diff --git a/src/main/java/com/minelittlepony/unicopia/magic/spell/DisguiseSpell.java b/src/main/java/com/minelittlepony/unicopia/magic/spell/DisguiseSpell.java index 3f6513f0..9af146a1 100644 --- a/src/main/java/com/minelittlepony/unicopia/magic/spell/DisguiseSpell.java +++ b/src/main/java/com/minelittlepony/unicopia/magic/spell/DisguiseSpell.java @@ -6,11 +6,11 @@ import javax.annotation.Nonnull; import javax.annotation.Nullable; import com.minelittlepony.unicopia.InteractionManager; +import com.minelittlepony.unicopia.Owned; import com.minelittlepony.unicopia.Race; import com.minelittlepony.unicopia.ability.FlightPredicate; import com.minelittlepony.unicopia.ability.HeightPredicate; -import com.minelittlepony.unicopia.entity.Owned; -import com.minelittlepony.unicopia.entity.player.Pony; +import com.minelittlepony.unicopia.equine.player.Pony; import com.minelittlepony.unicopia.magic.Affinity; import com.minelittlepony.unicopia.magic.CasterUtils; import com.minelittlepony.unicopia.magic.AttachableSpell; @@ -206,7 +206,7 @@ public class DisguiseSpell extends AbstractSpell implements AttachableSpell, Sup // Set first because position calculations rely on it to.age = from.age; to.removed = from.removed; - to.onGround = from.onGround; + to.setOnGround(from.isOnGround()); if (isAttachedEntity(entity)) { @@ -246,9 +246,9 @@ public class DisguiseSpell extends AbstractSpell implements AttachableSpell, Sup if (to instanceof PlayerEntity) { PlayerEntity l = (PlayerEntity)to; - l.field_7500 = l.getX(); - l.field_7521 = l.getY(); - l.field_7499 = l.getZ(); + l.capeX = l.getX(); + l.capeY = l.getY(); + l.capeZ = l.getZ(); } to.setVelocity(from.getVelocity()); @@ -277,11 +277,12 @@ public class DisguiseSpell extends AbstractSpell implements AttachableSpell, Sup l.handSwingProgress = from.handSwingProgress; l.lastHandSwingProgress = from.lastHandSwingProgress; l.handSwingTicks = from.handSwingTicks; - l.isHandSwinging = from.isHandSwinging; + l.handSwinging = from.handSwinging; l.hurtTime = from.hurtTime; l.deathTime = from.deathTime; - l.field_20347 = from.field_20347; + l.stuckStingerTimer = from.stuckStingerTimer; + l.stuckArrowTimer = from.stuckArrowTimer; l.setHealth(from.getHealth()); for (EquipmentSlot i : EquipmentSlot.values()) { @@ -549,7 +550,7 @@ public class DisguiseSpell extends AbstractSpell implements AttachableSpell, Sup } static abstract class PlayerAccess extends PlayerEntity { - public PlayerAccess() { super(null, null); } + public PlayerAccess() { super(null, null, null); } static TrackedData getModelBitFlag() { return PLAYER_MODEL_PARTS; } diff --git a/src/main/java/com/minelittlepony/unicopia/magic/spell/FireSpell.java b/src/main/java/com/minelittlepony/unicopia/magic/spell/FireSpell.java index 14da9ead..4d5b523c 100644 --- a/src/main/java/com/minelittlepony/unicopia/magic/spell/FireSpell.java +++ b/src/main/java/com/minelittlepony/unicopia/magic/spell/FireSpell.java @@ -3,16 +3,16 @@ package com.minelittlepony.unicopia.magic.spell; import javax.annotation.Nullable; import com.minelittlepony.unicopia.EquinePredicates; -import com.minelittlepony.unicopia.blockstate.StateMaps; -import com.minelittlepony.unicopia.entity.IMagicals; import com.minelittlepony.unicopia.magic.Affinity; import com.minelittlepony.unicopia.magic.CastResult; import com.minelittlepony.unicopia.magic.Caster; import com.minelittlepony.unicopia.magic.DispenceableSpell; +import com.minelittlepony.unicopia.magic.Magical; import com.minelittlepony.unicopia.magic.Useable; import com.minelittlepony.unicopia.util.MagicalDamageSource; import com.minelittlepony.unicopia.util.PosHelper; import com.minelittlepony.unicopia.util.VecHelper; +import com.minelittlepony.unicopia.util.blockstate.StateMaps; import com.minelittlepony.unicopia.util.shape.Shape; import com.minelittlepony.unicopia.util.shape.Sphere; @@ -120,7 +120,7 @@ public class FireSpell extends AbstractRangedAreaSpell implements Useable, Dispe if (id != Blocks.AIR) { if (id == Blocks.ICE || id == Blocks.PACKED_ICE) { - world.setBlockState(pos, (world.dimension.doesWaterVaporize() ? Blocks.AIR : Blocks.WATER).getDefaultState()); + world.setBlockState(pos, (world.getDimension().isUltrawarm() ? Blocks.AIR : Blocks.WATER).getDefaultState()); playEffect(world, pos); return true; @@ -139,14 +139,14 @@ public class FireSpell extends AbstractRangedAreaSpell implements Useable, Dispe sendPower(world, pos, power, 3, 0); return true; - } else if (state.matches(BlockTags.SAND) && world.random.nextInt(10) == 0) { + } else if (state.isIn(BlockTags.SAND) && world.random.nextInt(10) == 0) { if (isSurroundedBySand(world, pos)) { world.setBlockState(pos, Blocks.GLASS.getDefaultState()); playEffect(world, pos); return true; } - } else if (state.matches(BlockTags.LEAVES)) { + } else if (state.isIn(BlockTags.LEAVES)) { if (world.getBlockState(pos.up()).getMaterial() == Material.AIR) { world.setBlockState(pos.up(), Blocks.FIRE.getDefaultState()); @@ -178,7 +178,7 @@ public class FireSpell extends AbstractRangedAreaSpell implements Useable, Dispe protected boolean applyEntitySingle(Entity owner, World world, Entity e) { if ((!e.equals(owner) || (owner instanceof PlayerEntity && !EquinePredicates.PLAYER_UNICORN.test(owner))) && !(e instanceof ItemEntity) - && !(e instanceof IMagicals)) { + && !(e instanceof Magical)) { e.setOnFireFor(60); e.damage(getDamageCause(e, (LivingEntity)owner), 0.1f); playEffect(world, e.getBlockPos()); diff --git a/src/main/java/com/minelittlepony/unicopia/magic/spell/FlameSpell.java b/src/main/java/com/minelittlepony/unicopia/magic/spell/FlameSpell.java index 6b6dccb1..ec59ffda 100644 --- a/src/main/java/com/minelittlepony/unicopia/magic/spell/FlameSpell.java +++ b/src/main/java/com/minelittlepony/unicopia/magic/spell/FlameSpell.java @@ -1,6 +1,6 @@ package com.minelittlepony.unicopia.magic.spell; -import com.minelittlepony.unicopia.entity.player.Pony; +import com.minelittlepony.unicopia.equine.player.Pony; import com.minelittlepony.unicopia.magic.Affinity; import com.minelittlepony.unicopia.magic.Caster; import com.minelittlepony.unicopia.magic.HeldSpell; diff --git a/src/main/java/com/minelittlepony/unicopia/magic/spell/GlowingSpell.java b/src/main/java/com/minelittlepony/unicopia/magic/spell/GlowingSpell.java index af367c80..3572e59f 100644 --- a/src/main/java/com/minelittlepony/unicopia/magic/spell/GlowingSpell.java +++ b/src/main/java/com/minelittlepony/unicopia/magic/spell/GlowingSpell.java @@ -1,6 +1,6 @@ package com.minelittlepony.unicopia.magic.spell; -import com.minelittlepony.unicopia.entity.player.Pony; +import com.minelittlepony.unicopia.equine.player.Pony; import com.minelittlepony.unicopia.magic.Affinity; import com.minelittlepony.unicopia.magic.Caster; import com.minelittlepony.unicopia.magic.HeldSpell; diff --git a/src/main/java/com/minelittlepony/unicopia/magic/spell/IceSpell.java b/src/main/java/com/minelittlepony/unicopia/magic/spell/IceSpell.java index 5da71181..182faca6 100644 --- a/src/main/java/com/minelittlepony/unicopia/magic/spell/IceSpell.java +++ b/src/main/java/com/minelittlepony/unicopia/magic/spell/IceSpell.java @@ -2,8 +2,6 @@ package com.minelittlepony.unicopia.magic.spell; import javax.annotation.Nullable; -import com.minelittlepony.unicopia.block.UMaterials; -import com.minelittlepony.unicopia.blockstate.StateMaps; import com.minelittlepony.unicopia.magic.Affinity; import com.minelittlepony.unicopia.magic.CastResult; import com.minelittlepony.unicopia.magic.Caster; @@ -12,8 +10,10 @@ import com.minelittlepony.unicopia.magic.Useable; import com.minelittlepony.unicopia.util.MagicalDamageSource; import com.minelittlepony.unicopia.util.PosHelper; import com.minelittlepony.unicopia.util.VecHelper; +import com.minelittlepony.unicopia.util.blockstate.StateMaps; import com.minelittlepony.unicopia.util.shape.Shape; import com.minelittlepony.unicopia.util.shape.Sphere; +import com.minelittlepony.unicopia.world.block.UMaterials; import net.minecraft.block.Block; import net.minecraft.block.BlockState; @@ -122,7 +122,7 @@ public class IceSpell extends AbstractRangedAreaSpell implements Useable, Dispen world.setBlockState(pos, converted, 3); } else if (state.getMaterial() != UMaterials.CLOUD && world.isTopSolid(pos, owner) || (id == Blocks.SNOW) - || state.matches(BlockTags.LEAVES)) { + || state.isIn(BlockTags.LEAVES)) { incrementIce(world, pos.up()); } else if (state.getMaterial() == Material.ICE && world.random.nextInt(10) == 0) { if (isSurroundedByIce(world, pos)) { diff --git a/src/main/java/com/minelittlepony/unicopia/magic/spell/InfernoSpell.java b/src/main/java/com/minelittlepony/unicopia/magic/spell/InfernoSpell.java index 15439f5d..4b552b21 100644 --- a/src/main/java/com/minelittlepony/unicopia/magic/spell/InfernoSpell.java +++ b/src/main/java/com/minelittlepony/unicopia/magic/spell/InfernoSpell.java @@ -1,10 +1,10 @@ package com.minelittlepony.unicopia.magic.spell; -import com.minelittlepony.unicopia.blockstate.StateMaps; import com.minelittlepony.unicopia.magic.Affinity; import com.minelittlepony.unicopia.magic.CastResult; import com.minelittlepony.unicopia.magic.Caster; import com.minelittlepony.unicopia.util.MagicalDamageSource; +import com.minelittlepony.unicopia.util.blockstate.StateMaps; import com.minelittlepony.unicopia.util.shape.Shape; import com.minelittlepony.unicopia.util.shape.Sphere; diff --git a/src/main/java/com/minelittlepony/unicopia/magic/spell/NecromancySpell.java b/src/main/java/com/minelittlepony/unicopia/magic/spell/NecromancySpell.java index 17766996..2ce0741a 100644 --- a/src/main/java/com/minelittlepony/unicopia/magic/spell/NecromancySpell.java +++ b/src/main/java/com/minelittlepony/unicopia/magic/spell/NecromancySpell.java @@ -24,7 +24,7 @@ public class NecromancySpell extends AbstractRangedAreaSpell { private final List> spawns = Lists.newArrayList( EntityType.ZOMBIE, EntityType.HUSK, - EntityType.ZOMBIE_PIGMAN + EntityType.ZOMBIFIED_PIGLIN ); @Override @@ -91,7 +91,7 @@ public class NecromancySpell extends AbstractRangedAreaSpell { zombie.setVelocity(0, 0.3, 0); - WorldEvent.DOOR_BROKEN.play(source.getWorld(), zombie.getBlockPos()); + source.getWorld().syncWorldEvent(WorldEvent.ZOMBIE_BREAK_WOODEN_DOOR, zombie.getBlockPos(), 0); source.getWorld().spawnEntity(zombie); } diff --git a/src/main/java/com/minelittlepony/unicopia/magic/spell/PortalSpell.java b/src/main/java/com/minelittlepony/unicopia/magic/spell/PortalSpell.java index ddd18374..3c3d67fe 100644 --- a/src/main/java/com/minelittlepony/unicopia/magic/spell/PortalSpell.java +++ b/src/main/java/com/minelittlepony/unicopia/magic/spell/PortalSpell.java @@ -6,18 +6,18 @@ import java.util.UUID; import javax.annotation.Nullable; -import com.minelittlepony.unicopia.entity.IMagicals; -import com.minelittlepony.unicopia.entity.SpellcastEntity; -import com.minelittlepony.unicopia.entity.player.Pony; +import com.minelittlepony.unicopia.equine.player.Pony; import com.minelittlepony.unicopia.magic.Affinity; import com.minelittlepony.unicopia.magic.CastResult; import com.minelittlepony.unicopia.magic.Caster; +import com.minelittlepony.unicopia.magic.Magical; import com.minelittlepony.unicopia.magic.Spell; import com.minelittlepony.unicopia.magic.Useable; import com.minelittlepony.unicopia.particles.MagicParticleEffect; import com.minelittlepony.unicopia.util.NbtSerialisable; import com.minelittlepony.unicopia.util.shape.Shape; import com.minelittlepony.unicopia.util.shape.Sphere; +import com.minelittlepony.unicopia.world.entity.SpellcastEntity; import net.minecraft.entity.Entity; import net.minecraft.entity.player.PlayerEntity; @@ -185,7 +185,7 @@ public class PortalSpell extends AbstractRangedAreaSpell implements Useable { } protected boolean canTeleport(Entity i) { - return !(i instanceof IMagicals) && i.netherPortalCooldown == 0; + return !(i instanceof Magical) && i.netherPortalCooldown == 0; } protected void teleportEntity(Caster source, PortalSpell dest, Entity i) { diff --git a/src/main/java/com/minelittlepony/unicopia/magic/spell/ScorchSpell.java b/src/main/java/com/minelittlepony/unicopia/magic/spell/ScorchSpell.java index ec0441ea..e112ff7f 100644 --- a/src/main/java/com/minelittlepony/unicopia/magic/spell/ScorchSpell.java +++ b/src/main/java/com/minelittlepony/unicopia/magic/spell/ScorchSpell.java @@ -2,13 +2,13 @@ package com.minelittlepony.unicopia.magic.spell; import javax.annotation.Nullable; -import com.minelittlepony.unicopia.blockstate.StateMaps; import com.minelittlepony.unicopia.magic.Affinity; import com.minelittlepony.unicopia.magic.Caster; import com.minelittlepony.unicopia.magic.ThrowableSpell; import com.minelittlepony.unicopia.particles.MagicParticleEffect; import com.minelittlepony.unicopia.util.PosHelper; -import com.minelittlepony.unicopia.util.projectile.AdvancedProjectile; +import com.minelittlepony.unicopia.util.blockstate.StateMaps; +import com.minelittlepony.unicopia.util.projectile.Projectile; import com.minelittlepony.unicopia.util.shape.Sphere; import net.minecraft.block.BlockState; @@ -67,8 +67,8 @@ public class ScorchSpell extends FireSpell implements ThrowableSpell { @Override @Nullable - public AdvancedProjectile toss(Caster caster) { - AdvancedProjectile projectile = ThrowableSpell.super.toss(caster); + public Projectile toss(Caster caster) { + Projectile projectile = ThrowableSpell.super.toss(caster); if (projectile != null) { projectile.setGravity(false); diff --git a/src/main/java/com/minelittlepony/unicopia/magic/spell/ShieldSpell.java b/src/main/java/com/minelittlepony/unicopia/magic/spell/ShieldSpell.java index 42d08206..2c24cf80 100644 --- a/src/main/java/com/minelittlepony/unicopia/magic/spell/ShieldSpell.java +++ b/src/main/java/com/minelittlepony/unicopia/magic/spell/ShieldSpell.java @@ -4,8 +4,7 @@ import java.util.List; import java.util.stream.Collectors; import com.minelittlepony.unicopia.EquinePredicates; -import com.minelittlepony.unicopia.entity.SpellcastEntity; -import com.minelittlepony.unicopia.entity.player.Pony; +import com.minelittlepony.unicopia.equine.player.Pony; import com.minelittlepony.unicopia.magic.Affinity; import com.minelittlepony.unicopia.magic.AttachableSpell; import com.minelittlepony.unicopia.magic.Caster; @@ -14,6 +13,7 @@ import com.minelittlepony.unicopia.particles.ParticleHandle; import com.minelittlepony.unicopia.particles.SphereParticleEffect; import com.minelittlepony.unicopia.util.projectile.ProjectileUtil; import com.minelittlepony.unicopia.util.shape.Sphere; +import com.minelittlepony.unicopia.world.entity.SpellcastEntity; import net.minecraft.entity.Entity; import net.minecraft.entity.LivingEntity; diff --git a/src/main/java/com/minelittlepony/unicopia/magic/spell/SiphoningSpell.java b/src/main/java/com/minelittlepony/unicopia/magic/spell/SiphoningSpell.java index 6dfef9f3..a5cd7080 100644 --- a/src/main/java/com/minelittlepony/unicopia/magic/spell/SiphoningSpell.java +++ b/src/main/java/com/minelittlepony/unicopia/magic/spell/SiphoningSpell.java @@ -4,7 +4,7 @@ import java.util.List; import java.util.stream.Collectors; import com.minelittlepony.unicopia.Race; -import com.minelittlepony.unicopia.entity.player.Pony; +import com.minelittlepony.unicopia.equine.player.Pony; import com.minelittlepony.unicopia.magic.Affinity; import com.minelittlepony.unicopia.magic.Caster; import com.minelittlepony.unicopia.util.MagicalDamageSource; @@ -46,7 +46,7 @@ public class SiphoningSpell extends AbstractRangedAreaSpell { if (source.getAffinity() == Affinity.BAD) { if (owner != null) { float healthGain = 0; - float maxHealthGain = owner.getMaximumHealth() - owner.getHealth(); + float maxHealthGain = owner.getMaxHealth() - owner.getHealth(); if (maxHealthGain > 0) { float attackAmount = Math.max(maxHealthGain / target.size(), 0.5F); @@ -80,7 +80,7 @@ public class SiphoningSpell extends AbstractRangedAreaSpell { } else { target.forEach(e -> { - float maxHealthGain = e.getMaximumHealth() - e.getHealth(); + float maxHealthGain = e.getMaxHealth() - e.getHealth(); if (maxHealthGain <= 0) { if (source.getWorld().random.nextInt(30) == 0) { diff --git a/src/main/java/com/minelittlepony/unicopia/mixin/CriterionsRegistry.java b/src/main/java/com/minelittlepony/unicopia/mixin/CriterionsRegistry.java index 658ac879..0fceea19 100644 --- a/src/main/java/com/minelittlepony/unicopia/mixin/CriterionsRegistry.java +++ b/src/main/java/com/minelittlepony/unicopia/mixin/CriterionsRegistry.java @@ -4,9 +4,9 @@ import org.spongepowered.asm.mixin.Mixin; import org.spongepowered.asm.mixin.gen.Invoker; import net.minecraft.advancement.criterion.Criterion; -import net.minecraft.advancement.criterion.Criterions; +import net.minecraft.advancement.criterion.Criteria; -@Mixin(Criterions.class) +@Mixin(Criteria.class) public interface CriterionsRegistry { @Invoker("register") static > T register(T object) { diff --git a/src/main/java/com/minelittlepony/unicopia/mixin/MixinEntityContextImpl.java b/src/main/java/com/minelittlepony/unicopia/mixin/MixinEntityContextImpl.java index 88a0b9e4..6615847e 100644 --- a/src/main/java/com/minelittlepony/unicopia/mixin/MixinEntityContextImpl.java +++ b/src/main/java/com/minelittlepony/unicopia/mixin/MixinEntityContextImpl.java @@ -5,11 +5,12 @@ import org.spongepowered.asm.mixin.injection.At; import org.spongepowered.asm.mixin.injection.Inject; import org.spongepowered.asm.mixin.injection.callback.CallbackInfo; -import com.minelittlepony.unicopia.gas.CloudInteractionContext; -import net.minecraft.entity.Entity; -import net.minecraft.entity.EntityContextImpl; +import com.minelittlepony.unicopia.world.block.gas.CloudInteractionContext; -@Mixin(EntityContextImpl.class) +import net.minecraft.block.EntityShapeContext; +import net.minecraft.entity.Entity; + +@Mixin(EntityShapeContext.class) abstract class MixinEntityContextImpl implements CloudInteractionContext.Holder { private CloudInteractionContext cloudContext; diff --git a/src/main/java/com/minelittlepony/unicopia/mixin/MixinFallingBlock.java b/src/main/java/com/minelittlepony/unicopia/mixin/MixinFallingBlock.java index 274e1c47..90f400a3 100644 --- a/src/main/java/com/minelittlepony/unicopia/mixin/MixinFallingBlock.java +++ b/src/main/java/com/minelittlepony/unicopia/mixin/MixinFallingBlock.java @@ -5,7 +5,7 @@ import org.spongepowered.asm.mixin.injection.At; import org.spongepowered.asm.mixin.injection.Inject; import org.spongepowered.asm.mixin.injection.callback.CallbackInfoReturnable; -import com.minelittlepony.unicopia.gas.Gas; +import com.minelittlepony.unicopia.world.block.gas.Gas; import net.minecraft.block.Block; import net.minecraft.block.BlockState; diff --git a/src/main/java/com/minelittlepony/unicopia/mixin/MixinItemEntity.java b/src/main/java/com/minelittlepony/unicopia/mixin/MixinItemEntity.java index 381d47c4..cd44896e 100644 --- a/src/main/java/com/minelittlepony/unicopia/mixin/MixinItemEntity.java +++ b/src/main/java/com/minelittlepony/unicopia/mixin/MixinItemEntity.java @@ -7,7 +7,7 @@ import org.spongepowered.asm.mixin.injection.Inject; import org.spongepowered.asm.mixin.injection.callback.CallbackInfo; import com.minelittlepony.unicopia.ducks.IItemEntity; -import com.minelittlepony.unicopia.entity.ItemImpl; +import com.minelittlepony.unicopia.equine.ItemImpl; import net.minecraft.entity.Entity; import net.minecraft.entity.ItemEntity; diff --git a/src/main/java/com/minelittlepony/unicopia/mixin/MixinItems.java b/src/main/java/com/minelittlepony/unicopia/mixin/MixinItems.java index 938c9b0c..d4b28f95 100644 --- a/src/main/java/com/minelittlepony/unicopia/mixin/MixinItems.java +++ b/src/main/java/com/minelittlepony/unicopia/mixin/MixinItems.java @@ -4,7 +4,7 @@ import org.spongepowered.asm.mixin.Mixin; import org.spongepowered.asm.mixin.injection.At; import org.spongepowered.asm.mixin.injection.ModifyVariable; -import com.minelittlepony.unicopia.item.VanillaOverrides; +import com.minelittlepony.unicopia.world.item.VanillaOverrides; import net.minecraft.item.Item; import net.minecraft.item.Items; diff --git a/src/main/java/com/minelittlepony/unicopia/mixin/MixinLivingEntity.java b/src/main/java/com/minelittlepony/unicopia/mixin/MixinLivingEntity.java index 31f4002f..5d20d6db 100644 --- a/src/main/java/com/minelittlepony/unicopia/mixin/MixinLivingEntity.java +++ b/src/main/java/com/minelittlepony/unicopia/mixin/MixinLivingEntity.java @@ -9,8 +9,8 @@ import org.spongepowered.asm.mixin.injection.callback.CallbackInfo; import org.spongepowered.asm.mixin.injection.callback.CallbackInfoReturnable; import com.minelittlepony.unicopia.ducks.PonyContainer; -import com.minelittlepony.unicopia.entity.Ponylike; -import com.minelittlepony.unicopia.entity.Creature; +import com.minelittlepony.unicopia.equine.Creature; +import com.minelittlepony.unicopia.equine.Ponylike; import net.minecraft.entity.Entity; import net.minecraft.entity.LivingEntity; @@ -102,15 +102,4 @@ abstract class MixinLivingEntity extends Entity implements PonyContainer info) { - LivingEntity self = (LivingEntity)(Object)this; - - if (!self.isSpectator() && self.getBlockState().getBlock() instanceof com.minelittlepony.unicopia.ducks.Climbable) { - info.setReturnValue(true); - } - } } diff --git a/src/main/java/com/minelittlepony/unicopia/mixin/MixinPlayerEntity.java b/src/main/java/com/minelittlepony/unicopia/mixin/MixinPlayerEntity.java index 59e97e4a..59e36ec2 100644 --- a/src/main/java/com/minelittlepony/unicopia/mixin/MixinPlayerEntity.java +++ b/src/main/java/com/minelittlepony/unicopia/mixin/MixinPlayerEntity.java @@ -8,14 +8,15 @@ import org.spongepowered.asm.mixin.injection.callback.CallbackInfo; import org.spongepowered.asm.mixin.injection.callback.CallbackInfoReturnable; import com.minelittlepony.unicopia.ducks.PonyContainer; -import com.minelittlepony.unicopia.entity.Ponylike; -import com.minelittlepony.unicopia.entity.player.Pony; +import com.minelittlepony.unicopia.equine.Ponylike; +import com.minelittlepony.unicopia.equine.player.Pony; import com.mojang.datafixers.util.Either; import net.minecraft.entity.EntityDimensions; import net.minecraft.entity.EntityPose; import net.minecraft.entity.ItemEntity; import net.minecraft.entity.LivingEntity; +import net.minecraft.entity.attribute.DefaultAttributeContainer; import net.minecraft.entity.player.PlayerEntity; import net.minecraft.item.ItemStack; import net.minecraft.util.Unit; @@ -40,6 +41,11 @@ abstract class MixinPlayerEntity extends LivingEntity implements PonyContainer

info) { + Pony.registerAttributes(info.getReturnValue()); + } + @Inject(method = "eatFood(Lnet/minecraft/world/World;Lnet/minecraft/item/ItemStack;)Lnet/minecraft/item/ItemStack;", at = @At("HEAD")) public void onEatFood(World world, ItemStack stack, CallbackInfoReturnable info) { diff --git a/src/main/java/com/minelittlepony/unicopia/mixin/MixinProjectileEntity.java b/src/main/java/com/minelittlepony/unicopia/mixin/MixinProjectileEntity.java index 21cd929e..c72f8093 100644 --- a/src/main/java/com/minelittlepony/unicopia/mixin/MixinProjectileEntity.java +++ b/src/main/java/com/minelittlepony/unicopia/mixin/MixinProjectileEntity.java @@ -8,12 +8,11 @@ import org.spongepowered.asm.mixin.injection.callback.CallbackInfo; import com.minelittlepony.unicopia.ducks.PonyContainer; import net.minecraft.entity.Entity; -import net.minecraft.entity.projectile.Projectile; import net.minecraft.entity.projectile.ProjectileEntity; import net.minecraft.util.hit.EntityHitResult; @Mixin(ProjectileEntity.class) -abstract class MixinProjectileEntity extends Entity implements Projectile { +abstract class MixinProjectileEntity extends Entity { private MixinProjectileEntity() { super(null, null); } @Inject(method = "onEntityHit(Lnet/minecraft/util/hit/EntityHitResult;)V", diff --git a/src/main/java/com/minelittlepony/unicopia/mixin/MixinServerPlayerEntity.java b/src/main/java/com/minelittlepony/unicopia/mixin/MixinServerPlayerEntity.java index b9207af5..527eab1d 100644 --- a/src/main/java/com/minelittlepony/unicopia/mixin/MixinServerPlayerEntity.java +++ b/src/main/java/com/minelittlepony/unicopia/mixin/MixinServerPlayerEntity.java @@ -6,15 +6,15 @@ import org.spongepowered.asm.mixin.injection.Inject; import org.spongepowered.asm.mixin.injection.callback.CallbackInfo; import com.minelittlepony.unicopia.ducks.PonyContainer; -import com.minelittlepony.unicopia.entity.player.Pony; +import com.minelittlepony.unicopia.equine.player.Pony; -import net.minecraft.container.ContainerListener; import net.minecraft.entity.player.PlayerEntity; +import net.minecraft.screen.ScreenHandlerListener; import net.minecraft.server.network.ServerPlayerEntity; @Mixin(ServerPlayerEntity.class) -abstract class MixinServerPlayerEntity extends PlayerEntity implements ContainerListener, PonyContainer { - MixinServerPlayerEntity() {super(null, null);} +abstract class MixinServerPlayerEntity extends PlayerEntity implements ScreenHandlerListener, PonyContainer { + MixinServerPlayerEntity() {super(null, null, null);} @SuppressWarnings("unchecked") @Inject(method = "copyFrom(Lnet/minecraft/server/network/ServerPlayerEntity;Z)V", at = @At("HEAD")) diff --git a/src/main/java/com/minelittlepony/unicopia/mixin/MixinStructureFeature.java b/src/main/java/com/minelittlepony/unicopia/mixin/MixinStructureFeature.java new file mode 100644 index 00000000..925761ff --- /dev/null +++ b/src/main/java/com/minelittlepony/unicopia/mixin/MixinStructureFeature.java @@ -0,0 +1,14 @@ +package com.minelittlepony.unicopia.mixin; + +import org.spongepowered.asm.mixin.Mixin; +import org.spongepowered.asm.mixin.gen.Invoker; +import net.minecraft.world.gen.GenerationStep; +import net.minecraft.world.gen.feature.StructureFeature; + +@Mixin(StructureFeature.class) +public interface MixinStructureFeature { + @Invoker + static > F register(String name, F structureFeature, GenerationStep.Feature step) { + return null; + } +} diff --git a/src/main/java/com/minelittlepony/unicopia/mixin/MixinStructuresConfig.java b/src/main/java/com/minelittlepony/unicopia/mixin/MixinStructuresConfig.java new file mode 100644 index 00000000..5632acd6 --- /dev/null +++ b/src/main/java/com/minelittlepony/unicopia/mixin/MixinStructuresConfig.java @@ -0,0 +1,16 @@ +package com.minelittlepony.unicopia.mixin; + +import org.spongepowered.asm.mixin.Mixin; +import org.spongepowered.asm.mixin.gen.Accessor; +import com.google.common.collect.ImmutableMap; +import net.minecraft.world.gen.chunk.StructureConfig; +import net.minecraft.world.gen.chunk.StructuresConfig; +import net.minecraft.world.gen.feature.StructureFeature; + +@Mixin(StructuresConfig.class) +public interface MixinStructuresConfig { + @Accessor("DEFAULT_STRUCTURES") + static void setDefaultConfigs(ImmutableMap, StructureConfig> map) { + + } +} diff --git a/src/main/java/com/minelittlepony/unicopia/mixin/client/MixinCamera.java b/src/main/java/com/minelittlepony/unicopia/mixin/client/MixinCamera.java index 142ef481..720b0461 100644 --- a/src/main/java/com/minelittlepony/unicopia/mixin/client/MixinCamera.java +++ b/src/main/java/com/minelittlepony/unicopia/mixin/client/MixinCamera.java @@ -4,7 +4,8 @@ import org.spongepowered.asm.mixin.Mixin; import org.spongepowered.asm.mixin.injection.At; import org.spongepowered.asm.mixin.injection.ModifyVariable; -import com.minelittlepony.unicopia.entity.player.Pony; +import com.minelittlepony.unicopia.equine.player.Pony; + import net.minecraft.client.MinecraftClient; import net.minecraft.client.render.Camera; import net.minecraft.entity.player.PlayerEntity; diff --git a/src/main/java/com/minelittlepony/unicopia/mixin/client/MixinEntityRenderDispatcher.java b/src/main/java/com/minelittlepony/unicopia/mixin/client/MixinEntityRenderDispatcher.java index 6f1b0f23..b9ca75ef 100644 --- a/src/main/java/com/minelittlepony/unicopia/mixin/client/MixinEntityRenderDispatcher.java +++ b/src/main/java/com/minelittlepony/unicopia/mixin/client/MixinEntityRenderDispatcher.java @@ -5,9 +5,9 @@ import org.spongepowered.asm.mixin.injection.At; import org.spongepowered.asm.mixin.injection.Inject; import org.spongepowered.asm.mixin.injection.callback.CallbackInfo; -import com.minelittlepony.unicopia.client.render.WorldRenderDelegate; -import com.minelittlepony.unicopia.entity.player.Pony; +import com.minelittlepony.unicopia.equine.player.Pony; import com.minelittlepony.unicopia.magic.spell.DisguiseSpell; +import com.minelittlepony.unicopia.world.client.render.WorldRenderDelegate; import net.minecraft.client.MinecraftClient; import net.minecraft.client.render.VertexConsumerProvider; diff --git a/src/main/java/com/minelittlepony/unicopia/mixin/client/MixinGameRenderer.java b/src/main/java/com/minelittlepony/unicopia/mixin/client/MixinGameRenderer.java index 17ebc49b..8589cc88 100644 --- a/src/main/java/com/minelittlepony/unicopia/mixin/client/MixinGameRenderer.java +++ b/src/main/java/com/minelittlepony/unicopia/mixin/client/MixinGameRenderer.java @@ -6,8 +6,8 @@ import org.spongepowered.asm.mixin.injection.Inject; import org.spongepowered.asm.mixin.injection.callback.CallbackInfo; import org.spongepowered.asm.mixin.injection.callback.CallbackInfoReturnable; -import com.minelittlepony.unicopia.client.render.WorldRenderDelegate; -import com.minelittlepony.unicopia.entity.player.Pony; +import com.minelittlepony.unicopia.equine.player.Pony; +import com.minelittlepony.unicopia.world.client.render.WorldRenderDelegate; import net.minecraft.client.MinecraftClient; import net.minecraft.client.render.Camera; diff --git a/src/main/java/com/minelittlepony/unicopia/mixin/client/MixinInGameHud.java b/src/main/java/com/minelittlepony/unicopia/mixin/client/MixinInGameHud.java index 2b1e56e0..1dab3cb8 100644 --- a/src/main/java/com/minelittlepony/unicopia/mixin/client/MixinInGameHud.java +++ b/src/main/java/com/minelittlepony/unicopia/mixin/client/MixinInGameHud.java @@ -5,7 +5,7 @@ import org.spongepowered.asm.mixin.injection.At; import org.spongepowered.asm.mixin.injection.Inject; import org.spongepowered.asm.mixin.injection.callback.CallbackInfo; -import com.minelittlepony.unicopia.client.gui.UHud; +import com.minelittlepony.unicopia.world.client.gui.UHud; import net.minecraft.client.gui.hud.InGameHud; diff --git a/src/main/java/com/minelittlepony/unicopia/mixin/client/MixinItemModels.java b/src/main/java/com/minelittlepony/unicopia/mixin/client/MixinItemModels.java index f809099f..0c62010e 100644 --- a/src/main/java/com/minelittlepony/unicopia/mixin/client/MixinItemModels.java +++ b/src/main/java/com/minelittlepony/unicopia/mixin/client/MixinItemModels.java @@ -4,7 +4,7 @@ import org.spongepowered.asm.mixin.Mixin; import org.spongepowered.asm.mixin.injection.At; import org.spongepowered.asm.mixin.injection.ModifyVariable; -import com.minelittlepony.unicopia.item.ZapAppleItem; +import com.minelittlepony.unicopia.world.item.ZapAppleItem; import net.minecraft.client.render.item.ItemModels; import net.minecraft.item.ItemStack; diff --git a/src/main/java/com/minelittlepony/unicopia/mixin/client/MixinKeyboardInput.java b/src/main/java/com/minelittlepony/unicopia/mixin/client/MixinKeyboardInput.java index 1d35bc4a..8c53d82f 100644 --- a/src/main/java/com/minelittlepony/unicopia/mixin/client/MixinKeyboardInput.java +++ b/src/main/java/com/minelittlepony/unicopia/mixin/client/MixinKeyboardInput.java @@ -5,7 +5,7 @@ import org.spongepowered.asm.mixin.injection.At; import org.spongepowered.asm.mixin.injection.Inject; import org.spongepowered.asm.mixin.injection.callback.CallbackInfo; -import com.minelittlepony.unicopia.entity.player.Pony; +import com.minelittlepony.unicopia.equine.player.Pony; import net.minecraft.client.MinecraftClient; import net.minecraft.client.input.Input; diff --git a/src/main/java/com/minelittlepony/unicopia/mixin/client/MixinMouse.java b/src/main/java/com/minelittlepony/unicopia/mixin/client/MixinMouse.java index 6bcdf6ec..b8434e25 100644 --- a/src/main/java/com/minelittlepony/unicopia/mixin/client/MixinMouse.java +++ b/src/main/java/com/minelittlepony/unicopia/mixin/client/MixinMouse.java @@ -6,7 +6,7 @@ import org.spongepowered.asm.mixin.injection.At; import org.spongepowered.asm.mixin.injection.Inject; import org.spongepowered.asm.mixin.injection.callback.CallbackInfo; -import com.minelittlepony.unicopia.entity.player.Pony; +import com.minelittlepony.unicopia.equine.player.Pony; import net.minecraft.client.MinecraftClient; import net.minecraft.client.Mouse; diff --git a/src/main/java/com/minelittlepony/unicopia/network/Channel.java b/src/main/java/com/minelittlepony/unicopia/network/Channel.java index 304a6a67..8824047f 100644 --- a/src/main/java/com/minelittlepony/unicopia/network/Channel.java +++ b/src/main/java/com/minelittlepony/unicopia/network/Channel.java @@ -8,7 +8,7 @@ import net.fabricmc.fabric.api.network.PacketContext; import net.fabricmc.fabric.api.network.ServerSidePacketRegistry; import net.minecraft.entity.player.PlayerEntity; import net.minecraft.util.Identifier; -import net.minecraft.util.PacketByteBuf; +import net.minecraft.network.PacketByteBuf; public interface Channel { diff --git a/src/main/java/com/minelittlepony/unicopia/network/MsgPlayerAbility.java b/src/main/java/com/minelittlepony/unicopia/network/MsgPlayerAbility.java index b4ae6916..34770952 100644 --- a/src/main/java/com/minelittlepony/unicopia/network/MsgPlayerAbility.java +++ b/src/main/java/com/minelittlepony/unicopia/network/MsgPlayerAbility.java @@ -2,12 +2,12 @@ package com.minelittlepony.unicopia.network; import com.minelittlepony.unicopia.ability.Ability; import com.minelittlepony.unicopia.ability.data.Hit; +import com.minelittlepony.unicopia.equine.player.Pony; import com.minelittlepony.unicopia.ability.Abilities; -import com.minelittlepony.unicopia.entity.player.Pony; import net.fabricmc.fabric.api.network.PacketContext; import net.minecraft.util.Identifier; -import net.minecraft.util.PacketByteBuf; +import net.minecraft.network.PacketByteBuf; public class MsgPlayerAbility implements Channel.Packet { diff --git a/src/main/java/com/minelittlepony/unicopia/network/MsgPlayerCapabilities.java b/src/main/java/com/minelittlepony/unicopia/network/MsgPlayerCapabilities.java index d354d0f9..b5c1fd24 100644 --- a/src/main/java/com/minelittlepony/unicopia/network/MsgPlayerCapabilities.java +++ b/src/main/java/com/minelittlepony/unicopia/network/MsgPlayerCapabilities.java @@ -4,13 +4,13 @@ import java.io.IOException; import java.io.InputStream; import java.io.OutputStream; import com.minelittlepony.unicopia.Race; -import com.minelittlepony.unicopia.entity.player.Pony; +import com.minelittlepony.unicopia.equine.player.Pony; import io.netty.buffer.ByteBufInputStream; import io.netty.buffer.ByteBufOutputStream; import net.fabricmc.fabric.api.network.PacketContext; import net.minecraft.entity.player.PlayerEntity; -import net.minecraft.util.PacketByteBuf; +import net.minecraft.network.PacketByteBuf; import net.minecraft.nbt.CompoundTag; import net.minecraft.nbt.NbtIo; diff --git a/src/main/java/com/minelittlepony/unicopia/network/MsgRequestCapabilities.java b/src/main/java/com/minelittlepony/unicopia/network/MsgRequestCapabilities.java index 495d11c2..07d88040 100644 --- a/src/main/java/com/minelittlepony/unicopia/network/MsgRequestCapabilities.java +++ b/src/main/java/com/minelittlepony/unicopia/network/MsgRequestCapabilities.java @@ -1,10 +1,10 @@ package com.minelittlepony.unicopia.network; import com.minelittlepony.unicopia.Race; -import com.minelittlepony.unicopia.entity.player.Pony; +import com.minelittlepony.unicopia.equine.player.Pony; import net.fabricmc.fabric.api.network.PacketContext; -import net.minecraft.util.PacketByteBuf; +import net.minecraft.network.PacketByteBuf; public class MsgRequestCapabilities implements Channel.Packet { diff --git a/src/main/java/com/minelittlepony/unicopia/network/MsgSpawnProjectile.java b/src/main/java/com/minelittlepony/unicopia/network/MsgSpawnProjectile.java index eecaf549..8eee9730 100644 --- a/src/main/java/com/minelittlepony/unicopia/network/MsgSpawnProjectile.java +++ b/src/main/java/com/minelittlepony/unicopia/network/MsgSpawnProjectile.java @@ -3,10 +3,10 @@ package com.minelittlepony.unicopia.network; import java.io.IOException; import net.fabricmc.fabric.api.network.PacketContext; -import net.minecraft.client.network.packet.EntitySpawnS2CPacket; import net.minecraft.client.world.ClientWorld; import net.minecraft.entity.Entity; -import net.minecraft.util.PacketByteBuf; +import net.minecraft.network.PacketByteBuf; +import net.minecraft.network.packet.s2c.play.EntitySpawnS2CPacket; import net.minecraft.world.World; public class MsgSpawnProjectile extends EntitySpawnS2CPacket implements Channel.Packet { diff --git a/src/main/java/com/minelittlepony/unicopia/network/MsgSpawnRainbow.java b/src/main/java/com/minelittlepony/unicopia/network/MsgSpawnRainbow.java index 9bfd58d2..70c580e7 100644 --- a/src/main/java/com/minelittlepony/unicopia/network/MsgSpawnRainbow.java +++ b/src/main/java/com/minelittlepony/unicopia/network/MsgSpawnRainbow.java @@ -1,11 +1,12 @@ package com.minelittlepony.unicopia.network; -import com.minelittlepony.unicopia.entity.RainbowEntity; -import com.minelittlepony.unicopia.entity.UEntities; +import com.minelittlepony.unicopia.world.entity.RainbowEntity; +import com.minelittlepony.unicopia.world.entity.UEntities; + import net.fabricmc.fabric.api.network.PacketContext; import net.minecraft.client.MinecraftClient; import net.minecraft.entity.Entity; -import net.minecraft.util.PacketByteBuf; +import net.minecraft.network.PacketByteBuf; public class MsgSpawnRainbow implements Channel.Packet { diff --git a/src/main/java/com/minelittlepony/unicopia/particles/DiskParticleEffect.java b/src/main/java/com/minelittlepony/unicopia/particles/DiskParticleEffect.java index 594cb976..28b32742 100644 --- a/src/main/java/com/minelittlepony/unicopia/particles/DiskParticleEffect.java +++ b/src/main/java/com/minelittlepony/unicopia/particles/DiskParticleEffect.java @@ -5,7 +5,7 @@ import com.mojang.brigadier.exceptions.CommandSyntaxException; import net.minecraft.particle.ParticleEffect; import net.minecraft.particle.ParticleType; -import net.minecraft.util.PacketByteBuf; +import net.minecraft.network.PacketByteBuf; public class DiskParticleEffect extends SphereParticleEffect { public static final ParticleEffect.Factory FACTORY = new ParticleEffect.Factory() { diff --git a/src/main/java/com/minelittlepony/unicopia/particles/MagicParticleEffect.java b/src/main/java/com/minelittlepony/unicopia/particles/MagicParticleEffect.java index 2fa1e024..d661d4d3 100644 --- a/src/main/java/com/minelittlepony/unicopia/particles/MagicParticleEffect.java +++ b/src/main/java/com/minelittlepony/unicopia/particles/MagicParticleEffect.java @@ -2,13 +2,13 @@ package com.minelittlepony.unicopia.particles; import java.util.Locale; -import com.minelittlepony.util.Color; +import com.minelittlepony.common.util.Color; import com.mojang.brigadier.StringReader; import com.mojang.brigadier.exceptions.CommandSyntaxException; import net.minecraft.particle.ParticleEffect; import net.minecraft.particle.ParticleType; -import net.minecraft.util.PacketByteBuf; +import net.minecraft.network.PacketByteBuf; import net.minecraft.util.registry.Registry; public class MagicParticleEffect implements ParticleEffect { diff --git a/src/main/java/com/minelittlepony/unicopia/particles/ParticleEmitter.java b/src/main/java/com/minelittlepony/unicopia/particles/ParticleEmitter.java index e01d1e5a..c3e08ab5 100644 --- a/src/main/java/com/minelittlepony/unicopia/particles/ParticleEmitter.java +++ b/src/main/java/com/minelittlepony/unicopia/particles/ParticleEmitter.java @@ -55,7 +55,7 @@ public class ParticleEmitter { Vec3d origin = entity.getPos(); for (Direction side : Direction.values()) { - Vec3d plane = new Vec3d(side.getVector()); + Vec3d plane = Vec3d.of(side.getVector()); spawnDiggingFX(entity.getEntityWorld(), clampPlane(side.getAxis(), diff --git a/src/main/java/com/minelittlepony/unicopia/particles/ParticleUtils.java b/src/main/java/com/minelittlepony/unicopia/particles/ParticleUtils.java index 129f7a4c..05e621aa 100644 --- a/src/main/java/com/minelittlepony/unicopia/particles/ParticleUtils.java +++ b/src/main/java/com/minelittlepony/unicopia/particles/ParticleUtils.java @@ -13,7 +13,7 @@ public final class ParticleUtils { public static void spawnParticles(ParticleEffect particleId, Entity entity, int count) { double halfDist = Math.abs(entity.getStandingEyeHeight() / 1.5); - double middle = entity.getBoundingBox().y1 + halfDist; + double middle = entity.getBoundingBox().minY + halfDist; Shape shape = new Sphere(false, Math.abs((float)halfDist + entity.getWidth())); diff --git a/src/main/java/com/minelittlepony/unicopia/particles/SphereParticleEffect.java b/src/main/java/com/minelittlepony/unicopia/particles/SphereParticleEffect.java index 4e9813a6..25f680d5 100644 --- a/src/main/java/com/minelittlepony/unicopia/particles/SphereParticleEffect.java +++ b/src/main/java/com/minelittlepony/unicopia/particles/SphereParticleEffect.java @@ -2,13 +2,13 @@ package com.minelittlepony.unicopia.particles; import java.util.Locale; -import com.minelittlepony.util.Color; +import com.minelittlepony.common.util.Color; import com.mojang.brigadier.StringReader; import com.mojang.brigadier.exceptions.CommandSyntaxException; import net.minecraft.particle.ParticleEffect; import net.minecraft.particle.ParticleType; -import net.minecraft.util.PacketByteBuf; +import net.minecraft.network.PacketByteBuf; import net.minecraft.util.registry.Registry; public class SphereParticleEffect implements ParticleEffect { diff --git a/src/main/java/com/minelittlepony/unicopia/structure/CustomSaplingGenerator.java b/src/main/java/com/minelittlepony/unicopia/structure/CustomSaplingGenerator.java deleted file mode 100644 index d0881386..00000000 --- a/src/main/java/com/minelittlepony/unicopia/structure/CustomSaplingGenerator.java +++ /dev/null @@ -1,71 +0,0 @@ -package com.minelittlepony.unicopia.structure; - -import java.util.Random; -import javax.annotation.Nullable; - -import com.google.common.collect.ImmutableList; -import com.minelittlepony.unicopia.block.UBlocks; - -import net.minecraft.block.BlockState; -import net.minecraft.block.Blocks; -import net.minecraft.block.sapling.SaplingGenerator; -import net.minecraft.world.gen.decorator.BeehiveTreeDecorator; -import net.minecraft.world.gen.feature.BranchedTreeFeatureConfig; -import net.minecraft.world.gen.feature.ConfiguredFeature; -import net.minecraft.world.gen.feature.Feature; -import net.minecraft.world.gen.foliage.BlobFoliagePlacer; -import net.minecraft.world.gen.stateprovider.SimpleStateProvider; - -public class CustomSaplingGenerator extends SaplingGenerator { - public static final CustomSaplingGenerator APPLE_TREE = new CustomSaplingGenerator(5, Blocks.OAK_LOG.getDefaultState(), UBlocks.APPLE_LEAVES.getDefaultState()); - - public final BranchedTreeFeatureConfig fancyConfig; - public final BranchedTreeFeatureConfig fancyHiveConfig; - public final BranchedTreeFeatureConfig hiveConfig; - public final BranchedTreeFeatureConfig config; - - public CustomSaplingGenerator(int height, BlockState log, BlockState leaves) { - fancyConfig = new BranchedTreeFeatureConfig.Builder( - new SimpleStateProvider(log), - new SimpleStateProvider(leaves), - new BlobFoliagePlacer(0, 0)) - .baseHeight(height) - .build(); - fancyHiveConfig = new BranchedTreeFeatureConfig.Builder( - new SimpleStateProvider(log), - new SimpleStateProvider(leaves), - new BlobFoliagePlacer(0, 0)) - .treeDecorators(ImmutableList.of(new BeehiveTreeDecorator(0.05F))) - .baseHeight(height) - .build(); - - hiveConfig = new BranchedTreeFeatureConfig.Builder( - new SimpleStateProvider(log), - new SimpleStateProvider(leaves), - new BlobFoliagePlacer(2, 0)) - .baseHeight(height) - .heightRandA(height / 2) - .foliageHeight((height * 2) / 3) - .noVines() - .treeDecorators(ImmutableList.of(new BeehiveTreeDecorator(0.05F))) - .build(); - - config = new BranchedTreeFeatureConfig.Builder( - new SimpleStateProvider(log), - new SimpleStateProvider(leaves), - new BlobFoliagePlacer(2, 0)) - .baseHeight(4) - .heightRandA(2) - .foliageHeight(3) - .noVines() - .build(); - } - - @Override - @Nullable - protected ConfiguredFeature createTreeFeature(Random random, boolean hives) { - return random.nextInt(10) == 0 - ? Feature.FANCY_TREE.configure(hives ? fancyHiveConfig : fancyConfig) - : Feature.NORMAL_TREE.configure(hives ? hiveConfig : config); - } -} diff --git a/src/main/java/com/minelittlepony/unicopia/structure/UStructures.java b/src/main/java/com/minelittlepony/unicopia/structure/UStructures.java deleted file mode 100644 index 46b5f462..00000000 --- a/src/main/java/com/minelittlepony/unicopia/structure/UStructures.java +++ /dev/null @@ -1,71 +0,0 @@ -package com.minelittlepony.unicopia.structure; - -import com.google.common.collect.ImmutableList; - -import net.minecraft.structure.StructurePieceType; -import net.minecraft.util.Identifier; -import net.minecraft.util.registry.Registry; -import net.minecraft.world.biome.Biome; -import net.minecraft.world.biome.Biomes; -import net.minecraft.world.gen.GenerationStep; -import net.minecraft.world.gen.decorator.CountExtraChanceDecoratorConfig; -import net.minecraft.world.gen.decorator.Decorator; -import net.minecraft.world.gen.feature.DefaultFeatureConfig; -import net.minecraft.world.gen.feature.Feature; -import net.minecraft.world.gen.feature.FeatureConfig; -import net.minecraft.world.gen.feature.RandomFeatureConfig; -import net.minecraft.world.gen.feature.StructureFeature; - -public interface UStructures { - StructurePieceType CLOUD_HOUSE_PART = part("cloud_house", CloudDungeonFeature.Piece::new); - StructurePieceType RUIN_PART = part("ruin", RuinFeature.Piece::new); - - StructureFeature CLOUD_HOUSE = feature("cloud_house", new CloudDungeonFeature(DefaultFeatureConfig::deserialize, Biomes.OCEAN, - Biomes.WOODED_BADLANDS_PLATEAU, - Biomes.DESERT, - Biomes.DESERT_HILLS, - Biomes.JUNGLE, - Biomes.JUNGLE_HILLS, - Biomes.SWAMP, - Biomes.SWAMP_HILLS, - Biomes.ICE_SPIKES, - Biomes.TAIGA)); - StructureFeature RUIN = feature("ruin", new RuinFeature(DefaultFeatureConfig::deserialize, - Biomes.TAIGA, - Biomes.TAIGA_HILLS, - Biomes.GIANT_TREE_TAIGA, - Biomes.GIANT_TREE_TAIGA_HILLS, - Biomes.SNOWY_TAIGA, - Biomes.SNOWY_TAIGA_HILLS, - Biomes.GIANT_SPRUCE_TAIGA, - Biomes.GIANT_TREE_TAIGA_HILLS, - Biomes.SNOWY_TAIGA_MOUNTAINS, - Biomes.DARK_FOREST, - Biomes.DARK_FOREST_HILLS - )); - - static StructurePieceType part(String id, StructurePieceType type) { - return Registry.register(Registry.STRUCTURE_PIECE, new Identifier("unicopia", id), type); - } - - static > F feature(String name, F feature) { - Identifier id = new Identifier("unicopia", name); - return Registry.register(Registry.STRUCTURE_FEATURE, id, Registry.register(Registry.FEATURE, id, feature)); - } - - static void bootstrap() { - Registry.BIOME.forEach(biome -> { - Biome.Category category = biome.getCategory(); - - if (category == Biome.Category.FOREST) { - biome.addFeature(GenerationStep.Feature.VEGETAL_DECORATION, - Feature.RANDOM_SELECTOR.configure(new RandomFeatureConfig(ImmutableList.of( - Feature.NORMAL_TREE.configure(CustomSaplingGenerator.APPLE_TREE.hiveConfig).withChance(0.02F), - Feature.FANCY_TREE.configure(CustomSaplingGenerator.APPLE_TREE.fancyConfig).withChance(0.01F)), - Feature.NORMAL_TREE.configure(CustomSaplingGenerator.APPLE_TREE.config) - )) - .createDecoratedFeature(Decorator.COUNT_EXTRA_HEIGHTMAP.configure(new CountExtraChanceDecoratorConfig(0, 0.1F, 3)))); - } - }); - } -} diff --git a/src/main/java/com/minelittlepony/unicopia/toxin/Toxic.java b/src/main/java/com/minelittlepony/unicopia/toxin/Toxic.java index 02acd6c6..f3b44285 100644 --- a/src/main/java/com/minelittlepony/unicopia/toxin/Toxic.java +++ b/src/main/java/com/minelittlepony/unicopia/toxin/Toxic.java @@ -4,7 +4,7 @@ import java.util.function.Function; import java.util.function.Supplier; import com.minelittlepony.unicopia.Race; -import com.minelittlepony.unicopia.entity.player.Pony; +import com.minelittlepony.unicopia.equine.player.Pony; import net.minecraft.entity.LivingEntity; import net.minecraft.entity.player.PlayerEntity; diff --git a/src/main/java/com/minelittlepony/unicopia/toxin/ToxicBlockItem.java b/src/main/java/com/minelittlepony/unicopia/toxin/ToxicBlockItem.java deleted file mode 100644 index 1154ffb0..00000000 --- a/src/main/java/com/minelittlepony/unicopia/toxin/ToxicBlockItem.java +++ /dev/null @@ -1,18 +0,0 @@ -package com.minelittlepony.unicopia.toxin; - -import net.minecraft.block.Block; -import net.minecraft.item.BlockItem; -import net.minecraft.util.UseAction; - -public class ToxicBlockItem extends BlockItem { - - public ToxicBlockItem(Block block, Settings settings, Toxic toxic) { - super(block, settings); - ((ToxicHolder)this).setToxic(toxic); - } - - public ToxicBlockItem(Block block, Settings settings, UseAction action, Toxicity toxicity, Toxin toxin) { - super(block, settings); - ((ToxicHolder)this).setToxic(new Toxic(this, action, toxin, toxicity)); - } -} diff --git a/src/main/java/com/minelittlepony/unicopia/toxin/Toxicity.java b/src/main/java/com/minelittlepony/unicopia/toxin/Toxicity.java index 6e4226eb..8e9344c5 100644 --- a/src/main/java/com/minelittlepony/unicopia/toxin/Toxicity.java +++ b/src/main/java/com/minelittlepony/unicopia/toxin/Toxicity.java @@ -5,8 +5,6 @@ import java.util.Map; import java.util.function.Function; import java.util.stream.Collectors; -import com.minelittlepony.unicopia.item.UEffects; - import net.minecraft.entity.effect.StatusEffectInstance; import net.minecraft.entity.effect.StatusEffects; import net.minecraft.entity.player.PlayerEntity; @@ -54,9 +52,9 @@ public enum Toxicity implements Toxin { } public Text getTooltip() { - Text text = new TranslatableText(getTranslationKey()); - text.getStyle().setColor(toxicWhenCooked() ? Formatting.RED : toxicWhenRaw() ? Formatting.DARK_PURPLE : Formatting.GRAY); - return text; + return new TranslatableText(getTranslationKey()) + .styled(s -> s + .withColor(toxicWhenCooked() ? Formatting.RED : toxicWhenRaw() ? Formatting.DARK_PURPLE : Formatting.GRAY)); } public ItemStack ontoStack(ItemStack stack) { diff --git a/src/main/java/com/minelittlepony/unicopia/toxin/Toxics.java b/src/main/java/com/minelittlepony/unicopia/toxin/Toxics.java index 87e49a73..571f8938 100644 --- a/src/main/java/com/minelittlepony/unicopia/toxin/Toxics.java +++ b/src/main/java/com/minelittlepony/unicopia/toxin/Toxics.java @@ -1,7 +1,5 @@ package com.minelittlepony.unicopia.toxin; -import com.minelittlepony.unicopia.item.UFoodComponents; - import net.minecraft.item.FoodComponent; import net.minecraft.item.Item; import net.minecraft.item.Items; diff --git a/src/main/java/com/minelittlepony/unicopia/toxin/Toxin.java b/src/main/java/com/minelittlepony/unicopia/toxin/Toxin.java index 3b2c108e..837883ad 100644 --- a/src/main/java/com/minelittlepony/unicopia/toxin/Toxin.java +++ b/src/main/java/com/minelittlepony/unicopia/toxin/Toxin.java @@ -1,7 +1,5 @@ package com.minelittlepony.unicopia.toxin; -import com.minelittlepony.unicopia.item.UEffects; - import net.minecraft.entity.effect.StatusEffect; import net.minecraft.entity.effect.StatusEffectInstance; import net.minecraft.entity.effect.StatusEffects; diff --git a/src/main/java/com/minelittlepony/unicopia/item/UEffects.java b/src/main/java/com/minelittlepony/unicopia/toxin/UEffects.java similarity index 96% rename from src/main/java/com/minelittlepony/unicopia/item/UEffects.java rename to src/main/java/com/minelittlepony/unicopia/toxin/UEffects.java index 382302d1..09dab806 100644 --- a/src/main/java/com/minelittlepony/unicopia/item/UEffects.java +++ b/src/main/java/com/minelittlepony/unicopia/toxin/UEffects.java @@ -1,4 +1,4 @@ -package com.minelittlepony.unicopia.item; +package com.minelittlepony.unicopia.toxin; import com.minelittlepony.unicopia.util.CustomStatusEffect; import com.minelittlepony.unicopia.util.MagicalDamageSource; diff --git a/src/main/java/com/minelittlepony/unicopia/item/UFoodComponents.java b/src/main/java/com/minelittlepony/unicopia/toxin/UFoodComponents.java similarity index 96% rename from src/main/java/com/minelittlepony/unicopia/item/UFoodComponents.java rename to src/main/java/com/minelittlepony/unicopia/toxin/UFoodComponents.java index 3c8eb582..7deb807c 100644 --- a/src/main/java/com/minelittlepony/unicopia/item/UFoodComponents.java +++ b/src/main/java/com/minelittlepony/unicopia/toxin/UFoodComponents.java @@ -1,4 +1,4 @@ -package com.minelittlepony.unicopia.item; +package com.minelittlepony.unicopia.toxin; import net.minecraft.item.FoodComponent; diff --git a/src/main/java/com/minelittlepony/unicopia/util/HoeUtil.java b/src/main/java/com/minelittlepony/unicopia/util/HoeUtil.java index 48f846ea..0926c3b0 100644 --- a/src/main/java/com/minelittlepony/unicopia/util/HoeUtil.java +++ b/src/main/java/com/minelittlepony/unicopia/util/HoeUtil.java @@ -7,7 +7,7 @@ import net.minecraft.item.ItemUsageContext; public final class HoeUtil extends HoeItem { private HoeUtil() { - super(null, 0, null); + super(null, 0, 0, null); } public static void registerTillingAction(Block block, BlockState tilledState) { diff --git a/src/main/java/com/minelittlepony/unicopia/util/OreReplacer.java b/src/main/java/com/minelittlepony/unicopia/util/OreReplacer.java index b6a9b7a5..693a0d14 100644 --- a/src/main/java/com/minelittlepony/unicopia/util/OreReplacer.java +++ b/src/main/java/com/minelittlepony/unicopia/util/OreReplacer.java @@ -12,7 +12,7 @@ import net.minecraft.item.ItemStack; import net.minecraft.recipe.Ingredient; import net.minecraft.recipe.Recipe; import net.minecraft.recipe.RecipeType; -import net.minecraft.util.DefaultedList; +import net.minecraft.util.collection.DefaultedList; /** * An Ore Replacer. diff --git a/src/main/java/com/minelittlepony/unicopia/util/PosHelper.java b/src/main/java/com/minelittlepony/unicopia/util/PosHelper.java index 486075bd..41af8304 100644 --- a/src/main/java/com/minelittlepony/unicopia/util/PosHelper.java +++ b/src/main/java/com/minelittlepony/unicopia/util/PosHelper.java @@ -49,7 +49,7 @@ public interface PosHelper { } static Stream adjacentNeighbours(BlockPos origin) { - BlockPos.Mutable pos = new BlockPos.Mutable(origin); + BlockPos.Mutable pos = new BlockPos.Mutable(origin.getX(), origin.getY(), origin.getZ()); List directions = Lists.newArrayList(Direction.values()); Iterator iter = directions.iterator(); return StreamSupport.stream(new AbstractSpliterator(directions.size(), Spliterator.SIZED) { @@ -71,6 +71,6 @@ public interface PosHelper { return BlockPos.stream( origin.add(new BlockPos(shape.getLowerBound())), origin.add(new BlockPos(shape.getUpperBound())) - ).filter(pos -> shape.isPointInside(new Vec3d(pos.subtract(origin)))); + ).filter(pos -> shape.isPointInside(Vec3d.of(pos.subtract(origin)))); } } diff --git a/src/main/java/com/minelittlepony/unicopia/util/Registries.java b/src/main/java/com/minelittlepony/unicopia/util/Registries.java new file mode 100644 index 00000000..a96b1ea2 --- /dev/null +++ b/src/main/java/com/minelittlepony/unicopia/util/Registries.java @@ -0,0 +1,16 @@ +package com.minelittlepony.unicopia.util; + +import com.mojang.serialization.Lifecycle; + +import net.fabricmc.fabric.api.event.registry.FabricRegistryBuilder; +import net.minecraft.util.Identifier; +import net.minecraft.util.registry.Registry; +import net.minecraft.util.registry.RegistryKey; +import net.minecraft.util.registry.SimpleRegistry; + +public interface Registries { + + static Registry createSimple(Identifier id) { + return FabricRegistryBuilder.from(new SimpleRegistry(RegistryKey.ofRegistry(id), Lifecycle.stable())).buildAndRegister(); + } +} diff --git a/src/main/java/com/minelittlepony/unicopia/util/WorldEvent.java b/src/main/java/com/minelittlepony/unicopia/util/WorldEvent.java index 0f7c4504..04748be6 100644 --- a/src/main/java/com/minelittlepony/unicopia/util/WorldEvent.java +++ b/src/main/java/com/minelittlepony/unicopia/util/WorldEvent.java @@ -3,86 +3,82 @@ package com.minelittlepony.unicopia.util; import net.minecraft.block.Block; import net.minecraft.block.BlockState; import net.minecraft.util.math.BlockPos; -import net.minecraft.world.World; +import net.minecraft.world.WorldAccess; /** * All of the Auxiliary effects used in minecraft for World.playGlobalEvent */ -public enum WorldEvent { - DISPENSER_DISPENSE_BLOCK(1000), - DISPENSER_FAIL(1001), - DISPENSE_SHOOT_PROJECTILE(1002), - LAUNCH_ENDER_PEAR(1003), - LAUNCH_FIREWORKS_ROCKET(1004), - RECORD_DROP(1005), IRON_DOOR_OPEN(1005), - WOODEN_DOOR_OPEN(1006), - WOODEN_TRAPDOOR_OPEN(1007), - GATE_OPEN(1008), - FIRE_EXTENGUISH(1009), - PLAY_RECORD(1010), - IRON_DOOR_SLAM(1011), - WOODEN_DOOR_SLAM(1012), - WOODEN_TRAPDOOR_SLAM(1013), - FENCE_GATE_SWIVEL(1014), - GHAST_SCREAM(1015), - GHAST_SHOOT(1016), - ENDERMAN_SCREAM(1017), - FIRE_SHOOT(1018), - DOOR_SWIVEL(1019), WOOD_DOOR_KNOCK(1019), - REPAIR_ITEM(1020), IRON_DOOR_KNOCK(1020), - DOOR_BROKEN(1021), - WITHER_ATTACK(1022), - WITHER_SHOOT(1024), - ENTITY_TAKEOFF(1025), - MOB_INFECT(1026), - MOB_CURE(1027), - ANVIL_DESTROY(1029), - ANVIL_USE(1030), - ANVIL_LAND(1031), - PORTAL_WARP(1032), - ORGANIC_WET(1033), - ORGANIC_DRY(1034), - BREW_POTION(1035), - DOOR_CLOSE(1036), - DOOR_OPEN(1037), +public interface WorldEvent { + int + DISPENSER_SUCCESS = 1000, + DISPENSER_FAIL = 1001, + DISPENSER_LAUNCH = 1002, + ENDER_EYE_LAUNCH = 1003, + FIREWORKS_ROCKET_SHOOT = 1004, + IRON_DOOR_OPEN = 1005, + WOODEN_DOOR_OPEN = 1006, + WOODEN_TRAPDOOR_OPEN = 1007, + FENCE_GATE_OPEN = 1008, + FIRE_EXTINGUISH = 1009, + MUSIC_DISC_PLAY = 1010, + IRON_DOOR_CLOSE = 1011, + WOODEN_DOOR_CLOSE = 1012, + WOODEN_TRAPDOOR_CLOSE = 1013, + FENCE_GATE_CLOSE = 1014, + GHAST_WARN = 1015, + GHAST_SHOOT = 1016, + ENDER_DRAGON_SHOOT = 1017, + BLAZE_SHOOT = 1018, + ZOMBIE_ATTACK_WOODEN_DOOR = 1019, + ZOMBIE_ATTACK_IRON_DOOR = 1020, + ZOMBIE_BREAK_WOODEN_DOOR = 1021, + WITHER_BREAK_BLOCK = 1022, + WITHER_SHOOT = 1024, + BAT_TAKEOFF = 1025, + ZOMBIE_INFECT = 1026, + ZOMBIE_VILLAGER_CONVERTED = 1027, + ANVIL_DESTROY = 1029, + ANVIL_USE = 1030, + ANVIL_LAND = 1031, + PORTAL_TRAVEL = 1032, + CHORUS_FLOWER_GROW = 1033, + CHORUS_FLOWER_DEATH = 1034, + BREWING_STAND_BREW = 1035, + IRON_TRAPDOOR_CLOSE = 1036, + IRON_TRAPDOOR_OPEN = 1037, + PHANTOM_BITE = 1039, + ZOMBIE_CONVERTED_TO_DROWNED = 1040, + HUSK_CONVERTED_TO_ZOMBIE = 1041, + GRINDSTONE_USE = 1042, + BOOK_PAGE_TURN = 2043, + SMITHING_TABLE_USE = 1044, + COMPOSTER_COMPOST = 1500, + LAVA_EXTINGUISH = 1501, + REDSTONE_TORCH_BURNOUT = 1502, + END_PORTAL_FRAME_FILL = 1503, + DISPENSER_PARTICLES = 2000, + DESTROY_BLOCK = 2001, + XP_POP = 2002, PROJECTILE_HIT = 2002, + EYE_OF_ENDER = 2003, + MOB_SPAWNED = 2004, + BONEMEAL = 2005, + DRAGON_BREATH = 2006, + POTION_INSTANT = 2007, + ENDER_DRAGON_ATTACK = 2008, + SPONGE_SUCK = 2009, + ENDER_DRAGON_DEFEATED = 3000, + ENDER_DRAGON_GROWL = 3001, + UNKNOWN = 0; - - - DISPENSE_PARTICLES(2000), - DESTROY_BLOCK(2001), - XP_POP(2002), PROJECTILE_HIT(2002), - EYE_OF_ENDER(2003), - MOB_SPAWN(2004), - BONEMEAL(2005), - DRAGON_BREATH(2006), - POTION_INSTANT(2007), - DRAGON_DEFEATED(3000), - DRAGON_ROARS(3001), - - UNKNOWN(0); - - private final int id; - - WorldEvent(int id) { - this.id = id; + static void play(int event, WorldAccess world, BlockPos pos, BlockState state) { + world.syncWorldEvent(event, pos, Block.getRawIdFromState(state)); } - public int getId() { - return id; + static void play(int event, WorldAccess world, BlockPos pos) { + world.syncWorldEvent(event, pos, 0); } - public void play(World world, BlockPos pos, BlockState state) { - play(world, pos, Block.getRawIdFromState(state)); - } - - public void play(World world, BlockPos pos) { - play(world, pos, 0); - } - - private void play(World world, BlockPos pos, int data) { - world.playLevelEvent(getId(), pos, data); - } } diff --git a/src/main/java/com/minelittlepony/unicopia/blockstate/BlockStateConverter.java b/src/main/java/com/minelittlepony/unicopia/util/blockstate/BlockStateConverter.java similarity index 93% rename from src/main/java/com/minelittlepony/unicopia/blockstate/BlockStateConverter.java rename to src/main/java/com/minelittlepony/unicopia/util/blockstate/BlockStateConverter.java index a644473d..bf27d86f 100644 --- a/src/main/java/com/minelittlepony/unicopia/blockstate/BlockStateConverter.java +++ b/src/main/java/com/minelittlepony/unicopia/util/blockstate/BlockStateConverter.java @@ -1,4 +1,4 @@ -package com.minelittlepony.unicopia.blockstate; +package com.minelittlepony.unicopia.util.blockstate; import javax.annotation.Nonnull; import javax.annotation.Nullable; diff --git a/src/main/java/com/minelittlepony/unicopia/blockstate/BlockStateMap.java b/src/main/java/com/minelittlepony/unicopia/util/blockstate/BlockStateMap.java similarity index 96% rename from src/main/java/com/minelittlepony/unicopia/blockstate/BlockStateMap.java rename to src/main/java/com/minelittlepony/unicopia/util/blockstate/BlockStateMap.java index 98c7f4b5..6e0a79ca 100644 --- a/src/main/java/com/minelittlepony/unicopia/blockstate/BlockStateMap.java +++ b/src/main/java/com/minelittlepony/unicopia/util/blockstate/BlockStateMap.java @@ -1,4 +1,4 @@ -package com.minelittlepony.unicopia.blockstate; +package com.minelittlepony.unicopia.util.blockstate; import java.util.ArrayList; import java.util.function.Predicate; diff --git a/src/main/java/com/minelittlepony/unicopia/blockstate/ReversableBlockStateConverter.java b/src/main/java/com/minelittlepony/unicopia/util/blockstate/ReversableBlockStateConverter.java similarity index 69% rename from src/main/java/com/minelittlepony/unicopia/blockstate/ReversableBlockStateConverter.java rename to src/main/java/com/minelittlepony/unicopia/util/blockstate/ReversableBlockStateConverter.java index 1a3719ce..b25b3ccd 100644 --- a/src/main/java/com/minelittlepony/unicopia/blockstate/ReversableBlockStateConverter.java +++ b/src/main/java/com/minelittlepony/unicopia/util/blockstate/ReversableBlockStateConverter.java @@ -1,4 +1,4 @@ -package com.minelittlepony.unicopia.blockstate; +package com.minelittlepony.unicopia.util.blockstate; public interface ReversableBlockStateConverter extends BlockStateConverter { BlockStateConverter getInverse(); diff --git a/src/main/java/com/minelittlepony/unicopia/blockstate/ReversableBlockStateMap.java b/src/main/java/com/minelittlepony/unicopia/util/blockstate/ReversableBlockStateMap.java similarity index 89% rename from src/main/java/com/minelittlepony/unicopia/blockstate/ReversableBlockStateMap.java rename to src/main/java/com/minelittlepony/unicopia/util/blockstate/ReversableBlockStateMap.java index 848b514a..cc4d667e 100644 --- a/src/main/java/com/minelittlepony/unicopia/blockstate/ReversableBlockStateMap.java +++ b/src/main/java/com/minelittlepony/unicopia/util/blockstate/ReversableBlockStateMap.java @@ -1,4 +1,4 @@ -package com.minelittlepony.unicopia.blockstate; +package com.minelittlepony.unicopia.util.blockstate; class ReversableBlockStateMap extends BlockStateMap implements ReversableBlockStateConverter { private static final long serialVersionUID = 6154365988455383098L; diff --git a/src/main/java/com/minelittlepony/unicopia/blockstate/StateMapping.java b/src/main/java/com/minelittlepony/unicopia/util/blockstate/StateMapping.java similarity index 98% rename from src/main/java/com/minelittlepony/unicopia/blockstate/StateMapping.java rename to src/main/java/com/minelittlepony/unicopia/util/blockstate/StateMapping.java index bda1eb2d..4204f441 100644 --- a/src/main/java/com/minelittlepony/unicopia/blockstate/StateMapping.java +++ b/src/main/java/com/minelittlepony/unicopia/util/blockstate/StateMapping.java @@ -1,4 +1,4 @@ -package com.minelittlepony.unicopia.blockstate; +package com.minelittlepony.unicopia.util.blockstate; import java.util.function.Function; import java.util.function.Predicate; diff --git a/src/main/java/com/minelittlepony/unicopia/blockstate/StateMaps.java b/src/main/java/com/minelittlepony/unicopia/util/blockstate/StateMaps.java similarity index 98% rename from src/main/java/com/minelittlepony/unicopia/blockstate/StateMaps.java rename to src/main/java/com/minelittlepony/unicopia/util/blockstate/StateMaps.java index b4136d6e..62abbcb3 100644 --- a/src/main/java/com/minelittlepony/unicopia/blockstate/StateMaps.java +++ b/src/main/java/com/minelittlepony/unicopia/util/blockstate/StateMaps.java @@ -1,4 +1,4 @@ -package com.minelittlepony.unicopia.blockstate; +package com.minelittlepony.unicopia.util.blockstate; import net.minecraft.block.Blocks; import net.minecraft.block.FarmlandBlock; diff --git a/src/main/java/com/minelittlepony/unicopia/util/dummy/DummyClientPlayerEntity.java b/src/main/java/com/minelittlepony/unicopia/util/dummy/DummyClientPlayerEntity.java index 512039e9..d1841d59 100644 --- a/src/main/java/com/minelittlepony/unicopia/util/dummy/DummyClientPlayerEntity.java +++ b/src/main/java/com/minelittlepony/unicopia/util/dummy/DummyClientPlayerEntity.java @@ -3,19 +3,18 @@ package com.minelittlepony.unicopia.util.dummy; import javax.annotation.Nonnull; import com.minelittlepony.unicopia.InteractionManager; -import com.minelittlepony.unicopia.entity.Owned; +import com.minelittlepony.unicopia.Owned; import com.mojang.authlib.GameProfile; import net.minecraft.client.MinecraftClient; import net.minecraft.client.network.AbstractClientPlayerEntity; import net.minecraft.client.network.ClientPlayNetworkHandler; import net.minecraft.client.network.PlayerListEntry; -import net.minecraft.client.network.packet.PlayerListS2CPacket; import net.minecraft.client.world.ClientWorld; import net.minecraft.entity.player.PlayerEntity; import net.minecraft.item.ItemStack; +import net.minecraft.network.packet.s2c.play.PlayerListS2CPacket; import net.minecraft.text.LiteralText; -import net.minecraft.text.Text; import net.minecraft.world.GameMode; public class DummyClientPlayerEntity extends AbstractClientPlayerEntity implements Owned { @@ -74,13 +73,6 @@ public class DummyClientPlayerEntity extends AbstractClientPlayerEntity implemen this.owner = owner; } - @Override - public Text getDisplayName() { - Text name = super.getDisplayName(); - name.getStyle().setItalic(true); - return name; - } - private final class Packet extends PlayerListS2CPacket { PlayerListS2CPacket.Entry entry() { return new PlayerListS2CPacket.Entry( diff --git a/src/main/java/com/minelittlepony/unicopia/util/dummy/DummyPlayerEntity.java b/src/main/java/com/minelittlepony/unicopia/util/dummy/DummyPlayerEntity.java index f176d561..5c2d9bfa 100644 --- a/src/main/java/com/minelittlepony/unicopia/util/dummy/DummyPlayerEntity.java +++ b/src/main/java/com/minelittlepony/unicopia/util/dummy/DummyPlayerEntity.java @@ -1,12 +1,12 @@ package com.minelittlepony.unicopia.util.dummy; import com.minelittlepony.unicopia.InteractionManager; -import com.minelittlepony.unicopia.entity.Owned; +import com.minelittlepony.unicopia.Owned; import com.mojang.authlib.GameProfile; import net.minecraft.entity.player.PlayerEntity; import net.minecraft.item.ItemStack; -import net.minecraft.text.Text; +import net.minecraft.util.math.BlockPos; import net.minecraft.world.World; public class DummyPlayerEntity extends PlayerEntity implements Owned { @@ -14,7 +14,7 @@ public class DummyPlayerEntity extends PlayerEntity implements Owned { @@ -38,11 +37,4 @@ public class DummyServerPlayerEntity extends ServerPlayerEntity implements Owned public boolean shouldRenderName() { return !InteractionManager.instance().isClientPlayer(getOwner()); } - - @Override - public Text getDisplayName() { - Text name = super.getDisplayName(); - name.getStyle().setItalic(true); - return name; - } } diff --git a/src/main/java/com/minelittlepony/unicopia/util/projectile/AdvancedProjectile.java b/src/main/java/com/minelittlepony/unicopia/util/projectile/Projectile.java similarity index 83% rename from src/main/java/com/minelittlepony/unicopia/util/projectile/AdvancedProjectile.java rename to src/main/java/com/minelittlepony/unicopia/util/projectile/Projectile.java index 0f731af2..2b9cc8df 100644 --- a/src/main/java/com/minelittlepony/unicopia/util/projectile/AdvancedProjectile.java +++ b/src/main/java/com/minelittlepony/unicopia/util/projectile/Projectile.java @@ -4,11 +4,11 @@ import com.minelittlepony.unicopia.magic.ThrowableSpell; import net.minecraft.entity.Entity; import net.minecraft.entity.LivingEntity; -import net.minecraft.entity.projectile.Projectile; +import net.minecraft.entity.projectile.ProjectileEntity; import net.minecraft.item.ItemStack; import net.minecraft.world.World; -public interface AdvancedProjectile extends Projectile { +public interface Projectile { void setGravity(boolean gravity); @@ -33,6 +33,6 @@ public interface AdvancedProjectile extends Projectile { } default void launch(double x, double y, double z, float velocity, float inaccuracy) { - setVelocity(x, y, z, velocity, inaccuracy); + ((ProjectileEntity)this).setVelocity(x, y, z, velocity, inaccuracy); } } diff --git a/src/main/java/com/minelittlepony/unicopia/util/projectile/ProjectileUtil.java b/src/main/java/com/minelittlepony/unicopia/util/projectile/ProjectileUtil.java index 8feb9a0b..736cace8 100644 --- a/src/main/java/com/minelittlepony/unicopia/util/projectile/ProjectileUtil.java +++ b/src/main/java/com/minelittlepony/unicopia/util/projectile/ProjectileUtil.java @@ -3,12 +3,7 @@ package com.minelittlepony.unicopia.util.projectile; import javax.annotation.Nullable; import net.minecraft.entity.Entity; -import net.minecraft.entity.projectile.ArrowEntity; -import net.minecraft.entity.projectile.FireballEntity; -import net.minecraft.entity.projectile.LlamaSpitEntity; -import net.minecraft.entity.projectile.Projectile; import net.minecraft.entity.projectile.ProjectileEntity; -import net.minecraft.entity.thrown.ThrownEntity; import net.minecraft.util.math.Vec3d; public class ProjectileUtil { @@ -17,57 +12,17 @@ public class ProjectileUtil { * Checks if the given entity is a projectile. */ public static boolean isProjectile(Entity e) { - return e instanceof Projectile - || e instanceof FireballEntity; - } - - /** - * Checks if an entity is a thrown projectile. - */ - public static boolean isThrowable(Entity e) { - return e instanceof ThrownEntity - || e instanceof ArrowEntity - || e instanceof FireballEntity; + return e instanceof ProjectileEntity; } /** * Checks if the given projectile was thrown by the given entity */ public static boolean isProjectileThrownBy(Entity throwable, @Nullable T e) { - if (e == null || !isThrowable(throwable)) { - return false; - } - - return e.equals(getThrowingEntity(throwable)); + return e != null && isProjectile(throwable) && e.equals(((ProjectileEntity) throwable).getOwner()); } /** - * Gets the thrower for a projectile or null - */ - @Nullable - @SuppressWarnings("unchecked") - public static T getThrowingEntity(Entity throwable) { - - if (throwable instanceof ProjectileEntity) { - return (T)((ProjectileEntity) throwable).getOwner(); - } - - if (throwable instanceof FireballEntity) { - return (T)((FireballEntity) throwable).owner; - } - - if (throwable instanceof LlamaSpitEntity) { - return (T)((LlamaSpitEntity) throwable).owner; - } - - if (throwable instanceof ThrownEntity) { - return (T)((ThrownEntity) throwable).getOwner(); - } - - return null; - } - - /** * Sets the velocity and heading for a projectile. * * @param throwable The projectile @@ -78,8 +33,8 @@ public class ProjectileUtil { */ public static void setThrowableHeading(Entity throwable, Vec3d heading, float velocity, float inaccuracy) { - if (throwable instanceof Projectile) { - ((Projectile)throwable).setVelocity(heading.x, heading.y, heading.z, velocity, inaccuracy); + if (throwable instanceof ProjectileEntity) { + ((ProjectileEntity)throwable).setVelocity(heading.x, heading.y, heading.z, velocity, inaccuracy); } else { heading = heading.normalize().multiply(velocity); diff --git a/src/main/java/com/minelittlepony/unicopia/util/projectile/TossableItem.java b/src/main/java/com/minelittlepony/unicopia/world/TossableItem.java similarity index 79% rename from src/main/java/com/minelittlepony/unicopia/util/projectile/TossableItem.java rename to src/main/java/com/minelittlepony/unicopia/world/TossableItem.java index ffd4e08a..bd4b05e2 100644 --- a/src/main/java/com/minelittlepony/unicopia/util/projectile/TossableItem.java +++ b/src/main/java/com/minelittlepony/unicopia/world/TossableItem.java @@ -1,9 +1,11 @@ -package com.minelittlepony.unicopia.util.projectile; +package com.minelittlepony.unicopia.world; import javax.annotation.Nullable; -import com.minelittlepony.unicopia.entity.ProjectileEntity; import com.minelittlepony.unicopia.magic.Dispensable; +import com.minelittlepony.unicopia.util.projectile.Projectile; +import com.minelittlepony.unicopia.util.projectile.Tossable; +import com.minelittlepony.unicopia.world.entity.MagicProjectileEntity; import net.minecraft.block.DispenserBlock; import net.minecraft.entity.Entity; @@ -40,13 +42,13 @@ public interface TossableItem extends Tossable, Dispensable { } @Nullable - default AdvancedProjectile createProjectile(World world, PlayerEntity player) { - return new ProjectileEntity(null, world, player); + default Projectile createProjectile(World world, PlayerEntity player) { + return new MagicProjectileEntity(null, world, player); } @Nullable - default AdvancedProjectile createProjectile(World world, Position pos) { - return new ProjectileEntity(null, world, pos.getX(), pos.getY(), pos.getZ()); + default Projectile createProjectile(World world, Position pos) { + return new MagicProjectileEntity(null, world, pos.getX(), pos.getY(), pos.getZ()); } default void toss(World world, ItemStack itemstack, PlayerEntity player) { @@ -54,7 +56,7 @@ public interface TossableItem extends Tossable, Dispensable { world.playSound(null, player.getX(), player.getY(), player.getZ(), getThrowSound(itemstack), SoundCategory.NEUTRAL, 0.5F, 0.4F / (world.random.nextFloat() * 0.4F + 0.8F)); if (!world.isClient) { - AdvancedProjectile projectile = createProjectile(world, player); + Projectile projectile = createProjectile(world, player); if (projectile == null) { return; @@ -75,7 +77,7 @@ public interface TossableItem extends Tossable, Dispensable { } default ItemStack toss(World world, Position pos, Direction facing, ItemStack stack) { - AdvancedProjectile projectile = createProjectile(world, pos); + Projectile projectile = createProjectile(world, pos); if (projectile == null) { return stack; diff --git a/src/main/java/com/minelittlepony/unicopia/world/UnicopiaWorld.java b/src/main/java/com/minelittlepony/unicopia/world/UnicopiaWorld.java new file mode 100644 index 00000000..1b5518c9 --- /dev/null +++ b/src/main/java/com/minelittlepony/unicopia/world/UnicopiaWorld.java @@ -0,0 +1,41 @@ +package com.minelittlepony.unicopia.world; + +import com.minelittlepony.unicopia.mixin.CriterionsRegistry; +import com.minelittlepony.unicopia.world.advancement.BOHDeathCriterion; +import com.minelittlepony.unicopia.world.block.UBlocks; +import com.minelittlepony.unicopia.world.container.UContainers; +import com.minelittlepony.unicopia.world.item.UItems; +import com.minelittlepony.unicopia.world.recipe.URecipes; +import com.minelittlepony.unicopia.world.recipe.enchanting.Pages; +import com.minelittlepony.unicopia.world.structure.UStructures; + +import net.fabricmc.fabric.api.loot.v1.FabricLootSupplier; +import net.fabricmc.fabric.api.loot.v1.event.LootTableLoadingCallback; +import net.fabricmc.fabric.api.resource.ResourceManagerHelper; +import net.minecraft.loot.LootTable; +import net.minecraft.resource.ResourceType; +import net.minecraft.util.Identifier; + +public class UnicopiaWorld { + public static void bootstrap() { + UBlocks.bootstrap(); + UItems.bootstrap(); + UContainers.bootstrap(); + UStructures.bootstrap(); + URecipes.bootstrap(); + + ResourceManagerHelper.get(ResourceType.SERVER_DATA).registerReloadListener(Pages.instance()); + CriterionsRegistry.register(BOHDeathCriterion.INSTANCE); + LootTableLoadingCallback.EVENT.register((res, manager, id, supplier, setter) -> { + if (!"minecraft".contentEquals(id.getNamespace())) { + return; + } + + Identifier modId = new Identifier("unicopiamc", id.getPath()); + LootTable table = manager.getTable(modId); + if (table != LootTable.EMPTY) { + supplier.withPools(((FabricLootSupplier)table).getPools()); + } + }); + } +} diff --git a/src/main/java/com/minelittlepony/unicopia/advancement/AbstractCriterion.java b/src/main/java/com/minelittlepony/unicopia/world/advancement/AbstractCriterion.java similarity index 96% rename from src/main/java/com/minelittlepony/unicopia/advancement/AbstractCriterion.java rename to src/main/java/com/minelittlepony/unicopia/world/advancement/AbstractCriterion.java index 0fe06dae..2c6f3c02 100644 --- a/src/main/java/com/minelittlepony/unicopia/advancement/AbstractCriterion.java +++ b/src/main/java/com/minelittlepony/unicopia/world/advancement/AbstractCriterion.java @@ -1,4 +1,4 @@ -package com.minelittlepony.unicopia.advancement; +package com.minelittlepony.unicopia.world.advancement; import java.util.List; import java.util.Map; diff --git a/src/main/java/com/minelittlepony/unicopia/advancement/AdvancementPredicate.java b/src/main/java/com/minelittlepony/unicopia/world/advancement/AdvancementPredicate.java similarity index 94% rename from src/main/java/com/minelittlepony/unicopia/advancement/AdvancementPredicate.java rename to src/main/java/com/minelittlepony/unicopia/world/advancement/AdvancementPredicate.java index 808f6df8..5bf34dce 100644 --- a/src/main/java/com/minelittlepony/unicopia/advancement/AdvancementPredicate.java +++ b/src/main/java/com/minelittlepony/unicopia/world/advancement/AdvancementPredicate.java @@ -1,4 +1,4 @@ -package com.minelittlepony.unicopia.advancement; +package com.minelittlepony.unicopia.world.advancement; import com.google.gson.JsonElement; diff --git a/src/main/java/com/minelittlepony/unicopia/advancement/BOHDeathCriterion.java b/src/main/java/com/minelittlepony/unicopia/world/advancement/BOHDeathCriterion.java similarity index 76% rename from src/main/java/com/minelittlepony/unicopia/advancement/BOHDeathCriterion.java rename to src/main/java/com/minelittlepony/unicopia/world/advancement/BOHDeathCriterion.java index 10978665..ff78a2f6 100644 --- a/src/main/java/com/minelittlepony/unicopia/advancement/BOHDeathCriterion.java +++ b/src/main/java/com/minelittlepony/unicopia/world/advancement/BOHDeathCriterion.java @@ -1,12 +1,13 @@ -package com.minelittlepony.unicopia.advancement; +package com.minelittlepony.unicopia.world.advancement; import java.util.Optional; -import com.google.gson.JsonDeserializationContext; import com.google.gson.JsonObject; import net.minecraft.advancement.PlayerAdvancementTracker; import net.minecraft.advancement.criterion.AbstractCriterionConditions; +import net.minecraft.predicate.entity.AdvancementEntityPredicateDeserializer; +import net.minecraft.predicate.entity.EntityPredicate; import net.minecraft.server.network.ServerPlayerEntity; import net.minecraft.server.world.ServerWorld; import net.minecraft.util.Identifier; @@ -25,8 +26,11 @@ public class BOHDeathCriterion extends AbstractCriterion lightFunc(int luminance) { + return state -> state.get(Properties.LIT) ? luminance : 0; + } + @Override protected void appendProperties(StateManager.Builder builder) { builder.add(Properties.LIT); } - @Override - public int getTickRate(WorldView worldView) { - return 2; - } - @Override public void onBlockAdded(BlockState state, World world, BlockPos pos, BlockState oldState, boolean moved) { PosHelper.all(pos, p -> world.updateNeighborsAlways(p, this), Direction.values()); + world.getBlockTickScheduler().schedule(pos, this, 2); } @Override - public void onBlockRemoved(BlockState state, World world, BlockPos pos, BlockState newState, boolean moved) { + public void onStateReplaced(BlockState state, World world, BlockPos pos, BlockState newState, boolean moved) { if (!moved) { PosHelper.all(pos, p -> world.updateNeighborsAlways(p, this), Direction.values()); } } @Override - public VoxelShape getOutlineShape(BlockState state, BlockView source, BlockPos pos, EntityContext context) { + public VoxelShape getOutlineShape(BlockState state, BlockView source, BlockPos pos, ShapeContext context) { return STANDING; } @@ -136,6 +136,8 @@ public class GemTorchBlock extends TorchBlock implements Gas { world.setBlockState(pos, state.with(Properties.LIT, true)); } } + + world.getBlockTickScheduler().schedule(pos, this, 2); } @Override @@ -152,9 +154,4 @@ public class GemTorchBlock extends TorchBlock implements Gas { public int getWeakRedstonePower(BlockState state, BlockView world, BlockPos pos, Direction side) { return state.get(Properties.LIT) ? 12 : 0; } - - @Override - public int getLuminance(BlockState state) { - return state.get(Properties.LIT) ? super.getLuminance(state) : 0; - } } diff --git a/src/main/java/com/minelittlepony/unicopia/block/HiveWallBlock.java b/src/main/java/com/minelittlepony/unicopia/world/block/HiveWallBlock.java similarity index 96% rename from src/main/java/com/minelittlepony/unicopia/block/HiveWallBlock.java rename to src/main/java/com/minelittlepony/unicopia/world/block/HiveWallBlock.java index b8de75f2..af00dad0 100644 --- a/src/main/java/com/minelittlepony/unicopia/block/HiveWallBlock.java +++ b/src/main/java/com/minelittlepony/unicopia/world/block/HiveWallBlock.java @@ -1,4 +1,4 @@ -package com.minelittlepony.unicopia.block; +package com.minelittlepony.unicopia.world.block; import java.util.Map; import java.util.Random; @@ -6,7 +6,7 @@ import java.util.Random; import com.google.common.collect.Maps; import com.minelittlepony.unicopia.Race; import com.minelittlepony.unicopia.USounds; -import com.minelittlepony.unicopia.entity.player.Pony; +import com.minelittlepony.unicopia.equine.player.Pony; import com.minelittlepony.unicopia.util.PosHelper; import com.minelittlepony.unicopia.util.shape.Shape; import com.minelittlepony.unicopia.util.shape.Sphere; @@ -34,7 +34,6 @@ import net.minecraft.util.math.BlockPos; import net.minecraft.util.math.Direction; import net.minecraft.util.math.Vec3d; import net.minecraft.world.World; -import net.minecraft.world.WorldView; public class HiveWallBlock extends FallingBlock { @@ -50,11 +49,6 @@ public class HiveWallBlock extends FallingBlock { ); } - @Override - public boolean hasEmissiveLighting(BlockState state) { - return true; - } - @Override protected void appendProperties(StateManager.Builder builder) { builder.add(STATE).add(AXIS); @@ -119,7 +113,7 @@ public class HiveWallBlock extends FallingBlock { } } - world.getBlockTickScheduler().schedule(pos, this, getTickRate(world)); + world.getBlockTickScheduler().schedule(pos, this, 10); } public State getState(BlockState state) { @@ -138,8 +132,8 @@ public class HiveWallBlock extends FallingBlock { } @Override - public int getTickRate(WorldView view) { - return 10; + public int getFallDelay() { + return 10; } protected boolean testForAxis(World world, BlockPos pos, Axis axis) { @@ -155,7 +149,7 @@ public class HiveWallBlock extends FallingBlock { BlockState state = world.getBlockState(pos); return !(state.getMaterial().isLiquid() - || state.isFullOpaque(world, pos) + || state.isFullCube(world, pos) || state.isOpaque()); } @@ -196,7 +190,7 @@ public class HiveWallBlock extends FallingBlock { } @Override - public void onLanding(World world, BlockPos pos, BlockState fallingState, BlockState hitState) { + public void onLanding(World world, BlockPos pos, BlockState fallingBlockState, BlockState currentStateInPos, FallingBlockEntity fallingBlockEntity) { world.breakBlock(pos, true); } diff --git a/src/main/java/com/minelittlepony/unicopia/block/SlimeDripBlock.java b/src/main/java/com/minelittlepony/unicopia/world/block/SlimeDripBlock.java similarity index 91% rename from src/main/java/com/minelittlepony/unicopia/block/SlimeDripBlock.java rename to src/main/java/com/minelittlepony/unicopia/world/block/SlimeDripBlock.java index 1ff858b2..598b7adc 100644 --- a/src/main/java/com/minelittlepony/unicopia/block/SlimeDripBlock.java +++ b/src/main/java/com/minelittlepony/unicopia/world/block/SlimeDripBlock.java @@ -1,17 +1,16 @@ -package com.minelittlepony.unicopia.block; +package com.minelittlepony.unicopia.world.block; import java.util.Random; import com.minelittlepony.unicopia.EquinePredicates; import com.minelittlepony.unicopia.USounds; -import com.minelittlepony.unicopia.ducks.Climbable; import com.minelittlepony.unicopia.util.MagicalDamageSource; import com.minelittlepony.unicopia.util.PosHelper; import net.minecraft.block.Block; import net.minecraft.block.BlockState; +import net.minecraft.block.ShapeContext; import net.minecraft.entity.Entity; -import net.minecraft.entity.EntityContext; import net.minecraft.entity.LivingEntity; import net.minecraft.entity.player.PlayerEntity; import net.minecraft.item.ItemStack; @@ -34,7 +33,7 @@ import net.minecraft.world.BlockView; import net.minecraft.world.World; import net.minecraft.world.WorldView; -public class SlimeDripBlock extends Block implements Climbable { +public class SlimeDripBlock extends Block { public static final IntProperty AGE = IntProperty.of("age", 0, 7); public static final EnumProperty SHAPE = EnumProperty.of("shape", Shape.class); @@ -141,9 +140,9 @@ public class SlimeDripBlock extends Block implements Climbable { } @Override - public void onBlockRemoved(BlockState state, World world, BlockPos pos, BlockState replacement, boolean moved) { + public void onStateReplaced(BlockState state, World world, BlockPos pos, BlockState replacement, boolean moved) { world.updateNeighborsAlways(pos, this); - super.onBlockRemoved(state, world, pos, replacement, moved); + super.onStateReplaced(state, world, pos, replacement, moved); } @Override @@ -194,8 +193,8 @@ public class SlimeDripBlock extends Block implements Climbable { @Override - public VoxelShape getOutlineShape(BlockState state, BlockView view, BlockPos pos, EntityContext ePos) { - Vec3d offset = getOffsetPos(state, view, pos); + public VoxelShape getOutlineShape(BlockState state, BlockView view, BlockPos pos, ShapeContext ePos) { + Vec3d offset = state.getModelOffset(view, pos); if (state.get(SHAPE) == Shape.BULB) { return BULBS[state.get(AGE) / 2].offset(offset.x, offset.y, offset.z); @@ -213,14 +212,14 @@ public class SlimeDripBlock extends Block implements Climbable { @Override public void randomDisplayTick(BlockState state, World world, BlockPos pos, Random rand) { if (state.get(SHAPE) == Shape.BULB && rand.nextInt(8) == 0) { - Vec3d offset = state.getOffsetPos(world, pos).add(pos.getX(), pos.getY(), pos.getZ()); + Vec3d offset = state.getModelOffset(world, pos).add(pos.getX(), pos.getY(), pos.getZ()); Box bounds = BULBS[state.get(AGE) / 2] .offset(offset.x, offset.y, offset.z) .getBoundingBox(); - double x = bounds.x1 + (bounds.x2 - bounds.x1) * rand.nextFloat(); - double y = bounds.y1; - double z = bounds.z1 + (bounds.z2 - bounds.z1) * rand.nextFloat(); + double x = bounds.minX + (bounds.maxX - bounds.minX) * rand.nextFloat(); + double y = bounds.minY; + double z = bounds.minZ + (bounds.maxZ - bounds.minZ) * rand.nextFloat(); world.addParticle(ParticleTypes.DRIPPING_LAVA, x, y, z, 0, 0, 0); } diff --git a/src/main/java/com/minelittlepony/unicopia/block/SlimeLayerBlock.java b/src/main/java/com/minelittlepony/unicopia/world/block/SlimeLayerBlock.java similarity index 95% rename from src/main/java/com/minelittlepony/unicopia/block/SlimeLayerBlock.java rename to src/main/java/com/minelittlepony/unicopia/world/block/SlimeLayerBlock.java index c2a3ad0a..ea942df7 100644 --- a/src/main/java/com/minelittlepony/unicopia/block/SlimeLayerBlock.java +++ b/src/main/java/com/minelittlepony/unicopia/world/block/SlimeLayerBlock.java @@ -1,4 +1,4 @@ -package com.minelittlepony.unicopia.block; +package com.minelittlepony.unicopia.world.block; import net.minecraft.block.Blocks; import net.minecraft.block.SnowBlock; diff --git a/src/main/java/com/minelittlepony/unicopia/block/SmartSlabBlock.java b/src/main/java/com/minelittlepony/unicopia/world/block/SmartSlabBlock.java similarity index 84% rename from src/main/java/com/minelittlepony/unicopia/block/SmartSlabBlock.java rename to src/main/java/com/minelittlepony/unicopia/world/block/SmartSlabBlock.java index 1e756991..8e0780c0 100644 --- a/src/main/java/com/minelittlepony/unicopia/block/SmartSlabBlock.java +++ b/src/main/java/com/minelittlepony/unicopia/world/block/SmartSlabBlock.java @@ -1,4 +1,4 @@ -package com.minelittlepony.unicopia.block; +package com.minelittlepony.unicopia.world.block; import java.util.Random; @@ -8,7 +8,6 @@ import net.minecraft.block.Block; import net.minecraft.block.BlockState; import net.minecraft.block.SlabBlock; import net.minecraft.entity.Entity; -import net.minecraft.entity.EntityType; import net.minecraft.entity.player.PlayerEntity; import net.minecraft.item.ItemPlacementContext; import net.minecraft.server.world.ServerWorld; @@ -16,8 +15,8 @@ import net.minecraft.state.StateManager; import net.minecraft.util.math.BlockPos; import net.minecraft.util.math.Direction; import net.minecraft.world.BlockView; -import net.minecraft.world.IWorld; import net.minecraft.world.World; +import net.minecraft.world.WorldAccess; public class SmartSlabBlock extends SlabBlock { @@ -34,16 +33,6 @@ public class SmartSlabBlock extends SlabBlock { return modelState.isTranslucent(world, pos); } - @Override - public boolean allowsSpawning(BlockState state, BlockView view, BlockPos pos, EntityType type) { - return modelState.allowsSpawning(view, pos, type); - } - - @Override - public boolean isAir(BlockState state) { - return modelState.isAir(); - } - @Override public void scheduledTick(BlockState state, ServerWorld world, BlockPos pos, Random rand) { modelState.scheduledTick(world, pos, rand); @@ -78,7 +67,7 @@ public class SmartSlabBlock extends SlabBlock { @Override @Deprecated - public BlockState getStateForNeighborUpdate(BlockState state, Direction direction, BlockState other, IWorld world, BlockPos pos, BlockPos otherPos) { + public BlockState getStateForNeighborUpdate(BlockState state, Direction direction, BlockState other, WorldAccess world, BlockPos pos, BlockPos otherPos) { state = super.getStateForNeighborUpdate(state, direction, other, world, pos, otherPos); if (direction == Direction.UP) { diff --git a/src/main/java/com/minelittlepony/unicopia/block/SmartStairsBlock.java b/src/main/java/com/minelittlepony/unicopia/world/block/SmartStairsBlock.java similarity index 86% rename from src/main/java/com/minelittlepony/unicopia/block/SmartStairsBlock.java rename to src/main/java/com/minelittlepony/unicopia/world/block/SmartStairsBlock.java index 6239fec9..777f82a4 100644 --- a/src/main/java/com/minelittlepony/unicopia/block/SmartStairsBlock.java +++ b/src/main/java/com/minelittlepony/unicopia/world/block/SmartStairsBlock.java @@ -1,4 +1,4 @@ -package com.minelittlepony.unicopia.block; +package com.minelittlepony.unicopia.world.block; import javax.annotation.Nullable; @@ -6,15 +6,14 @@ import net.minecraft.block.Block; import net.minecraft.block.BlockState; import net.minecraft.block.StairsBlock; import net.minecraft.entity.Entity; -import net.minecraft.entity.EntityType; import net.minecraft.entity.player.PlayerEntity; import net.minecraft.item.ItemPlacementContext; import net.minecraft.state.StateManager; import net.minecraft.util.math.BlockPos; import net.minecraft.util.math.Direction; import net.minecraft.world.BlockView; -import net.minecraft.world.IWorld; import net.minecraft.world.World; +import net.minecraft.world.WorldAccess; public class SmartStairsBlock extends StairsBlock { @@ -31,11 +30,6 @@ public class SmartStairsBlock extends StairsBlock { return baseBlockState.isTranslucent(world, pos); } - @Override - public boolean allowsSpawning(BlockState state, BlockView view, BlockPos pos, EntityType type) { - return baseBlockState.allowsSpawning(view, pos, type); - } - @Override public void onLandedUpon(World w, BlockPos pos, Entity entity, float fallDistance) { baseBlockState.getBlock().onLandedUpon(w, pos, entity, fallDistance); @@ -65,7 +59,7 @@ public class SmartStairsBlock extends StairsBlock { @Override @Deprecated - public BlockState getStateForNeighborUpdate(BlockState state, Direction direction, BlockState other, IWorld world, BlockPos pos, BlockPos otherPos) { + public BlockState getStateForNeighborUpdate(BlockState state, Direction direction, BlockState other, WorldAccess world, BlockPos pos, BlockPos otherPos) { state = super.getStateForNeighborUpdate(state, direction, other, world, pos, otherPos); if (direction == Direction.UP) { diff --git a/src/main/java/com/minelittlepony/unicopia/block/StickPlantBlock.java b/src/main/java/com/minelittlepony/unicopia/world/block/StickPlantBlock.java similarity index 93% rename from src/main/java/com/minelittlepony/unicopia/block/StickPlantBlock.java rename to src/main/java/com/minelittlepony/unicopia/world/block/StickPlantBlock.java index 98ba7c90..1249acfd 100644 --- a/src/main/java/com/minelittlepony/unicopia/block/StickPlantBlock.java +++ b/src/main/java/com/minelittlepony/unicopia/world/block/StickPlantBlock.java @@ -1,12 +1,13 @@ -package com.minelittlepony.unicopia.block; +package com.minelittlepony.unicopia.world.block; + +import com.minelittlepony.unicopia.world.block.gas.CloudFarmlandBlock; -import com.minelittlepony.unicopia.gas.CloudFarmlandBlock; import net.minecraft.block.Block; import net.minecraft.block.BlockState; import net.minecraft.block.Blocks; import net.minecraft.block.CropBlock; import net.minecraft.block.FarmlandBlock; -import net.minecraft.entity.EntityContext; +import net.minecraft.block.ShapeContext; import net.minecraft.entity.player.PlayerEntity; import net.minecraft.item.Item; import net.minecraft.item.ItemConvertible; @@ -44,8 +45,8 @@ public class StickPlantBlock extends CropBlock { @Deprecated @Override - public VoxelShape getOutlineShape(BlockState state, BlockView source, BlockPos pos, EntityContext context) { - Vec3d off = state.getOffsetPos(source, pos); + public VoxelShape getOutlineShape(BlockState state, BlockView source, BlockPos pos, ShapeContext context) { + Vec3d off = state.getModelOffset(source, pos); return BOUNDING_BOX.offset(off.x, off.y, off.z); } diff --git a/src/main/java/com/minelittlepony/unicopia/block/TallCropBlock.java b/src/main/java/com/minelittlepony/unicopia/world/block/TallCropBlock.java similarity index 96% rename from src/main/java/com/minelittlepony/unicopia/block/TallCropBlock.java rename to src/main/java/com/minelittlepony/unicopia/world/block/TallCropBlock.java index b56744fa..a4d61c30 100644 --- a/src/main/java/com/minelittlepony/unicopia/block/TallCropBlock.java +++ b/src/main/java/com/minelittlepony/unicopia/world/block/TallCropBlock.java @@ -1,15 +1,15 @@ -package com.minelittlepony.unicopia.block; +package com.minelittlepony.unicopia.world.block; import java.util.Random; import javax.annotation.Nullable; -import com.minelittlepony.unicopia.item.UItems; +import com.minelittlepony.unicopia.world.item.UItems; import net.minecraft.block.Block; import net.minecraft.block.BlockState; import net.minecraft.block.CropBlock; -import net.minecraft.entity.EntityContext; +import net.minecraft.block.ShapeContext; import net.minecraft.entity.player.PlayerEntity; import net.minecraft.item.Item; import net.minecraft.server.world.ServerWorld; @@ -167,7 +167,7 @@ public class TallCropBlock extends CropBlock { } @Override - public VoxelShape getCollisionShape(BlockState state, BlockView view, BlockPos pos, EntityContext context) { + public VoxelShape getCollisionShape(BlockState state, BlockView view, BlockPos pos, ShapeContext context) { if (getHalf(state) != Half.MIDDLE) { return VoxelShapes.empty(); } @@ -175,8 +175,8 @@ public class TallCropBlock extends CropBlock { } @Override - public VoxelShape getOutlineShape(BlockState state, BlockView view, BlockPos pos, EntityContext ePos) { - Vec3d offset = getOffsetPos(state, view, pos); + public VoxelShape getOutlineShape(BlockState state, BlockView view, BlockPos pos, ShapeContext ePos) { + Vec3d offset = state.getModelOffset(view, pos); return SHAPES[Math.min(SHAPES.length - 1, getFullAge(view, pos))].offset(offset.x, offset.y, offset.z); } diff --git a/src/main/java/com/minelittlepony/unicopia/block/UBlocks.java b/src/main/java/com/minelittlepony/unicopia/world/block/UBlocks.java similarity index 66% rename from src/main/java/com/minelittlepony/unicopia/block/UBlocks.java rename to src/main/java/com/minelittlepony/unicopia/world/block/UBlocks.java index 52a64be2..783364f9 100644 --- a/src/main/java/com/minelittlepony/unicopia/block/UBlocks.java +++ b/src/main/java/com/minelittlepony/unicopia/world/block/UBlocks.java @@ -1,22 +1,22 @@ -package com.minelittlepony.unicopia.block; +package com.minelittlepony.unicopia.world.block; import com.minelittlepony.unicopia.TreeType; -import com.minelittlepony.unicopia.gas.CloudAnvilBlock; -import com.minelittlepony.unicopia.gas.CloudBlock; -import com.minelittlepony.unicopia.gas.CloudDoorBlock; -import com.minelittlepony.unicopia.gas.CloudFarmlandBlock; -import com.minelittlepony.unicopia.gas.CloudFenceBlock; -import com.minelittlepony.unicopia.gas.CloudSlabBlock; -import com.minelittlepony.unicopia.gas.CloudSoilBlock; -import com.minelittlepony.unicopia.gas.CloudStairsBlock; -import com.minelittlepony.unicopia.gas.CoverableCloudBlock; -import com.minelittlepony.unicopia.gas.GasState; -import com.minelittlepony.unicopia.gas.PillarCloudBlock; -import com.minelittlepony.unicopia.item.UItems; -import com.minelittlepony.unicopia.structure.CustomSaplingGenerator; +import com.minelittlepony.unicopia.world.block.gas.CloudAnvilBlock; +import com.minelittlepony.unicopia.world.block.gas.CloudBlock; +import com.minelittlepony.unicopia.world.block.gas.CloudDoorBlock; +import com.minelittlepony.unicopia.world.block.gas.CloudFarmlandBlock; +import com.minelittlepony.unicopia.world.block.gas.CloudFenceBlock; +import com.minelittlepony.unicopia.world.block.gas.CloudSlabBlock; +import com.minelittlepony.unicopia.world.block.gas.CloudSoilBlock; +import com.minelittlepony.unicopia.world.block.gas.CloudStairsBlock; +import com.minelittlepony.unicopia.world.block.gas.CoverableCloudBlock; +import com.minelittlepony.unicopia.world.block.gas.GasState; +import com.minelittlepony.unicopia.world.block.gas.PillarCloudBlock; +import com.minelittlepony.unicopia.world.item.UItems; +import com.minelittlepony.unicopia.world.structure.CustomSaplingGenerator; -import net.fabricmc.fabric.api.block.FabricBlockSettings; -import net.fabricmc.fabric.api.tools.FabricToolTags; +import net.fabricmc.fabric.api.object.builder.v1.block.FabricBlockSettings; +import net.fabricmc.fabric.api.tool.attribute.v1.FabricToolTags; import net.minecraft.block.Block; import net.minecraft.block.FallingBlock; import net.minecraft.block.Material; @@ -30,65 +30,57 @@ import net.minecraft.util.Identifier; import net.minecraft.util.registry.Registry; public interface UBlocks { - CloudFarmlandBlock CLOUD_FARMLAND = register("cloud_farmland", new CloudFarmlandBlock(GasState.NORMAL.configure().build())); + CloudFarmlandBlock CLOUD_FARMLAND = register("cloud_farmland", new CloudFarmlandBlock(GasState.NORMAL.configure())); CloudBlock CLOUD_BLOCK = register("cloud_block", new CloudSoilBlock(GasState.NORMAL)); CloudBlock ENCHANTED_CLOUD_BLOCK = register("enchanted_cloud_block", new CoverableCloudBlock(GasState.ENCHANTED)); CloudBlock DENSE_CLOUD_BLOCK = register("dense_cloud_block", new CloudBlock(GasState.DENSE)); CloudBlock DENSE_CLOUD_PILLAR = register("dense_cloud_pillar", new PillarCloudBlock(GasState.DENSE)); - CloudStairsBlock CLOUD_STAIRS = register("cloud_stairs", new CloudStairsBlock(CLOUD_BLOCK.getDefaultState(), GasState.NORMAL.configure().build())); - CloudStairsBlock ENCHANTED_CLOUD_STAIRS = register("enchanted_cloud_stairs", new CloudStairsBlock(ENCHANTED_CLOUD_BLOCK.getDefaultState(), GasState.ENCHANTED.configure().build())); - CloudStairsBlock DENSE_CLOUD_STAIRS = register("dense_cloud_stairs", new CloudStairsBlock(DENSE_CLOUD_BLOCK.getDefaultState(), GasState.DENSE.configure().build())); + CloudStairsBlock CLOUD_STAIRS = register("cloud_stairs", new CloudStairsBlock(CLOUD_BLOCK.getDefaultState(), GasState.NORMAL.configure())); + CloudStairsBlock ENCHANTED_CLOUD_STAIRS = register("enchanted_cloud_stairs", new CloudStairsBlock(ENCHANTED_CLOUD_BLOCK.getDefaultState(), GasState.ENCHANTED.configure())); + CloudStairsBlock DENSE_CLOUD_STAIRS = register("dense_cloud_stairs", new CloudStairsBlock(DENSE_CLOUD_BLOCK.getDefaultState(), GasState.DENSE.configure())); - CloudSlabBlock CLOUD_SLAB = register("cloud_slab", new CloudSlabBlock(CLOUD_BLOCK.getDefaultState(), GasState.NORMAL.configure().build())); - CloudSlabBlock ENCHANTED_CLOUD_SLAB = register("enchanted_cloud_slab", new CloudSlabBlock(ENCHANTED_CLOUD_BLOCK.getDefaultState(), GasState.ENCHANTED.configure().build())); - CloudSlabBlock DENSE_CLOUD_SLAB = register("dense_cloud_slab", new CloudSlabBlock(DENSE_CLOUD_BLOCK.getDefaultState(), GasState.DENSE.configure().build())); + CloudSlabBlock CLOUD_SLAB = register("cloud_slab", new CloudSlabBlock(CLOUD_BLOCK.getDefaultState(), GasState.NORMAL.configure())); + CloudSlabBlock ENCHANTED_CLOUD_SLAB = register("enchanted_cloud_slab", new CloudSlabBlock(ENCHANTED_CLOUD_BLOCK.getDefaultState(), GasState.ENCHANTED.configure())); + CloudSlabBlock DENSE_CLOUD_SLAB = register("dense_cloud_slab", new CloudSlabBlock(DENSE_CLOUD_BLOCK.getDefaultState(), GasState.DENSE.configure())); CloudDoorBlock MISTED_GLASS_DOOR = register("misted_glass_door", new CloudDoorBlock(FabricBlockSettings.of(Material.GLASS) .sounds(BlockSoundGroup.GLASS) .hardness(3) .resistance(200) .nonOpaque() - .breakByTool(FabricToolTags.PICKAXES, 0) - .build())); + .breakByTool(FabricToolTags.PICKAXES, 0))); DutchDoorBlock LIBRARY_DOOR = register("library_door", new DutchDoorBlock(FabricBlockSettings.of(Material.WOOD). sounds(BlockSoundGroup.WOOD) .hardness(3) - .nonOpaque() - .build())); + .nonOpaque())); DutchDoorBlock BAKERY_DOOR = register("bakery_door", new DutchDoorBlock(FabricBlockSettings.of(Material.WOOD) .sounds(BlockSoundGroup.WOOD) .hardness(3) - .nonOpaque() - .build())); + .nonOpaque())); DiamondDoorBlock DIAMOND_DOOR = register("diamond_door", new DiamondDoorBlock(FabricBlockSettings.of(Material.METAL) .sounds(BlockSoundGroup.METAL) .materialColor(MaterialColor.DIAMOND) .strength(6, 20) - .nonOpaque() - .build())); + .nonOpaque())); - GemTorchBlock ENCHANTED_TORCH = register("enchanted_torch", new GemTorchBlock(FabricBlockSettings.of(Material.PART) + GemTorchBlock ENCHANTED_TORCH = register("enchanted_torch", new GemTorchBlock(FabricBlockSettings.of(Material.SUPPORTED) .noCollision() .breakInstantly() .ticksRandomly() - .lightLevel(11) - .sounds(BlockSoundGroup.GLASS) - .build())); - GemTorchBlock ENCHANTED_WALL_TORCH = register("enchanted_wall_torch", new WallGemTorchBlock(FabricBlockSettings.of(Material.PART) + .lightLevel(GemTorchBlock.lightFunc(11)) + .sounds(BlockSoundGroup.GLASS))); + GemTorchBlock ENCHANTED_WALL_TORCH = register("enchanted_wall_torch", new WallGemTorchBlock(FabricBlockSettings.of(Material.SUPPORTED) .noCollision() .breakInstantly() .ticksRandomly() - .lightLevel(11) - .sounds(BlockSoundGroup.GLASS) - .build())); + .lightLevel(GemTorchBlock.lightFunc(11)) + .sounds(BlockSoundGroup.GLASS))); CloudAnvilBlock CLOUD_ANVIL = register("cloud_anvil", new CloudAnvilBlock(GasState.NORMAL.configure() - .strength(0.025F, 1) - .resistance(2000) + .strength(0.025F, 2000) .breakByTool(FabricToolTags.SHOVELS, 0) - .ticksRandomly() - .build())); + .ticksRandomly())); CloudFenceBlock CLOUD_FENCE = register("cloud_fence", new CloudFenceBlock(GasState.NORMAL)); @@ -96,25 +88,28 @@ public interface UBlocks { .noCollision() .ticksRandomly() .breakInstantly() - .sounds(BlockSoundGroup.CROP).build())); + .sounds(BlockSoundGroup.CROP))); StickPlantBlock STICK = register("stick", new StickPlantBlock(FabricBlockSettings.of(UMaterials.STICK) .nonOpaque() .strength(0.2F, 0.2F) - .sounds(BlockSoundGroup.WOOD) - .build(), Items.AIR, Items.AIR, Items.AIR)); + .sounds(BlockSoundGroup.WOOD), Items.AIR, Items.AIR, Items.AIR)); StickPlantBlock TOMATO_PLANT = register("tomato_plant", new StickPlantBlock(FabricBlockSettings.of(UMaterials.STICK) .nonOpaque() .strength(0.2F, 0.2F) .ticksRandomly() - .sounds(BlockSoundGroup.WOOD) - .build(), () -> UItems.TOMATO_SEEDS, () -> UItems.TOMATO, () -> UItems.ROTTEN_TOMATO)); + .sounds(BlockSoundGroup.WOOD), + () -> UItems.TOMATO_SEEDS, + () -> UItems.TOMATO, + () -> UItems.ROTTEN_TOMATO)); StickPlantBlock CLOUDSDALE_TOMATO_PLANT = register("cloudsdale_tomato_plant", new StickPlantBlock(FabricBlockSettings.of(UMaterials.STICK) .nonOpaque() .strength(0.2F, 0.2F) .ticksRandomly() - .sounds(BlockSoundGroup.WOOD) - .build(), () -> UItems.TOMATO_SEEDS, () -> UItems.CLOUDSDALE_TOMATO, () -> UItems.ROTTEN_CLOUDSDALE_TOMATO)); + .sounds(BlockSoundGroup.WOOD), + () -> UItems.TOMATO_SEEDS, + () -> UItems.CLOUDSDALE_TOMATO, + () -> UItems.ROTTEN_CLOUDSDALE_TOMATO)); HiveWallBlock HIVE_WALL_BLOCK = register("hive_wall_block", new HiveWallBlock(FabricBlockSettings.of(UMaterials.HIVE) .strength(10, 10) @@ -123,24 +118,20 @@ public interface UBlocks { .lightLevel(3) .sounds(BlockSoundGroup.SAND) .breakByTool(FabricToolTags.SHOVELS, 1) - .build())); + .emissiveLighting((state, world, pos) -> true))); Block CHITIN_SHELL_BLOCK = register("chitin_shell_block", new ChitinBlock(FabricBlockSettings.of(UMaterials.CHITIN) .strength(50, 2000) - .breakByTool(FabricToolTags.PICKAXES, 2) - .build())); + .breakByTool(FabricToolTags.PICKAXES, 2))); Block CHITIN_SHELL_STAIRS = register("chitin_shell_stairs", new SmartStairsBlock(CHITIN_SHELL_BLOCK.getDefaultState(), FabricBlockSettings.of(UMaterials.CHITIN) .strength(50, 2000) - .breakByTool(FabricToolTags.PICKAXES, 2) - .build())); + .breakByTool(FabricToolTags.PICKAXES, 2))); Block CHITIN_SHELL_SLAB = register("chitin_shell_slab", new SmartSlabBlock(CHITIN_SHELL_BLOCK.getDefaultState(), FabricBlockSettings.of(UMaterials.CHITIN) .strength(50, 2000) - .breakByTool(FabricToolTags.PICKAXES, 2) - .build())); + .breakByTool(FabricToolTags.PICKAXES, 2))); Block CHISELED_CHITIN_SHELL_BLOCK = register("chiseled_chitin_shell_block", new ChiselledChitinBlock(FabricBlockSettings.of(UMaterials.CHITIN) .strength(50, 2000) - .breakByTool(FabricToolTags.PICKAXES, 2) - .build())); + .breakByTool(FabricToolTags.PICKAXES, 2))); SlimeDripBlock SLIME_DRIP = register("slime_drip", new SlimeDripBlock(FabricBlockSettings.of(UMaterials.HIVE, MaterialColor.GRASS) .ticksRandomly() @@ -148,39 +139,32 @@ public interface UBlocks { .lightLevel(9) .slipperiness(0.5F) .sounds(BlockSoundGroup.SLIME) - .breakByTool(FabricToolTags.SHOVELS, 2) - .build())); - SlimeLayerBlock SLIME_LAYER = register("slime_layer", new SlimeLayerBlock(FabricBlockSettings.of(Material.CLAY, MaterialColor.GRASS) + .breakByTool(FabricToolTags.SHOVELS, 2))); + SlimeLayerBlock SLIME_LAYER = register("slime_layer", new SlimeLayerBlock(FabricBlockSettings.of(Material.ORGANIC_PRODUCT, MaterialColor.GRASS) .sounds(BlockSoundGroup.SLIME) .slipperiness(0.8F) - .nonOpaque() - .build())); + .nonOpaque())); Block SMOOTH_MARBLE_BLOCK = register("smooth_marble_block", new Block(FabricBlockSettings.of(Material.STONE) .strength(0.7F, 10) - .breakByTool(FabricToolTags.PICKAXES) - .build())); + .breakByTool(FabricToolTags.PICKAXES))); Block CHISELED_MARBLE_BLOCK = register("chiseled_marble_block", new Block(FabricBlockSettings.of(Material.STONE) .strength(0.8F, 10) - .breakByTool(FabricToolTags.PICKAXES) - .build())); + .breakByTool(FabricToolTags.PICKAXES))); Block SMOOTH_MARBLE_SLAB = register("smooth_marble_slab", new SlabBlock(FabricBlockSettings.of(Material.STONE) .strength(0.7F, 10) - .breakByTool(FabricToolTags.PICKAXES) - .build())); + .breakByTool(FabricToolTags.PICKAXES))); - Block SUGAR_BLOCK = register("sugar_block", new FallingBlock(FabricBlockSettings.of(Material.SAND) + Block SUGAR_BLOCK = register("sugar_block", new FallingBlock(FabricBlockSettings.of(Material.AGGREGATE) .strength(10, 10) .hardness(0.7F) .sounds(BlockSoundGroup.SAND) - .breakByTool(FabricToolTags.SHOVELS) - .build())); + .breakByTool(FabricToolTags.SHOVELS))); Block APPLE_LEAVES = register("apple_leaves", new FruitLeavesBlock(FabricBlockSettings.of(Material.LEAVES) .nonOpaque() .strength(0.2F, 0.2F) .ticksRandomly() - .sounds(BlockSoundGroup.GRASS) - .build()) + .sounds(BlockSoundGroup.GRASS)) .growthChance(1200) .tint(0xFFEE81) .fruit(W -> TreeType.OAK.pickRandomStack()) @@ -190,12 +174,11 @@ public interface UBlocks { .noCollision() .ticksRandomly() .breakInstantly() - .sounds(BlockSoundGroup.GRASS) - .build()) {}); + .sounds(BlockSoundGroup.GRASS)) {}); static T register(String name, T block) { - return Registry.BLOCK.add(new Identifier("unicopia", name), block); + return Registry.register(Registry.BLOCK, new Identifier("unicopia", name), block); } static void bootstrap() { } diff --git a/src/main/java/com/minelittlepony/unicopia/block/UMaterials.java b/src/main/java/com/minelittlepony/unicopia/world/block/UMaterials.java similarity index 80% rename from src/main/java/com/minelittlepony/unicopia/block/UMaterials.java rename to src/main/java/com/minelittlepony/unicopia/world/block/UMaterials.java index 052d2cfb..f0102e0f 100644 --- a/src/main/java/com/minelittlepony/unicopia/block/UMaterials.java +++ b/src/main/java/com/minelittlepony/unicopia/world/block/UMaterials.java @@ -1,6 +1,6 @@ -package com.minelittlepony.unicopia.block; +package com.minelittlepony.unicopia.world.block; -import net.fabricmc.fabric.api.block.FabricMaterialBuilder; +import net.fabricmc.fabric.api.object.builder.v1.block.FabricMaterialBuilder; import net.minecraft.block.Material; import net.minecraft.block.MaterialColor; diff --git a/src/main/java/com/minelittlepony/unicopia/block/WallGemTorchBlock.java b/src/main/java/com/minelittlepony/unicopia/world/block/WallGemTorchBlock.java similarity index 91% rename from src/main/java/com/minelittlepony/unicopia/block/WallGemTorchBlock.java rename to src/main/java/com/minelittlepony/unicopia/world/block/WallGemTorchBlock.java index 34f18e63..cec9ce24 100644 --- a/src/main/java/com/minelittlepony/unicopia/block/WallGemTorchBlock.java +++ b/src/main/java/com/minelittlepony/unicopia/world/block/WallGemTorchBlock.java @@ -1,11 +1,11 @@ -package com.minelittlepony.unicopia.block; +package com.minelittlepony.unicopia.world.block; import javax.annotation.Nullable; import net.minecraft.block.Block; import net.minecraft.block.BlockState; import net.minecraft.block.Blocks; -import net.minecraft.entity.EntityContext; +import net.minecraft.block.ShapeContext; import net.minecraft.item.ItemPlacementContext; import net.minecraft.state.StateManager; import net.minecraft.state.property.Properties; @@ -15,7 +15,7 @@ import net.minecraft.util.math.BlockPos; import net.minecraft.util.math.Direction; import net.minecraft.util.shape.VoxelShape; import net.minecraft.world.BlockView; -import net.minecraft.world.IWorld; +import net.minecraft.world.WorldAccess; import net.minecraft.world.WorldView; public class WallGemTorchBlock extends GemTorchBlock { @@ -55,7 +55,7 @@ public class WallGemTorchBlock extends GemTorchBlock { } @Override - public BlockState getStateForNeighborUpdate(BlockState state, Direction facing, BlockState neighborState, IWorld world, BlockPos pos, BlockPos neighborPos) { + public BlockState getStateForNeighborUpdate(BlockState state, Direction facing, BlockState neighborState, WorldAccess world, BlockPos pos, BlockPos neighborPos) { return Blocks.WALL_TORCH.getStateForNeighborUpdate(state, facing, neighborState, world, pos, neighborPos); } @@ -81,7 +81,7 @@ public class WallGemTorchBlock extends GemTorchBlock { } @Override - public VoxelShape getOutlineShape(BlockState state, BlockView source, BlockPos pos, EntityContext context) { + public VoxelShape getOutlineShape(BlockState state, BlockView source, BlockPos pos, ShapeContext context) { switch (state.get(Properties.HORIZONTAL_FACING)) { case EAST: return EAST; case WEST: return WEST; diff --git a/src/main/java/com/minelittlepony/unicopia/gas/CloudAnvilBlock.java b/src/main/java/com/minelittlepony/unicopia/world/block/gas/CloudAnvilBlock.java similarity index 86% rename from src/main/java/com/minelittlepony/unicopia/gas/CloudAnvilBlock.java rename to src/main/java/com/minelittlepony/unicopia/world/block/gas/CloudAnvilBlock.java index 03424af5..74b66cfa 100644 --- a/src/main/java/com/minelittlepony/unicopia/gas/CloudAnvilBlock.java +++ b/src/main/java/com/minelittlepony/unicopia/world/block/gas/CloudAnvilBlock.java @@ -1,4 +1,4 @@ -package com.minelittlepony.unicopia.gas; +package com.minelittlepony.unicopia.world.block.gas; import java.util.Random; @@ -9,7 +9,8 @@ import net.fabricmc.api.Environment; import net.minecraft.block.AnvilBlock; import net.minecraft.block.BlockState; import net.minecraft.entity.Entity; -import net.minecraft.entity.EntityContext; +import net.minecraft.entity.FallingBlockEntity; +import net.minecraft.block.ShapeContext; import net.minecraft.entity.player.PlayerEntity; import net.minecraft.server.world.ServerWorld; import net.minecraft.util.ActionResult; @@ -34,13 +35,13 @@ public class CloudAnvilBlock extends AnvilBlock implements Gas { } @Override - public void onLanding(World world, BlockPos pos, BlockState fallingState, BlockState hitState) { - WorldEvent.ENTITY_TAKEOFF.play(world, pos); + public void onLanding(World world, BlockPos pos, BlockState fallingState, BlockState hitState, FallingBlockEntity entity) { + world.syncWorldEvent(WorldEvent.BAT_TAKEOFF, pos, 0); } @Override - public void onDestroyedOnLanding(World world, BlockPos pos) { - WorldEvent.ENTITY_TAKEOFF.play(world, pos); + public void onDestroyedOnLanding(World world, BlockPos pos, FallingBlockEntity entity) { + world.syncWorldEvent(WorldEvent.BAT_TAKEOFF, pos, 0); } @Override @@ -78,7 +79,7 @@ public class CloudAnvilBlock extends AnvilBlock implements Gas { } @Override - public VoxelShape getOutlineShape(BlockState state, BlockView view, BlockPos pos, EntityContext context) { + public VoxelShape getOutlineShape(BlockState state, BlockView view, BlockPos pos, ShapeContext context) { if (getGasState(state).canPlace((CloudInteractionContext)context)) { return super.getOutlineShape(state, view, pos, context); } @@ -86,7 +87,7 @@ public class CloudAnvilBlock extends AnvilBlock implements Gas { } @Override - public VoxelShape getCollisionShape(BlockState state, BlockView view, BlockPos pos, EntityContext context) { + public VoxelShape getCollisionShape(BlockState state, BlockView view, BlockPos pos, ShapeContext context) { if (getGasState(state).canTouch((CloudInteractionContext)context)) { return super.getCollisionShape(state, view, pos, context); } diff --git a/src/main/java/com/minelittlepony/unicopia/gas/CloudBlock.java b/src/main/java/com/minelittlepony/unicopia/world/block/gas/CloudBlock.java similarity index 80% rename from src/main/java/com/minelittlepony/unicopia/gas/CloudBlock.java rename to src/main/java/com/minelittlepony/unicopia/world/block/gas/CloudBlock.java index 5f6cf20e..5db1b2f4 100644 --- a/src/main/java/com/minelittlepony/unicopia/gas/CloudBlock.java +++ b/src/main/java/com/minelittlepony/unicopia/world/block/gas/CloudBlock.java @@ -1,15 +1,15 @@ -package com.minelittlepony.unicopia.gas; +package com.minelittlepony.unicopia.world.block.gas; import java.util.Random; -import com.minelittlepony.unicopia.blockstate.StateMaps; +import com.minelittlepony.unicopia.util.blockstate.StateMaps; + import net.fabricmc.api.EnvType; import net.fabricmc.api.Environment; import net.minecraft.block.Block; import net.minecraft.block.BlockState; import net.minecraft.entity.Entity; -import net.minecraft.entity.EntityContext; -import net.minecraft.entity.EntityType; +import net.minecraft.block.ShapeContext; import net.minecraft.entity.player.PlayerEntity; import net.minecraft.server.world.ServerWorld; import net.minecraft.util.math.Direction; @@ -26,7 +26,6 @@ public class CloudBlock extends Block implements Gas { public CloudBlock(GasState variant) { super(variant.configure() .ticksRandomly() - .build() ); this.variant = variant; } @@ -41,28 +40,13 @@ public class CloudBlock extends Block implements Gas { return getGasState(state).isTranslucent() ? 0.9F : 0.5F; } - @Override - public boolean canSuffocate(BlockState state, BlockView view, BlockPos pos) { - return !getGasState(state).isTranslucent(); - } - @Override public boolean isTranslucent(BlockState state, BlockView world, BlockPos pos) { return getGasState(state).isTranslucent(); } @Override - public boolean isSimpleFullBlock(BlockState state, BlockView view, BlockPos pos) { - return !getGasState(state).isTranslucent() && super.isSimpleFullBlock(state, view, pos); - } - - @Override - public boolean allowsSpawning(BlockState state, BlockView view, BlockPos pos, EntityType type) { - return getGasState(state).isTranslucent(); - } - - @Override - public VoxelShape getOutlineShape(BlockState state, BlockView view, BlockPos pos, EntityContext context) { + public VoxelShape getOutlineShape(BlockState state, BlockView view, BlockPos pos, ShapeContext context) { if (getGasState(state).canPlace((CloudInteractionContext)context)) { return VoxelShapes.fullCube(); } @@ -70,7 +54,7 @@ public class CloudBlock extends Block implements Gas { } @Override - public VoxelShape getCollisionShape(BlockState state, BlockView view, BlockPos pos, EntityContext context) { + public VoxelShape getCollisionShape(BlockState state, BlockView view, BlockPos pos, ShapeContext context) { if (getGasState(state).canTouch((CloudInteractionContext)context)) { return collidable ? VoxelShapes.fullCube() : VoxelShapes.empty(); } diff --git a/src/main/java/com/minelittlepony/unicopia/gas/CloudDoorBlock.java b/src/main/java/com/minelittlepony/unicopia/world/block/gas/CloudDoorBlock.java similarity index 72% rename from src/main/java/com/minelittlepony/unicopia/gas/CloudDoorBlock.java rename to src/main/java/com/minelittlepony/unicopia/world/block/gas/CloudDoorBlock.java index 407333bd..bbc91774 100644 --- a/src/main/java/com/minelittlepony/unicopia/gas/CloudDoorBlock.java +++ b/src/main/java/com/minelittlepony/unicopia/world/block/gas/CloudDoorBlock.java @@ -1,6 +1,7 @@ -package com.minelittlepony.unicopia.gas; +package com.minelittlepony.unicopia.world.block.gas; + +import com.minelittlepony.unicopia.world.block.AbstractDoorBlock; -import com.minelittlepony.unicopia.block.AbstractDoorBlock; import net.minecraft.block.BlockState; import net.minecraft.entity.Entity; import net.minecraft.entity.player.PlayerEntity; @@ -29,14 +30,6 @@ public class CloudDoorBlock extends AbstractDoorBlock implements Gas { return super.onUse(state, worldIn, pos, player, hand, hit); } - @Deprecated - @Override - public float getHardness(BlockState blockState, BlockView world, BlockPos pos) { - float hardness = super.getHardness(blockState, world, pos); - - return Math.max(hardness, Math.min(60, hardness + (pos.getY() - 100))); - } - @Override public void onEntityCollision(BlockState state, World w, BlockPos pos, Entity entity) { if (!applyBouncyness(state, entity)) { @@ -46,9 +39,16 @@ public class CloudDoorBlock extends AbstractDoorBlock implements Gas { @Deprecated @Override - public float calcBlockBreakingDelta(BlockState state, PlayerEntity player, BlockView worldIn, BlockPos pos) { + public float calcBlockBreakingDelta(BlockState state, PlayerEntity player, BlockView world, BlockPos pos) { if (GasState.NORMAL.canTouch(player)) { - return super.calcBlockBreakingDelta(state, player, worldIn, pos); + float f = state.getHardness(world, pos); + f = Math.max(f, Math.min(60, f + (pos.getY() - 100))); + if (f == -1) { + return 0; + } + + float toolBreakingSpeedUp = player.isUsingEffectiveTool(state) ? 30 : 100; + return player.getBlockBreakingSpeed(state) / f / toolBreakingSpeedUp; } return -1; } diff --git a/src/main/java/com/minelittlepony/unicopia/gas/CloudFarmlandBlock.java b/src/main/java/com/minelittlepony/unicopia/world/block/gas/CloudFarmlandBlock.java similarity index 92% rename from src/main/java/com/minelittlepony/unicopia/gas/CloudFarmlandBlock.java rename to src/main/java/com/minelittlepony/unicopia/world/block/gas/CloudFarmlandBlock.java index 7c0376d9..b32062e8 100644 --- a/src/main/java/com/minelittlepony/unicopia/gas/CloudFarmlandBlock.java +++ b/src/main/java/com/minelittlepony/unicopia/world/block/gas/CloudFarmlandBlock.java @@ -1,12 +1,12 @@ -package com.minelittlepony.unicopia.gas; +package com.minelittlepony.unicopia.world.block.gas; -import com.minelittlepony.unicopia.block.UBlocks; import com.minelittlepony.unicopia.ducks.Farmland; +import com.minelittlepony.unicopia.world.block.UBlocks; import net.minecraft.block.BlockState; import net.minecraft.block.FarmlandBlock; import net.minecraft.entity.Entity; -import net.minecraft.entity.EntityContext; +import net.minecraft.block.ShapeContext; import net.minecraft.entity.player.PlayerEntity; import net.minecraft.util.math.BlockPos; import net.minecraft.util.math.Direction; @@ -60,7 +60,7 @@ public class CloudFarmlandBlock extends FarmlandBlock implements Farmland, Gas { } @Override - public VoxelShape getOutlineShape(BlockState state, BlockView view, BlockPos pos, EntityContext context) { + public VoxelShape getOutlineShape(BlockState state, BlockView view, BlockPos pos, ShapeContext context) { CloudInteractionContext ctx = (CloudInteractionContext)context; if (!getGasState(state).canPlace(ctx)) { @@ -71,7 +71,7 @@ public class CloudFarmlandBlock extends FarmlandBlock implements Farmland, Gas { } @Override - public VoxelShape getCollisionShape(BlockState state, BlockView view, BlockPos pos, EntityContext context) { + public VoxelShape getCollisionShape(BlockState state, BlockView view, BlockPos pos, ShapeContext context) { CloudInteractionContext ctx = (CloudInteractionContext)context; if (!getGasState(state).canTouch(ctx)) { diff --git a/src/main/java/com/minelittlepony/unicopia/gas/CloudFenceBlock.java b/src/main/java/com/minelittlepony/unicopia/world/block/gas/CloudFenceBlock.java similarity index 91% rename from src/main/java/com/minelittlepony/unicopia/gas/CloudFenceBlock.java rename to src/main/java/com/minelittlepony/unicopia/world/block/gas/CloudFenceBlock.java index 56bc6520..afd8f26f 100644 --- a/src/main/java/com/minelittlepony/unicopia/gas/CloudFenceBlock.java +++ b/src/main/java/com/minelittlepony/unicopia/world/block/gas/CloudFenceBlock.java @@ -1,9 +1,9 @@ -package com.minelittlepony.unicopia.gas; +package com.minelittlepony.unicopia.world.block.gas; import net.minecraft.block.BlockState; import net.minecraft.block.FenceBlock; +import net.minecraft.block.ShapeContext; import net.minecraft.entity.Entity; -import net.minecraft.entity.EntityContext; import net.minecraft.entity.player.PlayerEntity; import net.minecraft.util.math.BlockPos; import net.minecraft.util.shape.VoxelShape; @@ -16,7 +16,7 @@ public class CloudFenceBlock extends FenceBlock implements Gas { private final GasState variant; public CloudFenceBlock(GasState variant) { - super(variant.configure().build()); + super(variant.configure()); this.variant = variant; } @@ -45,7 +45,7 @@ public class CloudFenceBlock extends FenceBlock implements Gas { } @Override - public VoxelShape getOutlineShape(BlockState state, BlockView view, BlockPos pos, EntityContext context) { + public VoxelShape getOutlineShape(BlockState state, BlockView view, BlockPos pos, ShapeContext context) { CloudInteractionContext ctx = (CloudInteractionContext)context; if (!getGasState(state).canPlace(ctx)) { @@ -56,7 +56,7 @@ public class CloudFenceBlock extends FenceBlock implements Gas { } @Override - public VoxelShape getCollisionShape(BlockState state, BlockView view, BlockPos pos, EntityContext context) { + public VoxelShape getCollisionShape(BlockState state, BlockView view, BlockPos pos, ShapeContext context) { CloudInteractionContext ctx = (CloudInteractionContext)context; if (!getGasState(state).canTouch(ctx)) { diff --git a/src/main/java/com/minelittlepony/unicopia/gas/CloudInteractionContext.java b/src/main/java/com/minelittlepony/unicopia/world/block/gas/CloudInteractionContext.java similarity index 98% rename from src/main/java/com/minelittlepony/unicopia/gas/CloudInteractionContext.java rename to src/main/java/com/minelittlepony/unicopia/world/block/gas/CloudInteractionContext.java index d80a11f4..3937af35 100644 --- a/src/main/java/com/minelittlepony/unicopia/gas/CloudInteractionContext.java +++ b/src/main/java/com/minelittlepony/unicopia/world/block/gas/CloudInteractionContext.java @@ -1,4 +1,4 @@ -package com.minelittlepony.unicopia.gas; +package com.minelittlepony.unicopia.world.block.gas; import com.minelittlepony.unicopia.EquinePredicates; import net.minecraft.entity.Entity; diff --git a/src/main/java/com/minelittlepony/unicopia/gas/CloudSlabBlock.java b/src/main/java/com/minelittlepony/unicopia/world/block/gas/CloudSlabBlock.java similarity index 86% rename from src/main/java/com/minelittlepony/unicopia/gas/CloudSlabBlock.java rename to src/main/java/com/minelittlepony/unicopia/world/block/gas/CloudSlabBlock.java index d0d77356..80eba290 100644 --- a/src/main/java/com/minelittlepony/unicopia/gas/CloudSlabBlock.java +++ b/src/main/java/com/minelittlepony/unicopia/world/block/gas/CloudSlabBlock.java @@ -1,11 +1,11 @@ -package com.minelittlepony.unicopia.gas; +package com.minelittlepony.unicopia.world.block.gas; -import com.minelittlepony.unicopia.block.SmartSlabBlock; +import com.minelittlepony.unicopia.world.block.SmartSlabBlock; import net.fabricmc.api.EnvType; import net.fabricmc.api.Environment; import net.minecraft.block.BlockState; -import net.minecraft.entity.EntityContext; +import net.minecraft.block.ShapeContext; import net.minecraft.util.math.BlockPos; import net.minecraft.util.math.Direction; import net.minecraft.util.shape.VoxelShape; @@ -29,7 +29,7 @@ public class CloudSlabBlock extends SmartSlabBlock implements Gas { } @Override - public VoxelShape getOutlineShape(BlockState state, BlockView view, BlockPos pos, EntityContext context) { + public VoxelShape getOutlineShape(BlockState state, BlockView view, BlockPos pos, ShapeContext context) { if (getGasState(state).canPlace((CloudInteractionContext)context)) { return super.getOutlineShape(state, view, pos, context); } @@ -37,7 +37,7 @@ public class CloudSlabBlock extends SmartSlabBlock implements Gas { } @Override - public VoxelShape getCollisionShape(BlockState state, BlockView view, BlockPos pos, EntityContext context) { + public VoxelShape getCollisionShape(BlockState state, BlockView view, BlockPos pos, ShapeContext context) { if (getGasState(state).canTouch((CloudInteractionContext)context)) { return super.getCollisionShape(state, view, pos, context); } diff --git a/src/main/java/com/minelittlepony/unicopia/gas/CloudSoilBlock.java b/src/main/java/com/minelittlepony/unicopia/world/block/gas/CloudSoilBlock.java similarity index 76% rename from src/main/java/com/minelittlepony/unicopia/gas/CloudSoilBlock.java rename to src/main/java/com/minelittlepony/unicopia/world/block/gas/CloudSoilBlock.java index 6cb7b040..ea317b3d 100644 --- a/src/main/java/com/minelittlepony/unicopia/gas/CloudSoilBlock.java +++ b/src/main/java/com/minelittlepony/unicopia/world/block/gas/CloudSoilBlock.java @@ -1,8 +1,8 @@ -package com.minelittlepony.unicopia.gas; +package com.minelittlepony.unicopia.world.block.gas; -import com.minelittlepony.unicopia.block.UBlocks; -import com.minelittlepony.unicopia.entity.player.Pony; +import com.minelittlepony.unicopia.equine.player.Pony; import com.minelittlepony.unicopia.util.HoeUtil; +import com.minelittlepony.unicopia.world.block.UBlocks; import net.minecraft.item.ItemUsageContext; diff --git a/src/main/java/com/minelittlepony/unicopia/gas/CloudStairsBlock.java b/src/main/java/com/minelittlepony/unicopia/world/block/gas/CloudStairsBlock.java similarity index 84% rename from src/main/java/com/minelittlepony/unicopia/gas/CloudStairsBlock.java rename to src/main/java/com/minelittlepony/unicopia/world/block/gas/CloudStairsBlock.java index 072b89c9..107a8248 100644 --- a/src/main/java/com/minelittlepony/unicopia/gas/CloudStairsBlock.java +++ b/src/main/java/com/minelittlepony/unicopia/world/block/gas/CloudStairsBlock.java @@ -1,11 +1,11 @@ -package com.minelittlepony.unicopia.gas; +package com.minelittlepony.unicopia.world.block.gas; -import com.minelittlepony.unicopia.block.SmartStairsBlock; +import com.minelittlepony.unicopia.world.block.SmartStairsBlock; import net.fabricmc.api.EnvType; import net.fabricmc.api.Environment; import net.minecraft.block.BlockState; -import net.minecraft.entity.EntityContext; +import net.minecraft.block.ShapeContext; import net.minecraft.util.math.BlockPos; import net.minecraft.util.math.Direction; import net.minecraft.util.shape.VoxelShape; @@ -24,7 +24,7 @@ public class CloudStairsBlock extends SmartStairsBlock implements Gas { } @Override - public VoxelShape getOutlineShape(BlockState state, BlockView view, BlockPos pos, EntityContext context) { + public VoxelShape getOutlineShape(BlockState state, BlockView view, BlockPos pos, ShapeContext context) { if (getGasState(state).canPlace((CloudInteractionContext)context)) { return super.getOutlineShape(state, view, pos, context); } @@ -32,7 +32,7 @@ public class CloudStairsBlock extends SmartStairsBlock implements Gas { } @Override - public VoxelShape getCollisionShape(BlockState state, BlockView view, BlockPos pos, EntityContext context) { + public VoxelShape getCollisionShape(BlockState state, BlockView view, BlockPos pos, ShapeContext context) { if (getGasState(state).canTouch((CloudInteractionContext)context)) { return super.getCollisionShape(state, view, pos, context); } diff --git a/src/main/java/com/minelittlepony/unicopia/gas/CoverableCloudBlock.java b/src/main/java/com/minelittlepony/unicopia/world/block/gas/CoverableCloudBlock.java similarity index 82% rename from src/main/java/com/minelittlepony/unicopia/gas/CoverableCloudBlock.java rename to src/main/java/com/minelittlepony/unicopia/world/block/gas/CoverableCloudBlock.java index 7c41923f..833aa3f8 100644 --- a/src/main/java/com/minelittlepony/unicopia/gas/CoverableCloudBlock.java +++ b/src/main/java/com/minelittlepony/unicopia/world/block/gas/CoverableCloudBlock.java @@ -1,8 +1,8 @@ -package com.minelittlepony.unicopia.gas; +package com.minelittlepony.unicopia.world.block.gas; import javax.annotation.Nullable; -import com.minelittlepony.unicopia.block.Covering; +import com.minelittlepony.unicopia.world.block.Covering; import net.minecraft.block.Block; import net.minecraft.block.BlockState; @@ -10,7 +10,7 @@ import net.minecraft.item.ItemPlacementContext; import net.minecraft.state.StateManager; import net.minecraft.util.math.BlockPos; import net.minecraft.util.math.Direction; -import net.minecraft.world.IWorld; +import net.minecraft.world.WorldAccess; public class CoverableCloudBlock extends CloudBlock { @@ -27,7 +27,7 @@ public class CoverableCloudBlock extends CloudBlock { @Override @Deprecated - public BlockState getStateForNeighborUpdate(BlockState state, Direction direction, BlockState other, IWorld world, BlockPos pos, BlockPos otherPos) { + public BlockState getStateForNeighborUpdate(BlockState state, Direction direction, BlockState other, WorldAccess world, BlockPos pos, BlockPos otherPos) { if (direction == Direction.UP) { return state.with(Covering.PROPERTY, Covering.getCovering(world, otherPos)); } diff --git a/src/main/java/com/minelittlepony/unicopia/gas/Gas.java b/src/main/java/com/minelittlepony/unicopia/world/block/gas/Gas.java similarity index 97% rename from src/main/java/com/minelittlepony/unicopia/gas/Gas.java rename to src/main/java/com/minelittlepony/unicopia/world/block/gas/Gas.java index 8c0f76c2..c2eaab3d 100644 --- a/src/main/java/com/minelittlepony/unicopia/gas/Gas.java +++ b/src/main/java/com/minelittlepony/unicopia/world/block/gas/Gas.java @@ -1,4 +1,4 @@ -package com.minelittlepony.unicopia.gas; +package com.minelittlepony.unicopia.world.block.gas; import net.minecraft.block.BlockState; import net.minecraft.entity.Entity; diff --git a/src/main/java/com/minelittlepony/unicopia/gas/GasState.java b/src/main/java/com/minelittlepony/unicopia/world/block/gas/GasState.java similarity index 83% rename from src/main/java/com/minelittlepony/unicopia/gas/GasState.java rename to src/main/java/com/minelittlepony/unicopia/world/block/gas/GasState.java index 87081674..24ccc342 100644 --- a/src/main/java/com/minelittlepony/unicopia/gas/GasState.java +++ b/src/main/java/com/minelittlepony/unicopia/world/block/gas/GasState.java @@ -1,8 +1,9 @@ -package com.minelittlepony.unicopia.gas; +package com.minelittlepony.unicopia.world.block.gas; import com.minelittlepony.unicopia.EquinePredicates; -import com.minelittlepony.unicopia.block.UMaterials; -import net.fabricmc.fabric.api.block.FabricBlockSettings; +import com.minelittlepony.unicopia.world.block.UMaterials; + +import net.fabricmc.fabric.api.object.builder.v1.block.FabricBlockSettings; import net.minecraft.block.AbstractRailBlock; import net.minecraft.block.BedBlock; import net.minecraft.block.Block; @@ -22,7 +23,10 @@ public enum GasState { return FabricBlockSettings.of(UMaterials.CLOUD) .strength(0.5F, 1) .sounds(BlockSoundGroup.WOOL) - .nonOpaque(); + .nonOpaque() + .suffocates((state, b, c) -> !isTranslucent()) + .allowsSpawning((state, b, c, type) -> !isTranslucent()) + .blockVision((state, b, c) -> !isTranslucent()); } public boolean isTranslucent() { diff --git a/src/main/java/com/minelittlepony/unicopia/gas/PillarCloudBlock.java b/src/main/java/com/minelittlepony/unicopia/world/block/gas/PillarCloudBlock.java similarity index 96% rename from src/main/java/com/minelittlepony/unicopia/gas/PillarCloudBlock.java rename to src/main/java/com/minelittlepony/unicopia/world/block/gas/PillarCloudBlock.java index bdaae6bb..0b5651ac 100644 --- a/src/main/java/com/minelittlepony/unicopia/gas/PillarCloudBlock.java +++ b/src/main/java/com/minelittlepony/unicopia/world/block/gas/PillarCloudBlock.java @@ -1,4 +1,4 @@ -package com.minelittlepony.unicopia.gas; +package com.minelittlepony.unicopia.world.block.gas; import net.minecraft.block.Block; import net.minecraft.block.BlockState; diff --git a/src/main/java/com/minelittlepony/unicopia/world/client/UWorldClient.java b/src/main/java/com/minelittlepony/unicopia/world/client/UWorldClient.java new file mode 100644 index 00000000..558f4591 --- /dev/null +++ b/src/main/java/com/minelittlepony/unicopia/world/client/UWorldClient.java @@ -0,0 +1,52 @@ +package com.minelittlepony.unicopia.world.client; + +import com.minelittlepony.unicopia.world.block.UBlocks; +import com.minelittlepony.unicopia.world.client.gui.UScreens; +import com.minelittlepony.unicopia.world.client.render.ButterflyEntityRenderer; +import com.minelittlepony.unicopia.world.client.render.CloudEntityRenderer; +import com.minelittlepony.unicopia.world.client.render.CucoonEntityRenderer; +import com.minelittlepony.unicopia.world.client.render.RainbowEntityRenderer; +import com.minelittlepony.unicopia.world.client.render.SpearEntityRenderer; +import com.minelittlepony.unicopia.world.client.render.SpellbookEntityRender; +import com.minelittlepony.unicopia.world.client.render.SpellcastEntityRenderer; +import com.minelittlepony.unicopia.world.entity.UEntities; + +import net.fabricmc.fabric.api.blockrenderlayer.v1.BlockRenderLayerMap; +import net.fabricmc.fabric.api.client.rendereregistry.v1.EntityRendererRegistry; +import net.minecraft.client.render.RenderLayer; +import net.minecraft.client.render.entity.FlyingItemEntityRenderer; + +public interface UWorldClient { + static void bootstrap() { + EntityRendererRegistry.INSTANCE.register(UEntities.CLOUD, CloudEntityRenderer::new); + EntityRendererRegistry.INSTANCE.register(UEntities.WILD_CLOUD, CloudEntityRenderer::new); + EntityRendererRegistry.INSTANCE.register(UEntities.CONSTRUCTION_CLOUD, CloudEntityRenderer::new); + EntityRendererRegistry.INSTANCE.register(UEntities.RACING_CLOUD, CloudEntityRenderer::new); + EntityRendererRegistry.INSTANCE.register(UEntities.MAGIC_SPELL, SpellcastEntityRenderer::new); + EntityRendererRegistry.INSTANCE.register(UEntities.THROWN_ITEM, (manager, context) -> new FlyingItemEntityRenderer<>(manager, context.getItemRenderer())); + EntityRendererRegistry.INSTANCE.register(UEntities.SPELLBOOK, SpellbookEntityRender::new); + EntityRendererRegistry.INSTANCE.register(UEntities.RAINBOW, RainbowEntityRenderer::new); + EntityRendererRegistry.INSTANCE.register(UEntities.BUTTERFLY, ButterflyEntityRenderer::new); + EntityRendererRegistry.INSTANCE.register(UEntities.CUCOON, CucoonEntityRenderer::new); + EntityRendererRegistry.INSTANCE.register(UEntities.THROWN_SPEAR, SpearEntityRenderer::new); + + BlockRenderLayerMap.INSTANCE.putBlocks(RenderLayer.getCutout(), + UBlocks.ENCHANTED_TORCH, UBlocks.ENCHANTED_WALL_TORCH, + UBlocks.BAKERY_DOOR, UBlocks.LIBRARY_DOOR, UBlocks.MISTED_GLASS_DOOR, UBlocks.DIAMOND_DOOR, + UBlocks.APPLE_SAPLING, UBlocks.ALFALFA_CROPS, + UBlocks.TOMATO_PLANT, UBlocks.CLOUDSDALE_TOMATO_PLANT + ); + BlockRenderLayerMap.INSTANCE.putBlocks(RenderLayer.getTranslucent(), + UBlocks.CLOUD_ANVIL, UBlocks.CLOUD_FARMLAND, + UBlocks.CLOUD_BLOCK, UBlocks.CLOUD_SLAB, UBlocks.CLOUD_STAIRS, + UBlocks.ENCHANTED_CLOUD_BLOCK, UBlocks.ENCHANTED_CLOUD_SLAB, UBlocks.ENCHANTED_CLOUD_STAIRS, + + UBlocks.SLIME_DRIP, UBlocks.SLIME_LAYER + ); + BlockRenderLayerMap.INSTANCE.putBlocks(RenderLayer.getCutoutMipped(), + UBlocks.APPLE_LEAVES + ); + + UScreens.bootstrap(); + } +} diff --git a/src/main/java/com/minelittlepony/unicopia/world/client/gui/BagOfHoldingScreen.java b/src/main/java/com/minelittlepony/unicopia/world/client/gui/BagOfHoldingScreen.java new file mode 100644 index 00000000..ab6ce1bd --- /dev/null +++ b/src/main/java/com/minelittlepony/unicopia/world/client/gui/BagOfHoldingScreen.java @@ -0,0 +1,147 @@ +package com.minelittlepony.unicopia.world.client.gui; + +import java.util.List; + +import com.minelittlepony.common.client.gui.IViewRoot; +import com.minelittlepony.common.client.gui.dimension.Bounds; +import com.minelittlepony.common.client.gui.dimension.Padding; +import com.minelittlepony.common.client.gui.element.Scrollbar; +import com.minelittlepony.unicopia.world.container.BagOfHoldingContainer; +import com.mojang.blaze3d.platform.GlStateManager; + +import net.minecraft.client.gui.Element; +import net.minecraft.client.gui.screen.ingame.HandledScreen; +import net.minecraft.client.util.math.MatrixStack; +import net.minecraft.entity.player.PlayerInventory; +import net.minecraft.sound.SoundEvents; +import net.minecraft.text.Text; +import net.minecraft.util.Identifier; + +public class BagOfHoldingScreen extends HandledScreen implements IViewRoot { + private static final Identifier CHEST_GUI_TEXTURE = new Identifier("textures/gui/container/generic_54.png"); + + private final int inventoryRows; + private final int playerRows; + + private final Bounds bounds = Bounds.empty(); + private final Bounds contentBounds = Bounds.empty(); + private final Padding padding = new Padding(0, 0, 0, 0); + + private final Scrollbar scrollbar = new Scrollbar(this); + + public BagOfHoldingScreen(BagOfHoldingContainer handler, PlayerInventory inv, Text title) { + super(handler, inv, title); + + playerRows = playerInventory.size() / 9; + inventoryRows = (handler.slots.size() / 9) - 1; + } + + @Override + public void init() { + super.init(); + + bounds.left = x; + bounds.top = y; + bounds.width = backgroundWidth; + bounds.height = backgroundHeight; + contentBounds.width = bounds.width; + contentBounds.height = (inventoryRows + 1) * 18 + 17; + + scrollbar.reposition(); + children.add(scrollbar); + } + + @Override + public void onClose() { + super.onClose(); + client.player.playSound(SoundEvents.BLOCK_ENDER_CHEST_OPEN, 0.5F, 0.5F); + } + + @Override + public void render(MatrixStack matrices, int mouseX, int mouseY, float partialTicks) { + renderBackground(matrices); + + scrollbar.render(matrices, mouseX, mouseY, partialTicks); + + int scroll = -scrollbar.getVerticalScrollAmount(); + + GlStateManager.pushMatrix(); + GlStateManager.translatef(0, scroll, 0); + + super.render(matrices, mouseX, mouseY - scroll, partialTicks); + + int h = height; + height = Integer.MAX_VALUE; + drawMouseoverTooltip(matrices, mouseX, mouseY - scroll); + height = h; + + GlStateManager.popMatrix(); + } + + @Override + public boolean mouseClicked(double x, double y, int button) { + return super.mouseClicked(x, y + scrollbar.getVerticalScrollAmount(), button); + } + + @Override + public boolean mouseDragged(double x, double y, int button, double dx, double dy) { + + if (scrollbar.isMouseOver(x, y)) { + return scrollbar.mouseDragged(x, y + scrollbar.getVerticalScrollAmount(), button, dx, dy); + } + + return super.mouseDragged(x, y + scrollbar.getVerticalScrollAmount(), button, dx, dy); + } + + @Override + public boolean mouseReleased(double x, double y, int button) { + return super.mouseReleased(x, y + scrollbar.getVerticalScrollAmount(), button); + } + + @Override + protected void drawForeground(MatrixStack matrices, int mouseX, int mouseY) { + textRenderer.drawWithShadow(matrices, title, 8, 6, 0x404040); + } + + @Override + protected void drawBackground(MatrixStack matrices, float partialTicks, int mouseX, int mouseY) { + GlStateManager.color4f(1, 1, 1, 1); + + client.getTextureManager().bindTexture(CHEST_GUI_TEXTURE); + + int midX = (width - backgroundWidth) / 2; + int midY = (height - backgroundHeight) / 2; + + drawTexture(matrices, midX, midY, 0, 0, backgroundWidth, 18); + for (int i = 0; i < inventoryRows - (playerRows - 1); i++) { + drawTexture(matrices, midX, midY + (18 * (i + 1)), 0, 18, backgroundWidth, 18); + } + + drawTexture(matrices, midX, midY + (18 * (inventoryRows - (playerRows - 2))) - 1, 0, 131, backgroundWidth, 98); + } + + @Override + public Bounds getBounds() { + return bounds; + } + + @Override + public void setBounds(Bounds bounds) { + } + + @Override + public Bounds getContentBounds() { + return contentBounds; + } + + @Override + public Padding getContentPadding() { + return padding; + } + + @Override + public List getChildElements() { + // TODO Auto-generated method stub + return children; + } +} diff --git a/src/main/java/com/minelittlepony/unicopia/client/gui/SettingsScreen.java b/src/main/java/com/minelittlepony/unicopia/world/client/gui/SettingsScreen.java similarity index 93% rename from src/main/java/com/minelittlepony/unicopia/client/gui/SettingsScreen.java rename to src/main/java/com/minelittlepony/unicopia/world/client/gui/SettingsScreen.java index 97a5c51b..e62129e6 100644 --- a/src/main/java/com/minelittlepony/unicopia/client/gui/SettingsScreen.java +++ b/src/main/java/com/minelittlepony/unicopia/world/client/gui/SettingsScreen.java @@ -1,4 +1,4 @@ -package com.minelittlepony.unicopia.client.gui; +package com.minelittlepony.unicopia.world.client.gui; import com.minelittlepony.common.client.gui.GameGui; import com.minelittlepony.common.client.gui.element.Button; diff --git a/src/main/java/com/minelittlepony/unicopia/client/gui/SpellBookScreen.java b/src/main/java/com/minelittlepony/unicopia/world/client/gui/SpellBookScreen.java similarity index 59% rename from src/main/java/com/minelittlepony/unicopia/client/gui/SpellBookScreen.java rename to src/main/java/com/minelittlepony/unicopia/world/client/gui/SpellBookScreen.java index 79666570..efc2ade7 100644 --- a/src/main/java/com/minelittlepony/unicopia/client/gui/SpellBookScreen.java +++ b/src/main/java/com/minelittlepony/unicopia/world/client/gui/SpellBookScreen.java @@ -1,26 +1,27 @@ -package com.minelittlepony.unicopia.client.gui; +package com.minelittlepony.unicopia.world.client.gui; import org.lwjgl.opengl.GL11; import com.minelittlepony.common.client.gui.element.Button; import com.minelittlepony.unicopia.Unicopia; -import com.minelittlepony.unicopia.container.SpellBookContainer; -import com.minelittlepony.unicopia.container.SpellBookContainer.SpellbookSlot; -import com.minelittlepony.unicopia.enchanting.IPageUnlockListener; -import com.minelittlepony.unicopia.enchanting.Page; -import com.minelittlepony.unicopia.enchanting.PageState; -import com.minelittlepony.unicopia.enchanting.Pages; -import com.minelittlepony.unicopia.entity.player.Pony; +import com.minelittlepony.unicopia.equine.player.Pony; +import com.minelittlepony.unicopia.world.container.SpellBookContainer; +import com.minelittlepony.unicopia.world.container.SpellBookContainer.InputSlot; +import com.minelittlepony.unicopia.world.recipe.enchanting.IPageUnlockListener; +import com.minelittlepony.unicopia.world.recipe.enchanting.Page; +import com.minelittlepony.unicopia.world.recipe.enchanting.PageState; +import com.minelittlepony.unicopia.world.recipe.enchanting.Pages; import com.mojang.blaze3d.platform.GlStateManager; -import net.minecraft.client.gui.screen.ingame.ContainerScreen; +import net.minecraft.client.gui.screen.ingame.HandledScreen; import net.minecraft.client.texture.MissingSprite; -import net.minecraft.container.Slot; -import net.minecraft.entity.player.PlayerEntity; +import net.minecraft.client.util.math.MatrixStack; +import net.minecraft.entity.player.PlayerInventory; import net.minecraft.util.Identifier; -import net.minecraft.util.PacketByteBuf; +import net.minecraft.screen.slot.Slot; +import net.minecraft.text.Text; -public class SpellBookScreen extends ContainerScreen implements IPageUnlockListener { +public class SpellBookScreen extends HandledScreen implements IPageUnlockListener { private static Page currentPage; @@ -31,12 +32,12 @@ public class SpellBookScreen extends ContainerScreen impleme private PageButton nextPage; private PageButton prevPage; - public SpellBookScreen(int sync, Identifier id, PlayerEntity player, PacketByteBuf buf) { - super(new SpellBookContainer(sync, id, player, buf), player.inventory, buf.readText()); + public SpellBookScreen(SpellBookContainer handler, PlayerInventory inv, Text title) { + super(handler, inv, title); - containerWidth = 405; - containerHeight = 219; - this.player = Pony.of(player); + backgroundWidth = 405; + backgroundHeight = 219; + player = Pony.of(inv.player); } @Override @@ -92,19 +93,19 @@ public class SpellBookScreen extends ContainerScreen impleme } @Override - protected void fillGradient(int left, int top, int width, int height, int startColor, int endColor) { - if (focusedSlot == null || left != focusedSlot.xPosition || top != focusedSlot.yPosition || !drawSlotOverlay(focusedSlot)) { - super.fillGradient(left, top, width, height, startColor, endColor); + protected void fillGradient(MatrixStack matrices, int left, int top, int width, int height, int startColor, int endColor) { + if (focusedSlot == null || left != focusedSlot.x || top != focusedSlot.y || !drawSlotOverlay(matrices, focusedSlot)) { + super.fillGradient(matrices, left, top, width, height, startColor, endColor); } } - protected boolean drawSlotOverlay(Slot slot) { - if (slot instanceof SpellbookSlot) { + protected boolean drawSlotOverlay(MatrixStack matrices, Slot slot) { + if (slot instanceof InputSlot) { GlStateManager.enableBlend(); GL11.glDisable(GL11.GL_ALPHA_TEST); - minecraft.getTextureManager().bindTexture(TEXTURE); - blit(slot.xPosition - 1, slot.yPosition - 1, 74, 223, 18, 18, 512, 256); + client.getTextureManager().bindTexture(TEXTURE); + drawTexture(matrices, slot.x - 1, slot.y - 1, 74, 223, 18, 18, 512, 256); GL11.glEnable(GL11.GL_ALPHA_TEST); GlStateManager.disableBlend(); @@ -117,44 +118,44 @@ public class SpellBookScreen extends ContainerScreen impleme @Override - public void render(int mouseX, int mouseY, float partialTicks) { - super.render(mouseX, mouseY, partialTicks); - drawMouseoverTooltip(mouseX, mouseY); + public void render(MatrixStack matrices, int mouseX, int mouseY, float partialTicks) { + super.render(matrices, mouseX, mouseY, partialTicks); + drawMouseoverTooltip(matrices, mouseX, mouseY); } @Override - protected void drawForeground(int mouseX, int mouseY) { + protected void drawForeground(MatrixStack matrices, int mouseX, int mouseY) { String text = String.format("%d / %d", currentPage.getIndex() + 1, Pages.instance().getTotalPages()); - font.draw(text, 70 - font.getStringWidth(text)/2, 190, 0x0); + textRenderer.drawWithShadow(matrices, text, 70 - textRenderer.getWidth(text)/2, 190, 0x0); } @Override - protected void drawBackground(float partialTicks, int mouseX, int mouseY) { - renderBackground(0); + protected void drawBackground(MatrixStack matrices, float partialTicks, int mouseX, int mouseY) { + renderBackground(matrices, 0); GlStateManager.color4f(1, 1, 1, 1); - int left = (width - containerWidth) / 2; - int top = (height - containerHeight) / 2; + int left = (width - backgroundWidth) / 2; + int top = (height - backgroundHeight) / 2; - minecraft.getTextureManager().bindTexture(TEXTURE); - blit(left, top, 0, 0, containerWidth, containerHeight, 512, 256); + client.getTextureManager().bindTexture(TEXTURE); + drawTexture(matrices, left, top, 0, 0, backgroundWidth, backgroundHeight, 512, 256); GlStateManager.enableBlend(); GL11.glDisable(GL11.GL_ALPHA_TEST); - minecraft.getTextureManager().bindTexture(TEXTURE); - blit(left + 147, top + 49, 407, 2, 100, 101, 512, 256); + client.getTextureManager().bindTexture(TEXTURE); + drawTexture(matrices, left + 147, top + 49, 407, 2, 100, 101, 512, 256); if (player.getPages().getPageState(currentPage) != PageState.LOCKED) { Identifier texture = currentPage.getTexture(); - if (minecraft.getTextureManager().getTexture(texture) != MissingSprite.getMissingSpriteTexture()) { + if (client.getTextureManager().getTexture(texture) != MissingSprite.getMissingSpriteTexture()) { GlStateManager.blendFunc(GL11.GL_SRC_ALPHA, GL11.GL_ONE_MINUS_SRC_ALPHA); - minecraft.getTextureManager().bindTexture(texture); - blit(left, top, 0, 0, containerWidth, containerHeight, 512, 256); + client.getTextureManager().bindTexture(texture); + drawTexture(matrices, left, top, 0, 0, backgroundWidth, backgroundHeight, 512, 256); } else { if (player.getWorld().random.nextInt(100) == 0) { Unicopia.LOGGER.fatal("Missing texture " + texture); @@ -178,7 +179,7 @@ public class SpellBookScreen extends ContainerScreen impleme } @Override - public void renderButton(int mouseX, int mouseY, float partialTicks) { + public void renderButton(MatrixStack matrices, int mouseX, int mouseY, float partialTicks) { if (visible) { boolean shaking = false; @@ -200,7 +201,7 @@ public class SpellBookScreen extends ContainerScreen impleme } GlStateManager.color4f(1, 1, 1, 1); - minecraft.getTextureManager().bindTexture(TEXTURE); + client.getTextureManager().bindTexture(TEXTURE); int u = 0; int v = 220; @@ -217,7 +218,7 @@ public class SpellBookScreen extends ContainerScreen impleme v += 13; } - blit(x, y, u, v, 23, 13, 512, 256); + drawTexture(matrices, x, y, u, v, 23, 13, 512, 256); } } diff --git a/src/main/java/com/minelittlepony/unicopia/client/gui/UHud.java b/src/main/java/com/minelittlepony/unicopia/world/client/gui/UHud.java similarity index 71% rename from src/main/java/com/minelittlepony/unicopia/client/gui/UHud.java rename to src/main/java/com/minelittlepony/unicopia/world/client/gui/UHud.java index 6a5d14d1..909cf77f 100644 --- a/src/main/java/com/minelittlepony/unicopia/client/gui/UHud.java +++ b/src/main/java/com/minelittlepony/unicopia/world/client/gui/UHud.java @@ -1,14 +1,15 @@ -package com.minelittlepony.unicopia.client.gui; +package com.minelittlepony.unicopia.world.client.gui; import com.minelittlepony.unicopia.ability.Abilities; import com.minelittlepony.unicopia.ability.AbilityDispatcher; import com.minelittlepony.unicopia.ability.AbilitySlot; -import com.minelittlepony.unicopia.entity.player.Pony; +import com.minelittlepony.unicopia.equine.player.Pony; import com.mojang.blaze3d.systems.RenderSystem; import net.minecraft.client.MinecraftClient; import net.minecraft.client.gui.DrawableHelper; import net.minecraft.client.gui.hud.InGameHud; +import net.minecraft.client.util.math.MatrixStack; import net.minecraft.util.Identifier; import net.minecraft.util.math.MathHelper; @@ -35,6 +36,8 @@ public class UHud extends DrawableHelper { int x = 104 + (scaledWidth - 50) / 2; int y = 20 + scaledHeight - 70; + MatrixStack matrices = new MatrixStack(); + RenderSystem.enableAlphaTest(); RenderSystem.enableBlend(); @@ -45,7 +48,7 @@ public class UHud extends DrawableHelper { AbilityDispatcher abilities = Pony.of(client.player).getAbilities(); - blit(x, y, 0, 0, frameWidth, frameHeight, 128, 128); // background + drawTexture(matrices, x, y, 0, 0, frameWidth, frameHeight, 128, 128); // background AbilityDispatcher.Stat stat = abilities.getStat(AbilitySlot.PRIMARY); @@ -54,27 +57,27 @@ public class UHud extends DrawableHelper { if (progressPercent > 0 && progressPercent < 1) { int progressHeight = (int)(frameHeight * progressPercent); - blit(x, y + (frameHeight - progressHeight), + drawTexture(matrices, x, y + (frameHeight - progressHeight), 61, frameHeight - progressHeight, frameWidth, progressHeight, 128, 128); // progress } - renderAbilityIcon(stat, x + 9, y + 15, 32, 32, 32, 32); - blit(x, y, 0, 54, frameWidth, frameHeight, 128, 128); // frame + renderAbilityIcon(matrices, stat, x + 9, y + 15, 32, 32, 32, 32); + drawTexture(matrices, x, y, 0, 54, frameWidth, frameHeight, 128, 128); // frame - secondarySlot.render(abilities, x, y, tickDelta); - tertiarySlot.render(abilities, x, y, tickDelta); + secondarySlot.render(matrices, abilities, x, y, tickDelta); + tertiarySlot.render(matrices, abilities, x, y, tickDelta); RenderSystem.disableBlend(); RenderSystem.disableAlphaTest(); } - void renderAbilityIcon(AbilityDispatcher.Stat stat, int x, int y, int u, int v, int frameWidth, int frameHeight) { + void renderAbilityIcon(MatrixStack matrices, AbilityDispatcher.Stat stat, int x, int y, int u, int v, int frameWidth, int frameHeight) { stat.getAbility().ifPresent(ability -> { Identifier id = Abilities.REGISTRY.getId(ability); client.getTextureManager().bindTexture(new Identifier(id.getNamespace(), "textures/gui/ability/" + id.getPath() + ".png")); - blit(x, y, 0, 0, frameWidth, frameHeight, u, v); + drawTexture(matrices, x, y, 0, 0, frameWidth, frameHeight, u, v); client.getTextureManager().bindTexture(HUD_TEXTURE); }); @@ -94,14 +97,14 @@ public class UHud extends DrawableHelper { this.y = y; } - void render(AbilityDispatcher abilities, int x, int y, float tickDelta) { + void render(MatrixStack matrices, AbilityDispatcher abilities, int x, int y, float tickDelta) { x += this.x; y += this.y; AbilityDispatcher.Stat stat = abilities.getStat(slot); float cooldown = stat.getFillProgress(); - blit(x, y, 80, 105, 25, 25, 128, 128); + drawTexture(matrices, x, y, 80, 105, 25, 25, 128, 128); if (cooldown > 0 && cooldown < 1) { float lerpCooldown = MathHelper.lerp(tickDelta, cooldown, lastCooldown); @@ -114,13 +117,13 @@ public class UHud extends DrawableHelper { int progressBottom = y + slotPadding + slotSize; int progressTop = progressBottom - (int)(15F * cooldown); - fill(x + slotPadding, progressTop, x + slotPadding + slotSize, progressBottom, 0xFFFFFFFF); + fill(matrices, x + slotPadding, progressTop, x + slotPadding + slotSize, progressBottom, 0xFFFFFFFF); RenderSystem.enableAlphaTest(); RenderSystem.enableBlend(); } - renderAbilityIcon(stat, x + 2, y + 2, 20, 20, 20, 20); - blit(x, y, 105, 105, 25, 25, 128, 128); + renderAbilityIcon(matrices, stat, x + 2, y + 2, 20, 20, 20, 20); + drawTexture(matrices, x, y, 105, 105, 25, 25, 128, 128); } } diff --git a/src/main/java/com/minelittlepony/unicopia/world/client/gui/UScreens.java b/src/main/java/com/minelittlepony/unicopia/world/client/gui/UScreens.java new file mode 100644 index 00000000..e7ac9be8 --- /dev/null +++ b/src/main/java/com/minelittlepony/unicopia/world/client/gui/UScreens.java @@ -0,0 +1,27 @@ +package com.minelittlepony.unicopia.world.client.gui; + +import com.minelittlepony.unicopia.world.container.UContainers; + +import net.fabricmc.fabric.api.client.screenhandler.v1.ScreenRegistry; +import net.fabricmc.fabric.api.client.screenhandler.v1.ScreenRegistry.Factory; +import net.minecraft.client.gui.screen.Screen; +import net.minecraft.client.gui.screen.ingame.ScreenHandlerProvider; +import net.minecraft.screen.ScreenHandler; +import net.minecraft.screen.ScreenHandlerType; + +public interface UScreens { + static void bootstrap() { + register(UContainers.BAG_OF_HOLDING, BagOfHoldingScreen::new); + register(UContainers.SPELL_BOOK, SpellBookScreen::new); + } + + // TODO: farbreic :tiny_potato: + static < + H extends ScreenHandler, + S extends Screen & ScreenHandlerProvider> + void register( + ScreenHandlerType type, + Factory screenFactory) { + ScreenRegistry.register(type, screenFactory); + } +} diff --git a/src/main/java/com/minelittlepony/unicopia/world/client/package-info.java b/src/main/java/com/minelittlepony/unicopia/world/client/package-info.java new file mode 100644 index 00000000..58c0d70b --- /dev/null +++ b/src/main/java/com/minelittlepony/unicopia/world/client/package-info.java @@ -0,0 +1 @@ +package com.minelittlepony.unicopia.world.client; \ No newline at end of file diff --git a/src/main/java/com/minelittlepony/unicopia/client/render/ButterflyEntityRenderer.java b/src/main/java/com/minelittlepony/unicopia/world/client/render/ButterflyEntityRenderer.java similarity index 86% rename from src/main/java/com/minelittlepony/unicopia/client/render/ButterflyEntityRenderer.java rename to src/main/java/com/minelittlepony/unicopia/world/client/render/ButterflyEntityRenderer.java index a8a2f901..b1cd8202 100644 --- a/src/main/java/com/minelittlepony/unicopia/client/render/ButterflyEntityRenderer.java +++ b/src/main/java/com/minelittlepony/unicopia/world/client/render/ButterflyEntityRenderer.java @@ -1,7 +1,7 @@ -package com.minelittlepony.unicopia.client.render; +package com.minelittlepony.unicopia.world.client.render; -import com.minelittlepony.unicopia.client.render.model.ButterflyEntityModel; -import com.minelittlepony.unicopia.entity.ButterflyEntity; +import com.minelittlepony.unicopia.world.client.render.model.ButterflyEntityModel; +import com.minelittlepony.unicopia.world.entity.ButterflyEntity; import net.fabricmc.fabric.api.client.rendereregistry.v1.EntityRendererRegistry; import net.minecraft.client.render.entity.EntityRenderDispatcher; diff --git a/src/main/java/com/minelittlepony/unicopia/client/render/CloudEntityRenderer.java b/src/main/java/com/minelittlepony/unicopia/world/client/render/CloudEntityRenderer.java similarity index 91% rename from src/main/java/com/minelittlepony/unicopia/client/render/CloudEntityRenderer.java rename to src/main/java/com/minelittlepony/unicopia/world/client/render/CloudEntityRenderer.java index eaf9b70a..1125100e 100644 --- a/src/main/java/com/minelittlepony/unicopia/client/render/CloudEntityRenderer.java +++ b/src/main/java/com/minelittlepony/unicopia/world/client/render/CloudEntityRenderer.java @@ -1,4 +1,4 @@ -package com.minelittlepony.unicopia.client.render; +package com.minelittlepony.unicopia.world.client.render; import net.fabricmc.fabric.api.client.rendereregistry.v1.EntityRendererRegistry; import net.minecraft.client.render.VertexConsumerProvider; @@ -7,8 +7,8 @@ import net.minecraft.client.render.entity.MobEntityRenderer; import net.minecraft.client.util.math.MatrixStack; import net.minecraft.util.Identifier; -import com.minelittlepony.unicopia.client.render.model.CloudEntityModel; -import com.minelittlepony.unicopia.entity.CloudEntity; +import com.minelittlepony.unicopia.world.client.render.model.CloudEntityModel; +import com.minelittlepony.unicopia.world.entity.CloudEntity; public class CloudEntityRenderer extends MobEntityRenderer { private static final Identifier NORMAL = new Identifier("unicopia", "textures/entity/clouds.png"); diff --git a/src/main/java/com/minelittlepony/unicopia/client/render/CucoonEntityRenderer.java b/src/main/java/com/minelittlepony/unicopia/world/client/render/CucoonEntityRenderer.java similarity index 77% rename from src/main/java/com/minelittlepony/unicopia/client/render/CucoonEntityRenderer.java rename to src/main/java/com/minelittlepony/unicopia/world/client/render/CucoonEntityRenderer.java index 8556f740..449d2097 100644 --- a/src/main/java/com/minelittlepony/unicopia/client/render/CucoonEntityRenderer.java +++ b/src/main/java/com/minelittlepony/unicopia/world/client/render/CucoonEntityRenderer.java @@ -1,7 +1,8 @@ -package com.minelittlepony.unicopia.client.render; +package com.minelittlepony.unicopia.world.client.render; + +import com.minelittlepony.unicopia.world.client.render.model.CucoonEntityModel; +import com.minelittlepony.unicopia.world.entity.CucoonEntity; -import com.minelittlepony.unicopia.client.render.model.CucoonEntityModel; -import com.minelittlepony.unicopia.entity.CucoonEntity; import net.fabricmc.fabric.api.client.rendereregistry.v1.EntityRendererRegistry; import net.minecraft.client.render.entity.EntityRenderDispatcher; import net.minecraft.client.render.entity.LivingEntityRenderer; @@ -27,6 +28,6 @@ public class CucoonEntityRenderer extends LivingEntityRenderer { diff --git a/src/main/java/com/minelittlepony/unicopia/client/render/WorldRenderDelegate.java b/src/main/java/com/minelittlepony/unicopia/world/client/render/WorldRenderDelegate.java similarity index 94% rename from src/main/java/com/minelittlepony/unicopia/client/render/WorldRenderDelegate.java rename to src/main/java/com/minelittlepony/unicopia/world/client/render/WorldRenderDelegate.java index 9d98d8f0..09252c58 100644 --- a/src/main/java/com/minelittlepony/unicopia/client/render/WorldRenderDelegate.java +++ b/src/main/java/com/minelittlepony/unicopia/world/client/render/WorldRenderDelegate.java @@ -1,6 +1,6 @@ -package com.minelittlepony.unicopia.client.render; +package com.minelittlepony.unicopia.world.client.render; -import com.minelittlepony.unicopia.entity.player.Pony; +import com.minelittlepony.unicopia.equine.player.Pony; import net.minecraft.client.MinecraftClient; import net.minecraft.client.util.math.MatrixStack; diff --git a/src/main/java/com/minelittlepony/unicopia/client/render/model/ButterflyEntityModel.java b/src/main/java/com/minelittlepony/unicopia/world/client/render/model/ButterflyEntityModel.java similarity index 92% rename from src/main/java/com/minelittlepony/unicopia/client/render/model/ButterflyEntityModel.java rename to src/main/java/com/minelittlepony/unicopia/world/client/render/model/ButterflyEntityModel.java index 6c2fcf3a..cd13424f 100644 --- a/src/main/java/com/minelittlepony/unicopia/client/render/model/ButterflyEntityModel.java +++ b/src/main/java/com/minelittlepony/unicopia/world/client/render/model/ButterflyEntityModel.java @@ -1,7 +1,8 @@ -package com.minelittlepony.unicopia.client.render.model; +package com.minelittlepony.unicopia.world.client.render.model; + +import com.minelittlepony.unicopia.world.client.render.RenderLayers; +import com.minelittlepony.unicopia.world.entity.ButterflyEntity; -import com.minelittlepony.unicopia.client.render.RenderLayers; -import com.minelittlepony.unicopia.entity.ButterflyEntity; import net.minecraft.client.model.ModelPart; import net.minecraft.client.render.VertexConsumer; import net.minecraft.client.render.entity.model.EntityModel; diff --git a/src/main/java/com/minelittlepony/unicopia/client/render/model/CloudEntityModel.java b/src/main/java/com/minelittlepony/unicopia/world/client/render/model/CloudEntityModel.java similarity index 86% rename from src/main/java/com/minelittlepony/unicopia/client/render/model/CloudEntityModel.java rename to src/main/java/com/minelittlepony/unicopia/world/client/render/model/CloudEntityModel.java index a7011a5c..f16c40eb 100644 --- a/src/main/java/com/minelittlepony/unicopia/client/render/model/CloudEntityModel.java +++ b/src/main/java/com/minelittlepony/unicopia/world/client/render/model/CloudEntityModel.java @@ -1,7 +1,7 @@ -package com.minelittlepony.unicopia.client.render.model; +package com.minelittlepony.unicopia.world.client.render.model; -import com.minelittlepony.unicopia.client.render.RenderLayers; -import com.minelittlepony.unicopia.entity.CloudEntity; +import com.minelittlepony.unicopia.world.client.render.RenderLayers; +import com.minelittlepony.unicopia.world.entity.CloudEntity; import net.minecraft.client.model.ModelPart; import net.minecraft.client.render.VertexConsumer; diff --git a/src/main/java/com/minelittlepony/unicopia/client/render/model/CucoonEntityModel.java b/src/main/java/com/minelittlepony/unicopia/world/client/render/model/CucoonEntityModel.java similarity index 93% rename from src/main/java/com/minelittlepony/unicopia/client/render/model/CucoonEntityModel.java rename to src/main/java/com/minelittlepony/unicopia/world/client/render/model/CucoonEntityModel.java index ae64c691..34876ddd 100644 --- a/src/main/java/com/minelittlepony/unicopia/client/render/model/CucoonEntityModel.java +++ b/src/main/java/com/minelittlepony/unicopia/world/client/render/model/CucoonEntityModel.java @@ -1,6 +1,7 @@ -package com.minelittlepony.unicopia.client.render.model; +package com.minelittlepony.unicopia.world.client.render.model; + +import com.minelittlepony.unicopia.world.entity.CucoonEntity; -import com.minelittlepony.unicopia.entity.CucoonEntity; import net.minecraft.client.model.ModelPart; import net.minecraft.client.render.RenderLayer; import net.minecraft.client.render.VertexConsumer; diff --git a/src/main/java/com/minelittlepony/unicopia/client/render/model/GemEntityModel.java b/src/main/java/com/minelittlepony/unicopia/world/client/render/model/GemEntityModel.java similarity index 93% rename from src/main/java/com/minelittlepony/unicopia/client/render/model/GemEntityModel.java rename to src/main/java/com/minelittlepony/unicopia/world/client/render/model/GemEntityModel.java index 8d072a45..dfb3208e 100644 --- a/src/main/java/com/minelittlepony/unicopia/client/render/model/GemEntityModel.java +++ b/src/main/java/com/minelittlepony/unicopia/world/client/render/model/GemEntityModel.java @@ -1,13 +1,13 @@ -package com.minelittlepony.unicopia.client.render.model; +package com.minelittlepony.unicopia.world.client.render.model; import javax.annotation.Nullable; -import com.minelittlepony.unicopia.entity.SpellcastEntity; -import com.minelittlepony.unicopia.item.UItems; import com.minelittlepony.unicopia.magic.Affinity; import com.minelittlepony.unicopia.magic.Spell; import com.minelittlepony.unicopia.magic.spell.SpellRegistry; -import com.minelittlepony.util.Color; +import com.minelittlepony.unicopia.world.entity.SpellcastEntity; +import com.minelittlepony.unicopia.world.item.UItems; +import com.minelittlepony.common.util.Color; import net.minecraft.client.MinecraftClient; import net.minecraft.client.model.ModelPart; diff --git a/src/main/java/com/minelittlepony/unicopia/client/render/model/SpellbookModel.java b/src/main/java/com/minelittlepony/unicopia/world/client/render/model/SpellbookModel.java similarity index 96% rename from src/main/java/com/minelittlepony/unicopia/client/render/model/SpellbookModel.java rename to src/main/java/com/minelittlepony/unicopia/world/client/render/model/SpellbookModel.java index efa69d40..63dc3f76 100644 --- a/src/main/java/com/minelittlepony/unicopia/client/render/model/SpellbookModel.java +++ b/src/main/java/com/minelittlepony/unicopia/world/client/render/model/SpellbookModel.java @@ -1,9 +1,9 @@ -package com.minelittlepony.unicopia.client.render.model; +package com.minelittlepony.unicopia.world.client.render.model; import java.util.List; import com.google.common.collect.ImmutableList; -import com.minelittlepony.unicopia.entity.SpellbookEntity; +import com.minelittlepony.unicopia.world.entity.SpellbookEntity; import net.minecraft.client.model.ModelPart; import net.minecraft.client.render.VertexConsumer; diff --git a/src/main/java/com/minelittlepony/unicopia/container/BagOfHoldingContainer.java b/src/main/java/com/minelittlepony/unicopia/world/container/BagOfHoldingContainer.java similarity index 71% rename from src/main/java/com/minelittlepony/unicopia/container/BagOfHoldingContainer.java rename to src/main/java/com/minelittlepony/unicopia/world/container/BagOfHoldingContainer.java index 9e511e85..cfaef92c 100644 --- a/src/main/java/com/minelittlepony/unicopia/container/BagOfHoldingContainer.java +++ b/src/main/java/com/minelittlepony/unicopia/world/container/BagOfHoldingContainer.java @@ -1,35 +1,35 @@ -package com.minelittlepony.unicopia.container; +package com.minelittlepony.unicopia.world.container; -import net.minecraft.container.Container; -import net.minecraft.container.Slot; import net.minecraft.entity.player.PlayerEntity; +import net.minecraft.entity.player.PlayerInventory; import net.minecraft.inventory.Inventory; import net.minecraft.item.ItemStack; import net.minecraft.util.Hand; -import net.minecraft.util.Identifier; -import net.minecraft.util.PacketByteBuf; +import net.minecraft.screen.ScreenHandler; +import net.minecraft.screen.slot.Slot; -public class BagOfHoldingContainer extends Container { +public class BagOfHoldingContainer extends ScreenHandler { private final BagOfHoldingInventory inventory; private ItemStack sourceStack; - public BagOfHoldingContainer(int sync, Identifier id, PlayerEntity player, PacketByteBuf buf) { - super(null, sync); + public BagOfHoldingContainer(int sync, PlayerInventory inv) { + super(UContainers.BAG_OF_HOLDING, sync); + PlayerEntity player = inv.player; sourceStack = player.getStackInHand(Hand.MAIN_HAND); inventory = BagOfHoldingInventory.getInventoryFromStack(sourceStack); - inventory.onInvOpen(player); + inventory.onOpen(player); close(player); final int LEFT_MARGIN = 8; final int TOP_MARGIN = 18; - final int containerRows = (int)Math.ceil(inventory.getInvSize() / 9); - final int inventoryRows = (int)Math.ceil((player.inventory.getInvSize() - 9) / 9); + final int containerRows = (int)Math.ceil(inventory.size() / 9); + final int inventoryRows = (int)Math.ceil((player.inventory.size() - 9) / 9); - for (int i = 0; i < inventory.getInvSize(); i++) { + for (int i = 0; i < inventory.size(); i++) { int slotX = (i % 9) * 18; int slotY = (int)Math.floor(i / 9) * 18; @@ -39,7 +39,7 @@ public class BagOfHoldingContainer extends Container { int inventoryY = (containerRows * 18) + 8; int hotbarY = inventoryY + TOP_MARGIN + (inventoryRows * 18) + 4; - for (int i = 9; i < player.inventory.getInvSize() - 5; i++) { + for (int i = 9; i < player.inventory.size() - 5; i++) { int slotX = (i % 9) * 18; int slotY = (int)Math.floor(i / 9) * 18; @@ -54,7 +54,7 @@ public class BagOfHoldingContainer extends Container { @Override public void close(PlayerEntity player) { inventory.writeTostack(sourceStack); - inventory.onInvClose(player); + inventory.onClose(player); super.close(player); } @@ -73,11 +73,11 @@ public class BagOfHoldingContainer extends Container { ItemStack originalStack = slot.getStack(); resultingStack = originalStack.copy(); - if (index < inventory.getInvSize()) { - if (!insertItem(originalStack, inventory.getInvSize(), slots.size(), true)) { + if (index < inventory.size()) { + if (!insertItem(originalStack, inventory.size(), slots.size(), true)) { return ItemStack.EMPTY; } - } else if (!insertItem(originalStack, 0, inventory.getInvSize(), false)) { + } else if (!insertItem(originalStack, 0, inventory.size(), false)) { return ItemStack.EMPTY; } diff --git a/src/main/java/com/minelittlepony/unicopia/container/BagOfHoldingInventory.java b/src/main/java/com/minelittlepony/unicopia/world/container/BagOfHoldingInventory.java similarity index 87% rename from src/main/java/com/minelittlepony/unicopia/container/BagOfHoldingInventory.java rename to src/main/java/com/minelittlepony/unicopia/world/container/BagOfHoldingInventory.java index 884640ad..c0f0d52d 100644 --- a/src/main/java/com/minelittlepony/unicopia/container/BagOfHoldingInventory.java +++ b/src/main/java/com/minelittlepony/unicopia/world/container/BagOfHoldingInventory.java @@ -1,4 +1,4 @@ -package com.minelittlepony.unicopia.container; +package com.minelittlepony.unicopia.world.container; import java.util.ArrayList; import java.util.List; @@ -6,8 +6,8 @@ import java.util.Optional; import java.util.function.BiFunction; import com.minelittlepony.unicopia.UTags; -import com.minelittlepony.unicopia.advancement.BOHDeathCriterion; import com.minelittlepony.unicopia.util.NbtSerialisable; +import com.minelittlepony.unicopia.world.advancement.BOHDeathCriterion; import com.minelittlepony.unicopia.util.MagicalDamageSource; import net.minecraft.block.Block; @@ -19,8 +19,8 @@ import net.minecraft.entity.Entity; import net.minecraft.entity.ItemEntity; import net.minecraft.entity.mob.MobEntity; import net.minecraft.entity.player.PlayerEntity; -import net.minecraft.inventory.BasicInventory; import net.minecraft.inventory.Inventory; +import net.minecraft.inventory.SimpleInventory; import net.minecraft.item.ItemStack; import net.minecraft.item.SpawnEggItem; import net.minecraft.loot.context.LootContext; @@ -36,7 +36,7 @@ import net.minecraft.util.math.BlockPos; import net.minecraft.world.World; import net.minecraft.world.explosion.Explosion.DestructionType; -public class BagOfHoldingInventory extends BasicInventory implements NbtSerialisable { +public class BagOfHoldingInventory extends SimpleInventory implements NbtSerialisable { public static final int NBT_COMPOUND = 10; public static final int MIN_SIZE = 18; @@ -79,7 +79,7 @@ public class BagOfHoldingInventory extends BasicInventory implements NbtSerialis super(items.size() + 9 - (items.size() % 9)); for (int i = 0; i < items.size(); i++) { - setInvStack(i, items.get(i)); + setStack(i, items.get(i)); } if (source.hasCustomName()) { @@ -111,7 +111,7 @@ public class BagOfHoldingInventory extends BasicInventory implements NbtSerialis } } - add(stack); + addStack(stack); entity.remove(); if (entity instanceof MobEntity) { @@ -126,16 +126,17 @@ public class BagOfHoldingInventory extends BasicInventory implements NbtSerialis BlockEntity tile = state.getBlock().hasBlockEntity() ? world.getBlockEntity(pos) : null; LootContext.Builder context = new LootContext.Builder((ServerWorld)world) - .setRandom(world.random).put(LootContextParameters.POSITION, pos) - .put(LootContextParameters.TOOL, ItemStack.EMPTY) - .putNullable(LootContextParameters.BLOCK_ENTITY, tile); + .random(world.random) + .parameter(LootContextParameters.POSITION, pos) + .parameter(LootContextParameters.TOOL, ItemStack.EMPTY) + .optionalParameter(LootContextParameters.BLOCK_ENTITY, tile); ItemStack blockStack = state.getDroppedStacks(context).get(0); blockInventory.toTag(blockStack.getOrCreateSubTag("BlockEntityTag")); - for (int i = 0; i < blockInventory.getInvSize(); i++) { - ItemStack stack = blockInventory.getInvStack(i); + for (int i = 0; i < blockInventory.size(); i++) { + ItemStack stack = blockInventory.getStack(i); if (isIllegalItem(stack)) { blockStack.getSubTag("inventory").putBoolean("invalid", true); @@ -148,19 +149,19 @@ public class BagOfHoldingInventory extends BasicInventory implements NbtSerialis world.removeBlockEntity(pos); world.setBlockState(pos, Blocks.AIR.getDefaultState()); - add(blockStack); + addStack(blockStack); world.playSound(null, pos, SoundEvents.UI_TOAST_IN, SoundCategory.PLAYERS, 3.5F, 0.25F); } public void addItem(ItemEntity entity) { - add(entity.getStack()); + addStack(entity.getStack()); entity.remove(); entity.playSound(SoundEvents.UI_TOAST_IN, 3.5F, 0.25F); } @Override - public void onInvClose(PlayerEntity player) { + public void onClose(PlayerEntity player) { if (checkExplosionConditions()) { if (player instanceof ServerPlayerEntity) { BOHDeathCriterion.INSTANCE.trigger((ServerPlayerEntity)player); @@ -171,8 +172,8 @@ public class BagOfHoldingInventory extends BasicInventory implements NbtSerialis } protected boolean checkExplosionConditions() { - for (int i = 0; i < getInvSize(); i++) { - if (isIllegalItem(getInvStack(i))) { + for (int i = 0; i < size(); i++) { + if (isIllegalItem(getStack(i))) { return true; } } @@ -196,9 +197,9 @@ public class BagOfHoldingInventory extends BasicInventory implements NbtSerialis public void toNBT(CompoundTag compound) { ListTag nbtItems = new ListTag(); - for (int i = 0; i < getInvSize(); i++) { + for (int i = 0; i < size(); i++) { CompoundTag comp = new CompoundTag(); - ItemStack stack = getInvStack(i); + ItemStack stack = getStack(i); if (!isIllegalItem(stack)) { if (!stack.isEmpty()) { stack.toTag(comp); diff --git a/src/main/java/com/minelittlepony/unicopia/container/HeavyInventory.java b/src/main/java/com/minelittlepony/unicopia/world/container/HeavyInventory.java similarity index 92% rename from src/main/java/com/minelittlepony/unicopia/container/HeavyInventory.java rename to src/main/java/com/minelittlepony/unicopia/world/container/HeavyInventory.java index ade15406..f8734d50 100644 --- a/src/main/java/com/minelittlepony/unicopia/container/HeavyInventory.java +++ b/src/main/java/com/minelittlepony/unicopia/world/container/HeavyInventory.java @@ -1,4 +1,4 @@ -package com.minelittlepony.unicopia.container; +package com.minelittlepony.unicopia.world.container; import net.minecraft.block.Block; import net.minecraft.block.BlockEntityProvider; @@ -13,8 +13,8 @@ public class HeavyInventory { public static double getContentsTotalWorth(Inventory inventory, boolean deep) { double total = 0; - for (int i = 0; i < inventory.getInvSize(); i++) { - ItemStack stack = inventory.getInvStack(i); + for (int i = 0; i < inventory.size(); i++) { + ItemStack stack = inventory.getStack(i); double weightOfOne = decodeStackWeight(stack, deep); @@ -65,7 +65,7 @@ public class HeavyInventory { double weight = 0; if (te instanceof Inventory) { - te.fromTag(bet); + te.fromTag(b.getDefaultState(), bet); weight = getContentsTotalWorth((Inventory)te, deep); } diff --git a/src/main/java/com/minelittlepony/unicopia/container/SpellBookContainer.java b/src/main/java/com/minelittlepony/unicopia/world/container/SpellBookContainer.java similarity index 53% rename from src/main/java/com/minelittlepony/unicopia/container/SpellBookContainer.java rename to src/main/java/com/minelittlepony/unicopia/world/container/SpellBookContainer.java index 2f5cdf8a..e4ab424f 100644 --- a/src/main/java/com/minelittlepony/unicopia/container/SpellBookContainer.java +++ b/src/main/java/com/minelittlepony/unicopia/world/container/SpellBookContainer.java @@ -1,46 +1,46 @@ -package com.minelittlepony.unicopia.container; +package com.minelittlepony.unicopia.world.container; import javax.annotation.Nonnull; import com.minelittlepony.unicopia.AwaitTickQueue; import com.minelittlepony.unicopia.EquinePredicates; -import com.minelittlepony.unicopia.enchanting.IPageUnlockListener; -import com.minelittlepony.unicopia.entity.player.Pony; +import com.minelittlepony.unicopia.equine.player.Pony; import com.minelittlepony.unicopia.magic.spell.SpellRegistry; -import com.minelittlepony.unicopia.recipe.URecipes; +import com.minelittlepony.unicopia.world.recipe.URecipes; +import com.minelittlepony.unicopia.world.recipe.enchanting.IPageUnlockListener; -import net.minecraft.container.Container; -import net.minecraft.container.Slot; import net.minecraft.entity.player.PlayerEntity; -import net.minecraft.inventory.BasicInventory; +import net.minecraft.entity.player.PlayerInventory; +import net.minecraft.inventory.CraftingInventory; import net.minecraft.inventory.Inventory; +import net.minecraft.inventory.SimpleInventory; import net.minecraft.item.ItemStack; import net.minecraft.particle.ParticleTypes; import net.minecraft.recipe.Recipe; +import net.minecraft.screen.ScreenHandler; +import net.minecraft.screen.slot.Slot; import net.minecraft.sound.SoundEvents; -import net.minecraft.util.Identifier; -import net.minecraft.util.PacketByteBuf; import net.minecraft.world.World; import net.minecraft.world.explosion.Explosion.DestructionType; -public class SpellBookContainer extends Container { +public class SpellBookContainer extends ScreenHandler { - private final World worldObj; + private final World world; - private Inventory craftResult = new BasicInventory(1); + private Inventory result = new SimpleInventory(1); - private SpellBookInventory craftMatrix = new SpellBookInventory(craftResult, this, 5, 1); + private SBInventory input = new SBInventory(result, this, 5, 1); private IPageUnlockListener listener; - private SpellbookResultSlot resultSlot = null; + private SpellbookResultSlot output = null; private final PlayerEntity player; - public SpellBookContainer(int sync, Identifier id, PlayerEntity player, PacketByteBuf buf) { - super(null, sync); - worldObj = player.world; - this.player = player; + public SpellBookContainer(int sync, PlayerInventory inv) { + super(UContainers.SPELL_BOOK, sync); + world = inv.player.world; + this.player = inv.player; initCraftingSlots(); @@ -48,52 +48,52 @@ public class SpellBookContainer extends Container { addSlot(new Slot(player.inventory, i, 121 + i * 18, 195)); } - onContentChanged(craftMatrix); + onContentChanged(input); } public void setListener(IPageUnlockListener listener) { this.listener = listener; - if (resultSlot != null) { - resultSlot.setListener(listener); + if (output != null) { + output.setListener(listener); } } public void initCraftingSlots() { - addSlot(new SpellbookSlot(craftMatrix, 0, 175, 50)); - addSlot(new SpellbookSlot(craftMatrix, 1, 149, 94)); - addSlot(new SpellbookSlot(craftMatrix, 2, 175, 134)); - addSlot(new SpellbookSlot(craftMatrix, 3, 226, 120)); - addSlot(new SpellbookSlot(craftMatrix, 4, 227, 65)); - addSlot(resultSlot = new SpellbookResultSlot(listener, Pony.of(player), craftMatrix, craftResult, 0, 191, 92)); + addSlot(new InputSlot(input, 0, 175, 50)); + addSlot(new InputSlot(input, 1, 149, 94)); + addSlot(new InputSlot(input, 2, 175, 134)); + addSlot(new InputSlot(input, 3, 226, 120)); + addSlot(new InputSlot(input, 4, 227, 65)); + addSlot(output = new SpellbookResultSlot(listener, Pony.of(player), input, result, 0, 191, 92)); } @Override public void onContentChanged(Inventory inventoryIn) { - ItemStack current = craftResult.getInvStack(0); + ItemStack current = result.getStack(0); if (!current.isEmpty()) { - ItemStack crafted = player.world.getRecipeManager().getFirstMatch(URecipes.SPELL_BOOK, craftMatrix, worldObj) + ItemStack crafted = player.world.getRecipeManager().getFirstMatch(URecipes.SPELL_BOOK, input, world) .map(Recipe::getOutput) .orElse(ItemStack.EMPTY); if (!crafted.isEmpty()) { - resultSlot.setCrafted(true); + output.setCrafted(true); if (crafted.getItem() != current.getItem()) { - craftResult.setInvStack(0, ItemStack.EMPTY); - resultSlot.onTakeItem(player, crafted); + result.setStack(0, ItemStack.EMPTY); + output.onTakeItem(player, crafted); player.dropItem(crafted, true); player.playSound(SoundEvents.BLOCK_NOTE_BLOCK_SNARE, 1, 1); - worldObj.createExplosion(null, player.getX(), player.getY(), player.getZ(), 0, DestructionType.NONE); - worldObj.createExplosion(null, player.getX(), player.getY(), player.getZ(), 0, DestructionType.NONE); - worldObj.addParticle(ParticleTypes.EXPLOSION, player.getX(), player.getY(), player.getZ(), 1, 0, 0); + world.createExplosion(null, player.getX(), player.getY(), player.getZ(), 0, DestructionType.NONE); + world.createExplosion(null, player.getX(), player.getY(), player.getZ(), 0, DestructionType.NONE); + world.addParticle(ParticleTypes.EXPLOSION, player.getX(), player.getY(), player.getZ(), 1, 0, 0); - AwaitTickQueue.scheduleTask(player.world, w -> player.container.close(player), 0); + AwaitTickQueue.scheduleTask(player.world, w -> player.currentScreenHandler.close(player), 0); return; } @@ -103,11 +103,11 @@ public class SpellBookContainer extends Container { } else { current = SpellRegistry.instance().disenchantStack(current); - resultSlot.setCrafted(false); + output.setCrafted(false); player.playSound(SoundEvents.BLOCK_NOTE_BLOCK_BASS, 1, 1); } - craftResult.setInvStack(0, current); + result.setStack(0, current); } } @@ -122,7 +122,7 @@ public class SpellBookContainer extends Container { stack = slotStack.copy(); if (index > 5) { - if (!resultSlot.hasStack() && resultSlot.canInsert(stack)) { + if (!output.hasStack() && output.canInsert(stack)) { if (!insertItem(slotStack, 5, 6, false)) { return ItemStack.EMPTY; } @@ -135,7 +135,7 @@ public class SpellBookContainer extends Container { } slot.onStackChanged(slotStack, stack); - onContentChanged(craftMatrix); + onContentChanged(input); } if (slotStack.getCount() == stack.getCount()) { @@ -150,8 +150,8 @@ public class SpellBookContainer extends Container { @Override public void close(PlayerEntity player) { - dropInventory(player, worldObj, craftMatrix); - dropInventory(player, worldObj, craftResult); + dropInventory(player, world, input); + dropInventory(player, world, result); super.close(player); } @@ -160,9 +160,9 @@ public class SpellBookContainer extends Container { return EquinePredicates.PLAYER_UNICORN.test(player); } - public static class SpellbookSlot extends Slot { + public static class InputSlot extends Slot { - public SpellbookSlot(Inventory inventoryIn, int index, int xPosition, int yPosition) { + public InputSlot(Inventory inventoryIn, int index, int xPosition, int yPosition) { super(inventoryIn, index, xPosition, yPosition); } @@ -170,4 +170,18 @@ public class SpellBookContainer extends Container { return true; } } + + public static class SBInventory extends CraftingInventory { + + private final Inventory craftResult; + + public SBInventory(Inventory resultMatrix, ScreenHandler eventHandler, int width, int height) { + super(eventHandler, width, height); + craftResult = resultMatrix; + } + + public Inventory getCraftResultMatrix() { + return craftResult; + } + } } diff --git a/src/main/java/com/minelittlepony/unicopia/container/SpellbookResultSlot.java b/src/main/java/com/minelittlepony/unicopia/world/container/SpellbookResultSlot.java similarity index 66% rename from src/main/java/com/minelittlepony/unicopia/container/SpellbookResultSlot.java rename to src/main/java/com/minelittlepony/unicopia/world/container/SpellbookResultSlot.java index 4f3cf42a..a1ac5d26 100644 --- a/src/main/java/com/minelittlepony/unicopia/container/SpellbookResultSlot.java +++ b/src/main/java/com/minelittlepony/unicopia/world/container/SpellbookResultSlot.java @@ -1,32 +1,33 @@ -package com.minelittlepony.unicopia.container; +package com.minelittlepony.unicopia.world.container; -import com.minelittlepony.unicopia.enchanting.IPageUnlockListener; -import com.minelittlepony.unicopia.enchanting.SpellCraftingEvent; -import com.minelittlepony.unicopia.entity.player.Pony; -import com.minelittlepony.unicopia.item.MagicGemItem; +import com.minelittlepony.unicopia.equine.player.Pony; import com.minelittlepony.unicopia.magic.spell.SpellRegistry; -import com.minelittlepony.unicopia.recipe.URecipes; +import com.minelittlepony.unicopia.world.container.SpellBookContainer.SBInventory; +import com.minelittlepony.unicopia.world.item.MagicGemItem; +import com.minelittlepony.unicopia.world.recipe.URecipes; +import com.minelittlepony.unicopia.world.recipe.enchanting.IPageUnlockListener; +import com.minelittlepony.unicopia.world.recipe.enchanting.SpellCraftingEvent; import com.mojang.datafixers.util.Pair; -import net.minecraft.container.PlayerContainer; import net.minecraft.entity.player.PlayerEntity; import net.minecraft.inventory.Inventory; import net.minecraft.item.ItemStack; import net.minecraft.item.MusicDiscItem; -import net.minecraft.util.DefaultedList; +import net.minecraft.screen.PlayerScreenHandler; import net.minecraft.util.Identifier; +import net.minecraft.util.collection.DefaultedList; -public class SpellbookResultSlot extends SpellBookContainer.SpellbookSlot { +public class SpellbookResultSlot extends SpellBookContainer.InputSlot { public static final Identifier EMPTY_GEM_SLOT = new Identifier("unicopia", "item/empty_gem_slot"); private final Pony player; - private final SpellBookInventory craftMatrix; + private final SBInventory craftMatrix; private IPageUnlockListener listener; private boolean crafted; - public SpellbookResultSlot(IPageUnlockListener listener, Pony player, SpellBookInventory craftMatric, Inventory inventory, int index, int xPosition, int yPosition) { + public SpellbookResultSlot(IPageUnlockListener listener, Pony player, SBInventory craftMatric, Inventory inventory, int index, int xPosition, int yPosition) { super(inventory, index, xPosition, yPosition); this.player = player; this.listener = listener; @@ -46,27 +47,27 @@ public class SpellbookResultSlot extends SpellBookContainer.SpellbookSlot { if (crafted) { onCrafted(stack); - ItemStack current = craftMatrix.getCraftResultMatrix().getInvStack(0); - craftMatrix.getCraftResultMatrix().setInvStack(0, stack); + ItemStack current = craftMatrix.getCraftResultMatrix().getStack(0); + craftMatrix.getCraftResultMatrix().setStack(0, stack); DefaultedList remaining = player.world.getRecipeManager().getRemainingStacks(URecipes.SPELL_BOOK, craftMatrix, player.world); - craftMatrix.getCraftResultMatrix().setInvStack(0, current); + craftMatrix.getCraftResultMatrix().setStack(0, current); for (int i = 0; i < remaining.size(); ++i) { - current = craftMatrix.getInvStack(i); + current = craftMatrix.getStack(i); ItemStack remainder = remaining.get(i); if (!current.isEmpty()) { if (current.getCount() < stack.getCount()) { - craftMatrix.setInvStack(i, ItemStack.EMPTY); + craftMatrix.setStack(i, ItemStack.EMPTY); } else { - craftMatrix.takeInvStack(i, stack.getCount()); + craftMatrix.removeStack(i, stack.getCount()); } if (!remainder.isEmpty()) { - if (craftMatrix.getInvStack(i).isEmpty()) { - craftMatrix.setInvStack(i, remainder); + if (craftMatrix.getStack(i).isEmpty()) { + craftMatrix.setStack(i, remainder); } else { remainder.setCount(stack.getCount()); if (!player.inventory.insertStack(remainder)) { @@ -99,6 +100,6 @@ public class SpellbookResultSlot extends SpellBookContainer.SpellbookSlot { @Override public Pair getBackgroundSprite() { - return Pair.of(PlayerContainer.BLOCK_ATLAS_TEXTURE, EMPTY_GEM_SLOT); + return Pair.of(PlayerScreenHandler.BLOCK_ATLAS_TEXTURE, EMPTY_GEM_SLOT); } } \ No newline at end of file diff --git a/src/main/java/com/minelittlepony/unicopia/world/container/UContainers.java b/src/main/java/com/minelittlepony/unicopia/world/container/UContainers.java new file mode 100644 index 00000000..a7d6bd10 --- /dev/null +++ b/src/main/java/com/minelittlepony/unicopia/world/container/UContainers.java @@ -0,0 +1,19 @@ +package com.minelittlepony.unicopia.world.container; + +import net.fabricmc.fabric.api.screenhandler.v1.ScreenHandlerRegistry; +import net.fabricmc.fabric.api.screenhandler.v1.ScreenHandlerRegistry.SimpleClientHandlerFactory; +import net.minecraft.screen.ScreenHandler; +import net.minecraft.screen.ScreenHandlerType; +import net.minecraft.util.Identifier; + +public interface UContainers { + + ScreenHandlerType BAG_OF_HOLDING = register("bag_of_holding", BagOfHoldingContainer::new); + ScreenHandlerType SPELL_BOOK = register("spell_book", SpellBookContainer::new); + + static ScreenHandlerType register(String name, SimpleClientHandlerFactory factory) { + return ScreenHandlerRegistry.registerSimple(new Identifier("unicopia", name), factory); + } + + static void bootstrap() { } +} diff --git a/src/main/java/com/minelittlepony/unicopia/entity/ButterflyEntity.java b/src/main/java/com/minelittlepony/unicopia/world/entity/ButterflyEntity.java similarity index 90% rename from src/main/java/com/minelittlepony/unicopia/entity/ButterflyEntity.java rename to src/main/java/com/minelittlepony/unicopia/world/entity/ButterflyEntity.java index d776362b..ee16ab37 100644 --- a/src/main/java/com/minelittlepony/unicopia/entity/ButterflyEntity.java +++ b/src/main/java/com/minelittlepony/unicopia/world/entity/ButterflyEntity.java @@ -1,4 +1,4 @@ -package com.minelittlepony.unicopia.entity; +package com.minelittlepony.unicopia.world.entity; import java.util.Random; @@ -8,7 +8,8 @@ import net.minecraft.block.BlockState; import net.minecraft.entity.Entity; import net.minecraft.entity.EntityPose; import net.minecraft.entity.EntityType; -import net.minecraft.entity.SpawnType; +import net.minecraft.entity.SpawnReason; +import net.minecraft.entity.attribute.DefaultAttributeContainer; import net.minecraft.entity.attribute.EntityAttributes; import net.minecraft.entity.damage.DamageSource; import net.minecraft.entity.data.DataTracker; @@ -22,8 +23,8 @@ import net.minecraft.util.Identifier; import net.minecraft.util.math.BlockPos; import net.minecraft.util.math.MathHelper; import net.minecraft.util.math.Vec3d; -import net.minecraft.world.IWorld; import net.minecraft.world.World; +import net.minecraft.world.WorldAccess; import net.minecraft.world.biome.Biome.SpawnEntry; public class ButterflyEntity extends AmbientEntity { @@ -42,6 +43,10 @@ public class ButterflyEntity extends AmbientEntity { setResting(true); } + public static DefaultAttributeContainer.Builder createButterflyAttributes() { + return createLivingAttributes().add(EntityAttributes.GENERIC_MAX_HEALTH, 2); + } + @Nullable @Override protected SoundEvent getHurtSound(DamageSource damageSourceIn) { @@ -54,12 +59,6 @@ public class ButterflyEntity extends AmbientEntity { return null; } - @Override - protected void initAttributes() { - super.initAttributes(); - getAttributeInstance(EntityAttributes.MAX_HEALTH).setBaseValue(2); - } - @Override protected void initDataTracker() { super.initDataTracker(); @@ -114,7 +113,7 @@ public class ButterflyEntity extends AmbientEntity { return false; } - if (player.isSprinting() || player.isHandSwinging || player.forwardSpeed > 0 || player.sidewaysSpeed > 0) { + if (player.isSprinting() || player.handSwinging || player.forwardSpeed > 0 || player.sidewaysSpeed > 0) { return true; } } else if (!EntityPredicates.EXCEPT_CREATIVE_OR_SPECTATOR.test(e)) { @@ -191,11 +190,8 @@ public class ButterflyEntity extends AmbientEntity { } @Override - public boolean canSpawn(IWorld world, SpawnType type) { - if (type == SpawnType.NATURAL) { - return getY() < world.getSeaLevel() && world.getLightLevel(getBlockPos()) > 7; - } - return true; + public boolean canSpawn(WorldAccess world, SpawnReason reason) { + return reason != SpawnReason.NATURAL || (getY() < world.getSeaLevel() && world.getLightLevel(getBlockPos()) > 7); } @Override diff --git a/src/main/java/com/minelittlepony/unicopia/entity/CloudEntity.java b/src/main/java/com/minelittlepony/unicopia/world/entity/CloudEntity.java similarity index 93% rename from src/main/java/com/minelittlepony/unicopia/entity/CloudEntity.java rename to src/main/java/com/minelittlepony/unicopia/world/entity/CloudEntity.java index 662088c5..b462c9f2 100644 --- a/src/main/java/com/minelittlepony/unicopia/entity/CloudEntity.java +++ b/src/main/java/com/minelittlepony/unicopia/world/entity/CloudEntity.java @@ -1,4 +1,4 @@ -package com.minelittlepony.unicopia.entity; +package com.minelittlepony.unicopia.world.entity; import java.util.Map; @@ -6,13 +6,15 @@ import javax.annotation.Nullable; import com.google.common.collect.Streams; import com.minelittlepony.unicopia.EquinePredicates; +import com.minelittlepony.unicopia.InAnimate; import com.minelittlepony.unicopia.Race; -import com.minelittlepony.unicopia.ability.PegasusCloudInteractionAbility.ICloudEntity; -import com.minelittlepony.unicopia.block.UBlocks; -import com.minelittlepony.unicopia.entity.player.Pony; -import com.minelittlepony.unicopia.item.UItems; +import com.minelittlepony.unicopia.ability.PegasusCloudInteractionAbility.Interactable; +import com.minelittlepony.unicopia.equine.Ponylike; +import com.minelittlepony.unicopia.equine.player.Pony; import com.minelittlepony.unicopia.particles.ParticleEmitter; import com.minelittlepony.unicopia.particles.UParticles; +import com.minelittlepony.unicopia.world.block.UBlocks; +import com.minelittlepony.unicopia.world.item.UItems; import net.minecraft.block.BlockState; import net.minecraft.block.Blocks; @@ -31,7 +33,7 @@ import net.minecraft.entity.ItemEntity; import net.minecraft.entity.LightningEntity; import net.minecraft.entity.LivingEntity; import net.minecraft.entity.MovementType; -import net.minecraft.entity.SpawnType; +import net.minecraft.entity.SpawnReason; import net.minecraft.entity.damage.DamageSource; import net.minecraft.entity.data.DataTracker; import net.minecraft.entity.data.TrackedData; @@ -55,12 +57,12 @@ import net.minecraft.util.math.Box; import net.minecraft.util.math.MathHelper; import net.minecraft.util.math.Vec3d; import net.minecraft.world.Heightmap; -import net.minecraft.world.IWorld; import net.minecraft.world.LocalDifficulty; import net.minecraft.world.World; +import net.minecraft.world.WorldAccess; import net.minecraft.world.biome.Biome; -public class CloudEntity extends FlyingEntity implements ICloudEntity, InAnimate { +public class CloudEntity extends FlyingEntity implements Interactable, InAnimate { private static final TrackedData RAINTIMER = DataTracker.registerData(CloudEntity.class, TrackedDataHandlerRegistry.INTEGER); private static final TrackedData THUNDERING = DataTracker.registerData(CloudEntity.class, TrackedDataHandlerRegistry.BOOLEAN); @@ -132,7 +134,7 @@ public class CloudEntity extends FlyingEntity implements ICloudEntity, InAnimate } @Override - public EntityData initialize(IWorld world, LocalDifficulty difficulty, SpawnType type, @Nullable EntityData data, @Nullable CompoundTag tag) { + public EntityData initialize(WorldAccess world, LocalDifficulty difficulty, SpawnReason type, @Nullable EntityData data, @Nullable CompoundTag tag) { if (random.nextInt(20) == 0 && canRainHere()) { setRaining(); if (random.nextInt(20) == 0) { @@ -174,9 +176,9 @@ public class CloudEntity extends FlyingEntity implements ICloudEntity, InAnimate if (getIsRaining()) { if (world.isClient) { for (int i = 0; i < 30 * getCloudSize(); i++) { - double x = MathHelper.nextDouble(random, boundingbox.x1, boundingbox.x2); - double y = getBoundingBox().y1 + getHeight()/2; - double z = MathHelper.nextDouble(random, boundingbox.z1, boundingbox.z2); + double x = MathHelper.nextDouble(random, boundingbox.minX, boundingbox.maxX); + double y = getBoundingBox().minY + getHeight()/2; + double z = MathHelper.nextDouble(random, boundingbox.minZ, boundingbox.maxZ); ParticleEffect particleId = canSnowHere(new BlockPos(x, y, z)) ? ParticleTypes.ITEM_SNOWBALL : UParticles.RAIN_DROPS; @@ -283,9 +285,9 @@ public class CloudEntity extends FlyingEntity implements ICloudEntity, InAnimate if (isOnFire() && !dead) { for (int i = 0; i < 5; i++) { world.addParticle(ParticleTypes.CLOUD, - MathHelper.nextDouble(random, boundingbox.x1, boundingbox.x2), - MathHelper.nextDouble(random, boundingbox.y1, boundingbox.y2), - MathHelper.nextDouble(random, boundingbox.z1, boundingbox.z2), 0, 0.25, 0); + MathHelper.nextDouble(random, boundingbox.minX, boundingbox.maxX), + MathHelper.nextDouble(random, boundingbox.minY, boundingbox.maxY), + MathHelper.nextDouble(random, boundingbox.minZ, boundingbox.maxZ), 0, 0.25, 0); } } @@ -306,7 +308,7 @@ public class CloudEntity extends FlyingEntity implements ICloudEntity, InAnimate @Override public double getMountedHeightOffset() { - return getBoundingBox().y2 - getBoundingBox().y1 - 0.25; + return getBoundingBox().maxY - getBoundingBox().minY - 0.25; } @Override @@ -368,24 +370,18 @@ public class CloudEntity extends FlyingEntity implements ICloudEntity, InAnimate } protected float getRandomFlyingHeight() { - float a = getMaximumFlyingHeight(); float b = getMinimumFlyingHeight(); + float a = b + getMaximumAltitude(); return MathHelper.lerp(world.random.nextFloat(), Math.min(a, b), Math.max(a, b)); } protected float getMinimumFlyingHeight() { - float ground = world.getBiome(getBlockPos()).getDepth(); - float cloud = world.getDimension().getCloudHeight(); - - float min = Math.min(ground, cloud); - float max = Math.max(ground, cloud); - - return min + (max - min)/2; + return world.getTopY(Heightmap.Type.WORLD_SURFACE, MathHelper.floor(getX()), MathHelper.floor(getZ())); } - protected float getMaximumFlyingHeight() { - return world.getDimension().getCloudHeight() - 5; + protected int getMaximumAltitude() { + return 15; } @Override @@ -434,7 +430,7 @@ public class CloudEntity extends FlyingEntity implements ICloudEntity, InAnimate ItemStack stack = player.getMainHandStack(); - boolean canFly = EnchantmentHelper.getEnchantments(stack).containsKey(Enchantments.FEATHER_FALLING) + boolean canFly = EnchantmentHelper.get(stack).containsKey(Enchantments.FEATHER_FALLING) || EquinePredicates.PLAYER_PEGASUS.test(player); boolean stat = getStationary(); @@ -539,7 +535,7 @@ public class CloudEntity extends FlyingEntity implements ICloudEntity, InAnimate double bounceModifier = entity.fallDistance > 80 ? 80 : MathHelper.floor(entity.fallDistance * 10) / 10; - entity.onGround = true; + entity.setOnGround(true); Vec3d motion = entity.getVelocity(); double motionX = motion.x; @@ -612,7 +608,7 @@ public class CloudEntity extends FlyingEntity implements ICloudEntity, InAnimate public static int getFeatherEnchantStrength(ItemStack stack) { if (stack != null && !stack.isEmpty()) { - Map enchantments = EnchantmentHelper.getEnchantments(stack); + Map enchantments = EnchantmentHelper.get(stack); if (enchantments.containsKey(Enchantments.FEATHER_FALLING)) { return enchantments.get(Enchantments.FEATHER_FALLING); } @@ -634,7 +630,9 @@ public class CloudEntity extends FlyingEntity implements ICloudEntity, InAnimate public void spawnThunderbolt(BlockPos pos) { if (world instanceof ServerWorld) { - ((ServerWorld)world).addLightning(new LightningEntity(world, pos.getX(), pos.getY(), pos.getZ(), false)); + LightningEntity lightning = EntityType.LIGHTNING_BOLT.create(world); + lightning.positAfterTeleport(pos.getX(), pos.getY(), pos.getZ()); + world.spawnEntity(lightning); } } @@ -642,7 +640,7 @@ public class CloudEntity extends FlyingEntity implements ICloudEntity, InAnimate BlockPos pos = world.getTopPosition(Heightmap.Type.WORLD_SURFACE, inPos); if (pos.getY() >= getY()) { - while (World.isValid(pos)) { + while (!World.isHeightInvalid(pos)) { pos = pos.down(); if (world.getBlockState(pos).hasSolidTopSurface(world, pos, this)) { return pos.up(); diff --git a/src/main/java/com/minelittlepony/unicopia/entity/ConstructionCloudEntity.java b/src/main/java/com/minelittlepony/unicopia/world/entity/ConstructionCloudEntity.java similarity index 98% rename from src/main/java/com/minelittlepony/unicopia/entity/ConstructionCloudEntity.java rename to src/main/java/com/minelittlepony/unicopia/world/entity/ConstructionCloudEntity.java index 5ac8235b..9d8559d1 100644 --- a/src/main/java/com/minelittlepony/unicopia/entity/ConstructionCloudEntity.java +++ b/src/main/java/com/minelittlepony/unicopia/world/entity/ConstructionCloudEntity.java @@ -1,4 +1,4 @@ -package com.minelittlepony.unicopia.entity; +package com.minelittlepony.unicopia.world.entity; import com.minelittlepony.unicopia.EquinePredicates; diff --git a/src/main/java/com/minelittlepony/unicopia/entity/CucoonEntity.java b/src/main/java/com/minelittlepony/unicopia/world/entity/CucoonEntity.java similarity index 93% rename from src/main/java/com/minelittlepony/unicopia/entity/CucoonEntity.java rename to src/main/java/com/minelittlepony/unicopia/world/entity/CucoonEntity.java index 635ecb0a..96397309 100644 --- a/src/main/java/com/minelittlepony/unicopia/entity/CucoonEntity.java +++ b/src/main/java/com/minelittlepony/unicopia/world/entity/CucoonEntity.java @@ -1,17 +1,20 @@ -package com.minelittlepony.unicopia.entity; +package com.minelittlepony.unicopia.world.entity; import java.util.Collections; import javax.annotation.Nullable; import com.minelittlepony.unicopia.EquinePredicates; +import com.minelittlepony.unicopia.InAnimate; import com.minelittlepony.unicopia.Race; import com.minelittlepony.unicopia.USounds; -import com.minelittlepony.unicopia.entity.player.Pony; +import com.minelittlepony.unicopia.equine.Trap; +import com.minelittlepony.unicopia.equine.player.Pony; +import com.minelittlepony.unicopia.magic.Magical; import com.minelittlepony.unicopia.particles.UParticles; import com.minelittlepony.unicopia.util.MagicalDamageSource; -import net.fabricmc.fabric.api.tools.FabricToolTags; +import net.fabricmc.fabric.api.tool.attribute.v1.FabricToolTags; import net.minecraft.block.Blocks; import net.minecraft.entity.Entity; import net.minecraft.entity.EntityDimensions; @@ -40,7 +43,7 @@ import net.minecraft.util.math.Vec3d; import net.minecraft.world.GameRules; import net.minecraft.world.World; -public class CucoonEntity extends LivingEntity implements IMagicals, InAnimate, Trap { +public class CucoonEntity extends LivingEntity implements Magical, InAnimate, Trap { private static final TrackedData STRUGGLE_COUNT = DataTracker.registerData(CucoonEntity.class, TrackedDataHandlerRegistry.INTEGER); @@ -135,11 +138,11 @@ public class CucoonEntity extends LivingEntity implements IMagicals, InAnimate, if (passenger instanceof LivingEntity) { LivingEntity living = (LivingEntity)passenger; - if (!living.hasStatusEffect(StatusEffects.REGENERATION) && living.getHealth() < living.getMaximumHealth()) { + if (!living.hasStatusEffect(StatusEffects.REGENERATION) && living.getHealth() < living.getMaxHealth()) { living.addStatusEffect(new StatusEffectInstance(StatusEffects.REGENERATION, 20, 2)); } - if (!living.hasStatusEffect(StatusEffects.SLOWNESS) && living.getHealth() < living.getMaximumHealth()) { + if (!living.hasStatusEffect(StatusEffects.SLOWNESS) && living.getHealth() < living.getMaxHealth()) { living.addStatusEffect(new StatusEffectInstance(StatusEffects.SLOWNESS, 2000, 4)); } } @@ -162,7 +165,7 @@ public class CucoonEntity extends LivingEntity implements IMagicals, InAnimate, if (hand == Hand.MAIN_HAND && EquinePredicates.PLAYER_CHANGELING.test(player)) { Entity passenger = getPrimaryPassenger(); - if (passenger != null && (player.canConsume(false) || player.getHealth() < player.getMaximumHealth())) { + if (passenger != null && (player.canConsume(false) || player.getHealth() < player.getMaxHealth())) { DamageSource d = MagicalDamageSource.causePlayerDamage("feed", player); Pony.of(player).spawnParticles(UParticles.CHANGELING_MAGIC, 7); @@ -245,7 +248,7 @@ public class CucoonEntity extends LivingEntity implements IMagicals, InAnimate, @Override protected void updatePostDeath() { if (++deathTime == 20) { - if (!world.isClient && lastAttackedTicks > 0 && canDropLootAndXp() && world.getGameRules().getBoolean(GameRules.DO_MOB_LOOT)) { + if (!world.isClient && lastAttackedTicks > 0 && canDropLootAndXp() && world.getGameRules().getBoolean(GameRules.DO_ENTITY_DROPS)) { int i = getCurrentExperience(attackingPlayer); while (i > 0) { diff --git a/src/main/java/com/minelittlepony/unicopia/entity/FollowCasterGoal.java b/src/main/java/com/minelittlepony/unicopia/world/entity/FollowCasterGoal.java similarity index 96% rename from src/main/java/com/minelittlepony/unicopia/entity/FollowCasterGoal.java rename to src/main/java/com/minelittlepony/unicopia/world/entity/FollowCasterGoal.java index ec097f88..1f08dc51 100644 --- a/src/main/java/com/minelittlepony/unicopia/entity/FollowCasterGoal.java +++ b/src/main/java/com/minelittlepony/unicopia/world/entity/FollowCasterGoal.java @@ -1,4 +1,4 @@ -package com.minelittlepony.unicopia.entity; +package com.minelittlepony.unicopia.world.entity; import java.util.EnumSet; @@ -17,6 +17,7 @@ import net.minecraft.util.math.BlockPos; import net.minecraft.util.math.MathHelper; import net.minecraft.world.WorldView; +@Deprecated public class FollowCasterGoal extends Goal { protected final Caster caster; @@ -108,7 +109,7 @@ public class FollowCasterGoal extends Goal { } int x = MathHelper.floor(owner.getX()) - 2; - int y = MathHelper.floor(owner.getBoundingBox().y1); + int y = MathHelper.floor(owner.getBoundingBox().minY); int z = MathHelper.floor(owner.getZ()) - 2; for (int offX = 0; offX <= 4; offX++) { diff --git a/src/main/java/com/minelittlepony/unicopia/entity/ProjectileEntity.java b/src/main/java/com/minelittlepony/unicopia/world/entity/MagicProjectileEntity.java similarity index 89% rename from src/main/java/com/minelittlepony/unicopia/entity/ProjectileEntity.java rename to src/main/java/com/minelittlepony/unicopia/world/entity/MagicProjectileEntity.java index df1ac8fd..eda8bcc0 100644 --- a/src/main/java/com/minelittlepony/unicopia/entity/ProjectileEntity.java +++ b/src/main/java/com/minelittlepony/unicopia/world/entity/MagicProjectileEntity.java @@ -1,19 +1,20 @@ -package com.minelittlepony.unicopia.entity; +package com.minelittlepony.unicopia.world.entity; import java.util.UUID; import com.minelittlepony.unicopia.magic.Affinity; import com.minelittlepony.unicopia.magic.Caster; import com.minelittlepony.unicopia.magic.EtherialListener; +import com.minelittlepony.unicopia.magic.Magical; import com.minelittlepony.unicopia.magic.Spell; import com.minelittlepony.unicopia.magic.ThrowableSpell; import com.minelittlepony.unicopia.magic.spell.SpellRegistry; import com.minelittlepony.unicopia.network.Channel; import com.minelittlepony.unicopia.network.EffectSync; import com.minelittlepony.unicopia.network.MsgSpawnProjectile; -import com.minelittlepony.unicopia.util.projectile.AdvancedProjectile; +import com.minelittlepony.unicopia.util.projectile.Projectile; import com.minelittlepony.unicopia.util.projectile.Tossable; -import com.minelittlepony.unicopia.util.projectile.TossableItem; +import com.minelittlepony.unicopia.world.TossableItem; import net.minecraft.entity.Entity; import net.minecraft.entity.EntityType; @@ -22,7 +23,7 @@ import net.minecraft.entity.damage.DamageSource; import net.minecraft.entity.data.DataTracker; import net.minecraft.entity.data.TrackedData; import net.minecraft.entity.data.TrackedDataHandlerRegistry; -import net.minecraft.entity.thrown.ThrownItemEntity; +import net.minecraft.entity.projectile.thrown.ThrownItemEntity; import net.minecraft.item.Item; import net.minecraft.item.ItemStack; import net.minecraft.item.Items; @@ -44,11 +45,11 @@ import net.minecraft.world.World; * * Can also carry a spell if needed. */ -public class ProjectileEntity extends ThrownItemEntity implements IMagicals, AdvancedProjectile, Caster { +public class MagicProjectileEntity extends ThrownItemEntity implements Magical, Projectile, Caster { - private static final TrackedData DAMAGE = DataTracker.registerData(ProjectileEntity.class, TrackedDataHandlerRegistry.FLOAT); - private static final TrackedData HYDROPHOBIC = DataTracker.registerData(ProjectileEntity.class, TrackedDataHandlerRegistry.BOOLEAN); - private static final TrackedData EFFECT = DataTracker.registerData(ProjectileEntity.class, TrackedDataHandlerRegistry.TAG_COMPOUND); + private static final TrackedData DAMAGE = DataTracker.registerData(MagicProjectileEntity.class, TrackedDataHandlerRegistry.FLOAT); + private static final TrackedData HYDROPHOBIC = DataTracker.registerData(MagicProjectileEntity.class, TrackedDataHandlerRegistry.BOOLEAN); + private static final TrackedData EFFECT = DataTracker.registerData(MagicProjectileEntity.class, TrackedDataHandlerRegistry.TAG_COMPOUND); private final EffectSync effectDelegate = new EffectSync(this, EFFECT); @@ -56,16 +57,16 @@ public class ProjectileEntity extends ThrownItemEntity implements IMagicals, Adv private BlockPos lastBlockPos; - public ProjectileEntity(EntityType type, World world) { + public MagicProjectileEntity(EntityType type, World world) { super(type, world); } - public ProjectileEntity(EntityType type, World world, LivingEntity thrower) { + public MagicProjectileEntity(EntityType type, World world, LivingEntity thrower) { this(type, world, thrower.getX(), thrower.getY() + thrower.getStandingEyeHeight(), thrower.getZ()); setOwner(thrower); } - public ProjectileEntity(EntityType type, World world, double x, double y, double z) { + public MagicProjectileEntity(EntityType type, World world, double x, double y, double z) { super(type, world); setPos(x, y, z); @@ -288,7 +289,7 @@ public class ProjectileEntity extends ThrownItemEntity implements IMagicals, Adv protected void onHitEntity(EntityHitResult hit) { Entity entity = hit.getEntity(); - if (entity instanceof AdvancedProjectile) { + if (entity instanceof Projectile) { return; } diff --git a/src/main/java/com/minelittlepony/unicopia/entity/RacingCloudEntity.java b/src/main/java/com/minelittlepony/unicopia/world/entity/RacingCloudEntity.java similarity index 97% rename from src/main/java/com/minelittlepony/unicopia/entity/RacingCloudEntity.java rename to src/main/java/com/minelittlepony/unicopia/world/entity/RacingCloudEntity.java index 488528ad..1e50d1ae 100644 --- a/src/main/java/com/minelittlepony/unicopia/entity/RacingCloudEntity.java +++ b/src/main/java/com/minelittlepony/unicopia/world/entity/RacingCloudEntity.java @@ -1,4 +1,4 @@ -package com.minelittlepony.unicopia.entity; +package com.minelittlepony.unicopia.world.entity; import java.util.List; diff --git a/src/main/java/com/minelittlepony/unicopia/entity/RainbowEntity.java b/src/main/java/com/minelittlepony/unicopia/world/entity/RainbowEntity.java similarity index 93% rename from src/main/java/com/minelittlepony/unicopia/entity/RainbowEntity.java rename to src/main/java/com/minelittlepony/unicopia/world/entity/RainbowEntity.java index 60abec5f..55252a36 100644 --- a/src/main/java/com/minelittlepony/unicopia/entity/RainbowEntity.java +++ b/src/main/java/com/minelittlepony/unicopia/world/entity/RainbowEntity.java @@ -1,5 +1,6 @@ -package com.minelittlepony.unicopia.entity; +package com.minelittlepony.unicopia.world.entity; +import com.minelittlepony.unicopia.InAnimate; import com.minelittlepony.unicopia.Race; import com.minelittlepony.unicopia.network.Channel; import com.minelittlepony.unicopia.network.MsgSpawnRainbow; @@ -8,15 +9,15 @@ import net.minecraft.entity.Entity; import net.minecraft.entity.EntityDimensions; import net.minecraft.entity.EntityPose; import net.minecraft.entity.EntityType; -import net.minecraft.entity.SpawnType; +import net.minecraft.entity.SpawnReason; import net.minecraft.entity.mob.MobEntity; import net.minecraft.nbt.CompoundTag; import net.minecraft.network.Packet; import net.minecraft.sound.SoundCategory; import net.minecraft.util.math.Box; import net.minecraft.util.math.MathHelper; -import net.minecraft.world.IWorld; import net.minecraft.world.World; +import net.minecraft.world.WorldAccess; import net.minecraft.world.biome.Biome.SpawnEntry; public class RainbowEntity extends MobEntity implements InAnimate { @@ -108,7 +109,7 @@ public class RainbowEntity extends MobEntity implements InAnimate { } @Override - public boolean canSpawn(IWorld world, SpawnType type) { + public boolean canSpawn(WorldAccess world, SpawnReason type) { Box bounds = SPAWN_COLLISSION_RADIUS.offset(getPos()); diff --git a/src/main/java/com/minelittlepony/unicopia/entity/SpearEntity.java b/src/main/java/com/minelittlepony/unicopia/world/entity/SpearEntity.java similarity index 94% rename from src/main/java/com/minelittlepony/unicopia/entity/SpearEntity.java rename to src/main/java/com/minelittlepony/unicopia/world/entity/SpearEntity.java index 45edda83..4bc57273 100644 --- a/src/main/java/com/minelittlepony/unicopia/entity/SpearEntity.java +++ b/src/main/java/com/minelittlepony/unicopia/world/entity/SpearEntity.java @@ -1,10 +1,9 @@ -package com.minelittlepony.unicopia.entity; +package com.minelittlepony.unicopia.world.entity; import com.minelittlepony.unicopia.magic.ThrowableSpell; import com.minelittlepony.unicopia.util.MagicalDamageSource; -import com.minelittlepony.unicopia.util.projectile.AdvancedProjectile; +import com.minelittlepony.unicopia.util.projectile.Projectile; -import net.minecraft.client.network.packet.GameStateChangeS2CPacket; import net.minecraft.enchantment.EnchantmentHelper; import net.minecraft.entity.Entity; import net.minecraft.entity.EntityType; @@ -18,6 +17,7 @@ import net.minecraft.entity.mob.EndermanEntity; import net.minecraft.entity.player.PlayerEntity; import net.minecraft.entity.projectile.ArrowEntity; import net.minecraft.item.ItemStack; +import net.minecraft.network.packet.s2c.play.GameStateChangeS2CPacket; import net.minecraft.server.network.ServerPlayerEntity; import net.minecraft.sound.SoundEvents; import net.minecraft.util.hit.EntityHitResult; @@ -25,7 +25,7 @@ import net.minecraft.util.math.MathHelper; import net.minecraft.util.math.Vec3d; import net.minecraft.world.World; -public class SpearEntity extends ArrowEntity implements AdvancedProjectile { +public class SpearEntity extends ArrowEntity implements Projectile { private static final TrackedData ITEM = DataTracker.registerData(SpearEntity.class, TrackedDataHandlerRegistry.ITEM_STACK); @@ -124,7 +124,7 @@ public class SpearEntity extends ArrowEntity implements AdvancedProjectile { onHit(target); if (archer != null && target != archer && target instanceof PlayerEntity && archer instanceof ServerPlayerEntity) { - ((ServerPlayerEntity)archer).networkHandler.sendPacket(new GameStateChangeS2CPacket(6, 0)); + ((ServerPlayerEntity)archer).networkHandler.sendPacket(new GameStateChangeS2CPacket(GameStateChangeS2CPacket.PROJECTILE_HIT_PLAYER, 0)); } } diff --git a/src/main/java/com/minelittlepony/unicopia/entity/SpellbookEntity.java b/src/main/java/com/minelittlepony/unicopia/world/entity/SpellbookEntity.java similarity index 89% rename from src/main/java/com/minelittlepony/unicopia/entity/SpellbookEntity.java rename to src/main/java/com/minelittlepony/unicopia/world/entity/SpellbookEntity.java index 5f97f568..071d6121 100644 --- a/src/main/java/com/minelittlepony/unicopia/entity/SpellbookEntity.java +++ b/src/main/java/com/minelittlepony/unicopia/world/entity/SpellbookEntity.java @@ -1,11 +1,11 @@ -package com.minelittlepony.unicopia.entity; +package com.minelittlepony.unicopia.world.entity; import com.minelittlepony.unicopia.EquinePredicates; -import com.minelittlepony.unicopia.container.UContainers; import com.minelittlepony.unicopia.ducks.PickedItemSupplier; -import com.minelittlepony.unicopia.item.UItems; +import com.minelittlepony.unicopia.magic.Magical; +import com.minelittlepony.unicopia.world.container.SpellBookContainer; +import com.minelittlepony.unicopia.world.item.UItems; -import net.fabricmc.fabric.api.container.ContainerProviderRegistry; import net.minecraft.entity.EntityType; import net.minecraft.entity.damage.DamageSource; import net.minecraft.entity.data.DataTracker; @@ -17,7 +17,7 @@ import net.minecraft.item.ItemStack; import net.minecraft.nbt.CompoundTag; import net.minecraft.particle.ParticleTypes; import net.minecraft.predicate.entity.EntityPredicates; -import net.minecraft.server.network.ServerPlayerEntity; +import net.minecraft.screen.SimpleNamedScreenHandlerFactory; import net.minecraft.sound.BlockSoundGroup; import net.minecraft.sound.SoundCategory; import net.minecraft.sound.SoundEvents; @@ -27,7 +27,7 @@ import net.minecraft.util.math.Vec3d; import net.minecraft.world.GameRules; import net.minecraft.world.World; -public class SpellbookEntity extends MobEntity implements IMagicals, PickedItemSupplier { +public class SpellbookEntity extends MobEntity implements Magical, PickedItemSupplier { private static final TrackedData OPENED = DataTracker.registerData(SpellbookEntity.class, TrackedDataHandlerRegistry.BOOLEAN); private static final TrackedData ALTERED = DataTracker.registerData(SpellbookEntity.class, TrackedDataHandlerRegistry.BOOLEAN); @@ -119,7 +119,7 @@ public class SpellbookEntity extends MobEntity implements IMagicals, PickedItemS if (open) { world.getEntities(this, getBoundingBox().expand(2), EntityPredicates.EXCEPT_SPECTATOR.and(e -> e instanceof PlayerEntity)).stream().findFirst().ifPresent(player -> { - Vec3d diff = player.getPosVector().subtract(getPosVector()); + Vec3d diff = player.getPos().subtract(getPos()); double yaw = Math.atan2(diff.z, diff.x) * 180D / Math.PI - 90; setHeadYaw((float)yaw); @@ -156,7 +156,7 @@ public class SpellbookEntity extends MobEntity implements IMagicals, PickedItemS world.playSound(getX(), getY(), getZ(), sound.getBreakSound(), SoundCategory.BLOCKS, sound.getVolume(), sound.getPitch(), true); - if (world.getGameRules().getBoolean(GameRules.DO_TILE_DROPS)) { + if (world.getGameRules().getBoolean(GameRules.DO_ENTITY_DROPS)) { dropItem(UItems.SPELLBOOK, 1); } } @@ -175,11 +175,10 @@ public class SpellbookEntity extends MobEntity implements IMagicals, PickedItemS } if (EquinePredicates.PLAYER_UNICORN.test(player)) { - if (player instanceof ServerPlayerEntity) { - ContainerProviderRegistry.INSTANCE.openContainer(UContainers.SPELL_BOOK, player, o -> { - o.writeText(getName()); - }); - } + + player.openHandledScreen(new SimpleNamedScreenHandlerFactory( + (sync, inv, ply) -> new SpellBookContainer(sync, inv), + getName())); player.playSound(SoundEvents.BLOCK_FURNACE_FIRE_CRACKLE, 2, 1); return ActionResult.SUCCESS; } diff --git a/src/main/java/com/minelittlepony/unicopia/entity/SpellcastEntity.java b/src/main/java/com/minelittlepony/unicopia/world/entity/SpellcastEntity.java similarity index 96% rename from src/main/java/com/minelittlepony/unicopia/entity/SpellcastEntity.java rename to src/main/java/com/minelittlepony/unicopia/world/entity/SpellcastEntity.java index 79c83940..39e9f996 100644 --- a/src/main/java/com/minelittlepony/unicopia/entity/SpellcastEntity.java +++ b/src/main/java/com/minelittlepony/unicopia/world/entity/SpellcastEntity.java @@ -1,4 +1,4 @@ -package com.minelittlepony.unicopia.entity; +package com.minelittlepony.unicopia.world.entity; import java.util.Optional; import java.util.UUID; @@ -6,16 +6,18 @@ import java.util.UUID; import javax.annotation.Nullable; import com.minelittlepony.unicopia.EquinePredicates; +import com.minelittlepony.unicopia.InAnimate; import com.minelittlepony.unicopia.Race; import com.minelittlepony.unicopia.ducks.PickedItemSupplier; -import com.minelittlepony.unicopia.item.UItems; import com.minelittlepony.unicopia.magic.Affinity; import com.minelittlepony.unicopia.magic.Caster; import com.minelittlepony.unicopia.magic.EtherialListener; +import com.minelittlepony.unicopia.magic.Magical; import com.minelittlepony.unicopia.magic.Spell; -import com.minelittlepony.unicopia.magic.item.CastableMagicItem; import com.minelittlepony.unicopia.magic.spell.SpellRegistry; import com.minelittlepony.unicopia.network.EffectSync; +import com.minelittlepony.unicopia.world.item.CastableMagicItem; +import com.minelittlepony.unicopia.world.item.UItems; import net.minecraft.block.BlockState; import net.minecraft.entity.Entity; @@ -45,7 +47,7 @@ import net.minecraft.world.GameRules; import net.minecraft.world.World; import net.minecraft.world.explosion.Explosion.DestructionType; -public class SpellcastEntity extends MobEntityWithAi implements IMagicals, Caster, EtherialListener, InAnimate, PickedItemSupplier { +public class SpellcastEntity extends MobEntityWithAi implements Magical, Caster, EtherialListener, InAnimate, PickedItemSupplier { private static final TrackedData LEVEL = DataTracker.registerData(SpellcastEntity.class, TrackedDataHandlerRegistry.INTEGER); private static final TrackedData> OWNER = DataTracker.registerData(SpellcastEntity.class, TrackedDataHandlerRegistry.OPTIONAL_UUID); @@ -247,7 +249,7 @@ public class SpellcastEntity extends MobEntityWithAi implements IMagicals, Caste world.playSound(getX(), getY(), getZ(), sound.getBreakSound(), SoundCategory.NEUTRAL, sound.getVolume(), sound.getPitch(), true); - if (world.getGameRules().getBoolean(GameRules.DO_TILE_DROPS)) { + if (world.getGameRules().getBoolean(GameRules.DO_ENTITY_DROPS)) { int level = getCurrentLevel(); ItemStack stack = new ItemStack(getItem(), level + 1); diff --git a/src/main/java/com/minelittlepony/unicopia/world/entity/UEntities.java b/src/main/java/com/minelittlepony/unicopia/world/entity/UEntities.java new file mode 100644 index 00000000..56c590ae --- /dev/null +++ b/src/main/java/com/minelittlepony/unicopia/world/entity/UEntities.java @@ -0,0 +1,94 @@ +package com.minelittlepony.unicopia.world.entity; + +import java.util.List; + +import net.fabricmc.fabric.api.object.builder.v1.entity.FabricDefaultAttributeRegistry; +import net.fabricmc.fabric.api.object.builder.v1.entity.FabricEntityTypeBuilder; +import net.minecraft.entity.Entity; +import net.minecraft.entity.EntityDimensions; +import net.minecraft.entity.EntityType; +import net.minecraft.entity.LivingEntity; +import net.minecraft.entity.SpawnGroup; +import net.minecraft.entity.attribute.DefaultAttributeContainer; +import net.minecraft.util.Identifier; +import net.minecraft.util.registry.Registry; +import net.minecraft.world.biome.EndBiome; +import net.minecraft.world.biome.ForestBiome; +import net.minecraft.world.biome.MountainsBiome; +import net.minecraft.world.biome.NetherWastesBiome; +import net.minecraft.world.biome.OceanBiome; +import net.minecraft.world.biome.PlainsBiome; +import net.minecraft.world.biome.RiverBiome; + +public interface UEntities { + EntityType SPELLBOOK = register("spellbook", FabricEntityTypeBuilder.create(SpawnGroup.MISC, SpellbookEntity::new) + .dimensions(EntityDimensions.changing(0.6F, 0.6F)), + LivingEntity.createLivingAttributes()); + EntityType MAGIC_SPELL = register("magic_spell", FabricEntityTypeBuilder.create(SpawnGroup.MISC, SpellcastEntity::new) + .dimensions(EntityDimensions.changing(0.6F, 0.25F)), + LivingEntity.createLivingAttributes()); + EntityType CLOUD = register("cloud", FabricEntityTypeBuilder.create(SpawnGroup.CREATURE, CloudEntity::new) + .dimensions(CloudEntity.BASE_DIMENSIONS), + LivingEntity.createLivingAttributes()); + EntityType WILD_CLOUD = register("wild_cloud", FabricEntityTypeBuilder.create(SpawnGroup.CREATURE, WildCloudEntity::new) + .dimensions(CloudEntity.BASE_DIMENSIONS), + LivingEntity.createLivingAttributes()); + EntityType RACING_CLOUD = register("racing_cloud", FabricEntityTypeBuilder.create(SpawnGroup.CREATURE, RacingCloudEntity::new) + .dimensions(CloudEntity.BASE_DIMENSIONS), + LivingEntity.createLivingAttributes()); + EntityType CONSTRUCTION_CLOUD = register("construction_cloud", FabricEntityTypeBuilder.create(SpawnGroup.CREATURE, ConstructionCloudEntity::new) + .dimensions(CloudEntity.BASE_DIMENSIONS), + LivingEntity.createLivingAttributes()); + + EntityType RAINBOW = register("rainbow", FabricEntityTypeBuilder.create(SpawnGroup.AMBIENT, RainbowEntity::new) + .dimensions(EntityDimensions.fixed(1, 1)), + LivingEntity.createLivingAttributes()); + + EntityType CUCOON = register("cucoon", FabricEntityTypeBuilder.create(SpawnGroup.MISC, CucoonEntity::new) + .dimensions(EntityDimensions.changing(1.5F, 1.6F)), + LivingEntity.createLivingAttributes()); + + EntityType BUTTERFLY = register("butterfly", FabricEntityTypeBuilder.create(SpawnGroup.AMBIENT, ButterflyEntity::new) + .dimensions(EntityDimensions.fixed(1, 1)), + ButterflyEntity.createButterflyAttributes()); + + EntityType THROWN_ITEM = register("thrown_item", FabricEntityTypeBuilder.create(SpawnGroup.MISC, MagicProjectileEntity::new) + .trackable(100, 2) + .dimensions(EntityDimensions.fixed(0.25F, 0.25F))); + EntityType THROWN_SPEAR = register("thrown_spear", FabricEntityTypeBuilder.create(SpawnGroup.MISC, SpearEntity::new) + .trackable(100, 2) + .dimensions(EntityDimensions.fixed(0.6F, 0.6F))); + + static EntityType register(String name, FabricEntityTypeBuilder builder, DefaultAttributeContainer.Builder attributes) { + EntityType type = builder.build(); + FabricDefaultAttributeRegistry.register(type, attributes); + return Registry.register(Registry.ENTITY_TYPE, new Identifier("unicopia", name), type); + } + + static EntityType register(String name, FabricEntityTypeBuilder builder) { + EntityType type = builder.build(); + return Registry.register(Registry.ENTITY_TYPE, new Identifier("unicopia", name), type); + } + + static void bootstrap() { + Registry.BIOME.forEach(biome -> { + if (!(biome instanceof NetherWastesBiome || biome instanceof EndBiome)) { + addifAbsent(biome.getEntitySpawnList(SpawnGroup.AMBIENT), biome instanceof OceanBiome ? WildCloudEntity.SPAWN_ENTRY_OCEAN : WildCloudEntity.SPAWN_ENTRY_LAND); + addifAbsent(biome.getEntitySpawnList(SpawnGroup.CREATURE), RainbowEntity.SPAWN_ENTRY); + } + + if (biome instanceof PlainsBiome + || biome instanceof RiverBiome + || biome instanceof MountainsBiome + || biome instanceof ForestBiome) { + addifAbsent(biome.getEntitySpawnList(SpawnGroup.AMBIENT), ButterflyEntity.SPAWN_ENTRY); + } + }); + } + + static void addifAbsent(List entries, T entry) { + if (!entries.contains(entry)) { + entries.add(entry); + } + } +} diff --git a/src/main/java/com/minelittlepony/unicopia/entity/WildCloudEntity.java b/src/main/java/com/minelittlepony/unicopia/world/entity/WildCloudEntity.java similarity index 88% rename from src/main/java/com/minelittlepony/unicopia/entity/WildCloudEntity.java rename to src/main/java/com/minelittlepony/unicopia/world/entity/WildCloudEntity.java index 105452bc..1aef35c9 100644 --- a/src/main/java/com/minelittlepony/unicopia/entity/WildCloudEntity.java +++ b/src/main/java/com/minelittlepony/unicopia/world/entity/WildCloudEntity.java @@ -1,4 +1,4 @@ -package com.minelittlepony.unicopia.entity; +package com.minelittlepony.unicopia.world.entity; import java.util.Iterator; @@ -7,15 +7,15 @@ import javax.annotation.Nullable; import net.minecraft.entity.Entity; import net.minecraft.entity.EntityData; import net.minecraft.entity.EntityType; -import net.minecraft.entity.SpawnType; +import net.minecraft.entity.SpawnReason; import net.minecraft.nbt.CompoundTag; import net.minecraft.util.math.ChunkPos; -import net.minecraft.util.TypeFilterableList; +import net.minecraft.util.collection.TypeFilterableList; import net.minecraft.util.math.BlockPos; import net.minecraft.util.math.Vec3d; -import net.minecraft.world.IWorld; import net.minecraft.world.LocalDifficulty; import net.minecraft.world.World; +import net.minecraft.world.WorldAccess; import net.minecraft.world.biome.Biome.SpawnEntry; import net.minecraft.world.chunk.WorldChunk; @@ -58,8 +58,8 @@ public class WildCloudEntity extends CloudEntity { }*/ @Override - public boolean canSpawn(IWorld world, SpawnType type) { - if (type == SpawnType.NATURAL) { + public boolean canSpawn(WorldAccess world, SpawnReason type) { + if (type == SpawnReason.NATURAL) { int count = 0; ChunkPos cpos = new ChunkPos(getBlockPos()); @@ -82,7 +82,7 @@ public class WildCloudEntity extends CloudEntity { } @Override - public EntityData initialize(IWorld world, LocalDifficulty difficulty, SpawnType type, @Nullable EntityData data, @Nullable CompoundTag tag) { + public EntityData initialize(WorldAccess world, LocalDifficulty difficulty, SpawnReason type, @Nullable EntityData data, @Nullable CompoundTag tag) { data = super.initialize(world, difficulty, type, data, tag); if (!(data instanceof PackData)) { @@ -91,7 +91,7 @@ public class WildCloudEntity extends CloudEntity { targetAltitude = getRandomFlyingHeight(); if (getY() < minSpawnHeight) { - minSpawnHeight += random.nextInt(Math.max(1, (int)getMaximumFlyingHeight() - (int)minSpawnHeight)); + minSpawnHeight += random.nextInt(Math.max(1, getMaximumAltitude())); updatePositionAndAngles(getX(), minSpawnHeight - 1, getZ(), yaw, pitch); moveToBoundingBoxCenter(); diff --git a/src/main/java/com/minelittlepony/unicopia/item/AlicornAmuletItem.java b/src/main/java/com/minelittlepony/unicopia/world/item/AlicornAmuletItem.java similarity index 89% rename from src/main/java/com/minelittlepony/unicopia/item/AlicornAmuletItem.java rename to src/main/java/com/minelittlepony/unicopia/world/item/AlicornAmuletItem.java index 1f0b597c..71e05bd9 100644 --- a/src/main/java/com/minelittlepony/unicopia/item/AlicornAmuletItem.java +++ b/src/main/java/com/minelittlepony/unicopia/world/item/AlicornAmuletItem.java @@ -1,4 +1,4 @@ -package com.minelittlepony.unicopia.item; +package com.minelittlepony.unicopia.world.item; import java.util.List; import java.util.UUID; @@ -8,11 +8,11 @@ import javax.annotation.Nullable; import com.google.common.collect.Multimap; import com.minelittlepony.unicopia.AwaitTickQueue; import com.minelittlepony.unicopia.ducks.IItemEntity; -import com.minelittlepony.unicopia.entity.ItemImpl; -import com.minelittlepony.unicopia.entity.player.MagicReserves; -import com.minelittlepony.unicopia.entity.player.Pony; +import com.minelittlepony.unicopia.equine.ItemImpl; +import com.minelittlepony.unicopia.equine.player.MagicReserves; +import com.minelittlepony.unicopia.equine.player.Pony; +import com.minelittlepony.unicopia.magic.AffineItem; import com.minelittlepony.unicopia.magic.Affinity; -import com.minelittlepony.unicopia.magic.item.AddictiveMagicitem; import com.minelittlepony.unicopia.util.MagicalDamageSource; import com.minelittlepony.unicopia.util.VecHelper; @@ -27,6 +27,7 @@ import net.minecraft.entity.Entity; import net.minecraft.entity.EquipmentSlot; import net.minecraft.entity.ItemEntity; import net.minecraft.entity.MovementType; +import net.minecraft.entity.attribute.EntityAttribute; import net.minecraft.entity.attribute.EntityAttributeModifier; import net.minecraft.entity.attribute.EntityAttributes; import net.minecraft.entity.player.PlayerEntity; @@ -48,7 +49,7 @@ import net.minecraft.world.LocalDifficulty; import net.minecraft.world.World; import net.minecraft.world.explosion.Explosion.DestructionType; -public class AlicornAmuletItem extends ArmorItem implements AddictiveMagicitem, ItemImpl.TickableItem { +public class AlicornAmuletItem extends ArmorItem implements AffineItem, ItemImpl.TickableItem { private static final UUID[] MODIFIERS = new UUID[] { UUID.fromString("845DB27C-C624-495F-8C9F-6020A9A58B6B"), @@ -66,7 +67,6 @@ public class AlicornAmuletItem extends ArmorItem implements AddictiveMagicitem, return Affinity.BAD; } - @Override public ActionResult onGroundTick(IItemEntity item) { @@ -159,7 +159,7 @@ public class AlicornAmuletItem extends ArmorItem implements AddictiveMagicitem, PlayerEntity player = (PlayerEntity)entity; - if (player.getHealth() < player.getMaximumHealth()) { + if (player.getHealth() < player.getMaxHealth()) { player.heal(0.5F); } else if (player.canConsume(false)) { player.getHungerManager().add(1, 0); @@ -193,7 +193,7 @@ public class AlicornAmuletItem extends ArmorItem implements AddictiveMagicitem, } if (attachedTime > 0 && attachedTime % 100 == 0) { - world.playSound(null, player.getBlockPos(), SoundEvents.MUSIC_NETHER, SoundCategory.PLAYERS, 3, 1); + world.playSound(null, player.getBlockPos(), SoundEvents.AMBIENT_NETHER_WASTES_MOOD, SoundCategory.PLAYERS, 3, 1); } if (attachedTime > 1000) { @@ -227,7 +227,7 @@ public class AlicornAmuletItem extends ArmorItem implements AddictiveMagicitem, if (stack.getDamage() >= getMaxDamage() - 1) { stack.damage(10, player, p -> p.sendEquipmentBreakStatus(EquipmentSlot.CHEST)); - player.damage(MagicalDamageSource.ALICORN_AMULET, player.getMaximumHealth() - 0.01F); + player.damage(MagicalDamageSource.ALICORN_AMULET, player.getMaxHealth() - 0.01F); player.getHungerManager().setFoodLevel(1); Vec3d pos = player.getPos(); @@ -250,22 +250,27 @@ public class AlicornAmuletItem extends ArmorItem implements AddictiveMagicitem, LocalDifficulty difficulty = player.getWorld().getLocalDifficulty(player.getOrigin()); float amount = (attachedTime * (1 + needfulness)) * (1 + difficulty.getClampedLocalDifficulty()); - amount = Math.min(amount, player.getOwner().getMaximumHealth()); + amount = Math.min(amount, player.getOwner().getMaxHealth()); player.getOwner().damage(MagicalDamageSource.ALICORN_AMULET, amount); if (attachedTime > 120) { - player.getOwner().takeKnockback(player.getOwner(), 1, 1, 1); + player.getOwner().takeKnockback(1, 1, 1); } } @Override - public Multimap getModifiers(EquipmentSlot equipmentSlot) { - Multimap multimap = super.getModifiers(equipmentSlot); + public boolean alwaysActive() { + return false; + } + + @Override + public Multimap getAttributeModifiers(EquipmentSlot equipmentSlot) { + Multimap multimap = super.getAttributeModifiers(equipmentSlot); if (equipmentSlot == slot) { UUID modifierId = MODIFIERS[equipmentSlot.getEntitySlotId()]; - multimap.put(EntityAttributes.ATTACK_DAMAGE.getId(), new EntityAttributeModifier(modifierId, "Strength modifier", 50, EntityAttributeModifier.Operation.ADDITION)); + multimap.put(EntityAttributes.GENERIC_ATTACK_DAMAGE, new EntityAttributeModifier(modifierId, "Strength modifier", 50, EntityAttributeModifier.Operation.ADDITION)); } return multimap; @@ -307,5 +312,10 @@ public class AlicornAmuletItem extends ArmorItem implements AddictiveMagicitem, public float getToughness() { return 20; } + + @Override + public float getKnockbackResistance() { + return 0; + } } } diff --git a/src/main/java/com/minelittlepony/unicopia/item/AppleItem.java b/src/main/java/com/minelittlepony/unicopia/world/item/AppleItem.java similarity index 96% rename from src/main/java/com/minelittlepony/unicopia/item/AppleItem.java rename to src/main/java/com/minelittlepony/unicopia/world/item/AppleItem.java index 4af47fb1..c03c918d 100644 --- a/src/main/java/com/minelittlepony/unicopia/item/AppleItem.java +++ b/src/main/java/com/minelittlepony/unicopia/world/item/AppleItem.java @@ -1,10 +1,10 @@ -package com.minelittlepony.unicopia.item; +package com.minelittlepony.unicopia.world.item; import java.util.List; import javax.annotation.Nullable; import com.minelittlepony.unicopia.ducks.IItemEntity; -import com.minelittlepony.unicopia.entity.ItemImpl; +import com.minelittlepony.unicopia.equine.ItemImpl; import com.minelittlepony.unicopia.toxin.Toxicity; import net.minecraft.client.item.TooltipContext; import net.minecraft.entity.EntityType; diff --git a/src/main/java/com/minelittlepony/unicopia/item/BagOfHoldingItem.java b/src/main/java/com/minelittlepony/unicopia/world/item/BagOfHoldingItem.java similarity index 79% rename from src/main/java/com/minelittlepony/unicopia/item/BagOfHoldingItem.java rename to src/main/java/com/minelittlepony/unicopia/world/item/BagOfHoldingItem.java index 04bf0273..43d765f1 100644 --- a/src/main/java/com/minelittlepony/unicopia/item/BagOfHoldingItem.java +++ b/src/main/java/com/minelittlepony/unicopia/world/item/BagOfHoldingItem.java @@ -1,4 +1,4 @@ -package com.minelittlepony.unicopia.item; +package com.minelittlepony.unicopia.world.item; import java.util.HashMap; import java.util.List; @@ -6,14 +6,12 @@ import java.util.Map; import javax.annotation.Nullable; import com.minelittlepony.unicopia.EquinePredicates; -import com.minelittlepony.unicopia.container.BagOfHoldingInventory; -import com.minelittlepony.unicopia.container.UContainers; -import com.minelittlepony.unicopia.entity.IMagicals; +import com.minelittlepony.unicopia.magic.AffineItem; import com.minelittlepony.unicopia.magic.Affinity; -import com.minelittlepony.unicopia.magic.item.MagicItem; +import com.minelittlepony.unicopia.magic.Magical; import com.minelittlepony.unicopia.util.VecHelper; - -import net.fabricmc.fabric.api.container.ContainerProviderRegistry; +import com.minelittlepony.unicopia.world.container.BagOfHoldingContainer; +import com.minelittlepony.unicopia.world.container.BagOfHoldingInventory; import net.minecraft.block.entity.BlockEntity; import net.minecraft.client.item.TooltipContext; import net.minecraft.entity.Entity; @@ -23,7 +21,7 @@ import net.minecraft.entity.player.PlayerEntity; import net.minecraft.inventory.Inventory; import net.minecraft.item.Item; import net.minecraft.item.ItemStack; -import net.minecraft.server.network.ServerPlayerEntity; +import net.minecraft.screen.SimpleNamedScreenHandlerFactory; import net.minecraft.sound.SoundEvents; import net.minecraft.text.Text; import net.minecraft.text.TranslatableText; @@ -37,7 +35,7 @@ import net.minecraft.util.math.Box; import net.minecraft.util.math.BlockPos; import net.minecraft.world.World; -public class BagOfHoldingItem extends Item implements MagicItem { +public class BagOfHoldingItem extends Item implements AffineItem { public BagOfHoldingItem(Settings settings) { super(settings); @@ -57,7 +55,7 @@ public class BagOfHoldingItem extends Item implements MagicItem { }); counts.forEach((line, count) -> { - tooltip.add(line.deepCopy().append(" ").append(count.toString())); + tooltip.add(line.copy().append(" ").append(count.toString())); }); } @@ -86,7 +84,7 @@ public class BagOfHoldingItem extends Item implements MagicItem { inventory.addBlockEntity(world, pos, (BlockEntity & Inventory)tile); inventory.writeTostack(stack); - inventory.onInvClose(player); + inventory.onClose(player); } return new TypedActionResult<>(ActionResult.SUCCESS, stack); } @@ -101,7 +99,7 @@ public class BagOfHoldingItem extends Item implements MagicItem { inventory.addItem((ItemEntity)itemsAround.get(0)); inventory.writeTostack(stack); - inventory.onInvClose(player); + inventory.onClose(player); } return new TypedActionResult<>(ActionResult.SUCCESS, stack); } @@ -109,13 +107,13 @@ public class BagOfHoldingItem extends Item implements MagicItem { Entity e = ((EntityHitResult)hit).getEntity(); - if (e instanceof LivingEntity && !(e instanceof PlayerEntity) && !(e instanceof IMagicals)) { + if (e instanceof LivingEntity && !(e instanceof PlayerEntity) && !(e instanceof Magical)) { if (!world.isClient) { BagOfHoldingInventory inventory = BagOfHoldingInventory.getInventoryFromStack(stack); inventory.addEntity(world, e); inventory.writeTostack(stack); - inventory.onInvClose(player); + inventory.onClose(player); } return new TypedActionResult<>(ActionResult.SUCCESS, stack); } @@ -125,15 +123,9 @@ public class BagOfHoldingItem extends Item implements MagicItem { return new TypedActionResult<>(ActionResult.FAIL, stack); } - if (player instanceof ServerPlayerEntity) { - ContainerProviderRegistry.INSTANCE.openContainer(UContainers.BAG_OF_HOLDING, player, o -> { - if (stack.hasCustomName()) { - o.writeText(stack.getName()); - } else { - o.writeText(new TranslatableText("item.unicopia.bag_of_holding")); - } - }); - } + player.openHandledScreen(new SimpleNamedScreenHandlerFactory( + (sync, inv, ply) -> new BagOfHoldingContainer(sync, inv), + stack.hasCustomName() ? stack.getName() : new TranslatableText("item.unicopia.bag_of_holding"))); player.playSound(SoundEvents.BLOCK_ENDER_CHEST_OPEN, 0.5F, 1); return new TypedActionResult<>(ActionResult.SUCCESS, stack); @@ -143,4 +135,9 @@ public class BagOfHoldingItem extends Item implements MagicItem { public Affinity getAffinity() { return Affinity.NEUTRAL; } + + @Override + public boolean alwaysActive() { + return false; + } } diff --git a/src/main/java/com/minelittlepony/unicopia/magic/item/CastableMagicItem.java b/src/main/java/com/minelittlepony/unicopia/world/item/CastableMagicItem.java similarity index 87% rename from src/main/java/com/minelittlepony/unicopia/magic/item/CastableMagicItem.java rename to src/main/java/com/minelittlepony/unicopia/world/item/CastableMagicItem.java index 71659c5f..3574ee19 100644 --- a/src/main/java/com/minelittlepony/unicopia/magic/item/CastableMagicItem.java +++ b/src/main/java/com/minelittlepony/unicopia/world/item/CastableMagicItem.java @@ -1,12 +1,13 @@ -package com.minelittlepony.unicopia.magic.item; +package com.minelittlepony.unicopia.world.item; -import com.minelittlepony.unicopia.entity.SpellcastEntity; -import com.minelittlepony.unicopia.entity.UEntities; +import com.minelittlepony.unicopia.magic.AffineItem; import com.minelittlepony.unicopia.magic.CastResult; import com.minelittlepony.unicopia.magic.DispenceableSpell; import com.minelittlepony.unicopia.magic.Dispensable; import com.minelittlepony.unicopia.magic.Spell; import com.minelittlepony.unicopia.magic.spell.SpellRegistry; +import com.minelittlepony.unicopia.world.entity.SpellcastEntity; +import com.minelittlepony.unicopia.world.entity.UEntities; import net.minecraft.item.ItemStack; import net.minecraft.item.ItemUsageContext; @@ -16,7 +17,7 @@ import net.minecraft.util.math.BlockPointer; import net.minecraft.util.math.BlockPos; import net.minecraft.world.World; -public interface CastableMagicItem extends MagicItem, Dispensable { +public interface CastableMagicItem extends AffineItem, Dispensable { @Override default TypedActionResult dispenseStack(BlockPointer source, ItemStack stack) { diff --git a/src/main/java/com/minelittlepony/unicopia/item/CloudPlacerItem.java b/src/main/java/com/minelittlepony/unicopia/world/item/CloudPlacerItem.java similarity index 95% rename from src/main/java/com/minelittlepony/unicopia/item/CloudPlacerItem.java rename to src/main/java/com/minelittlepony/unicopia/world/item/CloudPlacerItem.java index 9b17a7c9..85f3d87c 100644 --- a/src/main/java/com/minelittlepony/unicopia/item/CloudPlacerItem.java +++ b/src/main/java/com/minelittlepony/unicopia/world/item/CloudPlacerItem.java @@ -1,7 +1,7 @@ -package com.minelittlepony.unicopia.item; +package com.minelittlepony.unicopia.world.item; -import com.minelittlepony.unicopia.entity.CloudEntity; import com.minelittlepony.unicopia.magic.Dispensable; +import com.minelittlepony.unicopia.world.entity.CloudEntity; import net.minecraft.block.DispenserBlock; import net.minecraft.entity.EntityType; diff --git a/src/main/java/com/minelittlepony/unicopia/item/CursedMagicGemItem.java b/src/main/java/com/minelittlepony/unicopia/world/item/CursedMagicGemItem.java similarity index 97% rename from src/main/java/com/minelittlepony/unicopia/item/CursedMagicGemItem.java rename to src/main/java/com/minelittlepony/unicopia/world/item/CursedMagicGemItem.java index 01ffe709..8329c37c 100644 --- a/src/main/java/com/minelittlepony/unicopia/item/CursedMagicGemItem.java +++ b/src/main/java/com/minelittlepony/unicopia/world/item/CursedMagicGemItem.java @@ -1,4 +1,4 @@ -package com.minelittlepony.unicopia.item; +package com.minelittlepony.unicopia.world.item; import com.minelittlepony.unicopia.magic.Affinity; import com.minelittlepony.unicopia.magic.CastResult; diff --git a/src/main/java/com/minelittlepony/unicopia/item/EnchantedStaffItem.java b/src/main/java/com/minelittlepony/unicopia/world/item/EnchantedStaffItem.java similarity index 96% rename from src/main/java/com/minelittlepony/unicopia/item/EnchantedStaffItem.java rename to src/main/java/com/minelittlepony/unicopia/world/item/EnchantedStaffItem.java index 037184fb..8dd10ef9 100644 --- a/src/main/java/com/minelittlepony/unicopia/item/EnchantedStaffItem.java +++ b/src/main/java/com/minelittlepony/unicopia/world/item/EnchantedStaffItem.java @@ -1,4 +1,4 @@ -package com.minelittlepony.unicopia.item; +package com.minelittlepony.unicopia.world.item; import java.util.List; @@ -6,13 +6,13 @@ import javax.annotation.Nonnull; import javax.annotation.Nullable; import com.minelittlepony.unicopia.EquinePredicates; -import com.minelittlepony.unicopia.entity.player.Pony; +import com.minelittlepony.unicopia.equine.player.Pony; import com.minelittlepony.unicopia.magic.Affinity; import com.minelittlepony.unicopia.magic.CasterUtils; import com.minelittlepony.unicopia.magic.Affine; import com.minelittlepony.unicopia.magic.Caster; import com.minelittlepony.unicopia.magic.ThrowableSpell; -import com.minelittlepony.unicopia.util.projectile.TossableItem; +import com.minelittlepony.unicopia.world.TossableItem; import net.minecraft.block.BlockState; import net.minecraft.client.item.TooltipContext; diff --git a/src/main/java/com/minelittlepony/unicopia/item/ExtendedShearsItem.java b/src/main/java/com/minelittlepony/unicopia/world/item/ExtendedShearsItem.java similarity index 97% rename from src/main/java/com/minelittlepony/unicopia/item/ExtendedShearsItem.java rename to src/main/java/com/minelittlepony/unicopia/world/item/ExtendedShearsItem.java index cc25579b..4e4be5dd 100644 --- a/src/main/java/com/minelittlepony/unicopia/item/ExtendedShearsItem.java +++ b/src/main/java/com/minelittlepony/unicopia/world/item/ExtendedShearsItem.java @@ -1,4 +1,4 @@ -package com.minelittlepony.unicopia.item; +package com.minelittlepony.unicopia.world.item; import java.util.Optional; diff --git a/src/main/java/com/minelittlepony/unicopia/item/MagicGemItem.java b/src/main/java/com/minelittlepony/unicopia/world/item/MagicGemItem.java similarity index 94% rename from src/main/java/com/minelittlepony/unicopia/item/MagicGemItem.java rename to src/main/java/com/minelittlepony/unicopia/world/item/MagicGemItem.java index b4d917ee..3f50232f 100644 --- a/src/main/java/com/minelittlepony/unicopia/item/MagicGemItem.java +++ b/src/main/java/com/minelittlepony/unicopia/world/item/MagicGemItem.java @@ -1,20 +1,19 @@ -package com.minelittlepony.unicopia.item; +package com.minelittlepony.unicopia.world.item; import java.util.List; import javax.annotation.Nullable; import com.minelittlepony.unicopia.EquinePredicates; -import com.minelittlepony.unicopia.entity.SpellcastEntity; import com.minelittlepony.unicopia.magic.Affinity; import com.minelittlepony.unicopia.magic.CastResult; import com.minelittlepony.unicopia.magic.DispenceableSpell; import com.minelittlepony.unicopia.magic.Dispensable; import com.minelittlepony.unicopia.magic.Spell; import com.minelittlepony.unicopia.magic.Useable; -import com.minelittlepony.unicopia.magic.item.CastableMagicItem; import com.minelittlepony.unicopia.magic.spell.SpellRegistry; import com.minelittlepony.unicopia.util.VecHelper; +import com.minelittlepony.unicopia.world.entity.SpellcastEntity; import net.minecraft.block.DispenserBlock; import net.minecraft.client.item.TooltipContext; @@ -29,7 +28,7 @@ import net.minecraft.util.math.BlockPointer; import net.minecraft.util.math.BlockPos; import net.minecraft.util.math.Direction; import net.minecraft.util.ActionResult; -import net.minecraft.util.DefaultedList; +import net.minecraft.util.collection.DefaultedList; import net.minecraft.util.Hand; import net.minecraft.util.Rarity; import net.minecraft.util.TypedActionResult; @@ -142,14 +141,10 @@ public class MagicGemItem extends Item implements CastableMagicItem { public void appendTooltip(ItemStack stack, @Nullable World worldIn, List tooltip, TooltipContext context) { if (SpellRegistry.stackHasEnchantment(stack)) { Affinity affinity = getAffinity(stack); - - Text text = new TranslatableText(String.format("%s.%s.tagline", + tooltip.add(new TranslatableText(String.format("%s.%s.tagline", affinity.getTranslationKey(), SpellRegistry.getKeyFromStack(stack) - )); - text.getStyle().setColor(affinity.getColourCode()); - - tooltip.add(text); + )).styled(s -> s.withColor(affinity.getColourCode()))); } } @@ -197,4 +192,9 @@ public class MagicGemItem extends Item implements CastableMagicItem { public Affinity getAffinity() { return Affinity.GOOD; } + + @Override + public boolean alwaysActive() { + return true; + } } diff --git a/src/main/java/com/minelittlepony/unicopia/item/MossItem.java b/src/main/java/com/minelittlepony/unicopia/world/item/MossItem.java similarity index 89% rename from src/main/java/com/minelittlepony/unicopia/item/MossItem.java rename to src/main/java/com/minelittlepony/unicopia/world/item/MossItem.java index 53c9c579..b22cc2ce 100644 --- a/src/main/java/com/minelittlepony/unicopia/item/MossItem.java +++ b/src/main/java/com/minelittlepony/unicopia/world/item/MossItem.java @@ -1,12 +1,12 @@ -package com.minelittlepony.unicopia.item; +package com.minelittlepony.unicopia.world.item; import javax.annotation.Nullable; -import com.minelittlepony.unicopia.blockstate.StateMaps; -import com.minelittlepony.unicopia.entity.player.Pony; +import com.minelittlepony.unicopia.equine.player.Pony; import com.minelittlepony.unicopia.toxin.ToxicItem; import com.minelittlepony.unicopia.toxin.Toxicity; import com.minelittlepony.unicopia.toxin.Toxin; +import com.minelittlepony.unicopia.util.blockstate.StateMaps; import net.minecraft.block.Block; import net.minecraft.block.BlockState; diff --git a/src/main/java/com/minelittlepony/unicopia/item/PredicatedBlockItem.java b/src/main/java/com/minelittlepony/unicopia/world/item/PredicatedBlockItem.java similarity index 96% rename from src/main/java/com/minelittlepony/unicopia/item/PredicatedBlockItem.java rename to src/main/java/com/minelittlepony/unicopia/world/item/PredicatedBlockItem.java index 660cbc75..98d3f2b3 100644 --- a/src/main/java/com/minelittlepony/unicopia/item/PredicatedBlockItem.java +++ b/src/main/java/com/minelittlepony/unicopia/world/item/PredicatedBlockItem.java @@ -1,4 +1,4 @@ -package com.minelittlepony.unicopia.item; +package com.minelittlepony.unicopia.world.item; import java.util.function.Predicate; diff --git a/src/main/java/com/minelittlepony/unicopia/item/RottenAppleItem.java b/src/main/java/com/minelittlepony/unicopia/world/item/RottenAppleItem.java similarity index 89% rename from src/main/java/com/minelittlepony/unicopia/item/RottenAppleItem.java rename to src/main/java/com/minelittlepony/unicopia/world/item/RottenAppleItem.java index 04517d1a..049c833c 100644 --- a/src/main/java/com/minelittlepony/unicopia/item/RottenAppleItem.java +++ b/src/main/java/com/minelittlepony/unicopia/world/item/RottenAppleItem.java @@ -1,4 +1,4 @@ -package com.minelittlepony.unicopia.item; +package com.minelittlepony.unicopia.world.item; import com.minelittlepony.unicopia.ducks.IItemEntity; diff --git a/src/main/java/com/minelittlepony/unicopia/item/RottenTomatoItem.java b/src/main/java/com/minelittlepony/unicopia/world/item/RottenTomatoItem.java similarity index 93% rename from src/main/java/com/minelittlepony/unicopia/item/RottenTomatoItem.java rename to src/main/java/com/minelittlepony/unicopia/world/item/RottenTomatoItem.java index b4631a60..3f6c4597 100644 --- a/src/main/java/com/minelittlepony/unicopia/item/RottenTomatoItem.java +++ b/src/main/java/com/minelittlepony/unicopia/world/item/RottenTomatoItem.java @@ -1,9 +1,9 @@ -package com.minelittlepony.unicopia.item; +package com.minelittlepony.unicopia.world.item; -import com.minelittlepony.unicopia.entity.player.Pony; +import com.minelittlepony.unicopia.equine.player.Pony; import com.minelittlepony.unicopia.magic.Caster; import com.minelittlepony.unicopia.magic.Dispensable; -import com.minelittlepony.unicopia.util.projectile.TossableItem; +import com.minelittlepony.unicopia.world.TossableItem; import net.minecraft.block.BlockState; import net.minecraft.block.Material; diff --git a/src/main/java/com/minelittlepony/unicopia/item/SpearItem.java b/src/main/java/com/minelittlepony/unicopia/world/item/SpearItem.java similarity index 86% rename from src/main/java/com/minelittlepony/unicopia/item/SpearItem.java rename to src/main/java/com/minelittlepony/unicopia/world/item/SpearItem.java index 832a3517..46cf3de6 100644 --- a/src/main/java/com/minelittlepony/unicopia/item/SpearItem.java +++ b/src/main/java/com/minelittlepony/unicopia/world/item/SpearItem.java @@ -1,11 +1,11 @@ -package com.minelittlepony.unicopia.item; +package com.minelittlepony.unicopia.world.item; import javax.annotation.Nullable; -import com.minelittlepony.unicopia.entity.SpearEntity; import com.minelittlepony.unicopia.magic.Caster; -import com.minelittlepony.unicopia.util.projectile.AdvancedProjectile; -import com.minelittlepony.unicopia.util.projectile.TossableItem; +import com.minelittlepony.unicopia.util.projectile.Projectile; +import com.minelittlepony.unicopia.world.TossableItem; +import com.minelittlepony.unicopia.world.entity.SpearEntity; import net.minecraft.block.BlockState; import net.minecraft.entity.EquipmentSlot; @@ -84,13 +84,13 @@ public class SpearItem extends Item implements TossableItem { @Nullable @Override - public AdvancedProjectile createProjectile(World world, PlayerEntity player) { + public Projectile createProjectile(World world, PlayerEntity player) { return new SpearEntity(world, player); } @Nullable @Override - public AdvancedProjectile createProjectile(World world, Position pos) { + public Projectile createProjectile(World world, Position pos) { return null; } diff --git a/src/main/java/com/minelittlepony/unicopia/item/SpellbookItem.java b/src/main/java/com/minelittlepony/unicopia/world/item/SpellbookItem.java similarity index 92% rename from src/main/java/com/minelittlepony/unicopia/item/SpellbookItem.java rename to src/main/java/com/minelittlepony/unicopia/world/item/SpellbookItem.java index 9e5675b1..fa2e2b89 100644 --- a/src/main/java/com/minelittlepony/unicopia/item/SpellbookItem.java +++ b/src/main/java/com/minelittlepony/unicopia/world/item/SpellbookItem.java @@ -1,11 +1,11 @@ -package com.minelittlepony.unicopia.item; +package com.minelittlepony.unicopia.world.item; import javax.annotation.Nullable; import com.minelittlepony.unicopia.EquinePredicates; -import com.minelittlepony.unicopia.entity.SpellbookEntity; -import com.minelittlepony.unicopia.entity.UEntities; import com.minelittlepony.unicopia.magic.Dispensable; +import com.minelittlepony.unicopia.world.entity.SpellbookEntity; +import com.minelittlepony.unicopia.world.entity.UEntities; import net.minecraft.block.DispenserBlock; import net.minecraft.entity.player.PlayerEntity; diff --git a/src/main/java/com/minelittlepony/unicopia/item/StaffItem.java b/src/main/java/com/minelittlepony/unicopia/world/item/StaffItem.java similarity index 76% rename from src/main/java/com/minelittlepony/unicopia/item/StaffItem.java rename to src/main/java/com/minelittlepony/unicopia/world/item/StaffItem.java index bc019106..68cb88ec 100644 --- a/src/main/java/com/minelittlepony/unicopia/item/StaffItem.java +++ b/src/main/java/com/minelittlepony/unicopia/world/item/StaffItem.java @@ -1,4 +1,4 @@ -package com.minelittlepony.unicopia.item; +package com.minelittlepony.unicopia.world.item; import java.util.List; import java.util.UUID; @@ -12,6 +12,7 @@ import net.minecraft.client.item.TooltipContext; import net.minecraft.entity.EntityDimensions; import net.minecraft.entity.EquipmentSlot; import net.minecraft.entity.LivingEntity; +import net.minecraft.entity.attribute.EntityAttribute; import net.minecraft.entity.attribute.EntityAttributeModifier; import net.minecraft.entity.attribute.EntityAttributes; import net.minecraft.entity.player.PlayerEntity; @@ -23,6 +24,7 @@ import net.minecraft.particle.ParticleTypes; import net.minecraft.sound.SoundEvents; import net.minecraft.text.Text; import net.minecraft.text.TranslatableText; +import net.minecraft.util.ActionResult; import net.minecraft.util.Hand; import net.minecraft.util.UseAction; import net.minecraft.util.math.MathHelper; @@ -30,14 +32,14 @@ import net.minecraft.world.World; public class StaffItem extends SwordItem { - protected static final UUID ATTACK_REACH_MODIFIER = UUID.fromString("FA235E1C-4280-A865-B01B-CBAE9985ACA3"); + protected static final UUID ATTACK_REACH_MODIFIER_ID = UUID.fromString("FA235E1C-4280-A865-B01B-CBAE9985ACA3"); public StaffItem(Settings settings) { super(ToolMaterials.WOOD, 2, 4, settings); } @Override - public boolean useOnEntity(ItemStack stack, PlayerEntity player, LivingEntity target, Hand hand) { + public ActionResult useOnEntity(ItemStack stack, PlayerEntity player, LivingEntity target, Hand hand) { World w = player.getEntityWorld(); EntityDimensions dims = target.getDimensions(target.getPose()); @@ -51,7 +53,7 @@ public class StaffItem extends SwordItem { ); } - return false; + return ActionResult.PASS; } @Override @@ -73,7 +75,7 @@ public class StaffItem extends SwordItem { protected boolean castContainedEffect(ItemStack stack, LivingEntity target, LivingEntity attacker) { target.getEntityWorld().playSound(null, target.getBlockPos(), SoundEvents.ENTITY_PLAYER_ATTACK_CRIT, attacker.getSoundCategory(), 1, 1); - target.takeKnockback(attacker, 2, + target.takeKnockback(2, MathHelper.sin(attacker.yaw * 0.017453292F), -MathHelper.cos(attacker.yaw * 0.017453292F) ); @@ -87,12 +89,12 @@ public class StaffItem extends SwordItem { } @Override - public Multimap getModifiers(EquipmentSlot slot) { - Multimap multimap = HashMultimap.create(); + public Multimap getAttributeModifiers(EquipmentSlot slot) { + Multimap multimap = HashMultimap.create(); if (slot == EquipmentSlot.MAINHAND) { - multimap.put(EntityAttributes.ATTACK_DAMAGE.getId(), new EntityAttributeModifier(ATTACK_DAMAGE_MODIFIER_UUID, "Weapon modifier", getAttackDamage(), EntityAttributeModifier.Operation.ADDITION)); - //multimap.put(PlayerEntity.REACH_DISTANCE.getId(), new EntityAttributeModifier(ATTACK_REACH_MODIFIER, "Weapon modifier", 3, EntityAttributeModifier.Operation.ADDITION)); + multimap.put(EntityAttributes.GENERIC_ATTACK_DAMAGE, new EntityAttributeModifier(ATTACK_DAMAGE_MODIFIER_ID, "Weapon modifier", getAttackDamage(), EntityAttributeModifier.Operation.ADDITION)); + //multimap.put(PlayerEntity.REACH_DISTANCE.getId(), new EntityAttributeModifier(ATTACK_REACH_MODIFIER_ID, "Weapon modifier", 3, EntityAttributeModifier.Operation.ADDITION)); } return multimap; diff --git a/src/main/java/com/minelittlepony/unicopia/item/StickItem.java b/src/main/java/com/minelittlepony/unicopia/world/item/StickItem.java similarity index 87% rename from src/main/java/com/minelittlepony/unicopia/item/StickItem.java rename to src/main/java/com/minelittlepony/unicopia/world/item/StickItem.java index fca16e2a..8deb82eb 100644 --- a/src/main/java/com/minelittlepony/unicopia/item/StickItem.java +++ b/src/main/java/com/minelittlepony/unicopia/world/item/StickItem.java @@ -1,10 +1,10 @@ -package com.minelittlepony.unicopia.item; +package com.minelittlepony.unicopia.world.item; import javax.annotation.Nullable; -import com.minelittlepony.unicopia.block.UBlocks; +import com.minelittlepony.unicopia.world.block.UBlocks; -import net.minecraft.advancement.criterion.Criterions; +import net.minecraft.advancement.criterion.Criteria; import net.minecraft.block.BlockState; import net.minecraft.entity.player.PlayerEntity; import net.minecraft.item.Item; @@ -44,7 +44,7 @@ public class StickItem extends Item { ItemStack itemstack = context.getStack(); if (player instanceof ServerPlayerEntity) { - Criterions.PLACED_BLOCK.trigger((ServerPlayerEntity)player, pos.up(), itemstack); + Criteria.PLACED_BLOCK.trigger((ServerPlayerEntity)player, pos.up(), itemstack); } BlockSoundGroup sound = world.getBlockState(pos).getSoundGroup(); diff --git a/src/main/java/com/minelittlepony/unicopia/item/SugaryItem.java b/src/main/java/com/minelittlepony/unicopia/world/item/SugaryItem.java similarity index 87% rename from src/main/java/com/minelittlepony/unicopia/item/SugaryItem.java rename to src/main/java/com/minelittlepony/unicopia/world/item/SugaryItem.java index dcbaf2de..0030070a 100644 --- a/src/main/java/com/minelittlepony/unicopia/item/SugaryItem.java +++ b/src/main/java/com/minelittlepony/unicopia/world/item/SugaryItem.java @@ -1,6 +1,6 @@ -package com.minelittlepony.unicopia.item; +package com.minelittlepony.unicopia.world.item; -import com.minelittlepony.unicopia.entity.player.Pony; +import com.minelittlepony.unicopia.equine.player.Pony; import net.minecraft.entity.LivingEntity; import net.minecraft.entity.player.PlayerEntity; diff --git a/src/main/java/com/minelittlepony/unicopia/item/TomatoItem.java b/src/main/java/com/minelittlepony/unicopia/world/item/TomatoItem.java similarity index 92% rename from src/main/java/com/minelittlepony/unicopia/item/TomatoItem.java rename to src/main/java/com/minelittlepony/unicopia/world/item/TomatoItem.java index 1ce2bf3a..3f98dff9 100644 --- a/src/main/java/com/minelittlepony/unicopia/item/TomatoItem.java +++ b/src/main/java/com/minelittlepony/unicopia/world/item/TomatoItem.java @@ -1,4 +1,4 @@ -package com.minelittlepony.unicopia.item; +package com.minelittlepony.unicopia.world.item; import net.minecraft.entity.LivingEntity; import net.minecraft.entity.effect.StatusEffects; diff --git a/src/main/java/com/minelittlepony/unicopia/item/TomatoSeedsItem.java b/src/main/java/com/minelittlepony/unicopia/world/item/TomatoSeedsItem.java similarity index 91% rename from src/main/java/com/minelittlepony/unicopia/item/TomatoSeedsItem.java rename to src/main/java/com/minelittlepony/unicopia/world/item/TomatoSeedsItem.java index 1b9c4dce..19f6ebec 100644 --- a/src/main/java/com/minelittlepony/unicopia/item/TomatoSeedsItem.java +++ b/src/main/java/com/minelittlepony/unicopia/world/item/TomatoSeedsItem.java @@ -1,7 +1,7 @@ -package com.minelittlepony.unicopia.item; +package com.minelittlepony.unicopia.world.item; -import com.minelittlepony.unicopia.block.StickPlantBlock; -import com.minelittlepony.unicopia.block.UBlocks; +import com.minelittlepony.unicopia.world.block.StickPlantBlock; +import com.minelittlepony.unicopia.world.block.UBlocks; import net.minecraft.block.Block; import net.minecraft.block.BlockState; diff --git a/src/main/java/com/minelittlepony/unicopia/item/UItems.java b/src/main/java/com/minelittlepony/unicopia/world/item/UItems.java similarity index 97% rename from src/main/java/com/minelittlepony/unicopia/item/UItems.java rename to src/main/java/com/minelittlepony/unicopia/world/item/UItems.java index 3c48ee21..1c5e5f3e 100644 --- a/src/main/java/com/minelittlepony/unicopia/item/UItems.java +++ b/src/main/java/com/minelittlepony/unicopia/world/item/UItems.java @@ -1,14 +1,15 @@ -package com.minelittlepony.unicopia.item; +package com.minelittlepony.unicopia.world.item; import static com.minelittlepony.unicopia.EquinePredicates.*; import com.minelittlepony.unicopia.USounds; -import com.minelittlepony.unicopia.block.UBlocks; -import com.minelittlepony.unicopia.entity.UEntities; import com.minelittlepony.unicopia.magic.spell.ScorchSpell; import com.minelittlepony.unicopia.toxin.ToxicItem; import com.minelittlepony.unicopia.toxin.Toxicity; import com.minelittlepony.unicopia.toxin.Toxin; +import com.minelittlepony.unicopia.toxin.UFoodComponents; +import com.minelittlepony.unicopia.world.block.UBlocks; +import com.minelittlepony.unicopia.world.entity.UEntities; import com.minelittlepony.unicopia.toxin.Toxics; import net.minecraft.item.Item; @@ -177,7 +178,7 @@ public interface UItems { if (item instanceof BlockItem) { ((BlockItem)item).appendBlocks(Item.BLOCK_ITEMS, item); } - return Registry.ITEM.add(new Identifier("unicopia", name), item); + return Registry.register(Registry.ITEM, new Identifier("unicopia", name), item); } static MusicDiscItem register(String name, SoundEvent sound) { diff --git a/src/main/java/com/minelittlepony/unicopia/item/VanillaOverrides.java b/src/main/java/com/minelittlepony/unicopia/world/item/VanillaOverrides.java similarity index 76% rename from src/main/java/com/minelittlepony/unicopia/item/VanillaOverrides.java rename to src/main/java/com/minelittlepony/unicopia/world/item/VanillaOverrides.java index f8915b42..4d1d6aea 100644 --- a/src/main/java/com/minelittlepony/unicopia/item/VanillaOverrides.java +++ b/src/main/java/com/minelittlepony/unicopia/world/item/VanillaOverrides.java @@ -1,15 +1,16 @@ -package com.minelittlepony.unicopia.item; +package com.minelittlepony.unicopia.world.item; + +import com.minelittlepony.unicopia.util.Registries; import net.minecraft.item.FoodComponents; import net.minecraft.item.Item; import net.minecraft.item.ItemGroup; import net.minecraft.util.Identifier; import net.minecraft.util.registry.Registry; -import net.minecraft.util.registry.SimpleRegistry; public final class VanillaOverrides { - public static final Registry REGISTRY = new SimpleRegistry<>(); + public static final Registry REGISTRY = Registries.createSimple(new Identifier("unicopia", "overrides")); private static T register(String name, T newItem) { return Registry.register(REGISTRY, new Identifier(name), newItem); diff --git a/src/main/java/com/minelittlepony/unicopia/item/ZapAppleItem.java b/src/main/java/com/minelittlepony/unicopia/world/item/ZapAppleItem.java similarity index 88% rename from src/main/java/com/minelittlepony/unicopia/item/ZapAppleItem.java rename to src/main/java/com/minelittlepony/unicopia/world/item/ZapAppleItem.java index 3f336af6..be2cc6e3 100644 --- a/src/main/java/com/minelittlepony/unicopia/item/ZapAppleItem.java +++ b/src/main/java/com/minelittlepony/unicopia/world/item/ZapAppleItem.java @@ -1,4 +1,4 @@ -package com.minelittlepony.unicopia.item; +package com.minelittlepony.unicopia.world.item; import com.minelittlepony.unicopia.UTags; @@ -7,6 +7,7 @@ import com.minelittlepony.unicopia.util.MagicalDamageSource; import com.minelittlepony.unicopia.util.VecHelper; import net.minecraft.entity.Entity; +import net.minecraft.entity.EntityType; import net.minecraft.entity.LightningEntity; import net.minecraft.entity.LivingEntity; import net.minecraft.entity.mob.CreeperEntity; @@ -19,7 +20,7 @@ import net.minecraft.item.ItemStack; import net.minecraft.item.Items; import net.minecraft.server.world.ServerWorld; import net.minecraft.util.ActionResult; -import net.minecraft.util.DefaultedList; +import net.minecraft.util.collection.DefaultedList; import net.minecraft.util.Hand; import net.minecraft.util.Identifier; import net.minecraft.util.Rarity; @@ -59,7 +60,10 @@ public class ZapAppleItem extends AppleItem { player.damage(MagicalDamageSource.ZAP_APPLE, 120); if (w instanceof ServerWorld) { - ((ServerWorld) w).addLightning(new LightningEntity(w, player.getX(), player.getY(), player.getZ(), false)); + LightningEntity lightning = EntityType.LIGHTNING_BOLT.create(w); + lightning.positAfterTeleport(player.getX(), player.getY(), player.getZ()); + + w.spawnEntity(lightning); } return stack; @@ -72,7 +76,11 @@ public class ZapAppleItem extends AppleItem { } public TypedActionResult onFedTo(ItemStack stack, PlayerEntity player, Entity e) { - e.onStruckByLightning(new LightningEntity(e.world, e.getX(), e.getY(), e.getZ(), false)); + + LightningEntity lightning = EntityType.LIGHTNING_BOLT.create(e.world); + lightning.positAfterTeleport(player.getX(), player.getY(), player.getZ()); + + e.onStruckByLightning(lightning); if (!player.abilities.creativeMode) { stack.decrement(1); diff --git a/src/main/java/com/minelittlepony/unicopia/recipe/Pattern.java b/src/main/java/com/minelittlepony/unicopia/world/recipe/Pattern.java similarity index 95% rename from src/main/java/com/minelittlepony/unicopia/recipe/Pattern.java rename to src/main/java/com/minelittlepony/unicopia/world/recipe/Pattern.java index b4d76150..a2ee232c 100644 --- a/src/main/java/com/minelittlepony/unicopia/recipe/Pattern.java +++ b/src/main/java/com/minelittlepony/unicopia/world/recipe/Pattern.java @@ -1,4 +1,4 @@ -package com.minelittlepony.unicopia.recipe; +package com.minelittlepony.unicopia.world.recipe; import java.util.Map; import java.util.Set; @@ -8,12 +8,12 @@ import com.google.common.collect.Sets; import com.google.gson.JsonArray; import com.google.gson.JsonObject; import com.google.gson.JsonSyntaxException; -import com.minelittlepony.unicopia.recipe.ingredient.PredicatedIngredient; +import com.minelittlepony.unicopia.world.recipe.ingredient.PredicatedIngredient; import net.minecraft.inventory.CraftingInventory; -import net.minecraft.util.DefaultedList; +import net.minecraft.util.collection.DefaultedList; import net.minecraft.util.JsonHelper; -import net.minecraft.util.PacketByteBuf; +import net.minecraft.network.PacketByteBuf; import net.minecraft.util.Util; public class Pattern { @@ -90,7 +90,7 @@ public class Pattern { } } - if (!ingredient.matches(inv.getInvStack(x + y * inv.getWidth()), 1)) { + if (!ingredient.matches(inv.getStack(x + y * inv.getWidth()), 1)) { return false; } } diff --git a/src/main/java/com/minelittlepony/unicopia/recipe/ShapedSpecialRecipe.java b/src/main/java/com/minelittlepony/unicopia/world/recipe/ShapedSpecialRecipe.java similarity index 92% rename from src/main/java/com/minelittlepony/unicopia/recipe/ShapedSpecialRecipe.java rename to src/main/java/com/minelittlepony/unicopia/world/recipe/ShapedSpecialRecipe.java index 629356ef..38a5737b 100644 --- a/src/main/java/com/minelittlepony/unicopia/recipe/ShapedSpecialRecipe.java +++ b/src/main/java/com/minelittlepony/unicopia/world/recipe/ShapedSpecialRecipe.java @@ -1,19 +1,19 @@ -package com.minelittlepony.unicopia.recipe; +package com.minelittlepony.unicopia.world.recipe; import java.util.Random; import com.google.gson.JsonObject; -import com.minelittlepony.unicopia.recipe.ingredient.PredicatedIngredient; +import com.minelittlepony.unicopia.world.recipe.ingredient.PredicatedIngredient; import net.minecraft.inventory.CraftingInventory; import net.minecraft.item.ItemStack; import net.minecraft.recipe.Ingredient; import net.minecraft.recipe.RecipeSerializer; import net.minecraft.recipe.SpecialCraftingRecipe; -import net.minecraft.util.DefaultedList; +import net.minecraft.util.collection.DefaultedList; import net.minecraft.util.Identifier; import net.minecraft.util.JsonHelper; -import net.minecraft.util.PacketByteBuf; +import net.minecraft.network.PacketByteBuf; import net.minecraft.world.World; public class ShapedSpecialRecipe extends SpecialCraftingRecipe { diff --git a/src/main/java/com/minelittlepony/unicopia/recipe/ShapelessSpecialRecipe.java b/src/main/java/com/minelittlepony/unicopia/world/recipe/ShapelessSpecialRecipe.java similarity index 93% rename from src/main/java/com/minelittlepony/unicopia/recipe/ShapelessSpecialRecipe.java rename to src/main/java/com/minelittlepony/unicopia/world/recipe/ShapelessSpecialRecipe.java index eca27fd5..ca0d79c2 100644 --- a/src/main/java/com/minelittlepony/unicopia/recipe/ShapelessSpecialRecipe.java +++ b/src/main/java/com/minelittlepony/unicopia/world/recipe/ShapelessSpecialRecipe.java @@ -1,18 +1,18 @@ -package com.minelittlepony.unicopia.recipe; +package com.minelittlepony.unicopia.world.recipe; import com.google.gson.JsonObject; import com.google.gson.JsonParseException; -import com.minelittlepony.unicopia.recipe.ingredient.PredicatedIngredient; +import com.minelittlepony.unicopia.world.recipe.ingredient.PredicatedIngredient; import net.minecraft.inventory.CraftingInventory; import net.minecraft.item.ItemStack; import net.minecraft.recipe.Ingredient; import net.minecraft.recipe.RecipeSerializer; import net.minecraft.recipe.SpecialCraftingRecipe; -import net.minecraft.util.DefaultedList; +import net.minecraft.util.collection.DefaultedList; import net.minecraft.util.Identifier; import net.minecraft.util.JsonHelper; -import net.minecraft.util.PacketByteBuf; +import net.minecraft.network.PacketByteBuf; import net.minecraft.world.World; public class ShapelessSpecialRecipe extends SpecialCraftingRecipe { diff --git a/src/main/java/com/minelittlepony/unicopia/recipe/SpellBookRecipe.java b/src/main/java/com/minelittlepony/unicopia/world/recipe/SpellBookRecipe.java similarity index 88% rename from src/main/java/com/minelittlepony/unicopia/recipe/SpellBookRecipe.java rename to src/main/java/com/minelittlepony/unicopia/world/recipe/SpellBookRecipe.java index fe99399b..fe9f1a29 100644 --- a/src/main/java/com/minelittlepony/unicopia/recipe/SpellBookRecipe.java +++ b/src/main/java/com/minelittlepony/unicopia/world/recipe/SpellBookRecipe.java @@ -1,9 +1,9 @@ -package com.minelittlepony.unicopia.recipe; +package com.minelittlepony.unicopia.world.recipe; import com.google.gson.JsonObject; -import com.minelittlepony.unicopia.container.SpellBookInventory; -import com.minelittlepony.unicopia.item.UItems; -import com.minelittlepony.unicopia.recipe.ingredient.PredicatedIngredient; +import com.minelittlepony.unicopia.world.container.SpellBookContainer; +import com.minelittlepony.unicopia.world.item.UItems; +import com.minelittlepony.unicopia.world.recipe.ingredient.PredicatedIngredient; import net.minecraft.inventory.CraftingInventory; import net.minecraft.item.ItemStack; @@ -11,10 +11,10 @@ import net.minecraft.recipe.Ingredient; import net.minecraft.recipe.Recipe; import net.minecraft.recipe.RecipeSerializer; import net.minecraft.recipe.RecipeType; -import net.minecraft.util.DefaultedList; +import net.minecraft.util.collection.DefaultedList; import net.minecraft.util.Identifier; import net.minecraft.util.JsonHelper; -import net.minecraft.util.PacketByteBuf; +import net.minecraft.network.PacketByteBuf; import net.minecraft.world.World; /** @@ -38,7 +38,7 @@ public class SpellBookRecipe implements Recipe { @Override public boolean matches(CraftingInventory inv, World world) { - ItemStack enchantedStack = ((SpellBookInventory)inv).getCraftResultMatrix().getInvStack(0); + ItemStack enchantedStack = ((SpellBookContainer.SBInventory)inv).getCraftResultMatrix().getStack(0); if (enchantedStack.isEmpty() || enchantedStack.getItem() == null) { return false; diff --git a/src/main/java/com/minelittlepony/unicopia/recipe/URecipes.java b/src/main/java/com/minelittlepony/unicopia/world/recipe/URecipes.java similarity index 96% rename from src/main/java/com/minelittlepony/unicopia/recipe/URecipes.java rename to src/main/java/com/minelittlepony/unicopia/world/recipe/URecipes.java index c1c1ef01..f2477d79 100644 --- a/src/main/java/com/minelittlepony/unicopia/recipe/URecipes.java +++ b/src/main/java/com/minelittlepony/unicopia/world/recipe/URecipes.java @@ -1,4 +1,4 @@ -package com.minelittlepony.unicopia.recipe; +package com.minelittlepony.unicopia.world.recipe; import net.minecraft.recipe.Recipe; import net.minecraft.recipe.RecipeSerializer; diff --git a/src/main/java/com/minelittlepony/unicopia/recipe/Utils.java b/src/main/java/com/minelittlepony/unicopia/world/recipe/Utils.java similarity index 87% rename from src/main/java/com/minelittlepony/unicopia/recipe/Utils.java rename to src/main/java/com/minelittlepony/unicopia/world/recipe/Utils.java index 3ef4b7bf..2fcf6ca1 100644 --- a/src/main/java/com/minelittlepony/unicopia/recipe/Utils.java +++ b/src/main/java/com/minelittlepony/unicopia/world/recipe/Utils.java @@ -1,4 +1,4 @@ -package com.minelittlepony.unicopia.recipe; +package com.minelittlepony.unicopia.world.recipe; import java.util.List; import java.util.Random; @@ -9,14 +9,14 @@ import com.google.common.collect.Lists; import com.google.gson.JsonElement; import com.google.gson.JsonObject; import com.google.gson.JsonParseException; -import com.minelittlepony.unicopia.recipe.ingredient.PredicatedIngredient; +import com.minelittlepony.unicopia.world.recipe.ingredient.PredicatedIngredient; import net.minecraft.inventory.Inventory; import net.minecraft.item.ItemStack; -import net.minecraft.util.DefaultedList; +import net.minecraft.util.collection.DefaultedList; import net.minecraft.util.Identifier; import net.minecraft.util.JsonHelper; -import net.minecraft.util.PacketByteBuf; +import net.minecraft.network.PacketByteBuf; public final class Utils { private Utils() {} @@ -58,8 +58,8 @@ public final class Utils { List toMatch = Lists.newArrayList(ingredients); - for (int i = 0; i < inv.getInvSize(); i++) { - ItemStack stack = inv.getInvStack(i); + for (int i = 0; i < inv.size(); i++) { + ItemStack stack = inv.getStack(i); if (!stack.isEmpty()) { if (toMatch.isEmpty() || !removeMatch(toMatch, stack, mult)) { diff --git a/src/main/java/com/minelittlepony/unicopia/enchanting/CompoundCondition.java b/src/main/java/com/minelittlepony/unicopia/world/recipe/enchanting/CompoundCondition.java similarity index 96% rename from src/main/java/com/minelittlepony/unicopia/enchanting/CompoundCondition.java rename to src/main/java/com/minelittlepony/unicopia/world/recipe/enchanting/CompoundCondition.java index d0258b05..ebab7de6 100644 --- a/src/main/java/com/minelittlepony/unicopia/enchanting/CompoundCondition.java +++ b/src/main/java/com/minelittlepony/unicopia/world/recipe/enchanting/CompoundCondition.java @@ -1,4 +1,4 @@ -package com.minelittlepony.unicopia.enchanting; +package com.minelittlepony.unicopia.world.recipe.enchanting; import java.util.List; import java.util.function.Predicate; diff --git a/src/main/java/com/minelittlepony/unicopia/enchanting/IConditionFactory.java b/src/main/java/com/minelittlepony/unicopia/world/recipe/enchanting/IConditionFactory.java similarity index 70% rename from src/main/java/com/minelittlepony/unicopia/enchanting/IConditionFactory.java rename to src/main/java/com/minelittlepony/unicopia/world/recipe/enchanting/IConditionFactory.java index ccfe32e9..36dcb7bb 100644 --- a/src/main/java/com/minelittlepony/unicopia/enchanting/IConditionFactory.java +++ b/src/main/java/com/minelittlepony/unicopia/world/recipe/enchanting/IConditionFactory.java @@ -1,4 +1,4 @@ -package com.minelittlepony.unicopia.enchanting; +package com.minelittlepony.unicopia.world.recipe.enchanting; import com.google.gson.JsonObject; diff --git a/src/main/java/com/minelittlepony/unicopia/enchanting/IPageUnlockListener.java b/src/main/java/com/minelittlepony/unicopia/world/recipe/enchanting/IPageUnlockListener.java similarity index 80% rename from src/main/java/com/minelittlepony/unicopia/enchanting/IPageUnlockListener.java rename to src/main/java/com/minelittlepony/unicopia/world/recipe/enchanting/IPageUnlockListener.java index a3789b07..9aa95228 100644 --- a/src/main/java/com/minelittlepony/unicopia/enchanting/IPageUnlockListener.java +++ b/src/main/java/com/minelittlepony/unicopia/world/recipe/enchanting/IPageUnlockListener.java @@ -1,4 +1,4 @@ -package com.minelittlepony.unicopia.enchanting; +package com.minelittlepony.unicopia.world.recipe.enchanting; @FunctionalInterface public interface IPageUnlockListener { diff --git a/src/main/java/com/minelittlepony/unicopia/enchanting/IUnlockCondition.java b/src/main/java/com/minelittlepony/unicopia/world/recipe/enchanting/IUnlockCondition.java similarity index 93% rename from src/main/java/com/minelittlepony/unicopia/enchanting/IUnlockCondition.java rename to src/main/java/com/minelittlepony/unicopia/world/recipe/enchanting/IUnlockCondition.java index 0cdfb476..3ebfb662 100644 --- a/src/main/java/com/minelittlepony/unicopia/enchanting/IUnlockCondition.java +++ b/src/main/java/com/minelittlepony/unicopia/world/recipe/enchanting/IUnlockCondition.java @@ -1,4 +1,4 @@ -package com.minelittlepony.unicopia.enchanting; +package com.minelittlepony.unicopia.world.recipe.enchanting; import com.google.gson.JsonObject; import com.google.gson.JsonParseException; diff --git a/src/main/java/com/minelittlepony/unicopia/world/recipe/enchanting/IUnlockEvent.java b/src/main/java/com/minelittlepony/unicopia/world/recipe/enchanting/IUnlockEvent.java new file mode 100644 index 00000000..48d2f151 --- /dev/null +++ b/src/main/java/com/minelittlepony/unicopia/world/recipe/enchanting/IUnlockEvent.java @@ -0,0 +1,5 @@ +package com.minelittlepony.unicopia.world.recipe.enchanting; + +public interface IUnlockEvent { + +} diff --git a/src/main/java/com/minelittlepony/unicopia/enchanting/Page.java b/src/main/java/com/minelittlepony/unicopia/world/recipe/enchanting/Page.java similarity index 92% rename from src/main/java/com/minelittlepony/unicopia/enchanting/Page.java rename to src/main/java/com/minelittlepony/unicopia/world/recipe/enchanting/Page.java index 2f2da7a1..17b9e943 100644 --- a/src/main/java/com/minelittlepony/unicopia/enchanting/Page.java +++ b/src/main/java/com/minelittlepony/unicopia/world/recipe/enchanting/Page.java @@ -1,4 +1,4 @@ -package com.minelittlepony.unicopia.enchanting; +package com.minelittlepony.unicopia.world.recipe.enchanting; import net.minecraft.util.Identifier; diff --git a/src/main/java/com/minelittlepony/unicopia/enchanting/PageInstance.java b/src/main/java/com/minelittlepony/unicopia/world/recipe/enchanting/PageInstance.java similarity index 97% rename from src/main/java/com/minelittlepony/unicopia/enchanting/PageInstance.java rename to src/main/java/com/minelittlepony/unicopia/world/recipe/enchanting/PageInstance.java index 573b371f..77b10052 100644 --- a/src/main/java/com/minelittlepony/unicopia/enchanting/PageInstance.java +++ b/src/main/java/com/minelittlepony/unicopia/world/recipe/enchanting/PageInstance.java @@ -1,4 +1,4 @@ -package com.minelittlepony.unicopia.enchanting; +package com.minelittlepony.unicopia.world.recipe.enchanting; import javax.annotation.Nonnull; import javax.annotation.Nullable; diff --git a/src/main/java/com/minelittlepony/unicopia/enchanting/PageOwner.java b/src/main/java/com/minelittlepony/unicopia/world/recipe/enchanting/PageOwner.java similarity index 94% rename from src/main/java/com/minelittlepony/unicopia/enchanting/PageOwner.java rename to src/main/java/com/minelittlepony/unicopia/world/recipe/enchanting/PageOwner.java index 02f247b5..7f1c2463 100644 --- a/src/main/java/com/minelittlepony/unicopia/enchanting/PageOwner.java +++ b/src/main/java/com/minelittlepony/unicopia/world/recipe/enchanting/PageOwner.java @@ -1,4 +1,4 @@ -package com.minelittlepony.unicopia.enchanting; +package com.minelittlepony.unicopia.world.recipe.enchanting; import java.util.Map; import java.util.function.Function; diff --git a/src/main/java/com/minelittlepony/unicopia/enchanting/PageState.java b/src/main/java/com/minelittlepony/unicopia/world/recipe/enchanting/PageState.java similarity index 86% rename from src/main/java/com/minelittlepony/unicopia/enchanting/PageState.java rename to src/main/java/com/minelittlepony/unicopia/world/recipe/enchanting/PageState.java index 6f2efa9e..98ca4234 100644 --- a/src/main/java/com/minelittlepony/unicopia/enchanting/PageState.java +++ b/src/main/java/com/minelittlepony/unicopia/world/recipe/enchanting/PageState.java @@ -1,4 +1,4 @@ -package com.minelittlepony.unicopia.enchanting; +package com.minelittlepony.unicopia.world.recipe.enchanting; public enum PageState { LOCKED, diff --git a/src/main/java/com/minelittlepony/unicopia/enchanting/PageStateCondition.java b/src/main/java/com/minelittlepony/unicopia/world/recipe/enchanting/PageStateCondition.java similarity index 91% rename from src/main/java/com/minelittlepony/unicopia/enchanting/PageStateCondition.java rename to src/main/java/com/minelittlepony/unicopia/world/recipe/enchanting/PageStateCondition.java index cd7d04a0..895a060b 100644 --- a/src/main/java/com/minelittlepony/unicopia/enchanting/PageStateCondition.java +++ b/src/main/java/com/minelittlepony/unicopia/world/recipe/enchanting/PageStateCondition.java @@ -1,4 +1,4 @@ -package com.minelittlepony.unicopia.enchanting; +package com.minelittlepony.unicopia.world.recipe.enchanting; import com.google.gson.JsonObject; diff --git a/src/main/java/com/minelittlepony/unicopia/enchanting/Pages.java b/src/main/java/com/minelittlepony/unicopia/world/recipe/enchanting/Pages.java similarity index 94% rename from src/main/java/com/minelittlepony/unicopia/enchanting/Pages.java rename to src/main/java/com/minelittlepony/unicopia/world/recipe/enchanting/Pages.java index c412c88e..ef5e6c9d 100644 --- a/src/main/java/com/minelittlepony/unicopia/enchanting/Pages.java +++ b/src/main/java/com/minelittlepony/unicopia/world/recipe/enchanting/Pages.java @@ -1,4 +1,4 @@ -package com.minelittlepony.unicopia.enchanting; +package com.minelittlepony.unicopia.world.recipe.enchanting; import java.util.List; import java.util.Map; @@ -12,6 +12,7 @@ import com.google.common.collect.Lists; import com.google.common.collect.Maps; import com.google.gson.Gson; import com.google.gson.GsonBuilder; +import com.google.gson.JsonElement; import com.google.gson.JsonObject; import net.fabricmc.fabric.api.resource.IdentifiableResourceReloadListener; import net.minecraft.resource.JsonDataLoader; @@ -52,9 +53,9 @@ public class Pages extends JsonDataLoader implements IdentifiableResourceReloadL } @Override - protected void apply(Map data, ResourceManager manager, Profiler profiled) { + protected void apply(Map data, ResourceManager manager, Profiler profiled) { pages.clear(); - data.forEach((id, json) -> pages.put(id, new PageInstance(id, json))); + data.forEach((id, json) -> pages.put(id, new PageInstance(id, json.getAsJsonObject()))); pagesByIndex = pages.values().stream().sorted(this::comparePages).collect(Collectors.toList()); diff --git a/src/main/java/com/minelittlepony/unicopia/enchanting/SpellCraftingEvent.java b/src/main/java/com/minelittlepony/unicopia/world/recipe/enchanting/SpellCraftingEvent.java similarity index 93% rename from src/main/java/com/minelittlepony/unicopia/enchanting/SpellCraftingEvent.java rename to src/main/java/com/minelittlepony/unicopia/world/recipe/enchanting/SpellCraftingEvent.java index 719e7ae5..131b9a48 100644 --- a/src/main/java/com/minelittlepony/unicopia/enchanting/SpellCraftingEvent.java +++ b/src/main/java/com/minelittlepony/unicopia/world/recipe/enchanting/SpellCraftingEvent.java @@ -1,13 +1,13 @@ -package com.minelittlepony.unicopia.enchanting; +package com.minelittlepony.unicopia.world.recipe.enchanting; import javax.annotation.Nonnull; import javax.annotation.Nullable; import com.google.gson.JsonObject; import com.google.gson.annotations.Expose; -import com.minelittlepony.unicopia.item.MagicGemItem; import com.minelittlepony.unicopia.magic.Affinity; import com.minelittlepony.unicopia.magic.spell.SpellRegistry; +import com.minelittlepony.unicopia.world.item.MagicGemItem; import net.minecraft.item.ItemStack; diff --git a/src/main/java/com/minelittlepony/unicopia/recipe/ingredient/ChoicePredicate.java b/src/main/java/com/minelittlepony/unicopia/world/recipe/ingredient/ChoicePredicate.java similarity index 88% rename from src/main/java/com/minelittlepony/unicopia/recipe/ingredient/ChoicePredicate.java rename to src/main/java/com/minelittlepony/unicopia/world/recipe/ingredient/ChoicePredicate.java index 5e7ac2c8..5c7701b1 100644 --- a/src/main/java/com/minelittlepony/unicopia/recipe/ingredient/ChoicePredicate.java +++ b/src/main/java/com/minelittlepony/unicopia/world/recipe/ingredient/ChoicePredicate.java @@ -1,14 +1,14 @@ -package com.minelittlepony.unicopia.recipe.ingredient; +package com.minelittlepony.unicopia.world.recipe.ingredient; import java.util.Random; import java.util.stream.Stream; import com.google.gson.JsonArray; -import com.minelittlepony.unicopia.recipe.Utils; +import com.minelittlepony.unicopia.world.recipe.Utils; import net.minecraft.item.ItemStack; -import net.minecraft.util.DefaultedList; -import net.minecraft.util.PacketByteBuf; +import net.minecraft.util.collection.DefaultedList; +import net.minecraft.network.PacketByteBuf; /** * Requires only one of the sub-ingredients to match when matching. diff --git a/src/main/java/com/minelittlepony/unicopia/recipe/ingredient/DamagePredicate.java b/src/main/java/com/minelittlepony/unicopia/world/recipe/ingredient/DamagePredicate.java similarity index 94% rename from src/main/java/com/minelittlepony/unicopia/recipe/ingredient/DamagePredicate.java rename to src/main/java/com/minelittlepony/unicopia/world/recipe/ingredient/DamagePredicate.java index 9dc857fb..27975dc2 100644 --- a/src/main/java/com/minelittlepony/unicopia/recipe/ingredient/DamagePredicate.java +++ b/src/main/java/com/minelittlepony/unicopia/world/recipe/ingredient/DamagePredicate.java @@ -1,4 +1,4 @@ -package com.minelittlepony.unicopia.recipe.ingredient; +package com.minelittlepony.unicopia.world.recipe.ingredient; import java.util.HashMap; import java.util.Map; @@ -7,11 +7,11 @@ import java.util.function.BiPredicate; import java.util.stream.Stream; import com.google.gson.JsonObject; -import com.minelittlepony.unicopia.recipe.Utils; +import com.minelittlepony.unicopia.world.recipe.Utils; import net.minecraft.item.ItemStack; import net.minecraft.util.JsonHelper; -import net.minecraft.util.PacketByteBuf; +import net.minecraft.network.PacketByteBuf; import net.minecraft.util.Util; /** diff --git a/src/main/java/com/minelittlepony/unicopia/recipe/ingredient/EnchantmentPredicate.java b/src/main/java/com/minelittlepony/unicopia/world/recipe/ingredient/EnchantmentPredicate.java similarity index 94% rename from src/main/java/com/minelittlepony/unicopia/recipe/ingredient/EnchantmentPredicate.java rename to src/main/java/com/minelittlepony/unicopia/world/recipe/ingredient/EnchantmentPredicate.java index bee85356..2b785453 100644 --- a/src/main/java/com/minelittlepony/unicopia/recipe/ingredient/EnchantmentPredicate.java +++ b/src/main/java/com/minelittlepony/unicopia/world/recipe/ingredient/EnchantmentPredicate.java @@ -1,11 +1,11 @@ -package com.minelittlepony.unicopia.recipe.ingredient; +package com.minelittlepony.unicopia.world.recipe.ingredient; import java.util.Random; import java.util.stream.Stream; import com.google.gson.JsonElement; import com.google.gson.JsonObject; -import com.minelittlepony.unicopia.recipe.Utils; +import com.minelittlepony.unicopia.world.recipe.Utils; import net.minecraft.enchantment.Enchantment; import net.minecraft.enchantment.EnchantmentHelper; @@ -13,7 +13,7 @@ import net.minecraft.item.ItemStack; import net.minecraft.item.Items; import net.minecraft.util.Identifier; import net.minecraft.util.JsonHelper; -import net.minecraft.util.PacketByteBuf; +import net.minecraft.network.PacketByteBuf; import net.minecraft.util.registry.Registry; /** diff --git a/src/main/java/com/minelittlepony/unicopia/recipe/ingredient/PotionPredicate.java b/src/main/java/com/minelittlepony/unicopia/world/recipe/ingredient/PotionPredicate.java similarity index 93% rename from src/main/java/com/minelittlepony/unicopia/recipe/ingredient/PotionPredicate.java rename to src/main/java/com/minelittlepony/unicopia/world/recipe/ingredient/PotionPredicate.java index 4cb3ffb7..b689f0a0 100644 --- a/src/main/java/com/minelittlepony/unicopia/recipe/ingredient/PotionPredicate.java +++ b/src/main/java/com/minelittlepony/unicopia/world/recipe/ingredient/PotionPredicate.java @@ -1,4 +1,4 @@ -package com.minelittlepony.unicopia.recipe.ingredient; +package com.minelittlepony.unicopia.world.recipe.ingredient; import java.util.Random; import java.util.stream.Stream; @@ -6,7 +6,7 @@ import java.util.stream.Stream; import com.google.gson.JsonElement; import com.google.gson.JsonObject; import com.google.gson.JsonParseException; -import com.minelittlepony.unicopia.recipe.Utils; +import com.minelittlepony.unicopia.world.recipe.Utils; import net.minecraft.item.ItemStack; import net.minecraft.item.Items; @@ -15,7 +15,7 @@ import net.minecraft.potion.PotionUtil; import net.minecraft.potion.Potions; import net.minecraft.util.Identifier; import net.minecraft.util.JsonHelper; -import net.minecraft.util.PacketByteBuf; +import net.minecraft.network.PacketByteBuf; import net.minecraft.util.registry.Registry; /** diff --git a/src/main/java/com/minelittlepony/unicopia/recipe/ingredient/Predicate.java b/src/main/java/com/minelittlepony/unicopia/world/recipe/ingredient/Predicate.java similarity index 92% rename from src/main/java/com/minelittlepony/unicopia/recipe/ingredient/Predicate.java rename to src/main/java/com/minelittlepony/unicopia/world/recipe/ingredient/Predicate.java index 2f71fc76..90bc2204 100644 --- a/src/main/java/com/minelittlepony/unicopia/recipe/ingredient/Predicate.java +++ b/src/main/java/com/minelittlepony/unicopia/world/recipe/ingredient/Predicate.java @@ -1,10 +1,10 @@ -package com.minelittlepony.unicopia.recipe.ingredient; +package com.minelittlepony.unicopia.world.recipe.ingredient; import java.util.Random; import java.util.stream.Stream; import net.minecraft.item.ItemStack; -import net.minecraft.util.PacketByteBuf; +import net.minecraft.network.PacketByteBuf; public interface Predicate { Predicate EMPTY = new Predicate() { diff --git a/src/main/java/com/minelittlepony/unicopia/recipe/ingredient/PredicateSerializer.java b/src/main/java/com/minelittlepony/unicopia/world/recipe/ingredient/PredicateSerializer.java similarity index 82% rename from src/main/java/com/minelittlepony/unicopia/recipe/ingredient/PredicateSerializer.java rename to src/main/java/com/minelittlepony/unicopia/world/recipe/ingredient/PredicateSerializer.java index 1a162891..a96b8e8d 100644 --- a/src/main/java/com/minelittlepony/unicopia/recipe/ingredient/PredicateSerializer.java +++ b/src/main/java/com/minelittlepony/unicopia/world/recipe/ingredient/PredicateSerializer.java @@ -1,15 +1,15 @@ -package com.minelittlepony.unicopia.recipe.ingredient; +package com.minelittlepony.unicopia.world.recipe.ingredient; import com.google.gson.JsonObject; +import com.minelittlepony.unicopia.util.Registries; import net.minecraft.util.Identifier; -import net.minecraft.util.PacketByteBuf; +import net.minecraft.network.PacketByteBuf; import net.minecraft.util.registry.Registry; -import net.minecraft.util.registry.SimpleRegistry; public interface PredicateSerializer { - Registry> REGISTRY = new SimpleRegistry<>(); - Registry JSON_READERS = new SimpleRegistry<>(); + Registry> REGISTRY = Registries.createSimple(new Identifier("unicopia", "recipe_predicate")); + Registry JSON_READERS = Registries.createSimple(new Identifier("unicopia", "recipe_predicate_reader")); PredicateSerializer EMPTY = register("empty", new PredicateSerializer() { @Override diff --git a/src/main/java/com/minelittlepony/unicopia/recipe/ingredient/PredicatedIngredient.java b/src/main/java/com/minelittlepony/unicopia/world/recipe/ingredient/PredicatedIngredient.java similarity index 94% rename from src/main/java/com/minelittlepony/unicopia/recipe/ingredient/PredicatedIngredient.java rename to src/main/java/com/minelittlepony/unicopia/world/recipe/ingredient/PredicatedIngredient.java index 5ff07b27..5cf0b46e 100644 --- a/src/main/java/com/minelittlepony/unicopia/recipe/ingredient/PredicatedIngredient.java +++ b/src/main/java/com/minelittlepony/unicopia/world/recipe/ingredient/PredicatedIngredient.java @@ -1,4 +1,4 @@ -package com.minelittlepony.unicopia.recipe.ingredient; +package com.minelittlepony.unicopia.world.recipe.ingredient; import java.util.List; import java.util.Random; @@ -11,13 +11,13 @@ import com.google.gson.JsonArray; import com.google.gson.JsonElement; import com.google.gson.JsonObject; import com.google.gson.JsonParseException; -import com.minelittlepony.unicopia.recipe.Utils; +import com.minelittlepony.unicopia.world.recipe.Utils; import net.minecraft.item.ItemStack; import net.minecraft.recipe.Ingredient; -import net.minecraft.util.DefaultedList; +import net.minecraft.util.collection.DefaultedList; import net.minecraft.util.Lazy; -import net.minecraft.util.PacketByteBuf; +import net.minecraft.network.PacketByteBuf; @Immutable public class PredicatedIngredient { diff --git a/src/main/java/com/minelittlepony/unicopia/recipe/ingredient/SpellPredicate.java b/src/main/java/com/minelittlepony/unicopia/world/recipe/ingredient/SpellPredicate.java similarity index 90% rename from src/main/java/com/minelittlepony/unicopia/recipe/ingredient/SpellPredicate.java rename to src/main/java/com/minelittlepony/unicopia/world/recipe/ingredient/SpellPredicate.java index 6df116ca..7b0aaebc 100644 --- a/src/main/java/com/minelittlepony/unicopia/recipe/ingredient/SpellPredicate.java +++ b/src/main/java/com/minelittlepony/unicopia/world/recipe/ingredient/SpellPredicate.java @@ -1,16 +1,16 @@ -package com.minelittlepony.unicopia.recipe.ingredient; +package com.minelittlepony.unicopia.world.recipe.ingredient; import java.util.Random; import java.util.stream.Stream; import com.google.gson.JsonObject; -import com.minelittlepony.unicopia.item.UItems; import com.minelittlepony.unicopia.magic.Spell; import com.minelittlepony.unicopia.magic.spell.SpellRegistry; -import com.minelittlepony.unicopia.recipe.Utils; +import com.minelittlepony.unicopia.world.item.UItems; +import com.minelittlepony.unicopia.world.recipe.Utils; import net.minecraft.item.ItemStack; -import net.minecraft.util.PacketByteBuf; +import net.minecraft.network.PacketByteBuf; /** * A predicate that tests for a specific spell on an input when matching. diff --git a/src/main/java/com/minelittlepony/unicopia/recipe/ingredient/StackPredicate.java b/src/main/java/com/minelittlepony/unicopia/world/recipe/ingredient/StackPredicate.java similarity index 93% rename from src/main/java/com/minelittlepony/unicopia/recipe/ingredient/StackPredicate.java rename to src/main/java/com/minelittlepony/unicopia/world/recipe/ingredient/StackPredicate.java index 1eaa1066..093f3d18 100644 --- a/src/main/java/com/minelittlepony/unicopia/recipe/ingredient/StackPredicate.java +++ b/src/main/java/com/minelittlepony/unicopia/world/recipe/ingredient/StackPredicate.java @@ -1,4 +1,4 @@ -package com.minelittlepony.unicopia.recipe.ingredient; +package com.minelittlepony.unicopia.world.recipe.ingredient; import java.util.Random; import java.util.stream.Stream; @@ -6,15 +6,15 @@ import java.util.stream.Stream; import com.google.gson.JsonElement; import com.google.gson.JsonObject; import com.google.gson.JsonSyntaxException; -import com.minelittlepony.unicopia.recipe.Utils; +import com.minelittlepony.unicopia.world.recipe.Utils; import net.minecraft.item.Item; import net.minecraft.item.ItemGroup; import net.minecraft.item.ItemStack; import net.minecraft.item.Items; -import net.minecraft.util.DefaultedList; +import net.minecraft.util.collection.DefaultedList; import net.minecraft.util.JsonHelper; -import net.minecraft.util.PacketByteBuf; +import net.minecraft.network.PacketByteBuf; import net.minecraft.util.registry.Registry; /** diff --git a/src/main/java/com/minelittlepony/unicopia/recipe/ingredient/TagPredicate.java b/src/main/java/com/minelittlepony/unicopia/world/recipe/ingredient/TagPredicate.java similarity index 88% rename from src/main/java/com/minelittlepony/unicopia/recipe/ingredient/TagPredicate.java rename to src/main/java/com/minelittlepony/unicopia/world/recipe/ingredient/TagPredicate.java index 3b3b2185..0a47353d 100644 --- a/src/main/java/com/minelittlepony/unicopia/recipe/ingredient/TagPredicate.java +++ b/src/main/java/com/minelittlepony/unicopia/world/recipe/ingredient/TagPredicate.java @@ -1,11 +1,11 @@ -package com.minelittlepony.unicopia.recipe.ingredient; +package com.minelittlepony.unicopia.world.recipe.ingredient; import java.util.Random; import java.util.stream.Stream; import com.google.gson.JsonElement; import com.google.gson.JsonObject; -import com.minelittlepony.unicopia.recipe.Utils; +import com.minelittlepony.unicopia.world.recipe.Utils; import net.minecraft.item.Item; import net.minecraft.item.ItemStack; @@ -13,7 +13,7 @@ import net.minecraft.tag.ItemTags; import net.minecraft.tag.Tag; import net.minecraft.util.Identifier; import net.minecraft.util.JsonHelper; -import net.minecraft.util.PacketByteBuf; +import net.minecraft.network.PacketByteBuf; /** * Tests for whether a tag contains the input when matching. @@ -34,10 +34,12 @@ class TagPredicate implements Predicate { return new TagPredicate(Utils.asIdentifier(e), 1); } + private final Identifier tagId; private final Tag tag; private final int count; TagPredicate(Identifier res, int count) { + tagId = res; tag = Utils.require(ItemTags.getContainer().get(res), "Unknown item tag '" + res + "'"); this.count = count; } @@ -62,7 +64,7 @@ class TagPredicate implements Predicate { @Override public void write(PacketByteBuf buf) { buf.writeInt(count); - buf.writeIdentifier(tag.getId()); + buf.writeIdentifier(tagId); } @Override @@ -83,7 +85,7 @@ class TagPredicate implements Predicate { @Override public void write(PacketByteBuf buf, TagPredicate predicate) { buf.writeInt(predicate.count); - buf.writeIdentifier(predicate.tag.getId()); + buf.writeIdentifier(predicate.tagId); } } } diff --git a/src/main/java/com/minelittlepony/unicopia/recipe/ingredient/ToxicityPredicate.java b/src/main/java/com/minelittlepony/unicopia/world/recipe/ingredient/ToxicityPredicate.java similarity index 91% rename from src/main/java/com/minelittlepony/unicopia/recipe/ingredient/ToxicityPredicate.java rename to src/main/java/com/minelittlepony/unicopia/world/recipe/ingredient/ToxicityPredicate.java index 275c6ad3..cbe0e485 100644 --- a/src/main/java/com/minelittlepony/unicopia/recipe/ingredient/ToxicityPredicate.java +++ b/src/main/java/com/minelittlepony/unicopia/world/recipe/ingredient/ToxicityPredicate.java @@ -1,15 +1,15 @@ -package com.minelittlepony.unicopia.recipe.ingredient; +package com.minelittlepony.unicopia.world.recipe.ingredient; import java.util.Random; import java.util.stream.Stream; import com.google.gson.JsonObject; import com.minelittlepony.unicopia.toxin.Toxicity; -import com.minelittlepony.unicopia.recipe.Utils; +import com.minelittlepony.unicopia.world.recipe.Utils; import net.minecraft.item.ItemStack; import net.minecraft.util.JsonHelper; -import net.minecraft.util.PacketByteBuf; +import net.minecraft.network.PacketByteBuf; /** * A predicate that tests for a specific spell on an input when matching. diff --git a/src/main/java/com/minelittlepony/unicopia/structure/CloudDungeonFeature.java b/src/main/java/com/minelittlepony/unicopia/world/structure/CloudDungeonFeature.java similarity index 60% rename from src/main/java/com/minelittlepony/unicopia/structure/CloudDungeonFeature.java rename to src/main/java/com/minelittlepony/unicopia/world/structure/CloudDungeonFeature.java index 596f229e..c1ffc057 100644 --- a/src/main/java/com/minelittlepony/unicopia/structure/CloudDungeonFeature.java +++ b/src/main/java/com/minelittlepony/unicopia/world/structure/CloudDungeonFeature.java @@ -1,13 +1,11 @@ -package com.minelittlepony.unicopia.structure; +package com.minelittlepony.unicopia.world.structure; import java.util.Random; -import java.util.function.Function; - -import com.mojang.datafixers.Dynamic; - +import com.mojang.serialization.Codec; import net.minecraft.nbt.CompoundTag; import net.minecraft.structure.SimpleStructurePiece; import net.minecraft.structure.StructureManager; +import net.minecraft.structure.StructurePieceType; import net.minecraft.structure.StructurePlacementData; import net.minecraft.structure.StructureStart; import net.minecraft.structure.processor.BlockIgnoreStructureProcessor; @@ -16,18 +14,13 @@ import net.minecraft.util.BlockRotation; import net.minecraft.util.Identifier; import net.minecraft.util.math.BlockBox; import net.minecraft.util.math.BlockPos; -import net.minecraft.world.IWorld; +import net.minecraft.world.WorldAccess; import net.minecraft.world.biome.Biome; -import net.minecraft.world.gen.GenerationStep; import net.minecraft.world.gen.chunk.ChunkGenerator; -import net.minecraft.world.gen.decorator.Decorator; -import net.minecraft.world.gen.decorator.NopeDecoratorConfig; -import net.minecraft.world.gen.feature.AbstractTempleFeature; import net.minecraft.world.gen.feature.DefaultFeatureConfig; -import net.minecraft.world.gen.feature.FeatureConfig; import net.minecraft.world.gen.feature.StructureFeature; -class CloudDungeonFeature extends AbstractTempleFeature { +class CloudDungeonFeature extends StructureFeature { private static final BlockPos POS = new BlockPos(4, 0, 15); private static final Identifier[] VARIANTS = new Identifier[] { new Identifier("unicopia", "cloud/center"), @@ -41,43 +34,22 @@ class CloudDungeonFeature extends AbstractTempleFeature { new Identifier("unicopia", "cloud/huge_ruin/four") }; - public CloudDungeonFeature(Function, ? extends DefaultFeatureConfig> func, Biome...biomes) { - super(func); - - for (Biome biome : biomes) { - biome.addFeature(GenerationStep.Feature.LOCAL_MODIFICATIONS, configure(FeatureConfig.DEFAULT) - .createDecoratedFeature(Decorator.NOPE - .configure(NopeDecoratorConfig.DEFAULT))); - } + public CloudDungeonFeature(Codec codec) { + super(codec); } @Override - protected int getSeedModifier() { - return 143592; - } - - @Override - public String getName() { - return "unicopia:clouds"; - } - - @Override - public int getRadius() { - return 12; - } - - @Override - public StructureStartFactory getStructureStartFactory() { + public StructureStartFactory getStructureStartFactory() { return Start::new; } - public static class Start extends StructureStart { - public Start(StructureFeature feature, int x, int z, BlockBox bound, int var6, long var7) { + public static class Start extends StructureStart { + public Start(StructureFeature feature, int x, int z, BlockBox bound, int var6, long var7) { super(feature, x, z, bound, var6, var7); } @Override - public void initialize(ChunkGenerator generator, StructureManager manager, int x, int z, Biome biome) { + public void init(ChunkGenerator generator, StructureManager manager, int x, int z, Biome biome, DefaultFeatureConfig featureConfig) { BlockRotation rotation = BlockRotation.values()[random.nextInt(BlockRotation.values().length)]; BlockPos pos = new BlockPos(x * 16, 150, z * 16); @@ -90,11 +62,13 @@ class CloudDungeonFeature extends AbstractTempleFeature { public static class Piece extends SimpleStructurePiece { + public static final StructurePieceType TYPE = Piece::new; + private final BlockRotation rotation; private final Identifier template; public Piece(StructureManager manager, Identifier template, BlockPos pos, BlockRotation rotation) { - super(UStructures.CLOUD_HOUSE_PART, 0); + super(TYPE, 0); this.pos = pos; this.rotation = rotation; this.template = template; @@ -103,29 +77,29 @@ class CloudDungeonFeature extends AbstractTempleFeature { } public Piece(StructureManager manager, CompoundTag tag) { - super(UStructures.CLOUD_HOUSE_PART, tag); + super(TYPE, tag); this.template = new Identifier(tag.getString("Template")); this.rotation = BlockRotation.valueOf(tag.getString("Rot")); init(manager); } @Override - protected void toNbt(CompoundTag compoundTag_1) { - super.toNbt(compoundTag_1); - compoundTag_1.putString("Template", template.toString()); - compoundTag_1.putString("Rot", rotation.name()); + protected void toNbt(CompoundTag tag) { + super.toNbt(tag); + tag.putString("Template", template.toString()); + tag.putString("Rot", rotation.name()); } private void init(StructureManager manager) { setStructureData(manager.getStructureOrBlank(template), pos, new StructurePlacementData() .setRotation(rotation) - .setMirrored(BlockMirror.NONE) + .setMirror(BlockMirror.NONE) .setPosition(POS) .addProcessor(BlockIgnoreStructureProcessor.IGNORE_AIR_AND_STRUCTURE_BLOCKS)); } @Override - protected void handleMetadata(String var1, BlockPos var2, IWorld var3, Random var4, BlockBox var5) { + protected void handleMetadata(String key, BlockPos pos, WorldAccess world, Random rand, BlockBox box) { } } diff --git a/src/main/java/com/minelittlepony/unicopia/world/structure/CustomSaplingGenerator.java b/src/main/java/com/minelittlepony/unicopia/world/structure/CustomSaplingGenerator.java new file mode 100644 index 00000000..f3282a75 --- /dev/null +++ b/src/main/java/com/minelittlepony/unicopia/world/structure/CustomSaplingGenerator.java @@ -0,0 +1,74 @@ +package com.minelittlepony.unicopia.world.structure; + +import java.util.Random; +import javax.annotation.Nullable; + +import com.google.common.collect.ImmutableList; +import com.minelittlepony.unicopia.world.block.UBlocks; + +import net.minecraft.block.BlockState; +import net.minecraft.block.Blocks; +import net.minecraft.block.sapling.SaplingGenerator; +import net.minecraft.world.gen.decorator.BeehiveTreeDecorator; +import net.minecraft.world.gen.feature.ConfiguredFeature; +import net.minecraft.world.gen.feature.Feature; +import net.minecraft.world.gen.feature.TreeFeatureConfig; +import net.minecraft.world.gen.feature.size.TwoLayersFeatureSize; +import net.minecraft.world.gen.foliage.BlobFoliagePlacer; +import net.minecraft.world.gen.stateprovider.SimpleBlockStateProvider; +import net.minecraft.world.gen.trunk.StraightTrunkPlacer; + +public class CustomSaplingGenerator extends SaplingGenerator { + public static final CustomSaplingGenerator APPLE_TREE = new CustomSaplingGenerator(5, Blocks.OAK_LOG.getDefaultState(), UBlocks.APPLE_LEAVES.getDefaultState()); + + public final TreeFeatureConfig fancyConfig; + public final TreeFeatureConfig fancyHiveConfig; + public final TreeFeatureConfig hiveConfig; + public final TreeFeatureConfig config; + + public CustomSaplingGenerator(int height, BlockState log, BlockState leaves) { + fancyConfig = new TreeFeatureConfig.Builder( + new SimpleBlockStateProvider(log), + new SimpleBlockStateProvider(leaves), + new BlobFoliagePlacer(2, 0, 0, 0, 3), + new StraightTrunkPlacer(height, 2, 0), + new TwoLayersFeatureSize(1, 0, 1)) + .build(); + fancyHiveConfig = new TreeFeatureConfig.Builder( + new SimpleBlockStateProvider(log), + new SimpleBlockStateProvider(leaves), + new BlobFoliagePlacer(2, 0, 0, 0, 3), + new StraightTrunkPlacer(height, 2, 0), + new TwoLayersFeatureSize(1, 0, 1)) + .decorators(ImmutableList.of(new BeehiveTreeDecorator(0.05F))) + .build(); + + hiveConfig = new TreeFeatureConfig.Builder( + new SimpleBlockStateProvider(log), + new SimpleBlockStateProvider(leaves), + new BlobFoliagePlacer(2, 0, 0, 0, 3), + new StraightTrunkPlacer(height, height / 2, (height * 2) / 3), + new TwoLayersFeatureSize(1, 0, 1)) + .ignoreVines() + .decorators(ImmutableList.of(new BeehiveTreeDecorator(0.05F))) + .build(); + + config = new TreeFeatureConfig.Builder( + new SimpleBlockStateProvider(log), + new SimpleBlockStateProvider(leaves), + new BlobFoliagePlacer(2, 0, 0, 0, 3), + new StraightTrunkPlacer(height, height / 2, (height * 2) / 3), + new TwoLayersFeatureSize(1, 0, 1)) + .ignoreVines() + .build(); + } + + @Override + @Nullable + protected ConfiguredFeature createTreeFeature(Random random, boolean hives) { + return Feature.TREE.configure(random.nextInt(10) == 0 + ? (hives ? fancyHiveConfig : fancyConfig) + : (hives ? hiveConfig : config) + ); + } +} diff --git a/src/main/java/com/minelittlepony/unicopia/structure/RuinFeature.java b/src/main/java/com/minelittlepony/unicopia/world/structure/RuinFeature.java similarity index 65% rename from src/main/java/com/minelittlepony/unicopia/structure/RuinFeature.java rename to src/main/java/com/minelittlepony/unicopia/world/structure/RuinFeature.java index 0408d740..19319996 100644 --- a/src/main/java/com/minelittlepony/unicopia/structure/RuinFeature.java +++ b/src/main/java/com/minelittlepony/unicopia/world/structure/RuinFeature.java @@ -1,13 +1,13 @@ -package com.minelittlepony.unicopia.structure; +package com.minelittlepony.unicopia.world.structure; import java.util.Random; -import java.util.function.Function; -import com.mojang.datafixers.Dynamic; +import com.mojang.serialization.Codec; import net.minecraft.nbt.CompoundTag; import net.minecraft.structure.SimpleStructurePiece; import net.minecraft.structure.StructureManager; +import net.minecraft.structure.StructurePieceType; import net.minecraft.structure.StructurePlacementData; import net.minecraft.structure.StructureStart; import net.minecraft.structure.processor.BlockIgnoreStructureProcessor; @@ -16,18 +16,13 @@ import net.minecraft.util.BlockRotation; import net.minecraft.util.Identifier; import net.minecraft.util.math.BlockBox; import net.minecraft.util.math.BlockPos; -import net.minecraft.world.IWorld; +import net.minecraft.world.WorldAccess; import net.minecraft.world.biome.Biome; -import net.minecraft.world.gen.GenerationStep; import net.minecraft.world.gen.chunk.ChunkGenerator; -import net.minecraft.world.gen.decorator.Decorator; -import net.minecraft.world.gen.decorator.DecoratorConfig; -import net.minecraft.world.gen.feature.AbstractTempleFeature; import net.minecraft.world.gen.feature.DefaultFeatureConfig; -import net.minecraft.world.gen.feature.FeatureConfig; import net.minecraft.world.gen.feature.StructureFeature; -class RuinFeature extends AbstractTempleFeature { +class RuinFeature extends StructureFeature { private static final BlockPos POS = new BlockPos(4, 0, 15); private static final Identifier[] VARIANTS = new Identifier[] { new Identifier("unicopia", "ground/tower"), @@ -37,43 +32,22 @@ class RuinFeature extends AbstractTempleFeature { new Identifier("unicopia", "ground/wizard_tower_blue") }; - public RuinFeature(Function, ? extends DefaultFeatureConfig> func, Biome... biomes) { + public RuinFeature(Codec func) { super(func); - - for (Biome biome : biomes) { - biome.addFeature(GenerationStep.Feature.SURFACE_STRUCTURES, - configure(FeatureConfig.DEFAULT) - .createDecoratedFeature(Decorator.NOPE.configure(DecoratorConfig.DEFAULT))); - } } @Override - public String getName() { - return "unicopia:ruins"; - } - - @Override - public int getRadius() { - return 12; - } - - @Override - protected int getSeedModifier() { - return 39548; - } - - @Override - public StructureStartFactory getStructureStartFactory() { + public StructureStartFactory getStructureStartFactory() { return Start::new; } - public static class Start extends StructureStart { - public Start(StructureFeature feature, int x, int z, BlockBox bound, int var6, long var7) { + public static class Start extends StructureStart { + public Start(StructureFeature feature, int x, int z, BlockBox bound, int var6, long var7) { super(feature, x, z, bound, var6, var7); } @Override - public void initialize(ChunkGenerator generator, StructureManager manager, int x, int z, Biome biome) { + public void init(ChunkGenerator generator, StructureManager manager, int x, int z, Biome biome, DefaultFeatureConfig featureConfig) { BlockRotation rotation = BlockRotation.values()[random.nextInt(BlockRotation.values().length)]; BlockPos pos = new BlockPos(x * 16, 150, z * 16); @@ -86,11 +60,13 @@ class RuinFeature extends AbstractTempleFeature { public static class Piece extends SimpleStructurePiece { + public static final StructurePieceType TYPE = Piece::new; + private final BlockRotation rotation; private final Identifier template; public Piece(StructureManager manager, Identifier template, BlockPos pos, BlockRotation rotation) { - super(UStructures.RUIN_PART, 0); + super(TYPE, 0); this.pos = pos; this.rotation = rotation; this.template = template; @@ -99,7 +75,7 @@ class RuinFeature extends AbstractTempleFeature { } public Piece(StructureManager manager, CompoundTag tag) { - super(UStructures.RUIN_PART, tag); + super(TYPE, tag); this.template = new Identifier(tag.getString("Template")); this.rotation = BlockRotation.valueOf(tag.getString("Rot")); init(manager); @@ -115,13 +91,13 @@ class RuinFeature extends AbstractTempleFeature { private void init(StructureManager manager) { setStructureData(manager.getStructureOrBlank(template), pos, new StructurePlacementData() .setRotation(rotation) - .setMirrored(BlockMirror.NONE) + .setMirror(BlockMirror.NONE) .setPosition(POS) .addProcessor(BlockIgnoreStructureProcessor.IGNORE_AIR_AND_STRUCTURE_BLOCKS)); } @Override - protected void handleMetadata(String var1, BlockPos var2, IWorld var3, Random var4, BlockBox var5) { + protected void handleMetadata(String var1, BlockPos var2, WorldAccess var3, Random var4, BlockBox var5) { } } } diff --git a/src/main/java/com/minelittlepony/unicopia/world/structure/StructureFeatureBuilder.java b/src/main/java/com/minelittlepony/unicopia/world/structure/StructureFeatureBuilder.java new file mode 100644 index 00000000..9292e7a4 --- /dev/null +++ b/src/main/java/com/minelittlepony/unicopia/world/structure/StructureFeatureBuilder.java @@ -0,0 +1,108 @@ +package com.minelittlepony.unicopia.world.structure; + +import java.util.ArrayList; +import java.util.HashMap; +import java.util.List; +import java.util.Map; +import java.util.function.Function; + +import com.google.common.collect.ImmutableMap; +import com.minelittlepony.unicopia.mixin.MixinStructureFeature; +import com.minelittlepony.unicopia.mixin.MixinStructuresConfig; +import com.mojang.serialization.Codec; + +import net.minecraft.structure.StructurePieceType; +import net.minecraft.util.Identifier; +import net.minecraft.util.registry.Registry; +import net.minecraft.world.biome.Biome; +import net.minecraft.world.gen.GenerationStep; +import net.minecraft.world.gen.chunk.StructureConfig; +import net.minecraft.world.gen.chunk.StructuresConfig; +import net.minecraft.world.gen.feature.ConfiguredStructureFeature; +import net.minecraft.world.gen.feature.FeatureConfig; +import net.minecraft.world.gen.feature.StructureFeature; + +public class StructureFeatureBuilder, C extends FeatureConfig> { + private final Identifier id; + + private final Codec codec; + + private final Function, T> factory; + + private GenerationStep.Feature step; + + private StructureConfig config = new StructureConfig(0, 0, 1); + + private List biomes = new ArrayList<>(); + + private final Map pieces = new HashMap<>(); + + public StructureFeatureBuilder(Identifier id, Codec codec, Function, T> factory) { + this.id = id; + this.codec = codec; + this.factory = factory; + } + + public StructureFeatureBuilder biomes(C config, Biome...biomes) { + this.biomes.add(new ConfiguredBiomes(config, biomes)); + return this; + } + + public StructureFeatureBuilder config(int spacing, int separation, int seed) { + if (spacing >= separation) { + throw new IllegalArgumentException("Spacing must be less than separation"); + } + config = new StructureConfig(spacing, separation, seed); + return this; + } + + public StructureFeatureBuilder step(GenerationStep.Feature step) { + this.step = step; + return this; + } + + public StructureFeatureBuilder piece(String name, StructurePieceType piece) { + if (!pieces.containsValue(piece)) { + pieces.put(name, piece); + } + return this; + } + + public T build() { + T feature = factory.apply(codec); + + Map, StructureConfig> configs = new HashMap<>(StructuresConfig.DEFAULT_STRUCTURES); + configs.put(feature, config); + + MixinStructuresConfig.setDefaultConfigs(ImmutableMap.copyOf(configs)); + + MixinStructureFeature.register(id.toString(), feature, step); + + pieces.forEach((name, piece) -> { + Registry.register(Registry.STRUCTURE_PIECE, new Identifier(id.getNamespace(), id.getPath() + "/" + name), piece); + }); + + if (!biomes.isEmpty()) { + biomes.forEach(set -> set.configure(feature)); + } + + return feature; + } + + class ConfiguredBiomes { + private final C config; + private final Biome[] biomes; + + ConfiguredBiomes(C config, Biome[] biomes) { + this.config = config; + this.biomes = biomes; + } + + void configure(T feature) { + ConfiguredStructureFeature> configuredFeature = feature.configure(config); + for (Biome biome : biomes) { + biome.addStructureFeature(configuredFeature); + } + } + } +} diff --git a/src/main/java/com/minelittlepony/unicopia/world/structure/StructureRegistry.java b/src/main/java/com/minelittlepony/unicopia/world/structure/StructureRegistry.java new file mode 100644 index 00000000..4255429a --- /dev/null +++ b/src/main/java/com/minelittlepony/unicopia/world/structure/StructureRegistry.java @@ -0,0 +1,16 @@ +package com.minelittlepony.unicopia.world.structure; + +import java.util.function.Function; + +import com.mojang.serialization.Codec; + +import net.minecraft.util.Identifier; +import net.minecraft.world.gen.feature.FeatureConfig; +import net.minecraft.world.gen.feature.StructureFeature; + +public class StructureRegistry { + public static , C extends FeatureConfig> StructureFeatureBuilder start(Identifier id, Codec codec, Function, T> factory) { + return new StructureFeatureBuilder<>(id, codec, factory); + } + +} diff --git a/src/main/java/com/minelittlepony/unicopia/world/structure/UStructures.java b/src/main/java/com/minelittlepony/unicopia/world/structure/UStructures.java new file mode 100644 index 00000000..75de7156 --- /dev/null +++ b/src/main/java/com/minelittlepony/unicopia/world/structure/UStructures.java @@ -0,0 +1,52 @@ +package com.minelittlepony.unicopia.world.structure; + +import com.google.common.collect.ImmutableList; + +import net.minecraft.structure.StructurePieceType; +import net.minecraft.util.Identifier; +import net.minecraft.util.registry.Registry; +import net.minecraft.world.biome.Biome; +import net.minecraft.world.biome.Biomes; +import net.minecraft.world.gen.GenerationStep; +import net.minecraft.world.gen.decorator.CountExtraChanceDecoratorConfig; +import net.minecraft.world.gen.decorator.Decorator; +import net.minecraft.world.gen.feature.DefaultFeatureConfig; +import net.minecraft.world.gen.feature.Feature; +import net.minecraft.world.gen.feature.RandomFeatureConfig; +import net.minecraft.world.gen.feature.StructureFeature; + +public interface UStructures { + StructureFeature CLOUD_HOUSE = StructureRegistry.start( + new Identifier("unicopia", "cloud_house"), DefaultFeatureConfig.CODEC, CloudDungeonFeature::new) + .config(0, 12, 143592) + .biomes(DefaultFeatureConfig.INSTANCE, Biomes.OCEAN, Biomes.WOODED_BADLANDS_PLATEAU, Biomes.DESERT, Biomes.DESERT_HILLS, Biomes.JUNGLE, Biomes.JUNGLE_HILLS, Biomes.SWAMP, Biomes.SWAMP_HILLS, Biomes.ICE_SPIKES, Biomes.TAIGA) + .piece("cloud_house", CloudDungeonFeature.Piece.TYPE) + .build(); + + StructureFeature RUIN = StructureRegistry.start( + new Identifier("unicopia", "ruin"), DefaultFeatureConfig.CODEC, RuinFeature::new) + .config(0, 12, 39548) + .biomes(DefaultFeatureConfig.INSTANCE, Biomes.TAIGA, Biomes.TAIGA_HILLS, Biomes.GIANT_TREE_TAIGA, Biomes.GIANT_TREE_TAIGA_HILLS, Biomes.SNOWY_TAIGA, Biomes.SNOWY_TAIGA_HILLS, Biomes.GIANT_SPRUCE_TAIGA, Biomes.GIANT_TREE_TAIGA_HILLS, Biomes.SNOWY_TAIGA_MOUNTAINS, Biomes.DARK_FOREST, Biomes.DARK_FOREST_HILLS) + .piece("ruin", RuinFeature.Piece.TYPE) + .build(); + + static StructurePieceType part(String id, StructurePieceType type) { + return Registry.register(Registry.STRUCTURE_PIECE, new Identifier("unicopia", id), type); + } + + static void bootstrap() { + Registry.BIOME.forEach(biome -> { + Biome.Category category = biome.getCategory(); + + if (category == Biome.Category.FOREST) { + biome.addFeature(GenerationStep.Feature.VEGETAL_DECORATION, + Feature.RANDOM_SELECTOR.configure(new RandomFeatureConfig(ImmutableList.of( + Feature.TREE.configure(CustomSaplingGenerator.APPLE_TREE.hiveConfig).withChance(0.02F), + Feature.TREE.configure(CustomSaplingGenerator.APPLE_TREE.fancyConfig).withChance(0.01F)), + Feature.TREE.configure(CustomSaplingGenerator.APPLE_TREE.config) + )) + .createDecoratedFeature(Decorator.COUNT_EXTRA_HEIGHTMAP.configure(new CountExtraChanceDecoratorConfig(0, 0.1F, 3)))); + } + }); + } +} diff --git a/src/main/resources/data/minecraft/tags/blocks/climbable.json b/src/main/resources/data/minecraft/tags/blocks/climbable.json new file mode 100644 index 00000000..8bd3e326 --- /dev/null +++ b/src/main/resources/data/minecraft/tags/blocks/climbable.json @@ -0,0 +1,6 @@ +{ + "replace": false, + "values": [ + "unicopia:slime_drip" + ] +} \ No newline at end of file diff --git a/src/main/resources/unicopia.mixin.json b/src/main/resources/unicopia.mixin.json index 3499811c..08618ae7 100644 --- a/src/main/resources/unicopia.mixin.json +++ b/src/main/resources/unicopia.mixin.json @@ -18,6 +18,8 @@ "MixinPlayerEntity", "MixinProjectileEntity", "MixinServerPlayerEntity", + "MixinStructureFeature", + "MixinStructuresConfig", "Walker" ], "client": [