mirror of
https://github.com/Sollace/Unicopia.git
synced 2024-11-23 21:38:00 +01:00
More organisation
This commit is contained in:
parent
50f3e09499
commit
89eed4e3f1
74 changed files with 133 additions and 254 deletions
|
@ -1,4 +1,4 @@
|
|||
package com.minelittlepony.unicopia.util;
|
||||
package com.minelittlepony.unicopia;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.Queue;
|
||||
|
@ -7,7 +7,6 @@ import java.util.stream.Collectors;
|
|||
|
||||
import com.google.common.collect.Lists;
|
||||
import com.google.common.collect.Queues;
|
||||
import com.minelittlepony.unicopia.UnicopiaCore;
|
||||
|
||||
import net.minecraft.world.World;
|
||||
|
|
@ -2,6 +2,7 @@ package com.minelittlepony.unicopia;
|
|||
|
||||
import java.util.List;
|
||||
|
||||
import com.minelittlepony.unicopia.block.UBlocks;
|
||||
import com.minelittlepony.unicopia.item.UItems;
|
||||
import com.minelittlepony.unicopia.magic.spell.SpellRegistry;
|
||||
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
package com.minelittlepony.unicopia;
|
||||
|
||||
public interface IKeyBinding {
|
||||
public interface KeyBind {
|
||||
String getKeyCategory();
|
||||
|
||||
String getKeyName();
|
|
@ -11,7 +11,9 @@ import com.minelittlepony.common.util.GamePaths;
|
|||
import com.minelittlepony.jumpingcastle.api.Channel;
|
||||
import com.minelittlepony.jumpingcastle.api.JumpingCastle;
|
||||
import com.minelittlepony.unicopia.ability.Abilities;
|
||||
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.enchanting.recipe.AffineIngredients;
|
||||
import com.minelittlepony.unicopia.item.UItems;
|
||||
|
|
|
@ -3,14 +3,14 @@ package com.minelittlepony.unicopia.ability;
|
|||
import javax.annotation.Nullable;
|
||||
|
||||
import com.google.gson.annotations.Expose;
|
||||
import com.minelittlepony.unicopia.IKeyBinding;
|
||||
import com.minelittlepony.unicopia.KeyBind;
|
||||
import com.minelittlepony.unicopia.Race;
|
||||
import com.minelittlepony.unicopia.entity.player.Pony;
|
||||
|
||||
import net.minecraft.util.math.BlockPos;
|
||||
import net.minecraft.world.World;
|
||||
|
||||
public interface Ability<T extends Ability.IData> extends IKeyBinding {
|
||||
public interface Ability<T extends Ability.IData> extends KeyBind {
|
||||
|
||||
@Override
|
||||
default String getKeyCategory() {
|
||||
|
|
|
@ -6,11 +6,11 @@ import javax.annotation.Nullable;
|
|||
import org.lwjgl.glfw.GLFW;
|
||||
|
||||
import com.minelittlepony.unicopia.Race;
|
||||
import com.minelittlepony.unicopia.UParticles;
|
||||
import com.minelittlepony.unicopia.entity.InAnimate;
|
||||
import com.minelittlepony.unicopia.entity.player.Pony;
|
||||
import com.minelittlepony.unicopia.magic.spell.DisguiseSpell;
|
||||
import com.minelittlepony.unicopia.util.VecHelper;
|
||||
import com.minelittlepony.unicopia.util.particles.UParticles;
|
||||
|
||||
import net.minecraft.block.BlockState;
|
||||
import net.minecraft.entity.Entity;
|
||||
|
|
|
@ -3,9 +3,9 @@ package com.minelittlepony.unicopia.ability;
|
|||
import org.lwjgl.glfw.GLFW;
|
||||
|
||||
import com.minelittlepony.unicopia.Race;
|
||||
import com.minelittlepony.unicopia.UParticles;
|
||||
import com.minelittlepony.unicopia.entity.player.Pony;
|
||||
import com.minelittlepony.unicopia.util.VecHelper;
|
||||
import com.minelittlepony.unicopia.util.particles.UParticles;
|
||||
|
||||
import net.minecraft.block.BlockState;
|
||||
import net.minecraft.item.BoneMealItem;
|
||||
|
|
|
@ -6,10 +6,10 @@ import org.lwjgl.glfw.GLFW;
|
|||
|
||||
import com.google.common.collect.Lists;
|
||||
import com.google.gson.annotations.Expose;
|
||||
import com.minelittlepony.unicopia.AwaitTickQueue;
|
||||
import com.minelittlepony.unicopia.Race;
|
||||
import com.minelittlepony.unicopia.entity.player.Pony;
|
||||
import com.minelittlepony.unicopia.item.AppleItem;
|
||||
import com.minelittlepony.unicopia.util.AwaitTickQueue;
|
||||
import com.minelittlepony.unicopia.util.MagicalDamageSource;
|
||||
import com.minelittlepony.unicopia.util.PosHelper;
|
||||
import com.minelittlepony.unicopia.util.VecHelper;
|
||||
|
|
|
@ -5,9 +5,9 @@ import java.util.Optional;
|
|||
import org.lwjgl.glfw.GLFW;
|
||||
|
||||
import com.minelittlepony.unicopia.Race;
|
||||
import com.minelittlepony.unicopia.UParticles;
|
||||
import com.minelittlepony.unicopia.entity.player.Pony;
|
||||
import com.minelittlepony.unicopia.util.VecHelper;
|
||||
import com.minelittlepony.unicopia.util.particles.UParticles;
|
||||
|
||||
import net.minecraft.entity.Entity;
|
||||
|
||||
|
|
|
@ -3,9 +3,9 @@ package com.minelittlepony.unicopia.ability;
|
|||
import org.lwjgl.glfw.GLFW;
|
||||
|
||||
import com.minelittlepony.unicopia.Race;
|
||||
import com.minelittlepony.unicopia.UParticles;
|
||||
import com.minelittlepony.unicopia.entity.player.Pony;
|
||||
import com.minelittlepony.unicopia.magic.spell.ShieldSpell;
|
||||
import com.minelittlepony.unicopia.util.particles.UParticles;
|
||||
|
||||
/**
|
||||
* A magic casting ability for unicorns.
|
||||
|
|
|
@ -3,9 +3,9 @@ package com.minelittlepony.unicopia.ability;
|
|||
import org.lwjgl.glfw.GLFW;
|
||||
|
||||
import com.minelittlepony.unicopia.Race;
|
||||
import com.minelittlepony.unicopia.UParticles;
|
||||
import com.minelittlepony.unicopia.entity.player.Pony;
|
||||
import com.minelittlepony.unicopia.util.VecHelper;
|
||||
import com.minelittlepony.unicopia.util.particles.UParticles;
|
||||
|
||||
import net.minecraft.block.Block;
|
||||
import net.minecraft.block.BlockState;
|
||||
|
|
|
@ -6,8 +6,6 @@ import java.util.Random;
|
|||
import javax.annotation.Nullable;
|
||||
|
||||
import com.minelittlepony.unicopia.EquinePredicates;
|
||||
import com.minelittlepony.unicopia.UBlocks;
|
||||
import com.minelittlepony.unicopia.UMaterials;
|
||||
import com.minelittlepony.unicopia.USounds;
|
||||
import com.minelittlepony.unicopia.util.MagicalDamageSource;
|
||||
import com.minelittlepony.unicopia.util.PosHelper;
|
||||
|
|
|
@ -3,7 +3,6 @@ package com.minelittlepony.unicopia.block;
|
|||
import javax.annotation.Nullable;
|
||||
|
||||
import com.minelittlepony.unicopia.Race;
|
||||
import com.minelittlepony.unicopia.UMaterials;
|
||||
import com.minelittlepony.unicopia.entity.player.Pony;
|
||||
|
||||
import net.fabricmc.fabric.api.block.FabricBlockSettings;
|
||||
|
|
|
@ -1,7 +1,6 @@
|
|||
package com.minelittlepony.unicopia.block;
|
||||
|
||||
import com.minelittlepony.unicopia.Race;
|
||||
import com.minelittlepony.unicopia.UMaterials;
|
||||
import com.minelittlepony.unicopia.entity.player.Pony;
|
||||
|
||||
import net.fabricmc.fabric.api.block.FabricBlockSettings;
|
||||
|
|
|
@ -2,9 +2,9 @@ package com.minelittlepony.unicopia.block;
|
|||
|
||||
import java.util.Random;
|
||||
|
||||
import com.minelittlepony.unicopia.CloudType;
|
||||
import com.minelittlepony.unicopia.UParticles;
|
||||
import com.minelittlepony.unicopia.gas.CloudType;
|
||||
import com.minelittlepony.unicopia.gas.Gas;
|
||||
import com.minelittlepony.unicopia.util.particles.UParticles;
|
||||
|
||||
import net.fabricmc.fabric.api.block.FabricBlockSettings;
|
||||
import net.minecraft.block.Block;
|
||||
|
|
|
@ -5,8 +5,6 @@ import java.util.Random;
|
|||
|
||||
import com.google.common.collect.Maps;
|
||||
import com.minelittlepony.unicopia.Race;
|
||||
import com.minelittlepony.unicopia.UBlocks;
|
||||
import com.minelittlepony.unicopia.UMaterials;
|
||||
import com.minelittlepony.unicopia.USounds;
|
||||
import com.minelittlepony.unicopia.entity.player.Pony;
|
||||
import com.minelittlepony.unicopia.util.PosHelper;
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
package com.minelittlepony.unicopia.block;
|
||||
|
||||
import java.util.List;
|
||||
import com.minelittlepony.unicopia.UBlocks;
|
||||
|
||||
import com.minelittlepony.unicopia.gas.CloudFarmlandBlock;
|
||||
import com.minelittlepony.unicopia.item.UItems;
|
||||
|
||||
|
|
|
@ -1,7 +1,6 @@
|
|||
package com.minelittlepony.unicopia;
|
||||
package com.minelittlepony.unicopia.block;
|
||||
|
||||
import com.minelittlepony.unicopia.block.BlockGrowingCuccoon;
|
||||
import com.minelittlepony.unicopia.block.TomatoPlantBlock;
|
||||
import com.minelittlepony.unicopia.UnicopiaCore;
|
||||
import com.minelittlepony.unicopia.gas.CloudAnvilBlock;
|
||||
import com.minelittlepony.unicopia.gas.CloudBlock;
|
||||
import com.minelittlepony.unicopia.gas.CloudDoorBlock;
|
||||
|
@ -9,17 +8,7 @@ import com.minelittlepony.unicopia.gas.CloudFarmlandBlock;
|
|||
import com.minelittlepony.unicopia.gas.CloudFenceBlock;
|
||||
import com.minelittlepony.unicopia.gas.CloudSlabBlock;
|
||||
import com.minelittlepony.unicopia.gas.CloudStairsBlock;
|
||||
import com.minelittlepony.unicopia.block.ChiselledChitinBlock;
|
||||
import com.minelittlepony.unicopia.block.ChitinBlock;
|
||||
import com.minelittlepony.unicopia.block.DiamondDoorBlock;
|
||||
import com.minelittlepony.unicopia.block.DutchDoorBlock;
|
||||
import com.minelittlepony.unicopia.block.FruitLeavesBlock;
|
||||
import com.minelittlepony.unicopia.block.GlowingGemBlock;
|
||||
import com.minelittlepony.unicopia.block.HiveWallBlock;
|
||||
import com.minelittlepony.unicopia.block.SlimeLayerBlock;
|
||||
import com.minelittlepony.unicopia.block.StickBlock;
|
||||
import com.minelittlepony.unicopia.block.SugarBlock;
|
||||
import com.minelittlepony.unicopia.block.TallCropBlock;
|
||||
import com.minelittlepony.unicopia.gas.CloudType;
|
||||
import com.minelittlepony.unicopia.item.AppleItem;
|
||||
import com.minelittlepony.unicopia.item.UItems;
|
||||
import com.minelittlepony.unicopia.structure.CustomSaplingGenerator;
|
|
@ -1,4 +1,4 @@
|
|||
package com.minelittlepony.unicopia;
|
||||
package com.minelittlepony.unicopia.block;
|
||||
|
||||
import net.minecraft.block.Material;
|
||||
import net.minecraft.block.MaterialColor;
|
|
@ -3,7 +3,7 @@ package com.minelittlepony.unicopia.client;
|
|||
import java.util.HashSet;
|
||||
import java.util.Set;
|
||||
|
||||
import com.minelittlepony.unicopia.IKeyBinding;
|
||||
import com.minelittlepony.unicopia.KeyBind;
|
||||
import com.minelittlepony.unicopia.UnicopiaCore;
|
||||
import com.minelittlepony.unicopia.ability.Abilities;
|
||||
import com.minelittlepony.unicopia.entity.player.Pony;
|
||||
|
@ -24,7 +24,7 @@ class KeyBindingsHandler {
|
|||
|
||||
private final Set<KeyBinding> pressed = new HashSet<>();
|
||||
|
||||
public void addKeybind(IKeyBinding p) {
|
||||
public void addKeybind(KeyBind p) {
|
||||
KeyBindingRegistry.INSTANCE.addCategory(p.getKeyCategory());
|
||||
|
||||
FabricKeyBinding b = FabricKeyBinding.Builder.create(new Identifier(UnicopiaCore.MODID, p.getKeyName()), InputUtil.Type.KEYSYM, p.getKeyCode(), p.getKeyCategory()).build();
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
package com.minelittlepony.unicopia.util;
|
||||
package com.minelittlepony.unicopia.client;
|
||||
|
||||
import com.minelittlepony.unicopia.Race;
|
||||
|
|
@ -10,16 +10,15 @@ import com.minelittlepony.jumpingcastle.api.Target;
|
|||
import com.minelittlepony.unicopia.Config;
|
||||
import com.minelittlepony.unicopia.InteractionManager;
|
||||
import com.minelittlepony.unicopia.Race;
|
||||
import com.minelittlepony.unicopia.UBlocks;
|
||||
import com.minelittlepony.unicopia.UnicopiaCore;
|
||||
import com.minelittlepony.unicopia.ability.Abilities;
|
||||
import com.minelittlepony.unicopia.block.UBlocks;
|
||||
import com.minelittlepony.unicopia.client.render.DisguiseRenderer;
|
||||
import com.minelittlepony.unicopia.ducks.Colourful;
|
||||
import com.minelittlepony.unicopia.entity.player.Pony;
|
||||
import com.minelittlepony.unicopia.item.UItems;
|
||||
import com.minelittlepony.unicopia.magic.spell.SpellRegistry;
|
||||
import com.minelittlepony.unicopia.network.MsgRequestCapabilities;
|
||||
import com.minelittlepony.unicopia.util.MineLPConnector;
|
||||
import com.minelittlepony.unicopia.util.dummy.DummyClientPlayerEntity;
|
||||
import com.mojang.authlib.GameProfile;
|
||||
import com.mojang.blaze3d.platform.GlStateManager;
|
||||
|
|
|
@ -2,7 +2,7 @@ package com.minelittlepony.unicopia.client.render.model;
|
|||
|
||||
import com.minelittlepony.unicopia.client.render.ModelQuads;
|
||||
import com.minelittlepony.unicopia.entity.SpellcastEntity;
|
||||
import com.minelittlepony.util.Color;
|
||||
import com.minelittlepony.unicopia.util.Color;
|
||||
import com.mojang.blaze3d.platform.GLX;
|
||||
import com.mojang.blaze3d.platform.GlStateManager;
|
||||
|
||||
|
|
|
@ -7,7 +7,6 @@ import java.util.function.BiFunction;
|
|||
|
||||
import com.minelittlepony.unicopia.UTags;
|
||||
import com.minelittlepony.unicopia.advancement.BOHDeathCriterion;
|
||||
import com.minelittlepony.unicopia.util.HeavyInventoryUtils;
|
||||
import com.minelittlepony.unicopia.util.NbtSerialisable;
|
||||
import com.minelittlepony.unicopia.util.MagicalDamageSource;
|
||||
|
||||
|
@ -113,7 +112,7 @@ public class BagOfHoldingInventory extends BasicInventory implements NbtSerialis
|
|||
}
|
||||
}
|
||||
|
||||
HeavyInventoryUtils.encodeStackWeight(blockStack, HeavyInventoryUtils.getContentsTotalWorth(blockInventory, true), true);
|
||||
HeavyInventory.encodeStackWeight(blockStack, HeavyInventory.getContentsTotalWorth(blockInventory, true), true);
|
||||
|
||||
world.removeBlockEntity(pos);
|
||||
world.setBlockState(pos, Blocks.AIR.getDefaultState());
|
||||
|
@ -181,7 +180,7 @@ public class BagOfHoldingInventory extends BasicInventory implements NbtSerialis
|
|||
}
|
||||
|
||||
public double getContentsTotalWorth() {
|
||||
return HeavyInventoryUtils.getContentsTotalWorth(this, true);
|
||||
return HeavyInventory.getContentsTotalWorth(this, true);
|
||||
}
|
||||
|
||||
public void writeTostack(ItemStack stack) {
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
package com.minelittlepony.unicopia.util;
|
||||
package com.minelittlepony.unicopia.container;
|
||||
|
||||
import net.minecraft.block.Block;
|
||||
import net.minecraft.block.BlockEntityProvider;
|
||||
|
@ -8,7 +8,7 @@ import net.minecraft.item.ItemStack;
|
|||
import net.minecraft.nbt.CompoundTag;
|
||||
import net.minecraft.world.EmptyBlockView;
|
||||
|
||||
public class HeavyInventoryUtils {
|
||||
public class HeavyInventory {
|
||||
|
||||
public static double getContentsTotalWorth(Inventory inventory, boolean deep) {
|
||||
double total = 0;
|
|
@ -2,11 +2,11 @@ package com.minelittlepony.unicopia.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.magic.spell.SpellRegistry;
|
||||
import com.minelittlepony.unicopia.util.AwaitTickQueue;
|
||||
|
||||
import net.minecraft.container.Container;
|
||||
import net.minecraft.container.Slot;
|
||||
|
|
|
@ -1,7 +1,6 @@
|
|||
package com.minelittlepony.unicopia;
|
||||
package com.minelittlepony.unicopia.container;
|
||||
|
||||
import com.minelittlepony.unicopia.container.BagOfHoldingContainer;
|
||||
import com.minelittlepony.unicopia.container.SpellBookContainer;
|
||||
import com.minelittlepony.unicopia.UnicopiaCore;
|
||||
|
||||
import net.fabricmc.fabric.api.container.ContainerProviderRegistry;
|
||||
import net.minecraft.util.Identifier;
|
|
@ -6,12 +6,12 @@ import javax.annotation.Nullable;
|
|||
|
||||
import com.minelittlepony.unicopia.EquinePredicates;
|
||||
import com.minelittlepony.unicopia.Race;
|
||||
import com.minelittlepony.unicopia.UBlocks;
|
||||
import com.minelittlepony.unicopia.UParticles;
|
||||
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.util.particles.ParticleEmitter;
|
||||
import com.minelittlepony.unicopia.util.particles.UParticles;
|
||||
|
||||
import net.minecraft.block.BlockState;
|
||||
import net.minecraft.block.Blocks;
|
||||
|
|
|
@ -7,10 +7,10 @@ import javax.annotation.Nullable;
|
|||
import com.google.common.collect.Lists;
|
||||
import com.minelittlepony.unicopia.EquinePredicates;
|
||||
import com.minelittlepony.unicopia.Race;
|
||||
import com.minelittlepony.unicopia.UParticles;
|
||||
import com.minelittlepony.unicopia.USounds;
|
||||
import com.minelittlepony.unicopia.entity.player.Pony;
|
||||
import com.minelittlepony.unicopia.util.MagicalDamageSource;
|
||||
import com.minelittlepony.unicopia.util.particles.UParticles;
|
||||
|
||||
import net.minecraft.block.Blocks;
|
||||
import net.minecraft.entity.Entity;
|
||||
|
|
|
@ -1,7 +1,6 @@
|
|||
package com.minelittlepony.unicopia.entity;
|
||||
|
||||
import com.minelittlepony.unicopia.Race;
|
||||
import com.minelittlepony.unicopia.UEntities;
|
||||
|
||||
import net.minecraft.client.MinecraftClient;
|
||||
import net.minecraft.client.network.packet.EntitySpawnGlobalS2CPacket;
|
||||
|
|
|
@ -1,17 +1,6 @@
|
|||
package com.minelittlepony.unicopia;
|
||||
package com.minelittlepony.unicopia.entity;
|
||||
|
||||
import com.minelittlepony.unicopia.entity.ButterflyEntity;
|
||||
import com.minelittlepony.unicopia.entity.CloudEntity;
|
||||
import com.minelittlepony.unicopia.entity.ConstructionCloudEntity;
|
||||
import com.minelittlepony.unicopia.entity.CuccoonEntity;
|
||||
import com.minelittlepony.unicopia.entity.ProjectileEntity;
|
||||
import com.minelittlepony.unicopia.entity.RacingCloudEntity;
|
||||
import com.minelittlepony.unicopia.entity.RainbowEntity;
|
||||
import com.minelittlepony.unicopia.entity.SpearEntity;
|
||||
import com.minelittlepony.unicopia.entity.SpellbookEntity;
|
||||
import com.minelittlepony.unicopia.entity.SpellcastEntity;
|
||||
import com.minelittlepony.unicopia.entity.WildCloudEntity;
|
||||
import com.minelittlepony.unicopia.util.collection.ListHelper;
|
||||
import java.util.List;
|
||||
|
||||
import net.minecraft.entity.Entity;
|
||||
import net.minecraft.entity.EntityCategory;
|
||||
|
@ -55,16 +44,22 @@ public interface UEntities {
|
|||
static void bootstrap() {
|
||||
Registry.BIOME.forEach(biome -> {
|
||||
if (!(biome instanceof NetherBiome || biome instanceof EndBiome)) {
|
||||
ListHelper.addifAbsent(biome.getEntitySpawnList(EntityCategory.AMBIENT), biome instanceof OceanBiome ? WildCloudEntity.SPAWN_ENTRY_OCEAN : WildCloudEntity.SPAWN_ENTRY_LAND);
|
||||
ListHelper.addifAbsent(biome.getEntitySpawnList(EntityCategory.CREATURE), RainbowEntity.SPAWN_ENTRY);
|
||||
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) {
|
||||
ListHelper.addifAbsent(biome.getEntitySpawnList(EntityCategory.AMBIENT), ButterflyEntity.SPAWN_ENTRY);
|
||||
addifAbsent(biome.getEntitySpawnList(EntityCategory.AMBIENT), ButterflyEntity.SPAWN_ENTRY);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
static <T> void addifAbsent(List<T> entries, T entry) {
|
||||
if (!entries.contains(entry)) {
|
||||
entries.add(entry);
|
||||
}
|
||||
}
|
||||
}
|
|
@ -4,8 +4,6 @@ import java.util.Iterator;
|
|||
|
||||
import javax.annotation.Nullable;
|
||||
|
||||
import com.minelittlepony.unicopia.UEntities;
|
||||
|
||||
import net.minecraft.entity.Entity;
|
||||
import net.minecraft.entity.EntityData;
|
||||
import net.minecraft.entity.EntityType;
|
||||
|
|
|
@ -3,7 +3,6 @@ package com.minelittlepony.unicopia.entity.player;
|
|||
import java.util.Random;
|
||||
|
||||
import com.minelittlepony.unicopia.Race;
|
||||
import com.minelittlepony.unicopia.UParticles;
|
||||
import com.minelittlepony.unicopia.USounds;
|
||||
import com.minelittlepony.unicopia.ability.FlightPredicate;
|
||||
import com.minelittlepony.unicopia.ability.HeightPredicate;
|
||||
|
@ -12,6 +11,7 @@ import com.minelittlepony.unicopia.entity.Updatable;
|
|||
import com.minelittlepony.unicopia.magic.MagicEffect;
|
||||
import com.minelittlepony.unicopia.mixin.MixinEntity;
|
||||
import com.minelittlepony.unicopia.util.NbtSerialisable;
|
||||
import com.minelittlepony.unicopia.util.particles.UParticles;
|
||||
import com.minelittlepony.unicopia.util.MutableVector;
|
||||
|
||||
import net.minecraft.entity.Entity;
|
||||
|
|
|
@ -3,8 +3,8 @@ package com.minelittlepony.unicopia.entity.player;
|
|||
import java.util.UUID;
|
||||
|
||||
import com.minelittlepony.unicopia.Race;
|
||||
import com.minelittlepony.unicopia.container.HeavyInventory;
|
||||
import com.minelittlepony.unicopia.mixin.Walker;
|
||||
import com.minelittlepony.unicopia.util.HeavyInventoryUtils;
|
||||
|
||||
import net.minecraft.entity.attribute.EntityAttribute;
|
||||
import net.minecraft.entity.attribute.EntityAttributeInstance;
|
||||
|
@ -25,7 +25,7 @@ public class PlayerAttributes {
|
|||
private double loadStrength = 0;
|
||||
|
||||
public void applyAttributes(PlayerEntity entity, Race race) {
|
||||
loadStrength = HeavyInventoryUtils.getContentsTotalWorth(entity.inventory, false);
|
||||
loadStrength = HeavyInventory.getContentsTotalWorth(entity.inventory, false);
|
||||
|
||||
((Walker)entity.abilities).setWalkSpeed(0.1F - (float)(loadStrength / 100000));
|
||||
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
package com.minelittlepony.unicopia.entity.player;
|
||||
|
||||
import com.minelittlepony.util.MotionCompositor;
|
||||
import com.minelittlepony.unicopia.util.MotionCompositor;
|
||||
|
||||
import net.minecraft.util.math.Vec3d;
|
||||
|
||||
|
|
|
@ -3,13 +3,13 @@ package com.minelittlepony.unicopia.entity.player;
|
|||
import javax.annotation.Nullable;
|
||||
|
||||
import com.minelittlepony.unicopia.Race;
|
||||
import com.minelittlepony.unicopia.UEffects;
|
||||
import com.minelittlepony.unicopia.UTags;
|
||||
import com.minelittlepony.unicopia.UnicopiaCore;
|
||||
import com.minelittlepony.unicopia.ability.AbilityReceiver;
|
||||
import com.minelittlepony.unicopia.enchanting.PageOwner;
|
||||
import com.minelittlepony.unicopia.entity.FlightControl;
|
||||
import com.minelittlepony.unicopia.entity.Trap;
|
||||
import com.minelittlepony.unicopia.item.UEffects;
|
||||
import com.minelittlepony.unicopia.magic.Affinity;
|
||||
import com.minelittlepony.unicopia.magic.AttachedMagicEffect;
|
||||
import com.minelittlepony.unicopia.magic.HeldMagicEffect;
|
||||
|
@ -18,8 +18,8 @@ import com.minelittlepony.unicopia.magic.MagicalItem;
|
|||
import com.minelittlepony.unicopia.magic.spell.SpellRegistry;
|
||||
import com.minelittlepony.unicopia.network.EffectSync;
|
||||
import com.minelittlepony.unicopia.network.MsgPlayerCapabilities;
|
||||
import com.minelittlepony.util.BasicEasingInterpolator;
|
||||
import com.minelittlepony.util.IInterpolator;
|
||||
import com.minelittlepony.unicopia.util.BasicEasingInterpolator;
|
||||
import com.minelittlepony.unicopia.util.IInterpolator;
|
||||
import com.mojang.datafixers.util.Either;
|
||||
|
||||
import net.minecraft.client.network.packet.EntityPassengersSetS2CPacket;
|
||||
|
|
|
@ -11,7 +11,7 @@ import com.minelittlepony.unicopia.entity.RaceContainer;
|
|||
import com.minelittlepony.unicopia.magic.Caster;
|
||||
import com.minelittlepony.unicopia.magic.HeldMagicEffect;
|
||||
import com.minelittlepony.unicopia.network.Transmittable;
|
||||
import com.minelittlepony.util.IInterpolator;
|
||||
import com.minelittlepony.unicopia.util.IInterpolator;
|
||||
import com.mojang.authlib.GameProfile;
|
||||
import com.mojang.datafixers.util.Either;
|
||||
|
||||
|
|
|
@ -2,7 +2,6 @@ package com.minelittlepony.unicopia.gas;
|
|||
|
||||
import java.util.Random;
|
||||
|
||||
import com.minelittlepony.unicopia.CloudType;
|
||||
import com.minelittlepony.unicopia.util.WorldEvent;
|
||||
|
||||
import net.fabricmc.fabric.api.block.FabricBlockSettings;
|
||||
|
|
|
@ -2,8 +2,7 @@ package com.minelittlepony.unicopia.gas;
|
|||
|
||||
import java.util.Random;
|
||||
|
||||
import com.minelittlepony.unicopia.CloudType;
|
||||
import com.minelittlepony.unicopia.UBlocks;
|
||||
import com.minelittlepony.unicopia.block.UBlocks;
|
||||
import com.minelittlepony.unicopia.entity.player.Pony;
|
||||
import com.minelittlepony.unicopia.item.MossItem;
|
||||
import com.minelittlepony.unicopia.util.HoeUtil;
|
||||
|
|
|
@ -1,8 +1,7 @@
|
|||
package com.minelittlepony.unicopia.gas;
|
||||
|
||||
import com.minelittlepony.unicopia.CloudType;
|
||||
import com.minelittlepony.unicopia.UMaterials;
|
||||
import com.minelittlepony.unicopia.block.AbstractDoorBlock;
|
||||
import com.minelittlepony.unicopia.block.UMaterials;
|
||||
|
||||
import net.fabricmc.fabric.api.block.FabricBlockSettings;
|
||||
import net.minecraft.block.BlockRenderLayer;
|
||||
|
|
|
@ -1,7 +1,6 @@
|
|||
package com.minelittlepony.unicopia.gas;
|
||||
|
||||
import com.minelittlepony.unicopia.CloudType;
|
||||
import com.minelittlepony.unicopia.UBlocks;
|
||||
import com.minelittlepony.unicopia.block.UBlocks;
|
||||
import com.minelittlepony.unicopia.ducks.Farmland;
|
||||
|
||||
import net.minecraft.block.BlockRenderLayer;
|
||||
|
|
|
@ -1,7 +1,5 @@
|
|||
package com.minelittlepony.unicopia.gas;
|
||||
|
||||
import com.minelittlepony.unicopia.CloudType;
|
||||
|
||||
import net.fabricmc.fabric.api.block.FabricBlockSettings;
|
||||
import net.minecraft.block.BlockRenderLayer;
|
||||
import net.minecraft.block.BlockState;
|
||||
|
|
|
@ -1,6 +1,5 @@
|
|||
package com.minelittlepony.unicopia.gas;
|
||||
|
||||
import com.minelittlepony.unicopia.CloudType;
|
||||
import com.minelittlepony.unicopia.block.USlab;
|
||||
|
||||
import net.fabricmc.fabric.api.block.FabricBlockSettings;
|
||||
|
|
|
@ -1,6 +1,5 @@
|
|||
package com.minelittlepony.unicopia.gas;
|
||||
|
||||
import com.minelittlepony.unicopia.CloudType;
|
||||
import com.minelittlepony.unicopia.block.UStairs;
|
||||
|
||||
import net.minecraft.block.Block;
|
||||
|
|
|
@ -1,5 +1,6 @@
|
|||
package com.minelittlepony.unicopia;
|
||||
package com.minelittlepony.unicopia.gas;
|
||||
|
||||
import com.minelittlepony.unicopia.EquinePredicates;
|
||||
import com.minelittlepony.unicopia.entity.CloudEntity;
|
||||
|
||||
import net.minecraft.entity.Entity;
|
|
@ -1,6 +1,5 @@
|
|||
package com.minelittlepony.unicopia.gas;
|
||||
|
||||
import com.minelittlepony.unicopia.CloudType;
|
||||
import com.minelittlepony.unicopia.EquinePredicates;
|
||||
|
||||
import net.minecraft.block.BedBlock;
|
||||
|
|
|
@ -6,12 +6,12 @@ import java.util.UUID;
|
|||
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.ItemEntityCapabilities;
|
||||
import com.minelittlepony.unicopia.entity.player.Pony;
|
||||
import com.minelittlepony.unicopia.magic.Affinity;
|
||||
import com.minelittlepony.unicopia.magic.AddictiveMagicalItem;
|
||||
import com.minelittlepony.unicopia.util.AwaitTickQueue;
|
||||
import com.minelittlepony.unicopia.util.MagicalDamageSource;
|
||||
import com.minelittlepony.unicopia.util.VecHelper;
|
||||
|
||||
|
|
|
@ -6,9 +6,9 @@ import java.util.Map;
|
|||
import javax.annotation.Nullable;
|
||||
|
||||
import com.minelittlepony.unicopia.EquinePredicates;
|
||||
import com.minelittlepony.unicopia.UContainers;
|
||||
import com.minelittlepony.unicopia.container.BagOfHoldingContainer;
|
||||
import com.minelittlepony.unicopia.container.BagOfHoldingInventory;
|
||||
import com.minelittlepony.unicopia.container.UContainers;
|
||||
import com.minelittlepony.unicopia.magic.Affinity;
|
||||
import com.minelittlepony.unicopia.magic.MagicalItem;
|
||||
import com.minelittlepony.unicopia.util.VecHelper;
|
||||
|
|
|
@ -3,8 +3,8 @@ package com.minelittlepony.unicopia.item;
|
|||
import javax.annotation.Nullable;
|
||||
|
||||
import com.minelittlepony.unicopia.EquinePredicates;
|
||||
import com.minelittlepony.unicopia.UEntities;
|
||||
import com.minelittlepony.unicopia.entity.SpellbookEntity;
|
||||
import com.minelittlepony.unicopia.entity.UEntities;
|
||||
import com.minelittlepony.unicopia.magic.Dispensable;
|
||||
|
||||
import net.minecraft.block.DispenserBlock;
|
||||
|
|
|
@ -2,7 +2,7 @@ package com.minelittlepony.unicopia.item;
|
|||
|
||||
import javax.annotation.Nullable;
|
||||
|
||||
import com.minelittlepony.unicopia.UBlocks;
|
||||
import com.minelittlepony.unicopia.block.UBlocks;
|
||||
|
||||
import net.minecraft.advancement.criterion.Criterions;
|
||||
import net.minecraft.entity.player.PlayerEntity;
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
package com.minelittlepony.unicopia.item;
|
||||
|
||||
import com.minelittlepony.unicopia.UBlocks;
|
||||
import com.minelittlepony.unicopia.block.StickBlock;
|
||||
import com.minelittlepony.unicopia.block.UBlocks;
|
||||
|
||||
import net.minecraft.block.Block;
|
||||
import net.minecraft.block.BlockState;
|
||||
|
|
|
@ -1,5 +1,6 @@
|
|||
package com.minelittlepony.unicopia;
|
||||
package com.minelittlepony.unicopia.item;
|
||||
|
||||
import com.minelittlepony.unicopia.UnicopiaCore;
|
||||
import com.minelittlepony.unicopia.util.CustomStatusEffect;
|
||||
import com.minelittlepony.unicopia.util.MagicalDamageSource;
|
||||
|
|
@ -2,9 +2,9 @@ package com.minelittlepony.unicopia.item;
|
|||
|
||||
import static com.minelittlepony.unicopia.EquinePredicates.*;
|
||||
|
||||
import com.minelittlepony.unicopia.UBlocks;
|
||||
import com.minelittlepony.unicopia.UEntities;
|
||||
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.DynamicToxicBlockItem;
|
||||
import com.minelittlepony.unicopia.toxin.DynamicToxicItem;
|
||||
|
|
|
@ -1,10 +1,10 @@
|
|||
package com.minelittlepony.unicopia.magic.spell;
|
||||
|
||||
import com.minelittlepony.unicopia.UParticles;
|
||||
import com.minelittlepony.unicopia.entity.player.Pony;
|
||||
import com.minelittlepony.unicopia.magic.Affinity;
|
||||
import com.minelittlepony.unicopia.magic.Caster;
|
||||
import com.minelittlepony.unicopia.util.MagicalDamageSource;
|
||||
import com.minelittlepony.unicopia.util.particles.UParticles;
|
||||
import com.minelittlepony.unicopia.util.shape.Sphere;
|
||||
|
||||
import net.minecraft.entity.Entity;
|
||||
|
|
|
@ -2,11 +2,11 @@ package com.minelittlepony.unicopia.magic.spell;
|
|||
|
||||
import java.util.Optional;
|
||||
|
||||
import com.minelittlepony.unicopia.UBlocks;
|
||||
import com.minelittlepony.unicopia.UEntities;
|
||||
import com.minelittlepony.unicopia.USounds;
|
||||
import com.minelittlepony.unicopia.block.UBlocks;
|
||||
import com.minelittlepony.unicopia.entity.CuccoonEntity;
|
||||
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.AttachedMagicEffect;
|
||||
|
|
|
@ -3,13 +3,13 @@ package com.minelittlepony.unicopia.magic.spell;
|
|||
import java.util.Random;
|
||||
import java.util.function.Consumer;
|
||||
|
||||
import com.minelittlepony.unicopia.UParticles;
|
||||
import com.minelittlepony.unicopia.entity.SpellcastEntity;
|
||||
import com.minelittlepony.unicopia.magic.Affinity;
|
||||
import com.minelittlepony.unicopia.magic.CasterUtils;
|
||||
import com.minelittlepony.unicopia.magic.Caster;
|
||||
import com.minelittlepony.unicopia.util.MagicalDamageSource;
|
||||
import com.minelittlepony.unicopia.util.PosHelper;
|
||||
import com.minelittlepony.unicopia.util.particles.UParticles;
|
||||
import com.minelittlepony.unicopia.util.shape.Shape;
|
||||
import com.minelittlepony.unicopia.util.shape.Sphere;
|
||||
|
||||
|
|
|
@ -7,7 +7,6 @@ import javax.annotation.Nullable;
|
|||
|
||||
import com.minelittlepony.unicopia.InteractionManager;
|
||||
import com.minelittlepony.unicopia.Race;
|
||||
import com.minelittlepony.unicopia.UParticles;
|
||||
import com.minelittlepony.unicopia.ability.FlightPredicate;
|
||||
import com.minelittlepony.unicopia.ability.HeightPredicate;
|
||||
import com.minelittlepony.unicopia.entity.Owned;
|
||||
|
@ -18,6 +17,7 @@ import com.minelittlepony.unicopia.magic.AttachedMagicEffect;
|
|||
import com.minelittlepony.unicopia.magic.Caster;
|
||||
import com.minelittlepony.unicopia.magic.MagicEffect;
|
||||
import com.minelittlepony.unicopia.magic.SuppressableEffect;
|
||||
import com.minelittlepony.unicopia.util.particles.UParticles;
|
||||
import com.minelittlepony.unicopia.util.projectile.ProjectileUtil;
|
||||
import com.mojang.authlib.GameProfile;
|
||||
|
||||
|
|
|
@ -2,7 +2,7 @@ package com.minelittlepony.unicopia.magic.spell;
|
|||
|
||||
import javax.annotation.Nullable;
|
||||
|
||||
import com.minelittlepony.unicopia.UMaterials;
|
||||
import com.minelittlepony.unicopia.block.UMaterials;
|
||||
import com.minelittlepony.unicopia.magic.Affinity;
|
||||
import com.minelittlepony.unicopia.magic.CastResult;
|
||||
import com.minelittlepony.unicopia.magic.Caster;
|
||||
|
|
|
@ -1,9 +1,9 @@
|
|||
package com.minelittlepony.unicopia.magic.spell;
|
||||
|
||||
import com.minelittlepony.unicopia.UParticles;
|
||||
import com.minelittlepony.unicopia.magic.Affinity;
|
||||
import com.minelittlepony.unicopia.magic.Caster;
|
||||
import com.minelittlepony.unicopia.magic.SuppressableEffect;
|
||||
import com.minelittlepony.unicopia.util.particles.UParticles;
|
||||
import com.minelittlepony.unicopia.util.shape.Shape;
|
||||
import com.minelittlepony.unicopia.util.shape.Sphere;
|
||||
|
||||
|
|
|
@ -2,11 +2,11 @@ package com.minelittlepony.unicopia.magic.spell;
|
|||
|
||||
import javax.annotation.Nullable;
|
||||
|
||||
import com.minelittlepony.unicopia.UParticles;
|
||||
import com.minelittlepony.unicopia.magic.Affinity;
|
||||
import com.minelittlepony.unicopia.magic.Caster;
|
||||
import com.minelittlepony.unicopia.magic.TossedMagicEffect;
|
||||
import com.minelittlepony.unicopia.util.PosHelper;
|
||||
import com.minelittlepony.unicopia.util.particles.UParticles;
|
||||
import com.minelittlepony.unicopia.util.projectile.AdvancedProjectile;
|
||||
import com.minelittlepony.unicopia.util.shape.Sphere;
|
||||
|
||||
|
|
|
@ -4,12 +4,12 @@ import java.util.List;
|
|||
import java.util.stream.Collectors;
|
||||
|
||||
import com.minelittlepony.unicopia.EquinePredicates;
|
||||
import com.minelittlepony.unicopia.UParticles;
|
||||
import com.minelittlepony.unicopia.entity.player.Pony;
|
||||
import com.minelittlepony.unicopia.magic.Affinity;
|
||||
import com.minelittlepony.unicopia.magic.AttachedMagicEffect;
|
||||
import com.minelittlepony.unicopia.magic.Caster;
|
||||
import com.minelittlepony.unicopia.util.particles.ParticleConnection;
|
||||
import com.minelittlepony.unicopia.util.particles.UParticles;
|
||||
import com.minelittlepony.unicopia.util.projectile.ProjectileUtil;
|
||||
import com.minelittlepony.unicopia.util.shape.Sphere;
|
||||
|
||||
|
|
|
@ -5,8 +5,8 @@ import java.util.List;
|
|||
import javax.annotation.Nullable;
|
||||
|
||||
import com.minelittlepony.unicopia.Race;
|
||||
import com.minelittlepony.unicopia.UEffects;
|
||||
import com.minelittlepony.unicopia.entity.player.Pony;
|
||||
import com.minelittlepony.unicopia.item.UEffects;
|
||||
|
||||
import net.minecraft.block.Block;
|
||||
import net.minecraft.client.item.TooltipContext;
|
||||
|
|
|
@ -5,8 +5,8 @@ import java.util.List;
|
|||
import javax.annotation.Nullable;
|
||||
|
||||
import com.minelittlepony.unicopia.Race;
|
||||
import com.minelittlepony.unicopia.UEffects;
|
||||
import com.minelittlepony.unicopia.entity.player.Pony;
|
||||
import com.minelittlepony.unicopia.item.UEffects;
|
||||
|
||||
import net.minecraft.client.item.TooltipContext;
|
||||
import net.minecraft.entity.LivingEntity;
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
package com.minelittlepony.util;
|
||||
package com.minelittlepony.unicopia.util;
|
||||
|
||||
import com.google.common.cache.CacheBuilder;
|
||||
import com.google.common.cache.CacheLoader;
|
15
src/main/java/com/minelittlepony/unicopia/util/Color.java
Normal file
15
src/main/java/com/minelittlepony/unicopia/util/Color.java
Normal file
|
@ -0,0 +1,15 @@
|
|||
package com.minelittlepony.unicopia.util;
|
||||
|
||||
public interface Color {
|
||||
static float r(int hex) {
|
||||
return (hex >> 16 & 255) / 255F;
|
||||
}
|
||||
|
||||
static float g(int hex) {
|
||||
return (hex >> 8 & 255) / 255F;
|
||||
}
|
||||
|
||||
static float b(int hex) {
|
||||
return (hex & 255) / 255F;
|
||||
}
|
||||
}
|
|
@ -1,4 +1,4 @@
|
|||
package com.minelittlepony.util;
|
||||
package com.minelittlepony.unicopia.util;
|
||||
|
||||
/**
|
||||
* Interpolator function for handling transitions between animation states.
|
|
@ -1,4 +1,4 @@
|
|||
package com.minelittlepony.util;
|
||||
package com.minelittlepony.unicopia.util;
|
||||
|
||||
import net.minecraft.entity.player.PlayerEntity;
|
||||
import net.minecraft.util.math.MathHelper;
|
||||
|
@ -10,18 +10,30 @@ import net.minecraft.util.math.MathHelper;
|
|||
*/
|
||||
public abstract class MotionCompositor {
|
||||
|
||||
static double clampLimit(double num, double limit) {
|
||||
return MathHelper.clamp(num, -limit, limit);
|
||||
}
|
||||
|
||||
static float sensibleAngle(float angle) {
|
||||
angle %= 360;
|
||||
|
||||
if (angle > 180) angle -= 360;
|
||||
if (angle < -180) angle += 360;
|
||||
|
||||
return angle;
|
||||
}
|
||||
/**
|
||||
* Gets the angle of horizontal roll in degrees based on the player's vertical and horizontal motion.
|
||||
*/
|
||||
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.field_6220 - player.field_6220);
|
||||
double roll = sensibleAngle(player.field_6220 - player.field_6220);
|
||||
double horMotion = Math.sqrt(motionX * motionX + motionZ * motionZ);
|
||||
float modelYaw = MathUtil.sensibleAngle(player.field_6220);
|
||||
float modelYaw = sensibleAngle(player.field_6220);
|
||||
|
||||
// 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) {
|
||||
if (Math.abs(sensibleAngle((float) Math.toDegrees(Math.atan2(motionX, motionZ)) + modelYaw)) > 90) {
|
||||
roll *= -1;
|
||||
}
|
||||
|
||||
|
@ -48,7 +60,7 @@ public abstract class MotionCompositor {
|
|||
angle /= 2;
|
||||
}
|
||||
|
||||
angle = MathUtil.clampLimit(angle, Math.PI / 3);
|
||||
angle = clampLimit(angle, Math.PI / 3);
|
||||
|
||||
return Math.toDegrees(angle);
|
||||
}
|
|
@ -14,13 +14,13 @@ import net.minecraft.util.math.Vec3d;
|
|||
import net.minecraft.util.math.Vec3i;
|
||||
import net.minecraft.world.World;
|
||||
|
||||
public class PosHelper {
|
||||
public interface PosHelper {
|
||||
|
||||
public static Vec3d offset(Vec3d a, Vec3i b) {
|
||||
static Vec3d offset(Vec3d a, Vec3i b) {
|
||||
return a.add(b.getX(), b.getY(), b.getZ());
|
||||
}
|
||||
|
||||
public static BlockPos findSolidGroundAt(World world, BlockPos pos) {
|
||||
static BlockPos findSolidGroundAt(World world, BlockPos pos) {
|
||||
while ((pos.getY() > 0 || !World.isHeightInvalid(pos))
|
||||
&& (world.isAir(pos) || world.getBlockState(pos).canPlaceAt(world, pos))) {
|
||||
pos = pos.down();
|
||||
|
@ -29,13 +29,13 @@ public class PosHelper {
|
|||
return pos;
|
||||
}
|
||||
|
||||
public static void all(BlockPos origin, Consumer<BlockPos> consumer, Direction... directions) {
|
||||
static void all(BlockPos origin, Consumer<BlockPos> consumer, Direction... directions) {
|
||||
for (Direction facing : directions) {
|
||||
consumer.accept(origin.offset(facing));
|
||||
}
|
||||
}
|
||||
|
||||
public static boolean some(BlockPos origin, Predicate<BlockPos> consumer, Direction... directions) {
|
||||
static boolean some(BlockPos origin, Predicate<BlockPos> consumer, Direction... directions) {
|
||||
for (Direction facing : directions) {
|
||||
if (consumer.test(origin.offset(facing))) {
|
||||
return true;
|
||||
|
@ -44,7 +44,7 @@ public class PosHelper {
|
|||
return false;
|
||||
}
|
||||
|
||||
public static Iterators<BlockPos> adjacentNeighbours(BlockPos origin) {
|
||||
static Iterators<BlockPos> adjacentNeighbours(BlockPos origin) {
|
||||
BlockPos.Mutable pos = new BlockPos.Mutable(origin);
|
||||
Iterator<Direction> directions = Lists.newArrayList(Direction.values()).iterator();
|
||||
|
||||
|
@ -60,7 +60,7 @@ public class PosHelper {
|
|||
});
|
||||
}
|
||||
|
||||
public static Iterators<BlockPos> getAllInRegionMutable(BlockPos origin, Shape shape) {
|
||||
static Iterators<BlockPos> getAllInRegionMutable(BlockPos origin, Shape shape) {
|
||||
Iterator<BlockPos> iter = BlockPos.iterate(
|
||||
origin.add(new BlockPos(shape.getLowerBound())),
|
||||
origin.add(new BlockPos(shape.getUpperBound()))
|
||||
|
@ -82,7 +82,8 @@ public class PosHelper {
|
|||
/**
|
||||
* Creates a stream of mutable block positions ranging from the beginning position to end.
|
||||
*/
|
||||
public static Stream<BlockPos> inRegion(BlockPos from, BlockPos to) {
|
||||
@Deprecated
|
||||
static Stream<BlockPos> inRegion(BlockPos from, BlockPos to) {
|
||||
return BlockPos.stream(from, to);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -20,8 +20,7 @@ import net.minecraft.util.math.Vec3d;
|
|||
import net.minecraft.world.RayTraceContext;
|
||||
import net.minecraft.world.World;
|
||||
|
||||
public class VecHelper {
|
||||
|
||||
public interface VecHelper {
|
||||
/**
|
||||
* Performs a ray cast from the given entity and returns a result for the first block that ray intercepts.
|
||||
*
|
||||
|
@ -33,7 +32,7 @@ public class VecHelper {
|
|||
*
|
||||
* @return RayTraceResult result or null
|
||||
*/
|
||||
public static HitResult rayTrace(Entity e, double distance, float partialTick) {
|
||||
static HitResult rayTrace(Entity e, double distance, float partialTick) {
|
||||
Vec3d cam = e.getCameraPosVec(partialTick);
|
||||
Vec3d look = e.getRotationVec(partialTick).multiply(distance);
|
||||
|
||||
|
@ -49,7 +48,7 @@ public class VecHelper {
|
|||
* Gets the entity the player is currently looking at, or null.
|
||||
*/
|
||||
@Nullable
|
||||
public static Entity getLookedAtEntity(LivingEntity e, int reach) {
|
||||
static Entity getLookedAtEntity(LivingEntity e, int reach) {
|
||||
HitResult objectMouseOver = getObjectMouseOver(e, reach, 1);
|
||||
|
||||
if (objectMouseOver instanceof EntityHitResult && objectMouseOver.getType() == BlockHitResult.Type.ENTITY) {
|
||||
|
@ -59,7 +58,7 @@ public class VecHelper {
|
|||
return null;
|
||||
}
|
||||
|
||||
public static Stream<Entity> findAllEntitiesInRange(@Nullable Entity origin, World w, BlockPos pos, double radius) {
|
||||
static Stream<Entity> findAllEntitiesInRange(@Nullable Entity origin, World w, BlockPos pos, double radius) {
|
||||
|
||||
BlockPos begin = pos.add(-radius, -radius, -radius);
|
||||
BlockPos end = pos.add(radius, radius, radius);
|
||||
|
@ -77,7 +76,7 @@ public class VecHelper {
|
|||
/**
|
||||
* Gets all entities within a given range from the player.
|
||||
*/
|
||||
public static List<Entity> getWithinRange(PlayerEntity player, double reach, @Nullable Predicate<? super Entity> predicate) {
|
||||
static List<Entity> getWithinRange(PlayerEntity player, double reach, @Nullable Predicate<? super Entity> predicate) {
|
||||
Vec3d look = player.getCameraPosVec(1).multiply(reach);
|
||||
|
||||
return player.world.getEntities(player, player
|
||||
|
@ -95,7 +94,7 @@ public class VecHelper {
|
|||
*
|
||||
* @return RayTraceResult result or null
|
||||
*/
|
||||
public static HitResult getObjectMouseOver(Entity e, double distance, float partialTick) {
|
||||
static HitResult getObjectMouseOver(Entity e, double distance, float partialTick) {
|
||||
return getObjectMouseOver(e, distance, partialTick, EntityPredicates.EXCEPT_SPECTATOR);
|
||||
}
|
||||
|
||||
|
@ -111,7 +110,7 @@ public class VecHelper {
|
|||
*
|
||||
* @return RayTraceResult result or null
|
||||
*/
|
||||
public static HitResult getObjectMouseOver(Entity e, double distance, float partialTick, Predicate<Entity> predicate) {
|
||||
static HitResult getObjectMouseOver(Entity e, double distance, float partialTick, Predicate<Entity> predicate) {
|
||||
HitResult tracedBlock = rayTrace(e, distance, partialTick);
|
||||
|
||||
double totalTraceDistance = distance;
|
||||
|
|
|
@ -2,16 +2,14 @@ package com.minelittlepony.unicopia.util;
|
|||
|
||||
import net.minecraft.world.World;
|
||||
|
||||
public final class WorldHelper {
|
||||
|
||||
|
||||
public interface WorldHelper {
|
||||
/**
|
||||
* Gets the daylight brightness value on a scale of 0-1.
|
||||
* Midday = 1
|
||||
* Sunrise/Sunset = 0
|
||||
* Nighttime = 0
|
||||
*/
|
||||
public static float getDaylightBrightness(World w, float partialTicks) {
|
||||
static float getDaylightBrightness(World w, float partialTicks) {
|
||||
float celst = w.getSkyAngle(partialTicks);
|
||||
|
||||
// ----------------------------
|
||||
|
@ -52,7 +50,7 @@ public final class WorldHelper {
|
|||
* Sunrise/Sunset = 0
|
||||
* Daytime = 0
|
||||
*/
|
||||
public static float getLunarBrightness(World w, float partialTicks) {
|
||||
static float getLunarBrightness(World w, float partialTicks) {
|
||||
float celst = w.getSkyAngle(partialTicks);
|
||||
|
||||
// ----------------------------
|
||||
|
|
|
@ -1,13 +0,0 @@
|
|||
package com.minelittlepony.unicopia.util.collection;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import net.minecraft.world.biome.Biome.SpawnEntry;
|
||||
|
||||
public final class ListHelper {
|
||||
public static void addifAbsent(List<SpawnEntry> entries, SpawnEntry entry) {
|
||||
if (!entries.contains(entry)) {
|
||||
entries.add(entry);
|
||||
}
|
||||
}
|
||||
}
|
|
@ -1,4 +1,4 @@
|
|||
package com.minelittlepony.unicopia;
|
||||
package com.minelittlepony.unicopia.util.particles;
|
||||
|
||||
import net.minecraft.particle.DefaultParticleType;
|
||||
import net.minecraft.util.Identifier;
|
|
@ -1,56 +0,0 @@
|
|||
package com.minelittlepony.util;
|
||||
|
||||
/**
|
||||
* Colouration Utilities
|
||||
*/
|
||||
public interface Color {
|
||||
|
||||
/**
|
||||
* Returns the ALPHA channel for the given colour hex code.
|
||||
*/
|
||||
static float a(int hex) {
|
||||
return (hex >> 24 & 255) / 255F;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the RED channel for the given colour hex code.
|
||||
*/
|
||||
static float r(int hex) {
|
||||
return (hex >> 16 & 255) / 255F;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the GREEN channel for the given colour hex code.
|
||||
*/
|
||||
static float g(int hex) {
|
||||
return (hex >> 8 & 255) / 255F;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the BLUE channel for the given colour hex code.
|
||||
*/
|
||||
static float b(int hex) {
|
||||
return (hex & 255) / 255F;
|
||||
}
|
||||
|
||||
/**
|
||||
* Converts the given rgb floats on a range of 0-1 into a colour hex code.
|
||||
*/
|
||||
static int argbToHex(float a, float r, float g, float b) {
|
||||
return argbToHex((int)(a * 255), (int) (r * 255), (int) (g * 255), (int) (b * 255));
|
||||
}
|
||||
|
||||
/**
|
||||
* Converts the given rbg int on a range of 0-255 into a colour hex code.
|
||||
*/
|
||||
static int argbToHex(int a, int r, int g, int b) {
|
||||
return (a << 24) | (r << 16) | (g << 8) | (b);
|
||||
}
|
||||
|
||||
/**
|
||||
* Converts a colour hex code from BGR to RGB (and back).
|
||||
*/
|
||||
static int abgrToArgb(int color) {
|
||||
return argbToHex(a(color), b(color), g(color), r(color));
|
||||
}
|
||||
}
|
|
@ -1,44 +0,0 @@
|
|||
package com.minelittlepony.util;
|
||||
|
||||
import net.minecraft.util.math.MathHelper;
|
||||
|
||||
public class MathUtil {
|
||||
|
||||
public static double clampLimit(double num, double limit) {
|
||||
return MathHelper.clamp(num, -limit, limit);
|
||||
}
|
||||
|
||||
public static int mod(int value, int mod) {
|
||||
value %= mod;
|
||||
|
||||
while (value < 0) value += mod;
|
||||
|
||||
return value;
|
||||
}
|
||||
|
||||
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));
|
||||
}
|
||||
|
||||
public static boolean compareFloats(float a, float b) {
|
||||
return Math.abs(a - b) <= 0.001F;
|
||||
}
|
||||
}
|
Loading…
Reference in a new issue