mirror of
https://github.com/Sollace/Unicopia.git
synced 2024-11-27 15:17:59 +01:00
Porting to Fabric/Yarn/1.14 part 3
This commit is contained in:
parent
897287600b
commit
9a42c8ebd5
171 changed files with 2700 additions and 2662 deletions
|
@ -1,6 +1,6 @@
|
|||
package com.minelittlepony.unicopia;
|
||||
|
||||
import com.minelittlepony.unicopia.entity.EntityCloud;
|
||||
import com.minelittlepony.unicopia.entity.CloudEntity;
|
||||
|
||||
import net.minecraft.entity.Entity;
|
||||
import net.minecraft.entity.ItemEntity;
|
||||
|
@ -26,15 +26,15 @@ public enum CloudType {
|
|||
return true;
|
||||
}
|
||||
|
||||
return Predicates.INTERACT_WITH_CLOUDS.test((PlayerEntity)e)
|
||||
|| (Predicates.MAGI.test(e) && EntityCloud.getFeatherEnchantStrength((PlayerEntity)e) > 0);
|
||||
return EquinePredicates.INTERACT_WITH_CLOUDS.test((PlayerEntity)e)
|
||||
|| (EquinePredicates.MAGI.test(e) && CloudEntity.getFeatherEnchantStrength((PlayerEntity)e) > 0);
|
||||
}
|
||||
|
||||
if (e instanceof ItemEntity) {
|
||||
return Predicates.ITEM_INTERACT_WITH_CLOUDS.test((ItemEntity)e);
|
||||
return EquinePredicates.ITEM_INTERACT_WITH_CLOUDS.test((ItemEntity)e);
|
||||
}
|
||||
|
||||
if (e instanceof EntityCloud && e.hasVehicle()) {
|
||||
if (e instanceof CloudEntity && e.hasVehicle()) {
|
||||
return canInteract(e.getVehicle());
|
||||
}
|
||||
|
||||
|
|
|
@ -15,16 +15,16 @@ import com.google.gson.annotations.Expose;
|
|||
import com.google.gson.stream.JsonReader;
|
||||
import com.google.gson.stream.JsonWriter;
|
||||
|
||||
public class UConfig {
|
||||
public class Config {
|
||||
|
||||
private static UConfig instance = new UConfig();
|
||||
private static Config instance = new Config();
|
||||
|
||||
private static final Gson gson = new GsonBuilder()
|
||||
.excludeFieldsWithoutExposeAnnotation()
|
||||
.setPrettyPrinting()
|
||||
.create();
|
||||
|
||||
public static UConfig instance() {
|
||||
public static Config instance() {
|
||||
return instance;
|
||||
}
|
||||
|
||||
|
@ -34,14 +34,14 @@ public class UConfig {
|
|||
try {
|
||||
if (file.exists()) {
|
||||
try(JsonReader reader = new JsonReader(new InputStreamReader(new FileInputStream(file)));) {
|
||||
instance = gson.fromJson(reader, UConfig.class);
|
||||
instance = gson.fromJson(reader, Config.class);
|
||||
}
|
||||
}
|
||||
} catch (IOException e) {
|
||||
e.printStackTrace();
|
||||
} finally {
|
||||
if (instance == null) {
|
||||
instance = new UConfig();
|
||||
instance = new Config();
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -112,7 +112,7 @@ public class UConfig {
|
|||
try (JsonWriter writer = new JsonWriter(new OutputStreamWriter(new FileOutputStream(file)))) {
|
||||
writer.setIndent(" ");
|
||||
|
||||
gson.toJson(this, UConfig.class, writer);
|
||||
gson.toJson(this, Config.class, writer);
|
||||
} catch (IOException e) {
|
||||
e.printStackTrace();
|
||||
}
|
|
@ -6,7 +6,7 @@ import net.minecraft.entity.Entity;
|
|||
import net.minecraft.entity.ItemEntity;
|
||||
import net.minecraft.entity.player.PlayerEntity;
|
||||
|
||||
public final class Predicates {
|
||||
public final class EquinePredicates {
|
||||
public static final Predicate<PlayerEntity> INTERACT_WITH_CLOUDS = player -> {
|
||||
return player != null && SpeciesList.instance().getPlayer(player).getSpecies().canInteractWithClouds();
|
||||
};
|
|
@ -1,21 +1,20 @@
|
|||
package com.minelittlepony.unicopia;
|
||||
|
||||
import net.minecraft.client.MinecraftClient;
|
||||
|
||||
public final class MineLP {
|
||||
private static boolean checkComplete;
|
||||
private static boolean modIsActive;
|
||||
|
||||
// TODO:
|
||||
/**
|
||||
* Returns true if mine little pony is present. That's all we need.
|
||||
*/
|
||||
static boolean modIsActive() {
|
||||
if (!checkComplete) {
|
||||
try {
|
||||
MineLittlePony.getInstance();
|
||||
// MineLittlePony.instance();
|
||||
|
||||
// always true, but this will throw if we don't have what we need.
|
||||
modIsActive = PonyRace.HUMAN.isHuman();
|
||||
// modIsActive = PonyRace.HUMAN.isHuman();
|
||||
} catch (Exception e) {
|
||||
modIsActive = false;
|
||||
}
|
||||
|
@ -29,7 +28,7 @@ public final class MineLP {
|
|||
return Race.HUMAN;
|
||||
}
|
||||
|
||||
switch (IPony.forPlayer(MinecraftClient.getInstance().player).getRace(false)) {
|
||||
/*switch (IPony.forPlayer(MinecraftClient.getInstance().player).getRace(false)) {
|
||||
case ALICORN:
|
||||
return Race.ALICORN;
|
||||
case CHANGELING:
|
||||
|
@ -49,6 +48,7 @@ public final class MineLP {
|
|||
default:
|
||||
return Race.EARTH;
|
||||
|
||||
}
|
||||
}*/
|
||||
return Race.EARTH;
|
||||
}
|
||||
}
|
|
@ -5,10 +5,11 @@ import java.util.UUID;
|
|||
|
||||
import javax.annotation.Nullable;
|
||||
|
||||
import com.minelittlepony.unicopia.UConfig;
|
||||
import com.minelittlepony.unicopia.Config;
|
||||
import com.minelittlepony.unicopia.ducks.IRaceContainerHolder;
|
||||
import com.minelittlepony.unicopia.entity.IEntity;
|
||||
import com.minelittlepony.unicopia.entity.player.IPlayer;
|
||||
import com.minelittlepony.unicopia.entity.capabilities.IPlayer;
|
||||
|
||||
import net.minecraft.entity.Entity;
|
||||
import net.minecraft.entity.player.PlayerEntity;
|
||||
|
||||
|
@ -21,17 +22,17 @@ public class SpeciesList {
|
|||
}
|
||||
|
||||
public boolean whiteListRace(Race race) {
|
||||
boolean result = UConfig.instance().getSpeciesWhiteList().add(race);
|
||||
boolean result = Config.instance().getSpeciesWhiteList().add(race);
|
||||
|
||||
UConfig.instance().save();
|
||||
Config.instance().save();
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
public boolean unwhiteListRace(Race race) {
|
||||
boolean result = UConfig.instance().getSpeciesWhiteList().remove(race);
|
||||
boolean result = Config.instance().getSpeciesWhiteList().remove(race);
|
||||
|
||||
UConfig.instance().save();
|
||||
Config.instance().save();
|
||||
|
||||
return result;
|
||||
}
|
||||
|
@ -41,7 +42,7 @@ public class SpeciesList {
|
|||
return false;
|
||||
}
|
||||
|
||||
return race.isDefault() || UConfig.instance().getSpeciesWhiteList().isEmpty() || UConfig.instance().getSpeciesWhiteList().contains(race);
|
||||
return race.isDefault() || Config.instance().getSpeciesWhiteList().isEmpty() || Config.instance().getSpeciesWhiteList().contains(race);
|
||||
}
|
||||
|
||||
public Race validate(Race race, PlayerEntity sender) {
|
||||
|
|
|
@ -91,7 +91,7 @@ public class UBlocks {
|
|||
public static final Block apple_leaves = register(new FruitLeavesBlock()
|
||||
.growthChance(1200)
|
||||
.tint(0xFFEE81)
|
||||
.fruit(ItemApple::getRandomItemStack)
|
||||
.fruit(AppleItem::getRandomItemStack)
|
||||
.compost(w -> new ItemStack(UItems.rotten_apple)), "apple_leaves");
|
||||
|
||||
|
||||
|
|
|
@ -5,8 +5,9 @@ import java.util.UUID;
|
|||
import javax.annotation.Nonnull;
|
||||
import javax.annotation.Nullable;
|
||||
|
||||
import com.minelittlepony.unicopia.client.UnicopiaClient;
|
||||
import com.minelittlepony.unicopia.entity.EntityFakeServerPlayer;
|
||||
import com.minelittlepony.unicopia.entity.player.IPlayer;
|
||||
import com.minelittlepony.unicopia.entity.capabilities.IPlayer;
|
||||
import com.mojang.authlib.GameProfile;
|
||||
|
||||
import net.minecraft.entity.Entity;
|
||||
|
|
|
@ -1,6 +1,7 @@
|
|||
package com.minelittlepony.unicopia;
|
||||
|
||||
import com.minelittlepony.unicopia.Unicopia;
|
||||
import com.minelittlepony.util.MagicalDamageSource;
|
||||
|
||||
import net.minecraft.entity.damage.DamageSource;
|
||||
import net.minecraft.entity.effect.StatusEffect;
|
||||
|
@ -10,22 +11,20 @@ import net.minecraft.potion.Potion;
|
|||
|
||||
public class UEffects {
|
||||
|
||||
public static final DamageSource food_poisoning = new DamageSource("food_poisoning").bypassesArmor();
|
||||
|
||||
public static final StatusEffect FOOD_POISONING = new UPotion(Unicopia.MODID, "food_poisoning", true, 3484199)
|
||||
.setIconIndex(3, 1)
|
||||
.setSilent()
|
||||
.setEffectiveness(0.25)
|
||||
.setApplicator((p, e, i) -> {
|
||||
|
||||
StatusEffectInstance nausea = e.getActivePotionEffect(StatusEffects.NAUSEA);
|
||||
StatusEffectInstance nausea = e.getStatusEffect(StatusEffects.NAUSEA);
|
||||
if (nausea == null) {
|
||||
StatusEffect foodEffect = e.getActivePotionEffect(p);
|
||||
StatusEffectInstance foodEffect = e.getStatusEffect(p);
|
||||
nausea = new StatusEffectInstance(StatusEffects.NAUSEA, foodEffect.getDuration(), foodEffect.getAmplifier(), foodEffect.getIsAmbient(), foodEffect.doesShowParticles());
|
||||
|
||||
e.addPotionEffect(nausea);
|
||||
}
|
||||
|
||||
e.attackEntityFrom(food_poisoning, i);
|
||||
e.damage(MagicalDamageSource.FOOD_POISONING, i);
|
||||
});
|
||||
}
|
||||
|
|
|
@ -1,87 +1,70 @@
|
|||
package com.minelittlepony.unicopia;
|
||||
|
||||
import com.minelittlepony.unicopia.Unicopia;
|
||||
import com.minelittlepony.unicopia.client.render.entity.ButterflyEntityRenderer;
|
||||
import com.minelittlepony.unicopia.client.render.entity.RenderCloud;
|
||||
import com.minelittlepony.unicopia.client.render.entity.RenderCuccoon;
|
||||
import com.minelittlepony.unicopia.client.render.entity.RenderGem;
|
||||
import com.minelittlepony.unicopia.client.render.entity.RenderProjectile;
|
||||
import com.minelittlepony.unicopia.client.render.entity.RenderRainbow;
|
||||
import com.minelittlepony.unicopia.client.render.entity.RenderSpear;
|
||||
import com.minelittlepony.unicopia.client.render.entity.RenderSpellbook;
|
||||
import com.minelittlepony.unicopia.entity.EntityButterfly;
|
||||
import com.minelittlepony.unicopia.entity.EntityCloud;
|
||||
import com.minelittlepony.unicopia.entity.EntityConstructionCloud;
|
||||
import com.minelittlepony.unicopia.entity.ButterflyEntity;
|
||||
import com.minelittlepony.unicopia.entity.CloudEntity;
|
||||
import com.minelittlepony.unicopia.entity.AdvancedProjectileEntity;
|
||||
import com.minelittlepony.unicopia.entity.ConstructionCloudEntity;
|
||||
import com.minelittlepony.unicopia.entity.EntityCuccoon;
|
||||
import com.minelittlepony.unicopia.entity.EntityRacingCloud;
|
||||
import com.minelittlepony.unicopia.entity.EntityRainbow;
|
||||
import com.minelittlepony.unicopia.entity.RainbowEntity;
|
||||
import com.minelittlepony.unicopia.entity.EntitySpear;
|
||||
import com.minelittlepony.unicopia.entity.SpellcastEntity;
|
||||
import com.minelittlepony.unicopia.entity.EntitySpellbook;
|
||||
import com.minelittlepony.unicopia.entity.EntityWildCloud;
|
||||
import com.minelittlepony.unicopia.entity.item.AdvancedProjectileEntity;
|
||||
import com.minelittlepony.unicopia.forgebullshit.BiomeBS;
|
||||
import com.minelittlepony.unicopia.forgebullshit.EntityType;
|
||||
import com.minelittlepony.util.collection.ListHelper;
|
||||
import com.minelittlepony.unicopia.entity.SpellbookEntity;
|
||||
import com.minelittlepony.unicopia.entity.WildCloudEntity;
|
||||
|
||||
import net.minecraft.entity.EnumCreatureType;
|
||||
import net.minecraft.world.biome.Biome;
|
||||
import net.minecraft.world.biome.BiomeEnd;
|
||||
import net.minecraft.world.biome.BiomeForest;
|
||||
import net.minecraft.world.biome.BiomeHell;
|
||||
import net.minecraft.world.biome.BiomeHills;
|
||||
import net.minecraft.world.biome.BiomePlains;
|
||||
import net.minecraft.world.biome.BiomeRiver;
|
||||
import net.minecraftforge.common.BiomeManager;
|
||||
import net.minecraftforge.fml.client.registry.RenderingRegistry;
|
||||
import net.minecraftforge.fml.common.registry.EntityEntry;
|
||||
import net.minecraftforge.registries.IForgeRegistry;
|
||||
import net.minecraft.entity.Entity;
|
||||
import net.minecraft.entity.EntityCategory;
|
||||
import net.minecraft.entity.EntityType;
|
||||
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 class UEntities {
|
||||
public static final EntityType<SpellbookEntity> SPELLBOOK = register("spellbook", EntityType.Builder.create(SpellbookEntity::new, EntityCategory.MISC).setDimensions(0.6f, 0.6f));
|
||||
public static final EntityType<SpellcastEntity> MAGIC_SPELL = register("magic_spell", EntityType.Builder.create(SpellcastEntity::new, EntityCategory.MISC).setDimensions(0.6F, 0.25F));
|
||||
public static final EntityType<CloudEntity> CLOUD = register("cloud", EntityType.Builder.create(CloudEntity::new, EntityCategory.CREATURE));
|
||||
public static final EntityType<WildCloudEntity> WILD_CLOUD = register("wild_cloud", EntityType.Builder.create(WildCloudEntity::new, EntityCategory.CREATURE));
|
||||
public static final EntityType<EntityRacingCloud> RACING_CLOUD = register("racing_cloud", EntityType.Builder.create(EntityRacingCloud::new, EntityCategory.CREATURE));
|
||||
public static final EntityType<ConstructionCloudEntity> CONSTRUCTION_CLOUD = register("construction_cloud", EntityType.Builder.create(ConstructionCloudEntity::new, EntityCategory.CREATURE));
|
||||
|
||||
static void init(IForgeRegistry<EntityEntry> registry) {
|
||||
EntityType builder = EntityType.builder(Unicopia.MODID);
|
||||
registry.registerAll(
|
||||
builder.creature(EntityCloud.class, "cloud").withEgg(0x4169e1, 0x7fff00),
|
||||
builder.creature(EntityWildCloud.class, "wild_cloud"),
|
||||
builder.creature(EntityRacingCloud.class, "racing_cloud"),
|
||||
builder.creature(EntityConstructionCloud.class, "construction_cloud"),
|
||||
builder.creature(SpellcastEntity.class, "magic_spell"),
|
||||
builder.creature(EntitySpellbook.class, "spellbook"),
|
||||
builder.creature(EntityRainbow.Spawner.class, "rainbow_spawner"),
|
||||
builder.creature(EntityCuccoon.class, "cuccoon"),
|
||||
builder.creature(EntityButterfly.class, "butterfly").withEgg(0x222200, 0xaaeeff),
|
||||
builder.projectile(EntityRainbow.class, "rainbow", 500, 5),
|
||||
builder.projectile(AdvancedProjectileEntity.class, "thrown_item", 100, 10),
|
||||
builder.projectile(EntitySpear.class, "spear", 100, 10)
|
||||
);
|
||||
public static final EntityType<RainbowEntity> RAINBOW = register("rainbow", EntityType.Builder.create(RainbowEntity::new, EntityCategory.AMBIENT));
|
||||
public static final EntityType<RainbowEntity.Spawner> RAINBOW_SPAWNER = register("rainbow_spawner", EntityType.Builder.create(RainbowEntity.Spawner::new, EntityCategory.MISC));
|
||||
|
||||
public static final EntityType<EntityCuccoon> CUCCOON = register("cuccoon", EntityType.Builder.create(EntityCuccoon::new, EntityCategory.MISC).setDimensions(0.6f, 0.6f));
|
||||
|
||||
public static final EntityType<ButterflyEntity> BUTTERFLY = register("butterfly", EntityType.Builder.create(ButterflyEntity::new, EntityCategory.AMBIENT));
|
||||
|
||||
public static final EntityType<AdvancedProjectileEntity> THROWN_ITEM = register("thrown_item", EntityType.Builder.create(AdvancedProjectileEntity::new, EntityCategory.MISC));
|
||||
public static final EntityType<EntitySpear> THROWN_SPEAR = register("thrown_spear", EntityType.Builder.create(EntitySpear::new, EntityCategory.MISC));
|
||||
|
||||
//builder.creature(CloudEntity.class, "cloud").withEgg(0x4169e1, 0x7fff00),
|
||||
//builder.creature(ButterflyEntity.class, "butterfly").withEgg(0x222200, 0xaaeeff),
|
||||
// builder.projectile(AdvancedProjectileEntity.class, "thrown_item", 100, 10),
|
||||
// builder.projectile(EntitySpear.class, "spear", 100, 10)
|
||||
|
||||
private static <T extends Entity> EntityType<T> register(String name, EntityType.Builder<T> builder) {
|
||||
return Registry.register(Registry.ENTITY_TYPE, name, builder.build(name));
|
||||
}
|
||||
|
||||
public static void preInit() {
|
||||
RenderingRegistry.registerEntityRenderingHandler(EntityCloud.class, RenderCloud::new);
|
||||
RenderingRegistry.registerEntityRenderingHandler(SpellcastEntity.class, RenderGem::new);
|
||||
RenderingRegistry.registerEntityRenderingHandler(AdvancedProjectileEntity.class, RenderProjectile::new);
|
||||
RenderingRegistry.registerEntityRenderingHandler(EntitySpellbook.class, RenderSpellbook::new);
|
||||
RenderingRegistry.registerEntityRenderingHandler(EntityRainbow.class, RenderRainbow::new);
|
||||
RenderingRegistry.registerEntityRenderingHandler(EntityButterfly.class, ButterflyEntityRenderer::new);
|
||||
RenderingRegistry.registerEntityRenderingHandler(EntityCuccoon.class, RenderCuccoon::new);
|
||||
RenderingRegistry.registerEntityRenderingHandler(EntitySpear.class, RenderSpear::new);
|
||||
}
|
||||
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);
|
||||
}
|
||||
|
||||
public static void registerSpawnEntries(Biome biome) {
|
||||
if (!(biome instanceof BiomeHell || biome instanceof BiomeEnd)) {
|
||||
|
||||
BiomeBS.addSpawnEntry(biome, EnumCreatureType.AMBIENT, EntityWildCloud.class, b ->
|
||||
BiomeManager.oceanBiomes.contains(b) ? EntityWildCloud.SPAWN_ENTRY_OCEAN : EntityWildCloud.SPAWN_ENTRY_LAND
|
||||
);
|
||||
|
||||
BiomeBS.addSpawnEntry(biome, EnumCreatureType.CREATURE, EntityRainbow.Spawner.class, b -> EntityRainbow.SPAWN_ENTRY);
|
||||
}
|
||||
|
||||
if (biome instanceof BiomePlains
|
||||
|| biome instanceof BiomeRiver
|
||||
|| biome instanceof BiomeHills
|
||||
|| biome instanceof BiomeForest) {
|
||||
BiomeBS.addSpawnEntry(biome, EnumCreatureType.AMBIENT, EntityButterfly.class, b -> EntityButterfly.SPAWN_ENTRY);
|
||||
}
|
||||
if (biome instanceof PlainsBiome
|
||||
|| biome instanceof RiverBiome
|
||||
|| biome instanceof MountainsBiome
|
||||
|| biome instanceof ForestBiome) {
|
||||
ListHelper.addifAbsent(biome.getEntitySpawnList(EntityCategory.AMBIENT), ButterflyEntity.SPAWN_ENTRY);
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
|
|
|
@ -5,24 +5,29 @@ import com.minelittlepony.unicopia.item.ItemAppleMultiType;
|
|||
import com.minelittlepony.unicopia.item.ItemCereal;
|
||||
import com.minelittlepony.unicopia.item.AppleItem;
|
||||
import com.minelittlepony.unicopia.item.CloudPlacerItem;
|
||||
import com.minelittlepony.unicopia.item.ItemCurse;
|
||||
import com.minelittlepony.unicopia.item.ItemFruitLeaves;
|
||||
import com.minelittlepony.unicopia.item.ExtendedShearsItem;
|
||||
import com.minelittlepony.unicopia.item.CursedMagicGemItem;
|
||||
import com.minelittlepony.unicopia.item.ItemMagicStaff;
|
||||
import com.minelittlepony.unicopia.item.ItemMoss;
|
||||
import com.minelittlepony.unicopia.item.MossItem;
|
||||
import com.minelittlepony.unicopia.item.ItemOfHolding;
|
||||
import com.minelittlepony.unicopia.item.ItemRottenApple;
|
||||
import com.minelittlepony.unicopia.item.ItemRottenTomato;
|
||||
import com.minelittlepony.unicopia.item.RottenAppleItem;
|
||||
import com.minelittlepony.unicopia.item.RottenTomatoItem;
|
||||
import com.minelittlepony.unicopia.item.ItemSpear;
|
||||
import com.minelittlepony.unicopia.item.ItemSpell;
|
||||
import com.minelittlepony.unicopia.item.ItemSpellbook;
|
||||
import com.minelittlepony.unicopia.item.MagicGemItem;
|
||||
import com.minelittlepony.unicopia.item.SpellbookItem;
|
||||
import com.minelittlepony.unicopia.item.ItemStaff;
|
||||
import com.minelittlepony.unicopia.item.ItemTomato;
|
||||
import com.minelittlepony.unicopia.item.ItemTomatoSeeds;
|
||||
import com.minelittlepony.unicopia.item.TomatoItem;
|
||||
import com.minelittlepony.unicopia.item.TomatoSeedsItem;
|
||||
import com.minelittlepony.unicopia.item.ItemZapApple;
|
||||
import com.minelittlepony.unicopia.item.PredicatedBlockItem;
|
||||
import com.minelittlepony.unicopia.item.StickItem;
|
||||
import com.minelittlepony.unicopia.item.URecord;
|
||||
import com.minelittlepony.unicopia.item.override.ItemShear;
|
||||
import com.minelittlepony.unicopia.item.override.ItemStick;
|
||||
import com.minelittlepony.unicopia.item.consumables.BushToxicityDeterminent;
|
||||
import com.minelittlepony.unicopia.item.consumables.CookedToxicityDeterminent;
|
||||
import com.minelittlepony.unicopia.item.consumables.FlowerToxicityDeterminent;
|
||||
import com.minelittlepony.unicopia.item.consumables.MultiItemEdible;
|
||||
import com.minelittlepony.unicopia.item.consumables.Toxicity;
|
||||
import com.minelittlepony.unicopia.item.consumables.UItemFoodDelegate;
|
||||
import com.minelittlepony.unicopia.magic.spells.SpellRegistry;
|
||||
|
||||
import net.minecraft.item.Item;
|
||||
|
@ -38,49 +43,43 @@ import net.minecraft.item.Items;
|
|||
import net.minecraft.item.TallBlockItem;
|
||||
import net.minecraft.item.Item.Settings;
|
||||
import net.minecraft.util.Identifier;
|
||||
import net.minecraft.util.UseAction;
|
||||
import net.minecraft.util.registry.Registry;
|
||||
|
||||
import static com.minelittlepony.unicopia.Predicates.*;
|
||||
import static com.minelittlepony.unicopia.EquinePredicates.*;
|
||||
|
||||
import javax.annotation.Nullable;
|
||||
|
||||
import com.minelittlepony.unicopia.UClient;
|
||||
import com.minelittlepony.unicopia.Unicopia;
|
||||
import com.minelittlepony.unicopia.edibles.BushToxicityDeterminent;
|
||||
import com.minelittlepony.unicopia.edibles.CookedToxicityDeterminent;
|
||||
import com.minelittlepony.unicopia.edibles.FlowerToxicityDeterminent;
|
||||
import com.minelittlepony.unicopia.edibles.MultiItemEdible;
|
||||
import com.minelittlepony.unicopia.edibles.Toxicity;
|
||||
import com.minelittlepony.unicopia.edibles.UItemFoodDelegate;
|
||||
import com.minelittlepony.unicopia.entity.EntityConstructionCloud;
|
||||
import com.minelittlepony.unicopia.entity.ConstructionCloudEntity;
|
||||
import com.minelittlepony.unicopia.entity.EntityRacingCloud;
|
||||
import com.minelittlepony.unicopia.entity.EntityWildCloud;
|
||||
import com.minelittlepony.unicopia.entity.WildCloudEntity;
|
||||
import com.minelittlepony.unicopia.forgebullshit.BuildInTexturesBakery;
|
||||
import com.minelittlepony.unicopia.forgebullshit.OreReplacer;
|
||||
import com.minelittlepony.unicopia.forgebullshit.UnFuckedItemSnow;
|
||||
|
||||
public class UItems {
|
||||
|
||||
private static final ItemStick stick = register(new ItemStick(new Item.Settings()), "minecraft", "stick");
|
||||
private static final ItemShear shears = register(new ItemShear(), "minecraft", "shears");
|
||||
private static final StickItem stick = register(new StickItem(), "minecraft", "stick");
|
||||
private static final ExtendedShearsItem shears = register(new ExtendedShearsItem(), "minecraft", "shears");
|
||||
|
||||
public static final AppleItem red_apple = register(new AppleItem(FoodComponents.APPLE), "minecraft", "apple");
|
||||
public static final AppleItem green_apple = register(new AppleItem(FoodComponents.APPLE), "apple_green");
|
||||
public static final AppleItem sweet_apple = register(new AppleItem(FoodComponents.APPLE), "apple_sweet");
|
||||
public static final AppleItem sour_apple = register(new AppleItem(FoodComponents.APPLE), "apple_sour");
|
||||
|
||||
public static final ItemAppleMultiType zap_apple = new ItemZapApple(Unicopia.MODID, "zap_apple")
|
||||
.setSubTypes("zap_apple", "red", "green", "sweet", "sour", "zap");
|
||||
public static final ItemAppleMultiType zap_apple = new ItemZapApple(Unicopia.MODID, "zap_apple").setSubTypes("zap_apple", "red", "green", "sweet", "sour", "zap");
|
||||
|
||||
public static final AppleItem rotten_apple = new ItemRottenApple(Unicopia.MODID, "rotten_apple");
|
||||
public static final AppleItem rotten_apple = register(new RottenAppleItem(FoodComponents.APPLE), "rotten_apple");
|
||||
public static final AppleItem cooked_zap_apple = register(new AppleItem(FoodComponents.APPLE), "cooked_zap_apple");
|
||||
|
||||
public static final Item cloud_matter = register(new Item(new Item.Settings().group(ItemGroup.MATERIALS)), "cloud_matter");
|
||||
public static final Item dew_drop = register(new Item(new Item.Settings().group(ItemGroup.MATERIALS)), "dew_drop");
|
||||
|
||||
public static final CloudPlacerItem racing_cloud_spawner = register(new CloudPlacerItem(EntityRacingCloud::new), "racing_cloud_spawner");
|
||||
public static final CloudPlacerItem construction_cloud_spawner = register(new CloudPlacerItem(EntityConstructionCloud::new), "construction_cloud_spawner");
|
||||
public static final CloudPlacerItem wild_cloud_spawner = register(new CloudPlacerItem(EntityWildCloud::new), "wild_cloud_spawner");
|
||||
public static final CloudPlacerItem construction_cloud_spawner = register(new CloudPlacerItem(ConstructionCloudEntity::new), "construction_cloud_spawner");
|
||||
public static final CloudPlacerItem wild_cloud_spawner = register(new CloudPlacerItem(WildCloudEntity::new), "wild_cloud_spawner");
|
||||
|
||||
public static final Item cloud_block = register(new PredicatedBlockItem(UBlocks.normal_cloud, new Item.Settings().group(ItemGroup.MATERIALS), INTERACT_WITH_CLOUDS), "cloud_block");
|
||||
public static final Item enchanted_cloud = register(new PredicatedBlockItem(UBlocks.enchanted_cloud, new Item.Settings().group(ItemGroup.MATERIALS), INTERACT_WITH_CLOUDS), "enchanted_cloud_block");
|
||||
|
@ -94,7 +93,7 @@ public class UItems {
|
|||
public static final Item anvil = register(new PredicatedBlockItem(UBlocks.anvil, new Item.Settings().group(ItemGroup.DECORATIONS), INTERACT_WITH_CLOUDS), "cloud_anvil");
|
||||
|
||||
public static final Item record_crusade = register(new URecord(USounds.RECORD_CRUSADE), "crusade");
|
||||
public static final Item record_pet = register(new URecord(USounds.RECORD_PET, "pet");
|
||||
public static final Item record_pet = register(new URecord(USounds.RECORD_PET), "pet");
|
||||
public static final Item record_popular = register(new URecord(USounds.RECORD_POPULAR), "popular");
|
||||
public static final Item record_funk = register(new URecord(USounds.RECORD_FUNK), "funk");
|
||||
|
||||
|
@ -116,19 +115,19 @@ public class UItems {
|
|||
public static final Item enchanted_cloud_slab = new PredicatedBlockItem(UBlocks.enchanted_cloud_slab, new Item.Settings().group(ItemGroup.BUILDING_BLOCKS), INTERACT_WITH_CLOUDS);
|
||||
public static final Item packed_cloud_slab = new PredicatedBlockItem(UBlocks.packed_cloud_slab, new Item.Settings().group(ItemGroup.BUILDING_BLOCKS), INTERACT_WITH_CLOUDS);
|
||||
|
||||
public static final ItemSpell spell = new ItemSpell(Unicopia.MODID, "gem");
|
||||
public static final ItemSpell curse = new ItemCurse(Unicopia.MODID, "corrupted_gem");
|
||||
public static final MagicGemItem spell = register(new MagicGemItem(), "gem");
|
||||
public static final MagicGemItem curse = register(new CursedMagicGemItem(), "corrupted_gem");
|
||||
|
||||
public static final ItemOfHolding bag_of_holding = new ItemOfHolding(Unicopia.MODID, "bag_of_holding");
|
||||
public static final ItemAlicornAmulet alicorn_amulet = new ItemAlicornAmulet(Unicopia.MODID, "alicorn_amulet");
|
||||
|
||||
public static final ItemSpellbook spellbook = new ItemSpellbook(Unicopia.MODID, "spellbook");
|
||||
public static final SpellbookItem spellbook = register(new SpellbookItem(), "spellbook");
|
||||
public static final Item staff_meadow_brook = new ItemStaff(Unicopia.MODID, "staff_meadow_brook").setMaxDamage(2);
|
||||
public static final Item staff_remembrance = new ItemMagicStaff(Unicopia.MODID, "staff_remembrance", new SpellScorch());
|
||||
|
||||
public static final Item spear = new ItemSpear(Unicopia.MODID, "spear");
|
||||
|
||||
public static final ItemMoss moss = new ItemMoss(Unicopia.MODID, "moss");
|
||||
public static final MossItem moss = new MossItem(Unicopia.MODID, "moss");
|
||||
|
||||
public static final Item alfalfa_seeds = new ItemSeedFood(1, 4, UBlocks.alfalfa, Blocks.FARMLAND)
|
||||
.setTranslationKey("alfalfa_seeds")
|
||||
|
@ -144,17 +143,17 @@ public class UItems {
|
|||
public static final Item cereal = new ItemCereal(Unicopia.MODID, "cereal", 9, 0.8F).setSugarAmount(1);
|
||||
public static final Item sugar_cereal = new ItemCereal(Unicopia.MODID, "sugar_cereal", 20, -2).setSugarAmount(110).setAlwaysEdible();
|
||||
|
||||
public static final ItemTomato tomato = new ItemTomato(Unicopia.MODID, "tomato", 4, 34);
|
||||
public static final ItemRottenTomato rotten_tomato = new ItemRottenTomato(Unicopia.MODID, "rotten_tomato", 4, 34);
|
||||
public static final TomatoItem tomato = new TomatoItem(Unicopia.MODID, "tomato", 4, 34);
|
||||
public static final RottenTomatoItem rotten_tomato = new RottenTomatoItem(Unicopia.MODID, "rotten_tomato", 4, 34);
|
||||
|
||||
public static final ItemTomato cloudsdale_tomato = new ItemTomato(Unicopia.MODID, "cloudsdale_tomato", 16, 4);
|
||||
public static final ItemRottenTomato rotten_cloudsdale_tomato = new ItemRottenTomato(Unicopia.MODID, "rotten_cloudsdale_tomato", 4, 34);
|
||||
public static final TomatoItem cloudsdale_tomato = new TomatoItem(Unicopia.MODID, "cloudsdale_tomato", 16, 4);
|
||||
public static final RottenTomatoItem rotten_cloudsdale_tomato = new RottenTomatoItem(Unicopia.MODID, "rotten_cloudsdale_tomato", 4, 34);
|
||||
|
||||
public static final ItemTomatoSeeds tomato_seeds = new ItemTomatoSeeds(Unicopia.MODID, "tomato_seeds");
|
||||
public static final TomatoSeedsItem tomato_seeds = new TomatoSeedsItem(Unicopia.MODID, "tomato_seeds");
|
||||
|
||||
public static final Item apple_seeds = new UItemDecoration(UBlocks.apple_tree, Unicopia.MODID, "apple_seeds");
|
||||
|
||||
public static final Item apple_leaves = new ItemFruitLeaves(UBlocks.apple_leaves);
|
||||
public static final Item apple_leaves = new BlockItem(UBlocks.apple_leaves);
|
||||
|
||||
public static final Item double_plant = new UItemFoodDelegate(Blocks.DOUBLE_PLANT, stack ->
|
||||
BlockDoublePlant.EnumPlantType.byMetadata(stack.getMetadata()).getTranslationKey()
|
||||
|
@ -198,20 +197,16 @@ public class UItems {
|
|||
|
||||
public static final Item wheat_worms = new MultiItemEdible(Unicopia.MODID, "wheat_worms", 1, 0, stack -> Toxicity.SEVERE);
|
||||
|
||||
public static final Item mug = new Item()
|
||||
.setTranslationKey("mug")
|
||||
.setRegistryName(Unicopia.MODID, "mug")
|
||||
.setCreativeTab(CreativeTabs.MATERIALS)
|
||||
.setFull3D();
|
||||
public static final Item mug = register(new Item(new Item.Settings().group(ItemGroup.MATERIALS)), "mug");
|
||||
public static final Item apple_cider = new MultiItemEdible(Unicopia.MODID, "apple_cider", 4, 2, stack -> Toxicity.MILD)
|
||||
.setUseAction(EnumAction.DRINK)
|
||||
.setUseAction(UseAction.DRINK)
|
||||
.setContainerItem(mug)
|
||||
.setFull3D();
|
||||
public static final Item juice = new MultiItemEdible(Unicopia.MODID, "juice", 2, 2, stack -> Toxicity.SAFE)
|
||||
.setUseAction(EnumAction.DRINK)
|
||||
.setUseAction(UseAction.DRINK)
|
||||
.setContainerItem(Items.GLASS_BOTTLE);
|
||||
public static final Item burned_juice = new MultiItemEdible(Unicopia.MODID, "burned_juice", 3, 1, stack -> Toxicity.FAIR)
|
||||
.setUseAction(EnumAction.DRINK)
|
||||
.setUseAction(UseAction.DRINK)
|
||||
.setContainerItem(Items.GLASS_BOTTLE);
|
||||
|
||||
|
||||
|
@ -227,12 +222,12 @@ public class UItems {
|
|||
BuildInTexturesBakery.getBuiltInTextures().add(new Identifier(Unicopia.MODID, "items/empty_slot_gem"));
|
||||
}
|
||||
|
||||
FurnaceRecipes.getInstance().addSmeltingRecipe(new ItemStack(zap_apple), new ItemStack(cooked_zap_apple), 0.1F);
|
||||
FurnaceRecipes.getInstance().addSmeltingRecipe(new ItemStack(juice), new ItemStack(burned_juice), 0);
|
||||
FurnaceRecipes.getInstance().addSmeltingRecipe(new ItemStack(cuccoon), new ItemStack(chitin_shell), 0.3F);
|
||||
FurnaceRecipes.instance().addSmeltingRecipe(new ItemStack(zap_apple), new ItemStack(cooked_zap_apple), 0.1F);
|
||||
FurnaceRecipes.instance().addSmeltingRecipe(new ItemStack(juice), new ItemStack(burned_juice), 0);
|
||||
FurnaceRecipes.instance().addSmeltingRecipe(new ItemStack(cuccoon), new ItemStack(chitin_shell), 0.3F);
|
||||
}
|
||||
|
||||
public static void fixRecipes() {
|
||||
static void fixRecipes() {
|
||||
new OreReplacer()
|
||||
.registerAll(stack -> stack.getItem().getRegistryName().equals(red_apple.getRegistryName()))
|
||||
.done();
|
||||
|
@ -254,4 +249,6 @@ public class UItems {
|
|||
return 0xffffff;
|
||||
}, spell, curse);
|
||||
}
|
||||
|
||||
static void bootstrap() {}
|
||||
}
|
||||
|
|
|
@ -8,8 +8,6 @@ import com.minelittlepony.unicopia.client.particle.ParticleUnicornMagic;
|
|||
|
||||
import net.fabricmc.api.EnvType;
|
||||
import net.fabricmc.api.Environment;
|
||||
import net.fabricmc.fabric.api.particles.ParticleFactoryRegistry;
|
||||
import net.fabricmc.fabric.api.particles.ParticleTypeRegistry;
|
||||
import net.minecraft.particle.DefaultParticleType;
|
||||
import net.minecraft.util.Identifier;
|
||||
|
||||
|
@ -21,13 +19,4 @@ public class UParticles {
|
|||
|
||||
public static final DefaultParticleType SPHERE = ParticleTypeRegistry.getTnstance().register(new Identifier("unicopia", "sphere"));
|
||||
public static final DefaultParticleType DISK = ParticleTypeRegistry.getTnstance().register(new Identifier("unicopia", "disk"));
|
||||
|
||||
@Environment(EnvType.CLIENT)
|
||||
public void onInitializeClient() {
|
||||
ParticleFactoryRegistry.getInstance().register(UNICORN_MAGIC, ParticleUnicornMagic::new);
|
||||
ParticleFactoryRegistry.getInstance().register(CHANGELING_MAGIC, ParticleChangelingMagic::new);
|
||||
ParticleFactoryRegistry.getInstance().register(RAIN_DROPS, ParticleRaindrops::new);
|
||||
ParticleFactoryRegistry.getInstance().register(SPHERE, ParticleSphere::new);
|
||||
ParticleFactoryRegistry.getInstance().register(DISK, ParticleDisk::new);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -54,17 +54,17 @@ public class UPotion extends StatusEffect {
|
|||
}
|
||||
|
||||
@Override
|
||||
public boolean shouldRender(PotionEffect effect) {
|
||||
public boolean shouldRender(StatusEffectInstance effect) {
|
||||
return !isSilent;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean shouldRenderInvText(PotionEffect effect) {
|
||||
public boolean shouldRenderInvText(StatusEffectInstance effect) {
|
||||
return !isSilent;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean shouldRenderHUD(PotionEffect effect) {
|
||||
public boolean shouldRenderHUD(StatusEffectInstance effect) {
|
||||
return !isSilent;
|
||||
}
|
||||
|
||||
|
|
|
@ -1,5 +1,7 @@
|
|||
package com.minelittlepony.unicopia;
|
||||
|
||||
import net.fabricmc.api.ModInitializer;
|
||||
import net.minecraft.entity.player.PlayerEntity;
|
||||
import net.minecraft.util.math.BlockPos;
|
||||
import net.minecraft.world.World;
|
||||
import net.minecraft.world.biome.Biome;
|
||||
|
@ -10,28 +12,26 @@ import org.apache.logging.log4j.LogManager;
|
|||
import org.apache.logging.log4j.Logger;
|
||||
|
||||
import com.google.gson.JsonObject;
|
||||
import com.minelittlepony.unicopia.ability.powers.PowersRegistry;
|
||||
import com.minelittlepony.unicopia.advancements.UAdvancements;
|
||||
import com.minelittlepony.unicopia.ability.PowersRegistry;
|
||||
import com.minelittlepony.unicopia.command.Commands;
|
||||
import com.minelittlepony.unicopia.enchanting.AffineIngredients;
|
||||
import com.minelittlepony.unicopia.enchanting.Pages;
|
||||
import com.minelittlepony.unicopia.enchanting.SpecialRecipe;
|
||||
import com.minelittlepony.unicopia.enchanting.SpellRecipe;
|
||||
import com.minelittlepony.unicopia.enchanting.recipe.AffineIngredients;
|
||||
import com.minelittlepony.unicopia.enchanting.recipe.SpecialRecipe;
|
||||
import com.minelittlepony.unicopia.enchanting.recipe.SpellRecipe;
|
||||
import com.minelittlepony.unicopia.inventory.gui.SpellBookContainer;
|
||||
import com.minelittlepony.unicopia.inventory.gui.GuiSpellBook;
|
||||
import com.minelittlepony.unicopia.network.MsgPlayerAbility;
|
||||
import com.minelittlepony.unicopia.network.MsgPlayerCapabilities;
|
||||
import com.minelittlepony.unicopia.network.MsgRequestCapabilities;
|
||||
import com.minelittlepony.unicopia.util.crafting.CraftingManager;
|
||||
import com.minelittlepony.unicopia.world.Hooks;
|
||||
import com.minelittlepony.unicopia.world.UWorld;
|
||||
|
||||
public class Unicopia implements IGuiHandler {
|
||||
public class Unicopia implements ModInitializer {
|
||||
public static final String MODID = "unicopia";
|
||||
public static final String NAME = "@NAME@";
|
||||
public static final String VERSION = "@VERSION@";
|
||||
|
||||
public static final Logger log = LogManager.getLogger();
|
||||
public static final Logger LOGGER = LogManager.getLogger();
|
||||
|
||||
private static IChannel channel;
|
||||
|
||||
|
@ -47,6 +47,7 @@ public class Unicopia implements IGuiHandler {
|
|||
}
|
||||
};
|
||||
|
||||
@Deprecated
|
||||
public static CraftingManager getCraftingManager() {
|
||||
return craftingManager;
|
||||
}
|
||||
|
@ -55,21 +56,10 @@ public class Unicopia implements IGuiHandler {
|
|||
return channel;
|
||||
}
|
||||
|
||||
public void preInit(FMLPreInitializationEvent event) {
|
||||
UConfig.init(event.getModConfigurationDirectory());
|
||||
UClient.instance().preInit();
|
||||
UWorld.instance().init();
|
||||
}
|
||||
@Override
|
||||
public void onInitialize() {
|
||||
Config.init(event.getModConfigurationDirectory());
|
||||
|
||||
public void onServerCreated(FMLServerAboutToStartEvent event) {
|
||||
Fixes.init(event.getServer().getDataFixer());
|
||||
}
|
||||
|
||||
public void onServerStart(FMLServerStartingEvent event) {
|
||||
Commands.init(event);
|
||||
}
|
||||
|
||||
public void init(FMLInitializationEvent event) {
|
||||
channel = JumpingCastle.subscribeTo(MODID, () -> {})
|
||||
.listenFor(MsgRequestCapabilities.class)
|
||||
.listenFor(MsgPlayerCapabilities.class)
|
||||
|
@ -79,37 +69,21 @@ public class Unicopia implements IGuiHandler {
|
|||
|
||||
UAdvancements.init();
|
||||
|
||||
FBS.init();
|
||||
|
||||
NetworkRegistry.INSTANCE.registerGuiHandler(this, this);
|
||||
|
||||
UClient.instance().init();
|
||||
}
|
||||
|
||||
public void postInit(FMLPostInitializationEvent event) {
|
||||
craftingManager.load();
|
||||
|
||||
Pages.instance().load();
|
||||
|
||||
Biome.REGISTRY.forEach(UEntities::registerSpawnEntries);
|
||||
UBlocks.bootstrap();
|
||||
UItems.bootstrap();
|
||||
Commands.bootstrap();
|
||||
|
||||
|
||||
UWorld.instance().init();
|
||||
|
||||
UClient.instance().preInit();
|
||||
UClient.instance().init();
|
||||
UClient.instance().postInit();
|
||||
|
||||
UItems.fixRecipes();
|
||||
}
|
||||
|
||||
@Override
|
||||
public Object getServerGuiElement(int ID, PlayerEntity player, World world, int x, int y, int z) {
|
||||
switch (ID) {
|
||||
case 0: return new SpellBookContainer(player.inventory, world, new BlockPos(x, y, z));
|
||||
default: return null;
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public Object getClientGuiElement(int ID, PlayerEntity player, World world, int x, int y, int z) {
|
||||
switch (ID) {
|
||||
case 0: return new GuiSpellBook(player);
|
||||
default: return null;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
package com.minelittlepony.unicopia.ability;
|
||||
|
||||
import com.minelittlepony.unicopia.entity.player.IPlayer;
|
||||
import com.minelittlepony.unicopia.entity.capabilities.IPlayer;
|
||||
|
||||
/**
|
||||
* Predicate for abilities to control whether a player can fly.
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
package com.minelittlepony.unicopia.ability;
|
||||
|
||||
import com.minelittlepony.unicopia.entity.player.IPlayer;
|
||||
import com.minelittlepony.unicopia.entity.capabilities.IPlayer;
|
||||
|
||||
/**
|
||||
* Predicate for abilities to control what the player's physical height is.
|
||||
|
|
|
@ -4,7 +4,7 @@ import javax.annotation.Nullable;
|
|||
|
||||
import com.minelittlepony.unicopia.Race;
|
||||
import com.minelittlepony.unicopia.client.input.IKeyBindingHandler;
|
||||
import com.minelittlepony.unicopia.entity.player.IPlayer;
|
||||
import com.minelittlepony.unicopia.entity.capabilities.IPlayer;
|
||||
|
||||
import net.minecraft.world.World;
|
||||
|
||||
|
|
|
@ -1,11 +1,9 @@
|
|||
package com.minelittlepony.unicopia.ability.powers;
|
||||
package com.minelittlepony.unicopia.ability;
|
||||
|
||||
import org.lwjgl.glfw.GLFW;
|
||||
|
||||
import com.minelittlepony.unicopia.Race;
|
||||
import com.minelittlepony.unicopia.ability.Hit;
|
||||
import com.minelittlepony.unicopia.ability.IPower;
|
||||
import com.minelittlepony.unicopia.entity.player.IPlayer;
|
||||
import com.minelittlepony.unicopia.entity.capabilities.IPlayer;
|
||||
import com.minelittlepony.util.VecHelper;
|
||||
|
||||
import net.minecraft.client.network.packet.EntityPassengersSetS2CPacket;
|
|
@ -1,4 +1,4 @@
|
|||
package com.minelittlepony.unicopia.ability.powers;
|
||||
package com.minelittlepony.unicopia.ability;
|
||||
|
||||
import java.util.Optional;
|
||||
|
||||
|
@ -6,9 +6,7 @@ import org.lwjgl.glfw.GLFW;
|
|||
|
||||
import com.minelittlepony.unicopia.Race;
|
||||
import com.minelittlepony.unicopia.UParticles;
|
||||
import com.minelittlepony.unicopia.ability.IPower;
|
||||
import com.minelittlepony.unicopia.ability.Numeric;
|
||||
import com.minelittlepony.unicopia.entity.player.IPlayer;
|
||||
import com.minelittlepony.unicopia.entity.capabilities.IPlayer;
|
||||
import com.minelittlepony.util.VecHelper;
|
||||
|
||||
import net.minecraft.entity.Entity;
|
|
@ -1,4 +1,4 @@
|
|||
package com.minelittlepony.unicopia.ability.powers;
|
||||
package com.minelittlepony.unicopia.ability;
|
||||
|
||||
|
||||
import javax.annotation.Nullable;
|
||||
|
@ -8,9 +8,8 @@ import org.lwjgl.glfw.GLFW;
|
|||
import com.minelittlepony.unicopia.Race;
|
||||
import com.minelittlepony.unicopia.SpeciesList;
|
||||
import com.minelittlepony.unicopia.UParticles;
|
||||
import com.minelittlepony.unicopia.ability.Hit;
|
||||
import com.minelittlepony.unicopia.entity.IInAnimate;
|
||||
import com.minelittlepony.unicopia.entity.player.IPlayer;
|
||||
import com.minelittlepony.unicopia.entity.capabilities.IPlayer;
|
||||
import com.minelittlepony.unicopia.magic.spells.SpellDisguise;
|
||||
import com.minelittlepony.util.VecHelper;
|
||||
|
|
@ -1,12 +1,10 @@
|
|||
package com.minelittlepony.unicopia.ability.powers;
|
||||
package com.minelittlepony.unicopia.ability;
|
||||
|
||||
import javax.annotation.Nullable;
|
||||
|
||||
import org.lwjgl.glfw.GLFW;
|
||||
import com.minelittlepony.unicopia.Race;
|
||||
import com.minelittlepony.unicopia.ability.Hit;
|
||||
import com.minelittlepony.unicopia.ability.IPower;
|
||||
import com.minelittlepony.unicopia.entity.player.IPlayer;
|
||||
import com.minelittlepony.unicopia.entity.capabilities.IPlayer;
|
||||
import com.minelittlepony.unicopia.magic.spells.SpellChangelingTrap;
|
||||
|
||||
public class PowerEngulf implements IPower<Hit> {
|
|
@ -1,4 +1,4 @@
|
|||
package com.minelittlepony.unicopia.ability.powers;
|
||||
package com.minelittlepony.unicopia.ability;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.stream.Collectors;
|
||||
|
@ -8,9 +8,7 @@ import javax.annotation.Nullable;
|
|||
import org.lwjgl.glfw.GLFW;
|
||||
|
||||
import com.minelittlepony.unicopia.Race;
|
||||
import com.minelittlepony.unicopia.ability.Hit;
|
||||
import com.minelittlepony.unicopia.ability.IPower;
|
||||
import com.minelittlepony.unicopia.entity.player.IPlayer;
|
||||
import com.minelittlepony.unicopia.entity.capabilities.IPlayer;
|
||||
import com.minelittlepony.util.MagicalDamageSource;
|
||||
import com.minelittlepony.util.VecHelper;
|
||||
|
|
@ -1,12 +1,10 @@
|
|||
package com.minelittlepony.unicopia.ability.powers;
|
||||
package com.minelittlepony.unicopia.ability;
|
||||
|
||||
import org.lwjgl.glfw.GLFW;
|
||||
|
||||
import com.minelittlepony.unicopia.Race;
|
||||
import com.minelittlepony.unicopia.UParticles;
|
||||
import com.minelittlepony.unicopia.ability.IPower;
|
||||
import com.minelittlepony.unicopia.ability.Location;
|
||||
import com.minelittlepony.unicopia.entity.player.IPlayer;
|
||||
import com.minelittlepony.unicopia.entity.capabilities.IPlayer;
|
||||
import com.minelittlepony.util.VecHelper;
|
||||
|
||||
import net.minecraft.block.BlockState;
|
|
@ -1,11 +1,9 @@
|
|||
package com.minelittlepony.unicopia.ability.powers;
|
||||
package com.minelittlepony.unicopia.ability;
|
||||
|
||||
import org.lwjgl.glfw.GLFW;
|
||||
import com.minelittlepony.unicopia.Race;
|
||||
import com.minelittlepony.unicopia.UParticles;
|
||||
import com.minelittlepony.unicopia.ability.Hit;
|
||||
import com.minelittlepony.unicopia.ability.IPower;
|
||||
import com.minelittlepony.unicopia.entity.player.IPlayer;
|
||||
import com.minelittlepony.unicopia.entity.capabilities.IPlayer;
|
||||
import com.minelittlepony.unicopia.magic.spells.SpellShield;
|
||||
|
||||
public class PowerMagic implements IPower<Hit> {
|
|
@ -1,18 +1,14 @@
|
|||
package com.minelittlepony.unicopia.ability.powers;
|
||||
package com.minelittlepony.unicopia.ability;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.Map.Entry;
|
||||
|
||||
import org.lwjgl.glfw.GLFW;
|
||||
|
||||
import com.google.common.collect.Lists;
|
||||
import com.google.gson.annotations.Expose;
|
||||
import com.minelittlepony.unicopia.Race;
|
||||
import com.minelittlepony.unicopia.SpeciesList;
|
||||
import com.minelittlepony.unicopia.ability.IPower;
|
||||
import com.minelittlepony.unicopia.ability.Location;
|
||||
import com.minelittlepony.unicopia.entity.player.IPlayer;
|
||||
import com.minelittlepony.unicopia.entity.capabilities.IPlayer;
|
||||
import com.minelittlepony.unicopia.item.AppleItem;
|
||||
import com.minelittlepony.unicopia.world.UWorld;
|
||||
import com.minelittlepony.util.MagicalDamageSource;
|
||||
|
@ -36,7 +32,6 @@ import net.minecraft.entity.player.PlayerEntity;
|
|||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.particle.BlockStateParticleEffect;
|
||||
import net.minecraft.particle.ParticleTypes;
|
||||
import net.minecraft.state.property.Property;
|
||||
import net.minecraft.util.hit.BlockHitResult;
|
||||
import net.minecraft.util.hit.HitResult;
|
||||
import net.minecraft.util.math.BlockPos;
|
||||
|
@ -301,7 +296,7 @@ public class PowerStomp implements IPower<PowerStomp.Data> {
|
|||
int breaks = 0;
|
||||
BlockState state;
|
||||
while (variantAndBlockEquals(w.getBlockState(pos.up()), log)) {
|
||||
if (PosHelper.some(pos, p -> isLeaves(w.getBlockState(p), log), HORIZONTALS)) {
|
||||
if (PosHelper.some(pos, p -> isLeaves(w.getBlockState(p), log), Direction.NORTH, Direction.SOUTH, Direction.EAST, Direction.WEST)) {
|
||||
break;
|
||||
}
|
||||
|
||||
|
@ -462,14 +457,16 @@ public class PowerStomp implements IPower<PowerStomp.Data> {
|
|||
}
|
||||
|
||||
private Object getVariant(BlockState state) {
|
||||
if (state.getBlock() instanceof LeavesBlock) {
|
||||
// TODO:
|
||||
/*if (state.getBlock() instanceof LeavesBlock) {
|
||||
return ((LeavesBlock)state.getBlock()).getWoodType(state);
|
||||
}
|
||||
|
||||
return state.getEntries().entrySet().stream()
|
||||
.filter(i -> i.getKey().getName().contentEquals("variant"))
|
||||
.map(i -> i.getValue())
|
||||
.findFirst().orElse(null);
|
||||
.findFirst().orElse(null);*/
|
||||
return null;
|
||||
}
|
||||
|
||||
protected static class Data extends Location {
|
|
@ -1,11 +1,9 @@
|
|||
package com.minelittlepony.unicopia.ability.powers;
|
||||
package com.minelittlepony.unicopia.ability;
|
||||
|
||||
import org.lwjgl.glfw.GLFW;
|
||||
import com.minelittlepony.unicopia.Race;
|
||||
import com.minelittlepony.unicopia.UParticles;
|
||||
import com.minelittlepony.unicopia.ability.IPower;
|
||||
import com.minelittlepony.unicopia.ability.Location;
|
||||
import com.minelittlepony.unicopia.entity.player.IPlayer;
|
||||
import com.minelittlepony.unicopia.entity.capabilities.IPlayer;
|
||||
import com.minelittlepony.util.VecHelper;
|
||||
|
||||
import net.minecraft.block.Block;
|
|
@ -1,4 +1,4 @@
|
|||
package com.minelittlepony.unicopia.ability.powers;
|
||||
package com.minelittlepony.unicopia.ability;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.HashMap;
|
||||
|
@ -7,16 +7,14 @@ import java.util.Map;
|
|||
import java.util.Optional;
|
||||
|
||||
import com.minelittlepony.unicopia.Race;
|
||||
import com.minelittlepony.unicopia.ability.IData;
|
||||
import com.minelittlepony.unicopia.ability.IPower;
|
||||
import com.minelittlepony.unicopia.client.input.Keyboard;
|
||||
|
||||
public class PowersRegistry {
|
||||
|
||||
private static PowersRegistry instance = new PowersRegistry();
|
||||
private static final PowersRegistry INSTANCE = new PowersRegistry();
|
||||
|
||||
public static PowersRegistry instance() {
|
||||
return instance;
|
||||
return INSTANCE;
|
||||
}
|
||||
|
||||
private final Map<Integer, List<IPower<? extends IData>>> keyToPowerMap = new HashMap<>();
|
|
@ -8,7 +8,7 @@ import javax.annotation.Nullable;
|
|||
import com.minelittlepony.unicopia.CloudType;
|
||||
import com.minelittlepony.unicopia.SpeciesList;
|
||||
import com.minelittlepony.unicopia.UBlocks;
|
||||
import com.minelittlepony.unicopia.item.ItemMoss;
|
||||
import com.minelittlepony.unicopia.item.MossItem;
|
||||
|
||||
import net.fabricmc.fabric.api.block.FabricBlockSettings;
|
||||
import net.minecraft.block.Block;
|
||||
|
@ -56,7 +56,7 @@ public class BlockCloud extends Block implements ICloudBlock, ITillable {
|
|||
pos = pos.offset(Direction.random(rand), 1 + rand.nextInt(2));
|
||||
state = world.getBlockState(pos);
|
||||
|
||||
BlockState converted = ItemMoss.affected.getInverse().getConverted(state);
|
||||
BlockState converted = MossItem.AFFECTED.getInverse().getConverted(state);
|
||||
|
||||
if (!state.equals(converted)) {
|
||||
world.setBlockState(pos, converted);
|
||||
|
|
|
@ -4,7 +4,7 @@ import java.util.function.Supplier;
|
|||
|
||||
import javax.annotation.Nullable;
|
||||
|
||||
import com.minelittlepony.unicopia.Predicates;
|
||||
import com.minelittlepony.unicopia.EquinePredicates;
|
||||
|
||||
import net.minecraft.block.SoundType;
|
||||
import net.minecraft.block.material.MapColor;
|
||||
|
@ -32,7 +32,7 @@ public class BlockDiamondDoor extends UDoor {
|
|||
|
||||
@Override
|
||||
protected boolean canOpen(@Nullable PlayerEntity player) {
|
||||
return Predicates.MAGI.test(player);
|
||||
return EquinePredicates.MAGI.test(player);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
|
@ -5,7 +5,7 @@ import java.util.Random;
|
|||
|
||||
import javax.annotation.Nullable;
|
||||
|
||||
import com.minelittlepony.unicopia.Predicates;
|
||||
import com.minelittlepony.unicopia.EquinePredicates;
|
||||
import com.minelittlepony.unicopia.UBlocks;
|
||||
import com.minelittlepony.unicopia.UMaterials;
|
||||
import com.minelittlepony.unicopia.USounds;
|
||||
|
@ -31,8 +31,6 @@ import net.minecraft.world.World;
|
|||
|
||||
public class BlockGrowingCuccoon extends Block {
|
||||
|
||||
public static final DamageSource DAMAGE_SOURCE = MagicalDamageSource.mundane("acid");
|
||||
|
||||
public static final IntProperty AGE = IntProperty.of("age", 0, 7);
|
||||
public static final EnumProperty<Shape> SHAPE = EnumProperty.of("shape", Shape.class);
|
||||
|
||||
|
@ -207,11 +205,11 @@ public class BlockGrowingCuccoon extends Block {
|
|||
|
||||
@Override
|
||||
public void onEntityCollision(World world, BlockPos pos, BlockState state, Entity entity) {
|
||||
if (entity instanceof LivingEntity && !entity.isDead) {
|
||||
if (entity instanceof LivingEntity && !entity.removed) {
|
||||
LivingEntity living = (LivingEntity)entity;
|
||||
|
||||
if (!Predicates.BUGGY.test(living) && living.getHealth() > 0) {
|
||||
living.attackEntityFrom(DAMAGE_SOURCE, 1);
|
||||
if (!EquinePredicates.BUGGY.test(living) && living.getHealth() > 0) {
|
||||
living.damage(MagicalDamageSource.ACID, 1);
|
||||
living.setInWeb();
|
||||
|
||||
if (!world.isClient) {
|
||||
|
@ -224,8 +222,8 @@ public class BlockGrowingCuccoon extends Block {
|
|||
if (world.rand.nextInt(13000) == 0) {
|
||||
PlayerEntity player = (PlayerEntity)living;
|
||||
|
||||
skull.setTagCompound(new NBTTagCompound());
|
||||
skull.getTagCompound().setTag("SkullOwner", NBTUtil.writeGameProfile(new NBTTagCompound(), player.getGameProfile()));
|
||||
skull.setTagCompound(new CompoundTag());
|
||||
skull.getTagCompound().setTag("SkullOwner", NBTUtil.writeGameProfile(new CompoundTag(), player.getGameProfile()));
|
||||
skull.setItemDamage(3);
|
||||
} else {
|
||||
living.dropItem(Items.SKULL, 1);
|
||||
|
|
|
@ -5,7 +5,7 @@ import javax.annotation.Nullable;
|
|||
import com.minelittlepony.unicopia.Race;
|
||||
import com.minelittlepony.unicopia.SpeciesList;
|
||||
import com.minelittlepony.unicopia.UMaterials;
|
||||
import com.minelittlepony.unicopia.entity.player.IPlayer;
|
||||
import com.minelittlepony.unicopia.entity.capabilities.IPlayer;
|
||||
|
||||
import net.fabricmc.fabric.api.block.FabricBlockSettings;
|
||||
import net.minecraft.block.Block;
|
||||
|
|
|
@ -3,7 +3,7 @@ package com.minelittlepony.unicopia.block;
|
|||
import com.minelittlepony.unicopia.Race;
|
||||
import com.minelittlepony.unicopia.SpeciesList;
|
||||
import com.minelittlepony.unicopia.UMaterials;
|
||||
import com.minelittlepony.unicopia.entity.player.IPlayer;
|
||||
import com.minelittlepony.unicopia.entity.capabilities.IPlayer;
|
||||
|
||||
import net.fabricmc.fabric.api.block.FabricBlockSettings;
|
||||
import net.minecraft.block.Block;
|
||||
|
|
|
@ -9,7 +9,7 @@ import com.minelittlepony.unicopia.SpeciesList;
|
|||
import com.minelittlepony.unicopia.UBlocks;
|
||||
import com.minelittlepony.unicopia.UMaterials;
|
||||
import com.minelittlepony.unicopia.USounds;
|
||||
import com.minelittlepony.unicopia.entity.player.IPlayer;
|
||||
import com.minelittlepony.unicopia.entity.capabilities.IPlayer;
|
||||
import com.minelittlepony.util.PosHelper;
|
||||
import com.minelittlepony.util.shape.IShape;
|
||||
import com.minelittlepony.util.shape.Sphere;
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
package com.minelittlepony.unicopia.block;
|
||||
|
||||
import com.minelittlepony.unicopia.CloudType;
|
||||
import com.minelittlepony.unicopia.Predicates;
|
||||
import com.minelittlepony.unicopia.EquinePredicates;
|
||||
import com.minelittlepony.unicopia.UClient;
|
||||
import net.minecraft.block.BedBlock;
|
||||
import net.minecraft.block.Block;
|
||||
|
@ -58,7 +58,7 @@ public interface ICloudBlock {
|
|||
}
|
||||
}
|
||||
|
||||
if (!Predicates.INTERACT_WITH_CLOUDS.apply(player)) {
|
||||
if (!EquinePredicates.INTERACT_WITH_CLOUDS.apply(player)) {
|
||||
return type != CloudType.ENCHANTED;
|
||||
}
|
||||
|
||||
|
|
|
@ -1,8 +1,12 @@
|
|||
package com.minelittlepony.unicopia;
|
||||
package com.minelittlepony.unicopia.client;
|
||||
|
||||
import com.minelittlepony.unicopia.entity.player.IPlayer;
|
||||
import com.minelittlepony.unicopia.SpeciesList;
|
||||
import com.minelittlepony.unicopia.UBlocks;
|
||||
import com.minelittlepony.unicopia.UClient;
|
||||
import com.minelittlepony.unicopia.UItems;
|
||||
import com.minelittlepony.unicopia.client.gui.UHud;
|
||||
import com.minelittlepony.unicopia.entity.player.ICamera;
|
||||
import com.minelittlepony.unicopia.entity.capabilities.ICamera;
|
||||
import com.minelittlepony.unicopia.entity.capabilities.IPlayer;
|
||||
import com.mojang.blaze3d.platform.GlStateManager;
|
||||
|
||||
import net.minecraft.client.MinecraftClient;
|
|
@ -0,0 +1,45 @@
|
|||
package com.minelittlepony.unicopia.client;
|
||||
|
||||
import com.minelittlepony.unicopia.client.render.entity.ButterflyEntityRenderer;
|
||||
import com.minelittlepony.unicopia.client.render.entity.RenderCloud;
|
||||
import com.minelittlepony.unicopia.client.render.entity.RenderCuccoon;
|
||||
import com.minelittlepony.unicopia.client.render.entity.RenderRainbow;
|
||||
import com.minelittlepony.unicopia.client.render.entity.RenderSpear;
|
||||
import com.minelittlepony.unicopia.client.render.entity.RenderSpellbook;
|
||||
import com.minelittlepony.unicopia.client.render.entity.SpellcastEntityRenderer;
|
||||
import com.minelittlepony.unicopia.entity.AdvancedProjectileEntity;
|
||||
import com.minelittlepony.unicopia.entity.ButterflyEntity;
|
||||
import com.minelittlepony.unicopia.entity.CloudEntity;
|
||||
import com.minelittlepony.unicopia.entity.EntityCuccoon;
|
||||
import com.minelittlepony.unicopia.entity.EntitySpear;
|
||||
import com.minelittlepony.unicopia.entity.RainbowEntity;
|
||||
import com.minelittlepony.unicopia.entity.SpellbookEntity;
|
||||
import com.minelittlepony.unicopia.entity.SpellcastEntity;
|
||||
import com.minelittlepony.unicopia.entity.WildCloudEntity;
|
||||
import com.minelittlepony.util.collection.ListHelper;
|
||||
|
||||
import net.fabricmc.fabric.api.client.render.EntityRendererRegistry;
|
||||
import net.minecraft.client.MinecraftClient;
|
||||
import net.minecraft.client.render.entity.FlyingItemEntityRenderer;
|
||||
import net.minecraft.entity.EntityCategory;
|
||||
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 class UEntityRenderers {
|
||||
static void bootstrap() {
|
||||
EntityRendererRegistry.INSTANCE.register(CloudEntity.class, RenderCloud::new);
|
||||
EntityRendererRegistry.INSTANCE.register(SpellcastEntity.class, SpellcastEntityRenderer::new);
|
||||
EntityRendererRegistry.INSTANCE.register(AdvancedProjectileEntity.class, (manager, context) -> new FlyingItemEntityRenderer<>(manager, MinecraftClient.getInstance().getItemRenderer()));
|
||||
EntityRendererRegistry.INSTANCE.register(SpellbookEntity.class, RenderSpellbook::new);
|
||||
EntityRendererRegistry.INSTANCE.register(RainbowEntity.class, RenderRainbow::new);
|
||||
EntityRendererRegistry.INSTANCE.register(ButterflyEntity.class, ButterflyEntityRenderer::new);
|
||||
EntityRendererRegistry.INSTANCE.register(EntityCuccoon.class, RenderCuccoon::new);
|
||||
EntityRendererRegistry.INSTANCE.register(EntitySpear.class, RenderSpear::new);
|
||||
}
|
||||
}
|
|
@ -0,0 +1,22 @@
|
|||
package com.minelittlepony.unicopia.client;
|
||||
|
||||
import com.minelittlepony.unicopia.client.particle.ParticleChangelingMagic;
|
||||
import com.minelittlepony.unicopia.client.particle.ParticleDisk;
|
||||
import com.minelittlepony.unicopia.client.particle.ParticleRaindrops;
|
||||
import com.minelittlepony.unicopia.client.particle.ParticleSphere;
|
||||
import com.minelittlepony.unicopia.client.particle.ParticleUnicornMagic;
|
||||
|
||||
import net.fabricmc.api.EnvType;
|
||||
import net.fabricmc.api.Environment;
|
||||
import net.minecraft.particle.DefaultParticleType;
|
||||
import net.minecraft.util.Identifier;
|
||||
|
||||
class UParticles extends com.minelittlepony.unicopia.UParticles {
|
||||
static void bootstrap() {
|
||||
ParticleFactoryRegistry.instance().register(UNICORN_MAGIC, ParticleUnicornMagic::new);
|
||||
ParticleFactoryRegistry.instance().register(CHANGELING_MAGIC, ParticleChangelingMagic::new);
|
||||
ParticleFactoryRegistry.instance().register(RAIN_DROPS, ParticleRaindrops::new);
|
||||
ParticleFactoryRegistry.instance().register(SPHERE, ParticleSphere::new);
|
||||
ParticleFactoryRegistry.instance().register(DISK, ParticleDisk::new);
|
||||
}
|
||||
}
|
|
@ -1,4 +1,4 @@
|
|||
package com.minelittlepony.unicopia;
|
||||
package com.minelittlepony.unicopia.client;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.UUID;
|
||||
|
@ -6,12 +6,20 @@ import java.util.UUID;
|
|||
import javax.annotation.Nonnull;
|
||||
import javax.annotation.Nullable;
|
||||
|
||||
import com.minelittlepony.unicopia.ability.powers.render.DisguiseRenderer;
|
||||
import com.minelittlepony.unicopia.MineLP;
|
||||
import com.minelittlepony.unicopia.Race;
|
||||
import com.minelittlepony.unicopia.SpeciesList;
|
||||
import com.minelittlepony.unicopia.UClient;
|
||||
import com.minelittlepony.unicopia.Config;
|
||||
import com.minelittlepony.unicopia.UEntities;
|
||||
import com.minelittlepony.unicopia.UParticles;
|
||||
import com.minelittlepony.unicopia.Unicopia;
|
||||
import com.minelittlepony.unicopia.client.ability.render.DisguiseRenderer;
|
||||
import com.minelittlepony.unicopia.client.gui.SettingsScreen;
|
||||
import com.minelittlepony.unicopia.client.input.Keyboard;
|
||||
import com.minelittlepony.unicopia.client.input.MouseControl;
|
||||
import com.minelittlepony.unicopia.entity.capabilities.IPlayer;
|
||||
import com.minelittlepony.unicopia.client.input.InversionAwareKeyboardInput;
|
||||
import com.minelittlepony.unicopia.entity.player.IPlayer;
|
||||
import com.minelittlepony.unicopia.network.MsgRequestCapabilities;
|
||||
import com.mojang.authlib.GameProfile;
|
||||
|
||||
|
@ -34,7 +42,7 @@ public class UnicopiaClient extends UClient {
|
|||
private static Race clientPlayerRace = getclientPlayerRace();
|
||||
|
||||
private static Race getclientPlayerRace() {
|
||||
if (!UConfig.instance().ignoresMineLittlePony()
|
||||
if (!Config.instance().ignoresMineLittlePony()
|
||||
&& MinecraftClient.getInstance().player != null) {
|
||||
Race race = MineLP.getPlayerPonyRace();
|
||||
|
||||
|
@ -44,7 +52,7 @@ public class UnicopiaClient extends UClient {
|
|||
}
|
||||
|
||||
|
||||
return UConfig.instance().getPrefferedRace();
|
||||
return Config.instance().getPrefferedRace();
|
||||
}
|
||||
|
||||
@Override
|
|
@ -1,6 +1,6 @@
|
|||
package com.minelittlepony.unicopia.ability.powers.render;
|
||||
package com.minelittlepony.unicopia.client.ability.render;
|
||||
|
||||
import com.minelittlepony.unicopia.entity.player.IPlayer;
|
||||
import com.minelittlepony.unicopia.entity.capabilities.IPlayer;
|
||||
import com.minelittlepony.unicopia.magic.spells.SpellDisguise;
|
||||
|
||||
import net.minecraft.client.MinecraftClient;
|
||||
|
@ -49,7 +49,7 @@ public class DisguiseRenderer {
|
|||
public boolean renderDisguiseToGui(IPlayer player) {
|
||||
SpellDisguise effect = player.getEffect(SpellDisguise.class, false);
|
||||
|
||||
if (effect == null || effect.getDead()) {
|
||||
if (effect == null || effect.isDead()) {
|
||||
return false;
|
||||
}
|
||||
|
|
@ -1,6 +1,6 @@
|
|||
package com.minelittlepony.unicopia.client.gui;
|
||||
|
||||
import com.minelittlepony.unicopia.entity.player.IPlayer;
|
||||
import com.minelittlepony.unicopia.entity.capabilities.IPlayer;
|
||||
import com.mojang.blaze3d.platform.GlStateManager;
|
||||
|
||||
import net.minecraft.client.gui.DrawableHelper;
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
package com.minelittlepony.unicopia.client.gui;
|
||||
|
||||
import com.minelittlepony.unicopia.entity.player.IPlayer;
|
||||
import com.minelittlepony.unicopia.entity.capabilities.IPlayer;
|
||||
|
||||
public interface IHudElement {
|
||||
|
||||
|
|
|
@ -5,7 +5,7 @@ import java.util.List;
|
|||
|
||||
import org.lwjgl.opengl.GL11;
|
||||
|
||||
import com.minelittlepony.unicopia.entity.player.IPlayer;
|
||||
import com.minelittlepony.unicopia.entity.capabilities.IPlayer;
|
||||
import com.mojang.blaze3d.platform.GlStateManager;
|
||||
|
||||
import net.minecraft.client.MinecraftClient;
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
package com.minelittlepony.unicopia.client.input;
|
||||
|
||||
import com.minelittlepony.unicopia.UClient;
|
||||
import com.minelittlepony.unicopia.entity.player.IPlayer;
|
||||
import com.minelittlepony.unicopia.entity.capabilities.IPlayer;
|
||||
|
||||
import net.minecraft.client.MinecraftClient;
|
||||
import net.minecraft.client.input.Input;
|
||||
|
|
|
@ -5,8 +5,8 @@ import java.util.List;
|
|||
|
||||
import com.minelittlepony.unicopia.SpeciesList;
|
||||
import com.minelittlepony.unicopia.Unicopia;
|
||||
import com.minelittlepony.unicopia.ability.powers.PowersRegistry;
|
||||
import com.minelittlepony.unicopia.entity.player.IPlayer;
|
||||
import com.minelittlepony.unicopia.ability.PowersRegistry;
|
||||
import com.minelittlepony.unicopia.entity.capabilities.IPlayer;
|
||||
|
||||
import net.fabricmc.fabric.api.client.keybinding.FabricKeyBinding;
|
||||
import net.fabricmc.fabric.api.client.keybinding.KeyBindingRegistry;
|
||||
|
|
|
@ -7,6 +7,7 @@ import net.minecraft.client.render.BufferBuilder;
|
|||
import net.minecraft.client.render.Camera;
|
||||
import net.minecraft.entity.Entity;
|
||||
import net.minecraft.particle.ParticleEffect;
|
||||
import net.minecraft.server.world.ServerWorld;
|
||||
import net.minecraft.world.World;
|
||||
|
||||
import org.lwjgl.opengl.GL11;
|
||||
|
@ -74,12 +75,12 @@ public class ParticleSphere extends Particle implements IAttachableParticle {
|
|||
super.tick();
|
||||
|
||||
if (caster != null) {
|
||||
if (!caster.hasEffect() || caster.getEffect().getDead() || caster.getEntity().removed) {
|
||||
if (!caster.hasEffect() || caster.getEffect().isDead() || caster.getEntity().removed) {
|
||||
markDead();
|
||||
} else {
|
||||
Entity e = caster.getEntity();
|
||||
|
||||
if (!caster.getWorld().loadedEntityList.contains(caster.getEntity())) {
|
||||
if (caster.getWorld().getEntityById(e.getEntityId()) == null) {
|
||||
markDead();
|
||||
}
|
||||
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
package com.minelittlepony.unicopia.client.render.entity;
|
||||
|
||||
import com.minelittlepony.unicopia.client.render.entity.model.ButterflyEntityModel;
|
||||
import com.minelittlepony.unicopia.entity.EntityButterfly;
|
||||
import com.minelittlepony.unicopia.entity.ButterflyEntity;
|
||||
import com.mojang.blaze3d.platform.GlStateManager;
|
||||
|
||||
import net.minecraft.client.render.entity.EntityRenderDispatcher;
|
||||
|
@ -9,24 +9,24 @@ import net.minecraft.client.render.entity.LivingEntityRenderer;
|
|||
import net.minecraft.util.Identifier;
|
||||
import net.minecraft.util.math.MathHelper;
|
||||
|
||||
public class ButterflyEntityRenderer extends LivingEntityRenderer<EntityButterfly, ButterflyEntityModel> {
|
||||
public class ButterflyEntityRenderer extends LivingEntityRenderer<ButterflyEntity, ButterflyEntityModel> {
|
||||
|
||||
public ButterflyEntityRenderer(EntityRenderDispatcher rm) {
|
||||
super(rm, new ButterflyEntityModel(), 0.25F);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected Identifier getTexture(EntityButterfly entity) {
|
||||
protected Identifier getTexture(ButterflyEntity entity) {
|
||||
return entity.getVariety().getSkin();
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void scale(EntityButterfly entity, float ticks) {
|
||||
protected void scale(ButterflyEntity entity, float ticks) {
|
||||
GlStateManager.scalef(0.35F, 0.35F, 0.35F);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void setupTransforms(EntityButterfly entity, float age, float yaw, float ticks) {
|
||||
protected void setupTransforms(ButterflyEntity entity, float age, float yaw, float ticks) {
|
||||
|
||||
if (!entity.isResting()) {
|
||||
GlStateManager.translated(0, MathHelper.cos(age / 3F) / 10F, 0);
|
||||
|
|
|
@ -1,26 +1,26 @@
|
|||
package com.minelittlepony.unicopia.client.render.entity;
|
||||
|
||||
import net.minecraft.client.renderer.GlStateManager;
|
||||
import net.minecraft.client.renderer.entity.RenderLiving;
|
||||
import net.minecraft.client.renderer.entity.RenderManager;
|
||||
import net.fabricmc.fabric.api.client.render.EntityRendererRegistry;
|
||||
import net.minecraft.client.render.entity.EntityRenderDispatcher;
|
||||
import net.minecraft.client.render.entity.LivingEntityRenderer;
|
||||
import net.minecraft.util.Identifier;
|
||||
|
||||
import org.lwjgl.opengl.GL11;
|
||||
|
||||
import com.minelittlepony.unicopia.client.render.entity.model.ModelCloud;
|
||||
import com.minelittlepony.unicopia.entity.EntityCloud;
|
||||
import com.minelittlepony.unicopia.entity.CloudEntity;
|
||||
import com.minelittlepony.util.WorldHelper;
|
||||
|
||||
public class RenderCloud extends RenderLiving<EntityCloud> {
|
||||
public class RenderCloud extends LivingEntityRenderer<CloudEntity, ModelCloud> {
|
||||
private static final Identifier cloud = new Identifier("unicopia", "textures/entity/clouds.png");
|
||||
private static final Identifier rainCloud = new Identifier("unicopia", "textures/entity/clouds_storm.png");
|
||||
|
||||
public RenderCloud(RenderManager rendermanagerIn) {
|
||||
super(rendermanagerIn, new ModelCloud(), 1f);
|
||||
public RenderCloud(EntityRenderDispatcher manager, EntityRendererRegistry.Context context) {
|
||||
super(manager, new ModelCloud(), 1f);
|
||||
}
|
||||
|
||||
@Override
|
||||
public float prepareScale(EntityCloud entity, float par2) {
|
||||
public float prepareScale(CloudEntity entity, float par2) {
|
||||
float scale = entity.getCloudSize();
|
||||
|
||||
GL11.glScalef(scale, scale, scale);
|
||||
|
@ -28,7 +28,7 @@ public class RenderCloud extends RenderLiving<EntityCloud> {
|
|||
}
|
||||
|
||||
@Override
|
||||
protected void renderModel(EntityCloud entity, float limbSwing, float limbSwingAmount, float ageInTicks, float netHeadYaw, float headPitch, float scaleFactor) {
|
||||
protected void renderModel(CloudEntity entity, float limbSwing, float limbSwingAmount, float ageInTicks, float netHeadYaw, float headPitch, float scaleFactor) {
|
||||
|
||||
if (!entity.isDead) {
|
||||
GlStateManager.pushMatrix();
|
||||
|
@ -54,7 +54,7 @@ public class RenderCloud extends RenderLiving<EntityCloud> {
|
|||
}
|
||||
|
||||
@Override
|
||||
protected Identifier getEntityTexture(EntityCloud entity) {
|
||||
protected Identifier getEntityTexture(CloudEntity entity) {
|
||||
if (entity.getIsRaining() && entity.getIsThundering()) {
|
||||
return rainCloud;
|
||||
}
|
||||
|
@ -62,12 +62,12 @@ public class RenderCloud extends RenderLiving<EntityCloud> {
|
|||
}
|
||||
|
||||
@Override
|
||||
protected int getColorMultiplier(EntityCloud par1LivingEntity, float yaw, float pitch) {
|
||||
protected int getColorMultiplier(CloudEntity par1LivingEntity, float yaw, float pitch) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected float getDeathMaxRotation(EntityCloud par1LivingEntity) {
|
||||
protected float getDeathMaxRotation(CloudEntity par1LivingEntity) {
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -36,7 +36,7 @@ public class RenderCuccoon extends RenderLivingBase<EntityCuccoon> {
|
|||
if (entity.isBeingRidden()) {
|
||||
Entity rider = entity.getPassengers().get(0);
|
||||
|
||||
if (!(rider == MinecraftClient.getInstance().player) || UClient.instance().getViewMode() != 0) {
|
||||
if (!(rider == MinecraftClient.instance().player) || UClient.instance().getViewMode() != 0) {
|
||||
GlStateManager.enableAlpha();
|
||||
GlStateManager.enableBlend();
|
||||
|
||||
|
|
|
@ -1,21 +0,0 @@
|
|||
package com.minelittlepony.unicopia.client.render.entity;
|
||||
|
||||
import com.minelittlepony.unicopia.entity.item.AdvancedProjectileEntity;
|
||||
|
||||
import net.minecraft.client.Minecraft;
|
||||
import net.minecraft.client.renderer.entity.RenderManager;
|
||||
import net.minecraft.client.renderer.entity.RenderSnowball;
|
||||
import net.minecraft.init.Items;
|
||||
import net.minecraft.item.ItemStack;
|
||||
|
||||
public class RenderProjectile extends RenderSnowball<AdvancedProjectileEntity> {
|
||||
|
||||
public RenderProjectile(RenderManager renderManager) {
|
||||
super(renderManager, Items.POTIONITEM, MinecraftClient.getInstance().getRenderItem());
|
||||
}
|
||||
|
||||
@Override
|
||||
public ItemStack getStackToRender(AdvancedProjectileEntity entity) {
|
||||
return entity.getItem();
|
||||
}
|
||||
}
|
|
@ -2,7 +2,7 @@ package com.minelittlepony.unicopia.client.render.entity;
|
|||
|
||||
import org.lwjgl.opengl.GL11;
|
||||
|
||||
import com.minelittlepony.unicopia.entity.EntityRainbow;
|
||||
import com.minelittlepony.unicopia.entity.RainbowEntity;
|
||||
import com.minelittlepony.util.WorldHelper;
|
||||
|
||||
import net.minecraft.client.Minecraft;
|
||||
|
@ -14,7 +14,7 @@ import net.minecraft.client.renderer.entity.RenderManager;
|
|||
import net.minecraft.client.renderer.vertex.DefaultVertexFormats;
|
||||
import net.minecraft.util.Identifier;
|
||||
|
||||
public class RenderRainbow extends Render<EntityRainbow> {
|
||||
public class RenderRainbow extends Render<RainbowEntity> {
|
||||
|
||||
public RenderRainbow(RenderManager renderManager) {
|
||||
super(renderManager);
|
||||
|
@ -22,9 +22,9 @@ public class RenderRainbow extends Render<EntityRainbow> {
|
|||
|
||||
private static final Identifier TEXTURE = new Identifier("unicopia", "textures/environment/rainbow.png");
|
||||
|
||||
public void doRender(EntityRainbow entity, double x, double y, double z, float entityYaw, float partialTicks) {
|
||||
float distance = MinecraftClient.getInstance().getRenderViewEntity().getDistance(entity);
|
||||
float maxDistance = 16 * MinecraftClient.getInstance().gameSettings.renderDistanceChunks;
|
||||
public void doRender(RainbowEntity entity, double x, double y, double z, float entityYaw, float partialTicks) {
|
||||
float distance = MinecraftClient.instance().getRenderViewEntity().getDistance(entity);
|
||||
float maxDistance = 16 * MinecraftClient.instance().gameSettings.renderDistanceChunks;
|
||||
double r = entity.getRadius();
|
||||
float light = WorldHelper.getDaylightBrightness(entity.getEntityWorld(), partialTicks);
|
||||
|
||||
|
@ -49,7 +49,7 @@ public class RenderRainbow extends Render<EntityRainbow> {
|
|||
|
||||
GlStateManager.color(1, 1, 1, opacity);
|
||||
|
||||
Tessellator tessellator = Tessellator.getInstance();
|
||||
Tessellator tessellator = Tessellator.instance();
|
||||
BufferBuilder bufferbuilder = tessellator.getBuffer();
|
||||
|
||||
bufferbuilder.begin(GL11.GL_QUADS, DefaultVertexFormats.POSITION_TEX);
|
||||
|
@ -67,7 +67,7 @@ public class RenderRainbow extends Render<EntityRainbow> {
|
|||
}
|
||||
|
||||
@Override
|
||||
protected Identifier getEntityTexture(EntityRainbow entity) {
|
||||
protected Identifier getEntityTexture(RainbowEntity entity) {
|
||||
return TEXTURE;
|
||||
}
|
||||
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
package com.minelittlepony.unicopia.client.render.entity;
|
||||
|
||||
import com.minelittlepony.unicopia.client.render.entity.model.ModelSpellbook;
|
||||
import com.minelittlepony.unicopia.entity.EntitySpellbook;
|
||||
import com.minelittlepony.unicopia.entity.SpellbookEntity;
|
||||
|
||||
import net.minecraft.client.renderer.GlStateManager;
|
||||
import net.minecraft.client.renderer.entity.RenderLiving;
|
||||
|
@ -9,7 +9,7 @@ import net.minecraft.client.renderer.entity.RenderManager;
|
|||
import net.minecraft.util.math.MathHelper;
|
||||
import net.minecraft.util.Identifier;
|
||||
|
||||
public class RenderSpellbook extends RenderLiving<EntitySpellbook> {
|
||||
public class RenderSpellbook extends RenderLiving<SpellbookEntity> {
|
||||
|
||||
private static final Identifier BLUE = new Identifier("unicopia", "textures/entity/enchanting_table_book_blue.png");
|
||||
private static final Identifier NORMAL = new Identifier("unicopia", "textures/entity/enchanting_table_book.png");
|
||||
|
@ -19,17 +19,17 @@ public class RenderSpellbook extends RenderLiving<EntitySpellbook> {
|
|||
}
|
||||
|
||||
@Override
|
||||
protected Identifier getEntityTexture(EntitySpellbook entity) {
|
||||
protected Identifier getEntityTexture(SpellbookEntity entity) {
|
||||
return entity.getIsAltered() ? BLUE : NORMAL;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected float getDeathMaxRotation(EntitySpellbook entity) {
|
||||
protected float getDeathMaxRotation(SpellbookEntity entity) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void renderModel(EntitySpellbook entity, float time, float walkSpeed, float stutter, float yaw, float pitch, float increment) {
|
||||
protected void renderModel(SpellbookEntity entity, float time, float walkSpeed, float stutter, float yaw, float pitch, float increment) {
|
||||
|
||||
float breath = MathHelper.sin(((float)entity.ticksExisted + stutter) / 20) * 0.01F + 0.1F;
|
||||
|
||||
|
@ -40,14 +40,14 @@ public class RenderSpellbook extends RenderLiving<EntitySpellbook> {
|
|||
if (first_page_rot > 1) first_page_rot = 1;
|
||||
if (second_page_rot > 1) second_page_rot = 1;
|
||||
|
||||
if (!((EntitySpellbook)entity).getIsOpen()) {
|
||||
if (!((SpellbookEntity)entity).getIsOpen()) {
|
||||
GlStateManager.translate(0, 1.44f, 0);
|
||||
} else {
|
||||
GlStateManager.translate(0, 1.2f + breath, 0);
|
||||
}
|
||||
GlStateManager.pushMatrix();
|
||||
|
||||
if (!((EntitySpellbook)entity).getIsOpen()) {
|
||||
if (!((SpellbookEntity)entity).getIsOpen()) {
|
||||
first_page_rot = second_page_rot = open_angle = 0;
|
||||
GlStateManager.rotate(90.0F, 1.0F, 0.0F, 0.0F);
|
||||
GlStateManager.rotate(90.0F, 0.0F, 0.0F, 1.0F);
|
||||
|
@ -63,12 +63,12 @@ public class RenderSpellbook extends RenderLiving<EntitySpellbook> {
|
|||
}
|
||||
|
||||
@Override
|
||||
protected void applyRotations(EntitySpellbook entity, float p_77043_2_, float p_77043_3_, float partialTicks) {
|
||||
protected void applyRotations(SpellbookEntity entity, float p_77043_2_, float p_77043_3_, float partialTicks) {
|
||||
GlStateManager.rotate(-interpolateRotation(entity.prevRotationYaw, entity.rotationYaw, partialTicks), 0, 1, 0);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected boolean canRenderName(EntitySpellbook targetEntity) {
|
||||
protected boolean canRenderName(SpellbookEntity targetEntity) {
|
||||
return super.canRenderName(targetEntity) && (targetEntity.getAlwaysRenderNameTagForRender() || targetEntity.hasCustomName() && targetEntity == renderManager.pointedEntity);
|
||||
}
|
||||
}
|
|
@ -3,16 +3,19 @@ package com.minelittlepony.unicopia.client.render.entity;
|
|||
import com.minelittlepony.unicopia.client.render.entity.model.ModelGem;
|
||||
import com.minelittlepony.unicopia.entity.SpellcastEntity;
|
||||
|
||||
import net.fabricmc.fabric.api.client.render.EntityRendererRegistry;
|
||||
import net.minecraft.client.render.Frustum;
|
||||
import net.minecraft.client.render.VisibleRegion;
|
||||
import net.minecraft.client.render.entity.EntityRenderDispatcher;
|
||||
import net.minecraft.client.render.entity.LivingEntityRenderer;
|
||||
import net.minecraft.util.Identifier;
|
||||
|
||||
public class RenderGem extends LivingEntityRenderer<SpellcastEntity, ModelGem> {
|
||||
public class SpellcastEntityRenderer extends LivingEntityRenderer<SpellcastEntity, ModelGem> {
|
||||
|
||||
private static final Identifier gem = new Identifier("unicopia", "textures/entity/gem.png");
|
||||
|
||||
public RenderGem(EntityRenderDispatcher rendermanagerIn) {
|
||||
super(rendermanagerIn, new ModelGem(), 0);
|
||||
public SpellcastEntityRenderer(EntityRenderDispatcher manager, EntityRendererRegistry.Context context) {
|
||||
super(manager, new ModelGem(), 0);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -21,7 +24,7 @@ public class RenderGem extends LivingEntityRenderer<SpellcastEntity, ModelGem> {
|
|||
}
|
||||
|
||||
@Override
|
||||
public boolean shouldRender(SpellcastEntity livingEntity, ICamera camera, double camX, double camY, double camZ) {
|
||||
public boolean isVisible(SpellcastEntity livingEntity, VisibleRegion camera, double camX, double camY, double camZ) {
|
||||
return true;
|
||||
}
|
||||
|
||||
|
@ -33,6 +36,6 @@ public class RenderGem extends LivingEntityRenderer<SpellcastEntity, ModelGem> {
|
|||
@Override
|
||||
protected boolean canRenderName(SpellcastEntity targetEntity) {
|
||||
return super.canRenderName(targetEntity) && (targetEntity.getAlwaysRenderNameTagForRender()
|
||||
|| targetEntity.hasCustomName() && targetEntity == renderManager.pointedEntity);
|
||||
|| targetEntity.hasCustomName() && targetEntity == renderManager.targetedEntity);
|
||||
}
|
||||
}
|
|
@ -1,13 +1,13 @@
|
|||
package com.minelittlepony.unicopia.client.render.entity.model;
|
||||
|
||||
import com.minelittlepony.unicopia.entity.EntityButterfly;
|
||||
import com.minelittlepony.unicopia.entity.ButterflyEntity;
|
||||
import com.mojang.blaze3d.platform.GlStateManager;
|
||||
|
||||
import net.minecraft.client.model.Cuboid;
|
||||
import net.minecraft.client.render.entity.model.EntityModel;
|
||||
import net.minecraft.util.math.MathHelper;
|
||||
|
||||
public class ButterflyEntityModel extends EntityModel<EntityButterfly> {
|
||||
public class ButterflyEntityModel extends EntityModel<ButterflyEntity> {
|
||||
|
||||
private Cuboid body;
|
||||
|
||||
|
@ -55,7 +55,7 @@ public class ButterflyEntityModel extends EntityModel<EntityButterfly> {
|
|||
}
|
||||
|
||||
@Override
|
||||
public void render(EntityButterfly entityIn, float limbSwing, float limbSwingAmount, float ageInTicks, float netHeadYaw, float headPitch, float scale) {
|
||||
public void render(ButterflyEntity entityIn, float limbSwing, float limbSwingAmount, float ageInTicks, float netHeadYaw, float headPitch, float scale) {
|
||||
|
||||
setAngles(entityIn, limbSwing, limbSwingAmount, ageInTicks, netHeadYaw, headPitch, scale);
|
||||
|
||||
|
@ -67,7 +67,7 @@ public class ButterflyEntityModel extends EntityModel<EntityButterfly> {
|
|||
}
|
||||
|
||||
@Override
|
||||
public void setAngles(EntityButterfly entity, float limbSwing, float limbSwingAmount, float ageInTicks, float netHeadYaw, float headPitch, float scaleFactor) {
|
||||
public void setAngles(ButterflyEntity entity, float limbSwing, float limbSwingAmount, float ageInTicks, float netHeadYaw, float headPitch, float scaleFactor) {
|
||||
|
||||
float flap = MathHelper.cos(ageInTicks) * (float)Math.PI / 4;
|
||||
|
||||
|
|
|
@ -3,7 +3,7 @@ package com.minelittlepony.unicopia.command;
|
|||
import java.util.List;
|
||||
|
||||
import com.minelittlepony.unicopia.SpeciesList;
|
||||
import com.minelittlepony.unicopia.entity.player.IPlayer;
|
||||
import com.minelittlepony.unicopia.entity.capabilities.IPlayer;
|
||||
import com.minelittlepony.unicopia.magic.spells.SpellDisguise;
|
||||
|
||||
import net.minecraft.command.CommandException;
|
||||
|
@ -64,13 +64,13 @@ class CommandDisguise extends Command {
|
|||
}
|
||||
|
||||
protected Entity constructDisguiseEntity(World world, String[] args) throws CommandException {
|
||||
NBTTagCompound nbt = getEntityNBT(args);
|
||||
CompoundTag nbt = getEntityNBT(args);
|
||||
nbt.setString("id", args[1]);
|
||||
|
||||
return AnvilChunkLoader.readWorldEntityPos(nbt, world, 0, 0, 0, false);
|
||||
}
|
||||
|
||||
protected NBTTagCompound getEntityNBT(String[] args) throws CommandException {
|
||||
protected CompoundTag getEntityNBT(String[] args) throws CommandException {
|
||||
if (args.length > 2) {
|
||||
try {
|
||||
return JsonToNBT.getTagFromJson(buildString(args, 2));
|
||||
|
@ -79,7 +79,7 @@ class CommandDisguise extends Command {
|
|||
}
|
||||
}
|
||||
|
||||
return new NBTTagCompound();
|
||||
return new CompoundTag();
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
|
@ -3,7 +3,7 @@ package com.minelittlepony.unicopia.command;
|
|||
import java.util.List;
|
||||
|
||||
import com.minelittlepony.unicopia.SpeciesList;
|
||||
import com.minelittlepony.unicopia.entity.player.IPlayer;
|
||||
import com.minelittlepony.unicopia.entity.capabilities.IPlayer;
|
||||
|
||||
import net.minecraft.command.CommandBase;
|
||||
import net.minecraft.command.CommandException;
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
package com.minelittlepony.unicopia.command;
|
||||
|
||||
import com.minelittlepony.unicopia.SpeciesList;
|
||||
import com.minelittlepony.unicopia.entity.player.IPlayer;
|
||||
import com.minelittlepony.unicopia.entity.capabilities.IPlayer;
|
||||
|
||||
import net.minecraft.command.CommandException;
|
||||
import net.minecraft.command.CommandGameMode;
|
||||
|
|
|
@ -1,10 +1,7 @@
|
|||
package com.minelittlepony.unicopia.command;
|
||||
|
||||
import net.minecraftforge.fml.common.event.FMLServerStartingEvent;
|
||||
|
||||
public class Commands {
|
||||
|
||||
public static void init(FMLServerStartingEvent event) {
|
||||
public static void bootstrap() {
|
||||
event.registerServerCommand(new CommandOverrideGameMode());
|
||||
event.registerServerCommand(new CommandSpecies());
|
||||
event.registerServerCommand(new CommandRacelist());
|
||||
|
|
|
@ -1,128 +0,0 @@
|
|||
package com.minelittlepony.unicopia.edibles;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import javax.annotation.Nullable;
|
||||
|
||||
import com.minelittlepony.unicopia.Race;
|
||||
import com.minelittlepony.unicopia.SpeciesList;
|
||||
import com.minelittlepony.unicopia.UEffects;
|
||||
|
||||
import net.minecraft.advancements.CriteriaTriggers;
|
||||
import net.minecraft.client.util.ITooltipFlag;
|
||||
import net.minecraft.entity.LivingEntity;
|
||||
import net.minecraft.entity.player.PlayerEntity;
|
||||
import net.minecraft.entity.player.ServerPlayerEntity;
|
||||
import net.minecraft.init.MobEffects;
|
||||
import net.minecraft.init.SoundEvents;
|
||||
import net.minecraft.item.EnumAction;
|
||||
import net.minecraft.item.Item;
|
||||
import net.minecraft.item.ItemFood;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.potion.PotionEffect;
|
||||
import net.minecraft.stats.StatList;
|
||||
import net.minecraft.util.ActionResult;
|
||||
import net.minecraft.util.EnumActionResult;
|
||||
import net.minecraft.util.EnumHand;
|
||||
import net.minecraft.util.SoundCategory;
|
||||
import net.minecraft.world.World;
|
||||
|
||||
public abstract class ItemEdible extends ItemFood implements IEdible {
|
||||
|
||||
private EnumAction useAction = EnumAction.EAT;
|
||||
|
||||
public ItemEdible(int amount, int saturation, boolean isMeat) {
|
||||
super(amount, saturation, isMeat);
|
||||
}
|
||||
|
||||
public ItemEdible(String domain, String name, int amount, int saturation, boolean isMeat) {
|
||||
super(amount, saturation, isMeat);
|
||||
|
||||
setTranslationKey(name);
|
||||
setRegistryName(domain, name);
|
||||
}
|
||||
|
||||
public Item setUseAction(EnumAction action) {
|
||||
useAction = action;
|
||||
|
||||
return this;
|
||||
}
|
||||
|
||||
public EnumAction getItemUseAction(ItemStack stack) {
|
||||
return useAction;
|
||||
}
|
||||
|
||||
protected void onFoodEaten(ItemStack stack, World worldIn, PlayerEntity player) {
|
||||
Race race = SpeciesList.instance().getPlayer(player).getSpecies();
|
||||
Toxicity toxicity = (race.isDefault() || race == Race.CHANGELING) ? Toxicity.LETHAL : getToxicityLevel(stack);
|
||||
|
||||
addSecondaryEffects(player, toxicity, stack);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void addInformation(ItemStack stack, @Nullable World worldIn, List<String> tooltip, ITooltipFlag flagIn) {
|
||||
tooltip.add(getToxicityLevel(stack).getTooltip());
|
||||
}
|
||||
|
||||
@Override
|
||||
public ItemStack onItemUseFinish(ItemStack stack, World worldIn, LivingEntity entityLiving) {
|
||||
|
||||
PlayerEntity entityplayer = entityLiving instanceof PlayerEntity ? (PlayerEntity)entityLiving : null;
|
||||
|
||||
if (entityplayer != null) {
|
||||
entityplayer.getFoodStats().addStats(this, stack);
|
||||
|
||||
worldIn.playSound(null, entityplayer.posX, entityplayer.posY, entityplayer.posZ, SoundEvents.ENTITY_PLAYER_BURP, SoundCategory.PLAYERS, 0.5F, worldIn.rand.nextFloat() * 0.1F + 0.9F);
|
||||
|
||||
onFoodEaten(stack, worldIn, entityplayer);
|
||||
|
||||
// replaced "this" with "stack.getItem()"
|
||||
entityplayer.addStat(StatList.getObjectUseStats(stack.getItem()));
|
||||
|
||||
if (entityplayer instanceof ServerPlayerEntity) {
|
||||
CriteriaTriggers.CONSUME_ITEM.trigger((ServerPlayerEntity)entityplayer, stack);
|
||||
}
|
||||
}
|
||||
|
||||
if (entityplayer == null || !entityplayer.capabilities.isCreativeMode) {
|
||||
stack.shrink(1);
|
||||
}
|
||||
|
||||
ItemStack container = getContainerItem(stack);
|
||||
|
||||
if (!container.isEmpty() && entityplayer != null && !entityplayer.capabilities.isCreativeMode) {
|
||||
if (stack.isEmpty()) {
|
||||
return getContainerItem(stack);
|
||||
}
|
||||
|
||||
entityplayer.inventory.addItemStackToInventory(getContainerItem(stack));
|
||||
}
|
||||
|
||||
return stack;
|
||||
}
|
||||
|
||||
@Override
|
||||
public TypedActionResult<ItemStack> onItemRightClick(World world, PlayerEntity player, EnumHand hand) {
|
||||
Race race = SpeciesList.instance().getPlayer(player).getSpecies();
|
||||
|
||||
if (race.isDefault() || race == Race.CHANGELING) {
|
||||
return new TypedActionResult<ItemStack>(EnumActionResult.FAIL, player.getStackInHand(hand));
|
||||
}
|
||||
|
||||
return super.onItemRightClick(world, player, hand);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void addSecondaryEffects(PlayerEntity player, Toxicity toxicity, ItemStack stack) {
|
||||
|
||||
if (toxicity.toxicWhenRaw()) {
|
||||
player.addPotionEffect(toxicity.getPoisonEffect());
|
||||
}
|
||||
|
||||
if (toxicity.isLethal()) {
|
||||
player.addPotionEffect(new PotionEffect(UEffects.FOOD_POISONING, 300, 7, false, false));
|
||||
} else if (toxicity.toxicWhenCooked()) {
|
||||
player.addPotionEffect(new PotionEffect(MobEffects.NAUSEA, 3, 1, false, false));
|
||||
}
|
||||
}
|
||||
}
|
|
@ -1,54 +0,0 @@
|
|||
package com.minelittlepony.unicopia.edibles;
|
||||
|
||||
import javax.annotation.Nonnull;
|
||||
import com.minelittlepony.unicopia.forgebullshit.IMultiItem;
|
||||
import net.minecraft.entity.player.PlayerEntity;
|
||||
import net.minecraft.item.Item;
|
||||
import net.minecraft.item.ItemStack;
|
||||
|
||||
public class MultiItemEdible extends ItemEdible implements IMultiItem {
|
||||
|
||||
private String translationKey;
|
||||
|
||||
private final IEdible toxicityDeterminant;
|
||||
|
||||
public MultiItemEdible(@Nonnull IEdible mapper) {
|
||||
super(1, 0, false);
|
||||
|
||||
toxicityDeterminant = mapper;
|
||||
}
|
||||
|
||||
public MultiItemEdible(String domain, String name, int amount, int saturation, @Nonnull IEdible mapper) {
|
||||
super(domain, name, amount, saturation, false);
|
||||
|
||||
toxicityDeterminant = mapper;
|
||||
}
|
||||
|
||||
public Item setTranslationKey(String key) {
|
||||
translationKey = key;
|
||||
|
||||
return super.setTranslationKey(key);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void addSecondaryEffects(PlayerEntity player, Toxicity toxicity, ItemStack stack) {
|
||||
super.addSecondaryEffects(player, toxicity, stack);
|
||||
|
||||
toxicityDeterminant.addSecondaryEffects(player, toxicity, stack);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Toxicity getToxicityLevel(ItemStack stack) {
|
||||
return toxicityDeterminant.getToxicityLevel(stack);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String[] getVariants() {
|
||||
return Toxicity.getVariants(translationKey);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean variantsAreHidden() {
|
||||
return true;
|
||||
}
|
||||
}
|
|
@ -1,134 +0,0 @@
|
|||
package com.minelittlepony.unicopia.enchanting;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
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.inventory.gui.SpellBookInventory;
|
||||
|
||||
import net.minecraft.inventory.InventoryCrafting;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.item.crafting.IRecipe;
|
||||
import net.minecraft.util.NonNullList;
|
||||
import net.minecraft.world.World;
|
||||
import net.minecraftforge.registries.IForgeRegistryEntry.Impl;
|
||||
|
||||
public abstract class AbstractSpecialRecipe extends Impl<IRecipe> implements IRecipe {
|
||||
|
||||
private final SpellIngredient spellitem;
|
||||
|
||||
private final NonNullList<SpellIngredient> ingredients;
|
||||
|
||||
static NonNullList<SpellIngredient> parseIngrediants(JsonObject json) {
|
||||
NonNullList<SpellIngredient> ingredients = NonNullList.create();
|
||||
|
||||
for (JsonElement i : json.get("ingredients").getAsJsonArray()) {
|
||||
SpellIngredient ingredient = SpellIngredient.parse(i);
|
||||
|
||||
if (ingredient != null) {
|
||||
ingredients.add(ingredient);
|
||||
}
|
||||
}
|
||||
|
||||
if (ingredients.isEmpty()) {
|
||||
throw new JsonParseException("Recipe cannot have 0 ingredients");
|
||||
}
|
||||
|
||||
return ingredients;
|
||||
}
|
||||
|
||||
static SpellIngredient parseSingleIngredient(JsonObject json) {
|
||||
SpellIngredient result = SpellIngredient.parse(json.get("item"));
|
||||
|
||||
if (result == null) {
|
||||
throw new JsonParseException("Recipe cannot have no enchantable input");
|
||||
}
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
public AbstractSpecialRecipe(SpellIngredient spellitem, NonNullList<SpellIngredient> ingredients) {
|
||||
this.spellitem = spellitem;
|
||||
this.ingredients = ingredients;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean matches(InventoryCrafting inv, World worldIn) {
|
||||
ItemStack enchantedStack = ((SpellBookInventory)inv).getCraftResultMatrix().getStackInSlot(0);
|
||||
|
||||
if (enchantedStack.isEmpty() || enchantedStack.getItem() == null) {
|
||||
return false;
|
||||
}
|
||||
|
||||
if (!spellitem.matches(enchantedStack, enchantedStack.getCount())) {
|
||||
return false;
|
||||
}
|
||||
|
||||
int materialMult = enchantedStack.getCount();
|
||||
|
||||
ArrayList<SpellIngredient> toMatch = Lists.newArrayList(ingredients);
|
||||
|
||||
for (int i = 0; i < inv.getSizeInventory(); i++) {
|
||||
ItemStack stack = inv.getStackInSlot(i);
|
||||
|
||||
if (!stack.isEmpty()) {
|
||||
if (toMatch.isEmpty() || !removeMatch(toMatch, stack, materialMult)) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return toMatch.isEmpty();
|
||||
}
|
||||
|
||||
private boolean removeMatch(List<SpellIngredient> toMatch, ItemStack stack, int materialMult) {
|
||||
return toMatch.stream()
|
||||
.filter(s -> s.matches(stack, materialMult))
|
||||
.findFirst()
|
||||
.filter(toMatch::remove)
|
||||
.isPresent();
|
||||
}
|
||||
|
||||
@Override
|
||||
public ItemStack getCraftingResult(InventoryCrafting inv) {
|
||||
return getRecipeOutput();
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean canFit(int width, int height) {
|
||||
return width * height < ingredients.size();
|
||||
}
|
||||
|
||||
public SpellIngredient getSpellItem() {
|
||||
return spellitem;
|
||||
}
|
||||
|
||||
public NonNullList<SpellIngredient> getSpellIngredients() {
|
||||
return ingredients;
|
||||
}
|
||||
|
||||
@Override
|
||||
public ItemStack getRecipeOutput() {
|
||||
return spellitem.getStack();
|
||||
}
|
||||
|
||||
@Override
|
||||
public NonNullList<ItemStack> getRemainingItems(InventoryCrafting inv) {
|
||||
NonNullList<ItemStack> remainers = NonNullList.<ItemStack>withSize(inv.getSizeInventory(), ItemStack.EMPTY);
|
||||
|
||||
for (int i = 0; i < remainers.size(); i++) {
|
||||
ItemStack stack = inv.getStackInSlot(i);
|
||||
|
||||
if (stack != null && stack.getItem().hasContainerItem(stack)) {
|
||||
remainers.set(i, new ItemStack(stack.getItem().getContainerItem()));
|
||||
}
|
||||
}
|
||||
|
||||
return remainers;
|
||||
}
|
||||
|
||||
|
||||
}
|
|
@ -1,30 +0,0 @@
|
|||
package com.minelittlepony.unicopia.enchanting;
|
||||
|
||||
import com.google.gson.JsonObject;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.item.crafting.IRecipe;
|
||||
import net.minecraft.util.NonNullList;
|
||||
|
||||
public class SpecialRecipe extends AbstractSpecialRecipe {
|
||||
|
||||
private final SpellIngredient output;
|
||||
|
||||
public static IRecipe deserialize(JsonObject json) {
|
||||
return new SpecialRecipe(
|
||||
parseSingleIngredient(json.get("input").getAsJsonObject()),
|
||||
parseSingleIngredient(json.get("output").getAsJsonObject()),
|
||||
parseIngrediants(json)
|
||||
);
|
||||
}
|
||||
|
||||
public SpecialRecipe(SpellIngredient input, SpellIngredient output, NonNullList<SpellIngredient> ingredients) {
|
||||
super(input, ingredients);
|
||||
|
||||
this.output = output;
|
||||
}
|
||||
|
||||
@Override
|
||||
public ItemStack getRecipeOutput() {
|
||||
return output.getStack();
|
||||
}
|
||||
}
|
|
@ -5,7 +5,7 @@ import javax.annotation.Nullable;
|
|||
|
||||
import com.google.gson.JsonObject;
|
||||
import com.google.gson.annotations.Expose;
|
||||
import com.minelittlepony.unicopia.item.ItemSpell;
|
||||
import com.minelittlepony.unicopia.item.MagicGemItem;
|
||||
import com.minelittlepony.unicopia.spell.SpellAffinity;
|
||||
import com.minelittlepony.unicopia.spell.SpellRegistry;
|
||||
|
||||
|
@ -50,8 +50,8 @@ public class SpellCraftingEvent {
|
|||
|
||||
@Override
|
||||
public boolean matches(IPageOwner prop, Event event) {
|
||||
if (!event.stack.isEmpty() && event.stack.getItem() instanceof ItemSpell) {
|
||||
return ((ItemSpell)event.stack.getItem()).getAffinity() == affinity
|
||||
if (!event.stack.isEmpty() && event.stack.getItem() instanceof MagicGemItem) {
|
||||
return ((MagicGemItem)event.stack.getItem()).getAffinity() == affinity
|
||||
&& SpellRegistry.getKeyFromStack(event.stack).equals(spell);
|
||||
}
|
||||
|
||||
|
|
|
@ -1,162 +0,0 @@
|
|||
package com.minelittlepony.unicopia.enchanting;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.Optional;
|
||||
import java.util.stream.Stream;
|
||||
|
||||
import javax.annotation.Nullable;
|
||||
|
||||
import com.google.common.collect.Lists;
|
||||
import com.google.common.collect.Streams;
|
||||
import com.google.gson.JsonArray;
|
||||
import com.google.gson.JsonElement;
|
||||
import com.google.gson.JsonObject;
|
||||
import com.minelittlepony.unicopia.enchanting.AffineIngredients.AffineIngredient;
|
||||
import com.minelittlepony.unicopia.spell.SpellRegistry;
|
||||
|
||||
import net.minecraft.creativetab.CreativeTabs;
|
||||
import net.minecraft.item.Item;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.util.NonNullList;
|
||||
|
||||
public interface SpellIngredient {
|
||||
|
||||
static SpellIngredient EMPTY = new Single(ItemStack.EMPTY, false);
|
||||
|
||||
@Nullable
|
||||
static SpellIngredient parse(JsonElement json) {
|
||||
if (json.isJsonArray()) {
|
||||
return Compound.parse(json.getAsJsonArray());
|
||||
}
|
||||
|
||||
return Single.parse(json.getAsJsonObject());
|
||||
}
|
||||
|
||||
boolean matches(ItemStack other, int materialMult);
|
||||
|
||||
ItemStack getStack();
|
||||
|
||||
Stream<ItemStack> getStacks();
|
||||
|
||||
class Compound implements SpellIngredient {
|
||||
private final List<SpellIngredient> items;
|
||||
|
||||
Compound(List<SpellIngredient> items) {
|
||||
this.items = items;
|
||||
}
|
||||
|
||||
public Stream<ItemStack> getStacks() {
|
||||
Stream<ItemStack> stacks = Lists.<ItemStack>newArrayList().stream();
|
||||
|
||||
for (SpellIngredient i : items) {
|
||||
stacks = Streams.concat(stacks, i.getStacks());
|
||||
}
|
||||
|
||||
return stacks.distinct();
|
||||
}
|
||||
|
||||
@Override
|
||||
public ItemStack getStack() {
|
||||
return items.get((int)(Math.random() * items.size())).getStack();
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean matches(ItemStack other, int materialMult) {
|
||||
return items.stream().anyMatch(item -> item.matches(other, materialMult));
|
||||
}
|
||||
|
||||
@Nullable
|
||||
static SpellIngredient parse(JsonArray json) {
|
||||
if (json.size() > 0) {
|
||||
List<SpellIngredient> items = Lists.newArrayList();
|
||||
|
||||
for (JsonElement j : json) {
|
||||
SpellIngredient item = SpellIngredient.parse(j);
|
||||
|
||||
if (item != null) {
|
||||
items.add(item);
|
||||
}
|
||||
}
|
||||
|
||||
if (!items.isEmpty()) {
|
||||
return new Compound(items);
|
||||
}
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
class Single implements SpellIngredient {
|
||||
|
||||
private final ItemStack contained;
|
||||
private final boolean ignoreMeta;
|
||||
|
||||
Single(ItemStack stack, boolean meta) {
|
||||
contained = stack;
|
||||
ignoreMeta = meta;
|
||||
}
|
||||
|
||||
public Stream<ItemStack> getStacks() {
|
||||
if (ignoreMeta && !contained.isEmpty()) {
|
||||
NonNullList<ItemStack> subItems = NonNullList.create();
|
||||
contained.getItem().getSubItems(CreativeTabs.SEARCH, subItems);
|
||||
|
||||
return subItems.stream();
|
||||
}
|
||||
|
||||
return Streams.stream(Optional.ofNullable(contained));
|
||||
}
|
||||
|
||||
@Override
|
||||
public ItemStack getStack() {
|
||||
return contained;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean matches(ItemStack other, int materialMult) {
|
||||
if (other.isEmpty() != contained.isEmpty()) {
|
||||
return false;
|
||||
} else if (other.isEmpty()) {
|
||||
return true;
|
||||
}
|
||||
|
||||
if (other.isEmpty()) {
|
||||
return false;
|
||||
}
|
||||
|
||||
if (contained.getItem() == other.getItem()
|
||||
&& (ignoreMeta || other.getMetadata() == contained.getMetadata())
|
||||
&& ItemStack.areItemStackTagsEqual(contained, other)) {
|
||||
return other.getCount() >= (materialMult * contained.getCount());
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
@Nullable
|
||||
public static SpellIngredient parse(JsonObject json) {
|
||||
Item item = json.has("item") ? Item.getByNameOrId(json.get("item").getAsString()) : null;
|
||||
|
||||
if (item != null) {
|
||||
int metadata = Math.max(0, json.has("data") ? json.get("data").getAsInt() : 0);
|
||||
int size = Math.max(1, json.has("count") ? json.get("count").getAsInt() : 1);
|
||||
String spell = json.has("spell") ? json.get("spell").getAsString() : null;
|
||||
|
||||
ItemStack stack = new ItemStack(item, size, metadata);
|
||||
|
||||
if (spell != null) {
|
||||
stack = SpellRegistry.getInstance().enchantStack(stack, spell);
|
||||
}
|
||||
|
||||
return new Single(stack, !(json.has("spell") || json.has("data")));
|
||||
}
|
||||
|
||||
if (json.has("id")) {
|
||||
return AffineIngredient.parse(json);
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
}
|
||||
}
|
|
@ -1,47 +0,0 @@
|
|||
package com.minelittlepony.unicopia.enchanting;
|
||||
|
||||
import com.google.gson.JsonObject;
|
||||
import com.minelittlepony.unicopia.inventory.gui.SpellBookInventory;
|
||||
import com.minelittlepony.unicopia.spell.SpellRegistry;
|
||||
|
||||
import net.minecraft.inventory.IInventory;
|
||||
import net.minecraft.inventory.InventoryCrafting;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.item.crafting.IRecipe;
|
||||
import net.minecraft.util.NonNullList;
|
||||
|
||||
public class SpellRecipe extends AbstractSpecialRecipe {
|
||||
|
||||
private final String spellId;
|
||||
|
||||
public static IRecipe deserialize(JsonObject json) {
|
||||
|
||||
JsonObject resultJson = json.get("result").getAsJsonObject();
|
||||
|
||||
return new SpellRecipe(
|
||||
parseSingleIngredient(resultJson),
|
||||
resultJson.get("spell").getAsString(),
|
||||
parseIngrediants(json)
|
||||
);
|
||||
}
|
||||
|
||||
public SpellRecipe(SpellIngredient spellitem, String spellName, NonNullList<SpellIngredient> ingredients) {
|
||||
super(spellitem, ingredients);
|
||||
this.spellId = spellName;
|
||||
}
|
||||
|
||||
@Override
|
||||
public ItemStack getCraftingResult(InventoryCrafting inv) {
|
||||
SpellBookInventory inventory = (SpellBookInventory)inv;
|
||||
|
||||
IInventory craftResult = inventory.getCraftResultMatrix();
|
||||
ItemStack stackToEnchant = craftResult.getStackInSlot(0);
|
||||
|
||||
return SpellRegistry.getInstance().enchantStack(stackToEnchant, spellId);
|
||||
}
|
||||
|
||||
@Override
|
||||
public ItemStack getRecipeOutput() {
|
||||
return SpellRegistry.getInstance().enchantStack(super.getRecipeOutput(), spellId);
|
||||
}
|
||||
}
|
|
@ -0,0 +1,100 @@
|
|||
package com.minelittlepony.unicopia.enchanting.recipe;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
import com.google.common.collect.Lists;
|
||||
import com.minelittlepony.unicopia.UItems;
|
||||
import com.minelittlepony.unicopia.inventory.gui.SpellBookInventory;
|
||||
|
||||
import net.minecraft.inventory.CraftingInventory;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.recipe.Recipe;
|
||||
import net.minecraft.util.DefaultedList;
|
||||
import net.minecraft.util.Identifier;
|
||||
import net.minecraft.world.World;
|
||||
|
||||
public abstract class AbstractSpecialRecipe implements Recipe<CraftingInventory> {
|
||||
|
||||
private final SpellIngredient spellitem;
|
||||
|
||||
private final DefaultedList<SpellIngredient> ingredients;
|
||||
|
||||
private final Identifier id;
|
||||
|
||||
public AbstractSpecialRecipe(Identifier id, SpellIngredient spellitem, DefaultedList<SpellIngredient> ingredients) {
|
||||
this.id = id;
|
||||
this.spellitem = spellitem;
|
||||
this.ingredients = ingredients;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean matches(CraftingInventory inv, World worldIn) {
|
||||
ItemStack enchantedStack = ((SpellBookInventory)inv).getCraftResultMatrix().getInvStack(0);
|
||||
|
||||
if (enchantedStack.isEmpty() || enchantedStack.getItem() == null) {
|
||||
return false;
|
||||
}
|
||||
|
||||
if (!spellitem.matches(enchantedStack, enchantedStack.getCount())) {
|
||||
return false;
|
||||
}
|
||||
|
||||
int materialMult = enchantedStack.getCount();
|
||||
|
||||
ArrayList<SpellIngredient> toMatch = Lists.newArrayList(ingredients);
|
||||
|
||||
for (int i = 0; i < inv.getInvSize(); i++) {
|
||||
ItemStack stack = inv.getInvStack(i);
|
||||
|
||||
if (!stack.isEmpty()) {
|
||||
if (toMatch.isEmpty() || !removeMatch(toMatch, stack, materialMult)) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return toMatch.isEmpty();
|
||||
}
|
||||
|
||||
private boolean removeMatch(List<SpellIngredient> toMatch, ItemStack stack, int materialMult) {
|
||||
return toMatch.stream()
|
||||
.filter(s -> s.matches(stack, materialMult))
|
||||
.findFirst()
|
||||
.filter(toMatch::remove)
|
||||
.isPresent();
|
||||
}
|
||||
|
||||
@Override
|
||||
public Identifier getId() {
|
||||
return id;
|
||||
}
|
||||
|
||||
@Override
|
||||
public ItemStack craft(CraftingInventory inv) {
|
||||
return getOutput();
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean fits(int width, int height) {
|
||||
return width * height < ingredients.size();
|
||||
}
|
||||
|
||||
@Override
|
||||
public ItemStack getRecipeKindIcon() {
|
||||
return new ItemStack(UItems.spell);
|
||||
}
|
||||
|
||||
public SpellIngredient getSpellItem() {
|
||||
return spellitem;
|
||||
}
|
||||
|
||||
public DefaultedList<SpellIngredient> getSpellIngredients() {
|
||||
return ingredients;
|
||||
}
|
||||
|
||||
@Override
|
||||
public ItemStack getOutput() {
|
||||
return spellitem.getStack();
|
||||
}
|
||||
}
|
|
@ -1,4 +1,4 @@
|
|||
package com.minelittlepony.unicopia.enchanting;
|
||||
package com.minelittlepony.unicopia.enchanting.recipe;
|
||||
|
||||
import java.util.Map;
|
||||
import java.util.stream.Stream;
|
|
@ -0,0 +1,80 @@
|
|||
package com.minelittlepony.unicopia.enchanting.recipe;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.stream.Stream;
|
||||
|
||||
import com.google.common.collect.Lists;
|
||||
import com.google.common.collect.Streams;
|
||||
import com.google.gson.JsonArray;
|
||||
import com.google.gson.JsonElement;
|
||||
import com.google.gson.JsonParseException;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.util.PacketByteBuf;
|
||||
|
||||
class CompoundSpellIngredient implements SpellIngredient {
|
||||
static final Serializer<CompoundSpellIngredient> SERIALIZER = new Serializer<CompoundSpellIngredient>() {
|
||||
@Override
|
||||
public CompoundSpellIngredient read(JsonElement json) {
|
||||
JsonArray arr = json.getAsJsonArray();
|
||||
|
||||
if (arr.size() > 0) {
|
||||
List<SpellIngredient> items = Lists.newArrayList();
|
||||
|
||||
for (JsonElement j : arr) {
|
||||
SpellIngredient item = SpellIngredient.parse(j);
|
||||
|
||||
if (item != null) {
|
||||
items.add(item);
|
||||
}
|
||||
}
|
||||
|
||||
if (!items.isEmpty()) {
|
||||
return new CompoundSpellIngredient(items);
|
||||
}
|
||||
}
|
||||
|
||||
throw new JsonParseException("Invalid spell ingredient (compound)");
|
||||
}
|
||||
|
||||
@Override
|
||||
public CompoundSpellIngredient read(PacketByteBuf buff) {
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void write(PacketByteBuf buff, CompoundSpellIngredient recipe) {
|
||||
}
|
||||
};
|
||||
|
||||
private final List<SpellIngredient> items;
|
||||
|
||||
CompoundSpellIngredient(List<SpellIngredient> items) {
|
||||
this.items = items;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Stream<ItemStack> getStacks() {
|
||||
Stream<ItemStack> stacks = Lists.<ItemStack>newArrayList().stream();
|
||||
|
||||
for (SpellIngredient i : items) {
|
||||
stacks = Streams.concat(stacks, i.getStacks());
|
||||
}
|
||||
|
||||
return stacks.distinct();
|
||||
}
|
||||
|
||||
@Override
|
||||
public ItemStack getStack() {
|
||||
return items.get((int)(Math.random() * items.size())).getStack();
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean matches(ItemStack other, int materialMult) {
|
||||
return items.stream().anyMatch(item -> item.matches(other, materialMult));
|
||||
}
|
||||
|
||||
@Override
|
||||
public Serializer<?> getSerializer() {
|
||||
return SERIALIZER;
|
||||
}
|
||||
}
|
|
@ -0,0 +1,108 @@
|
|||
package com.minelittlepony.unicopia.enchanting.recipe;
|
||||
|
||||
import java.util.Optional;
|
||||
import java.util.stream.Stream;
|
||||
|
||||
import javax.annotation.Nullable;
|
||||
|
||||
import com.google.common.collect.Streams;
|
||||
import com.google.gson.JsonElement;
|
||||
import com.google.gson.JsonObject;
|
||||
import com.google.gson.JsonParseException;
|
||||
import com.minelittlepony.unicopia.enchanting.recipe.AffineIngredients.AffineIngredient;
|
||||
import com.minelittlepony.unicopia.enchanting.recipe.SpellIngredient.Serializer;
|
||||
import com.minelittlepony.unicopia.magic.spells.SpellRegistry;
|
||||
|
||||
import net.minecraft.item.Item;
|
||||
import net.minecraft.item.ItemGroup;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.util.DefaultedList;
|
||||
import net.minecraft.util.Identifier;
|
||||
import net.minecraft.util.PacketByteBuf;
|
||||
import net.minecraft.util.registry.Registry;
|
||||
|
||||
class SingleSpellIngredient implements SpellIngredient {
|
||||
static final Serializer<SpellIngredient> SERIALIZER = new Serializer<SpellIngredient>() {
|
||||
@Override
|
||||
public SpellIngredient read(JsonElement json) {
|
||||
JsonObject obj = json.getAsJsonObject();
|
||||
Item item = obj.has("item") ? Registry.ITEM.get(new Identifier(obj.get("item").getAsString())) : null;
|
||||
|
||||
if (item != null) {
|
||||
int size = Math.max(1, obj.has("count") ? obj.get("count").getAsInt() : 1);
|
||||
String spell = obj.has("spell") ? obj.get("spell").getAsString() : null;
|
||||
|
||||
ItemStack stack = new ItemStack(item, size);
|
||||
|
||||
if (spell != null) {
|
||||
stack = SpellRegistry.instance().enchantStack(stack, spell);
|
||||
}
|
||||
|
||||
return new SingleSpellIngredient(stack, !(obj.has("spell") || obj.has("data")));
|
||||
}
|
||||
|
||||
if (obj.has("id")) {
|
||||
return AffineIngredient.parse(obj);
|
||||
}
|
||||
|
||||
throw new JsonParseException("Invalid spell ingredient (single)");
|
||||
}
|
||||
|
||||
@Override
|
||||
public SingleSpellIngredient read(PacketByteBuf buff) {
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void write(PacketByteBuf buff, SpellIngredient recipe) {
|
||||
}
|
||||
};
|
||||
|
||||
private final ItemStack contained;
|
||||
|
||||
SingleSpellIngredient(ItemStack stack, boolean meta) {
|
||||
contained = stack;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Stream<ItemStack> getStacks() {
|
||||
if (!contained.isEmpty()) {
|
||||
DefaultedList<ItemStack> subItems = DefaultedList.of();
|
||||
contained.getItem().getSubItems(ItemGroup.SEARCH, subItems);
|
||||
|
||||
return subItems.stream();
|
||||
}
|
||||
|
||||
return Streams.stream(Optional.ofNullable(contained));
|
||||
}
|
||||
|
||||
@Override
|
||||
public ItemStack getStack() {
|
||||
return contained;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean matches(ItemStack other, int materialMult) {
|
||||
if (other.isEmpty() != contained.isEmpty()) {
|
||||
return false;
|
||||
} else if (other.isEmpty()) {
|
||||
return true;
|
||||
}
|
||||
|
||||
if (other.isEmpty()) {
|
||||
return false;
|
||||
}
|
||||
|
||||
if (contained.getItem() == other.getItem()
|
||||
&& ItemStack.areItemsEqual(contained, other)) {
|
||||
return other.getCount() >= (materialMult * contained.getCount());
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Serializer<?> getSerializer() {
|
||||
return SERIALIZER;
|
||||
}
|
||||
}
|
|
@ -0,0 +1,53 @@
|
|||
package com.minelittlepony.unicopia.enchanting.recipe;
|
||||
|
||||
import com.google.gson.JsonObject;
|
||||
|
||||
import net.minecraft.inventory.CraftingInventory;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.recipe.Recipe;
|
||||
import net.minecraft.recipe.RecipeSerializer;
|
||||
import net.minecraft.recipe.RecipeType;
|
||||
import net.minecraft.util.DefaultedList;
|
||||
import net.minecraft.util.Identifier;
|
||||
|
||||
public class SpecialRecipe extends AbstractSpecialRecipe {
|
||||
|
||||
private final SpellIngredient output;
|
||||
|
||||
public static Recipe<CraftingInventory> deserialize(JsonObject json) {
|
||||
return new SpecialRecipe(null,
|
||||
SpellIngredient.single(json.get("input").getAsJsonObject()),
|
||||
SpellIngredient.single(json.get("output").getAsJsonObject()),
|
||||
SpellIngredient.multiple(json)
|
||||
);
|
||||
}
|
||||
|
||||
public SpecialRecipe(Identifier id, SpellIngredient input, SpellIngredient output, DefaultedList<SpellIngredient> ingredients) {
|
||||
super(id, input, ingredients);
|
||||
|
||||
this.output = output;
|
||||
}
|
||||
|
||||
@Override
|
||||
public ItemStack getOutput() {
|
||||
return output.getStack();
|
||||
}
|
||||
|
||||
@Override
|
||||
public Identifier getId() {
|
||||
// TODO Auto-generated method stub
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public RecipeSerializer<?> getSerializer() {
|
||||
// TODO Auto-generated method stub
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public RecipeType<?> getType() {
|
||||
// TODO Auto-generated method stub
|
||||
return null;
|
||||
}
|
||||
}
|
|
@ -0,0 +1,83 @@
|
|||
package com.minelittlepony.unicopia.enchanting.recipe;
|
||||
|
||||
import java.util.stream.Stream;
|
||||
|
||||
import com.google.gson.JsonElement;
|
||||
import com.google.gson.JsonObject;
|
||||
import com.google.gson.JsonParseException;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.util.DefaultedList;
|
||||
import net.minecraft.util.PacketByteBuf;
|
||||
|
||||
public interface SpellIngredient {
|
||||
|
||||
SpellIngredient EMPTY = new SingleSpellIngredient(ItemStack.EMPTY, false);
|
||||
|
||||
Serializer<SpellIngredient> SERIALIZER = new Serializer<SpellIngredient>() {
|
||||
@Override
|
||||
public SpellIngredient read(JsonElement json) {
|
||||
if (json.isJsonArray()) {
|
||||
return CompoundSpellIngredient.SERIALIZER.read(json);
|
||||
}
|
||||
|
||||
return SingleSpellIngredient.SERIALIZER.read(json);
|
||||
}
|
||||
|
||||
@Override
|
||||
public SpellIngredient read(PacketByteBuf buff) {
|
||||
byte type = buff.readByte();
|
||||
|
||||
if (type == 0) {
|
||||
return SingleSpellIngredient.SERIALIZER.read(buff);
|
||||
}
|
||||
return CompoundSpellIngredient.SERIALIZER.read(buff);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void write(PacketByteBuf buff, SpellIngredient recipe) {
|
||||
buff.writeByte(recipe instanceof SingleSpellIngredient ? 0 : 1);
|
||||
recipe.write(buff);
|
||||
}
|
||||
};
|
||||
|
||||
static SpellIngredient single(JsonObject json) {
|
||||
return parse(json.get("item"));
|
||||
}
|
||||
|
||||
static DefaultedList<SpellIngredient> multiple(JsonObject json) {
|
||||
DefaultedList<SpellIngredient> ingredients = DefaultedList.of();
|
||||
|
||||
json.get("ingredients").getAsJsonArray().forEach(i -> ingredients.add(parse(i)));
|
||||
|
||||
if (ingredients.isEmpty()) {
|
||||
throw new JsonParseException("Recipe cannot have 0 ingredients");
|
||||
}
|
||||
|
||||
return ingredients;
|
||||
}
|
||||
|
||||
static SpellIngredient parse(JsonElement json) {
|
||||
return SERIALIZER.read(json);
|
||||
}
|
||||
|
||||
boolean matches(ItemStack other, int materialMult);
|
||||
|
||||
ItemStack getStack();
|
||||
|
||||
Stream<ItemStack> getStacks();
|
||||
|
||||
Serializer<?> getSerializer();
|
||||
|
||||
@SuppressWarnings("unchecked")
|
||||
default void write(PacketByteBuf buff) {
|
||||
((Serializer<SpellIngredient>)getSerializer()).write(buff, this);
|
||||
}
|
||||
|
||||
interface Serializer<T> {
|
||||
T read(JsonElement json);
|
||||
|
||||
T read(PacketByteBuf buff);
|
||||
|
||||
void write(PacketByteBuf buff, T ingredient);
|
||||
}
|
||||
}
|
|
@ -0,0 +1,96 @@
|
|||
package com.minelittlepony.unicopia.enchanting.recipe;
|
||||
|
||||
import com.google.gson.JsonObject;
|
||||
import com.minelittlepony.unicopia.UItems;
|
||||
import com.minelittlepony.unicopia.inventory.gui.SpellBookInventory;
|
||||
import com.minelittlepony.unicopia.magic.spells.SpellRegistry;
|
||||
|
||||
import net.minecraft.inventory.CraftingInventory;
|
||||
import net.minecraft.inventory.Inventory;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.recipe.RecipeSerializer;
|
||||
import net.minecraft.recipe.RecipeType;
|
||||
import net.minecraft.util.DefaultedList;
|
||||
import net.minecraft.util.Identifier;
|
||||
import net.minecraft.util.PacketByteBuf;
|
||||
|
||||
public class SpellRecipe extends AbstractSpecialRecipe {
|
||||
|
||||
private final String spellId;
|
||||
|
||||
public SpellRecipe(Identifier id, SpellIngredient spellitem, String spellName, DefaultedList<SpellIngredient> ingredients) {
|
||||
super(id, spellitem, ingredients);
|
||||
this.spellId = spellName;
|
||||
}
|
||||
|
||||
@Override
|
||||
public ItemStack getRecipeKindIcon() {
|
||||
return new ItemStack(UItems.spellbook);
|
||||
}
|
||||
|
||||
@Override
|
||||
public ItemStack craft(CraftingInventory inv) {
|
||||
SpellBookInventory inventory = (SpellBookInventory)inv;
|
||||
|
||||
Inventory craftResult = inventory.getCraftResultMatrix();
|
||||
ItemStack stackToEnchant = craftResult.getInvStack(0);
|
||||
|
||||
return SpellRegistry.instance().enchantStack(stackToEnchant, spellId);
|
||||
}
|
||||
|
||||
@Override
|
||||
public ItemStack getOutput() {
|
||||
return SpellRegistry.instance().enchantStack(super.getOutput(), spellId);
|
||||
}
|
||||
|
||||
@Override
|
||||
public RecipeSerializer<?> getSerializer() {
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public RecipeType<?> getType() {
|
||||
return null;
|
||||
}
|
||||
|
||||
public static class Serializer implements RecipeSerializer<SpellRecipe> {
|
||||
|
||||
@Override
|
||||
public SpellRecipe read(Identifier id, JsonObject json) {
|
||||
JsonObject resultJson = json.get("result").getAsJsonObject();
|
||||
|
||||
return new SpellRecipe(id,
|
||||
SpellIngredient.single(resultJson),
|
||||
resultJson.get("spell").getAsString(),
|
||||
SpellIngredient.multiple(json)
|
||||
);
|
||||
}
|
||||
|
||||
@Override
|
||||
public SpellRecipe read(Identifier id, PacketByteBuf buff) {
|
||||
SpellIngredient spellItem = SpellIngredient.SERIALIZER.read(buff);
|
||||
String spellName = buff.readString();
|
||||
|
||||
int size = buff.readInt();
|
||||
DefaultedList<SpellIngredient> ingredients = DefaultedList.ofSize(0, SpellIngredient.EMPTY);
|
||||
|
||||
while (ingredients.size() < size) {
|
||||
ingredients.add(SpellIngredient.SERIALIZER.read(buff));
|
||||
}
|
||||
|
||||
return new SpellRecipe(id,
|
||||
spellItem,
|
||||
spellName,
|
||||
ingredients);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void write(PacketByteBuf buff, SpellRecipe recipe) {
|
||||
recipe.getSpellItem().write(buff);
|
||||
buff.writeString(recipe.spellId);
|
||||
DefaultedList<SpellIngredient> ingredients = recipe.getSpellIngredients();
|
||||
buff.writeInt(ingredients.size());
|
||||
ingredients.forEach(i -> i.write(buff));
|
||||
}
|
||||
}
|
||||
}
|
|
@ -1,8 +1,7 @@
|
|||
package com.minelittlepony.unicopia.entity.item;
|
||||
package com.minelittlepony.unicopia.entity;
|
||||
|
||||
import java.util.UUID;
|
||||
|
||||
import com.minelittlepony.unicopia.entity.IMagicals;
|
||||
import com.minelittlepony.unicopia.magic.Affinity;
|
||||
import com.minelittlepony.unicopia.magic.ICaster;
|
||||
import com.minelittlepony.unicopia.magic.IMagicEffect;
|
||||
|
@ -176,7 +175,7 @@ public class AdvancedProjectileEntity extends ThrownItemEntity implements IMagic
|
|||
}
|
||||
|
||||
if (hasEffect()) {
|
||||
if (getEffect().getDead()) {
|
||||
if (getEffect().isDead()) {
|
||||
remove();
|
||||
} else {
|
||||
getEffect().update(this);
|
|
@ -28,21 +28,21 @@ import net.minecraft.world.IWorld;
|
|||
import net.minecraft.world.World;
|
||||
import net.minecraft.world.biome.Biome.SpawnEntry;
|
||||
|
||||
public class EntityButterfly extends AmbientEntity {
|
||||
public class ButterflyEntity extends AmbientEntity {
|
||||
|
||||
public static final EntityType<EntityButterfly> TYPE = EntityType.Builder.create(EntityButterfly::new, EntityCategory.AMBIENT)
|
||||
public static final EntityType<ButterflyEntity> TYPE = EntityType.Builder.create(ButterflyEntity::new, EntityCategory.AMBIENT)
|
||||
.setDimensions(0.1F, 0.1F)
|
||||
.build("butterfly");
|
||||
|
||||
public static final SpawnEntry SPAWN_ENTRY = new SpawnEntry(TYPE, 15, 9, 15);
|
||||
|
||||
private static final TrackedData<Boolean> RESTING = DataTracker.registerData(EntityButterfly.class, TrackedDataHandlerRegistry.BOOLEAN);
|
||||
private static final TrackedData<Boolean> RESTING = DataTracker.registerData(ButterflyEntity.class, TrackedDataHandlerRegistry.BOOLEAN);
|
||||
|
||||
private static final TrackedData<Integer> VARIANT = DataTracker.registerData(EntityButterfly.class, TrackedDataHandlerRegistry.INTEGER);
|
||||
private static final TrackedData<Integer> VARIANT = DataTracker.registerData(ButterflyEntity.class, TrackedDataHandlerRegistry.INTEGER);
|
||||
|
||||
private BlockPos hoveringPosition;
|
||||
|
||||
public EntityButterfly(EntityType<EntityButterfly> type, World world) {
|
||||
public ButterflyEntity(EntityType<ButterflyEntity> type, World world) {
|
||||
super(type, world);
|
||||
setVariaty(Variant.random(world.random));
|
||||
setResting(true);
|
||||
|
@ -109,7 +109,7 @@ public class EntityButterfly extends AmbientEntity {
|
|||
}
|
||||
|
||||
protected boolean isAggressor(Entity e) {
|
||||
if (e instanceof EntityButterfly) {
|
||||
if (e instanceof ButterflyEntity) {
|
||||
return false;
|
||||
}
|
||||
|
|
@ -2,14 +2,18 @@ package com.minelittlepony.unicopia.entity;
|
|||
|
||||
import java.util.Map;
|
||||
|
||||
import com.minelittlepony.unicopia.Predicates;
|
||||
import javax.annotation.Nullable;
|
||||
|
||||
import com.minelittlepony.unicopia.EquinePredicates;
|
||||
import com.minelittlepony.unicopia.Race;
|
||||
import com.minelittlepony.unicopia.SpeciesList;
|
||||
import com.minelittlepony.unicopia.UBlocks;
|
||||
import com.minelittlepony.unicopia.UItems;
|
||||
import com.minelittlepony.unicopia.UParticles;
|
||||
import com.minelittlepony.unicopia.ability.powers.PowerCloudBase.ICloudEntity;
|
||||
import com.minelittlepony.unicopia.ability.PowerCloudBase.ICloudEntity;
|
||||
import com.minelittlepony.unicopia.particles.ParticleEmitter;
|
||||
|
||||
import net.minecraft.block.BlockState;
|
||||
import net.minecraft.block.Blocks;
|
||||
import net.minecraft.block.CropBlock;
|
||||
import net.minecraft.block.FarmlandBlock;
|
||||
|
@ -18,9 +22,12 @@ import net.minecraft.enchantment.Enchantment;
|
|||
import net.minecraft.enchantment.EnchantmentHelper;
|
||||
import net.minecraft.enchantment.Enchantments;
|
||||
import net.minecraft.entity.Entity;
|
||||
import net.minecraft.entity.EntityData;
|
||||
import net.minecraft.entity.EntityType;
|
||||
import net.minecraft.entity.ItemEntity;
|
||||
import net.minecraft.entity.LightningEntity;
|
||||
import net.minecraft.entity.MovementType;
|
||||
import net.minecraft.entity.SpawnType;
|
||||
import net.minecraft.entity.damage.DamageSource;
|
||||
import net.minecraft.entity.data.DataTracker;
|
||||
import net.minecraft.entity.data.TrackedData;
|
||||
|
@ -28,24 +35,36 @@ import net.minecraft.entity.data.TrackedDataHandlerRegistry;
|
|||
import net.minecraft.entity.mob.FlyingEntity;
|
||||
import net.minecraft.entity.player.PlayerEntity;
|
||||
import net.minecraft.item.Item;
|
||||
import net.minecraft.item.ItemConvertible;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.item.ShovelItem;
|
||||
import net.minecraft.item.SwordItem;
|
||||
import net.minecraft.nbt.CompoundTag;
|
||||
import net.minecraft.particle.ParticleEffect;
|
||||
import net.minecraft.particle.ParticleTypes;
|
||||
import net.minecraft.server.world.ServerWorld;
|
||||
import net.minecraft.sound.BlockSoundGroup;
|
||||
import net.minecraft.sound.SoundCategory;
|
||||
import net.minecraft.sound.SoundEvent;
|
||||
import net.minecraft.sound.SoundEvents;
|
||||
import net.minecraft.util.math.BlockPos;
|
||||
import net.minecraft.util.math.Box;
|
||||
import net.minecraft.util.math.Direction;
|
||||
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.biome.Biome;
|
||||
|
||||
public class EntityCloud extends FlyingEntity implements ICloudEntity, IAnimals, IInAnimate {
|
||||
public class CloudEntity extends FlyingEntity implements ICloudEntity, IInAnimate {
|
||||
|
||||
private static final TrackedData<Integer> RAINTIMER = DataTracker.registerData(EntityCloud.class, TrackedDataHandlerRegistry.INTEGER);
|
||||
private static final TrackedData<Boolean> THUNDERING = DataTracker.registerData(EntityCloud.class, TrackedDataHandlerRegistry.BOOLEAN);
|
||||
private static final TrackedData<Integer> SCALE = DataTracker.registerData(EntityCloud.class, TrackedDataHandlerRegistry.INTEGER);
|
||||
private static final TrackedData<Integer> RAINTIMER = DataTracker.registerData(CloudEntity.class, TrackedDataHandlerRegistry.INTEGER);
|
||||
private static final TrackedData<Boolean> THUNDERING = DataTracker.registerData(CloudEntity.class, TrackedDataHandlerRegistry.BOOLEAN);
|
||||
private static final TrackedData<Integer> SCALE = DataTracker.registerData(CloudEntity.class, TrackedDataHandlerRegistry.INTEGER);
|
||||
|
||||
private static final TrackedData<Boolean> STATIONARY = DataTracker.registerData(EntityCloud.class, TrackedDataHandlerRegistry.BOOLEAN);
|
||||
private static final TrackedData<Boolean> STATIONARY = DataTracker.registerData(CloudEntity.class, TrackedDataHandlerRegistry.BOOLEAN);
|
||||
|
||||
protected double targetAltitude;
|
||||
|
||||
|
@ -55,7 +74,7 @@ public class EntityCloud extends FlyingEntity implements ICloudEntity, IAnimals,
|
|||
private final double baseWidth = 3f;
|
||||
private final double baseHeight = 0.8f;
|
||||
|
||||
public EntityCloud(EntityType<EntityCloud> type, World world) {
|
||||
public CloudEntity(EntityType<? extends CloudEntity> type, World world) {
|
||||
super(type, world);
|
||||
ignoreCameraFrustum = true;
|
||||
targetAltitude = getRandomFlyingHeight();
|
||||
|
@ -80,20 +99,11 @@ public class EntityCloud extends FlyingEntity implements ICloudEntity, IAnimals,
|
|||
return SoundEvents.BLOCK_WOOL_BREAK;
|
||||
}
|
||||
|
||||
@Override
|
||||
// TODO: loot table
|
||||
/*@Override
|
||||
protected Item getDropItem() {
|
||||
return UItems.cloud_matter;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected boolean canTriggerWalking() {
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean doesEntityNotTriggerPressurePlate() {
|
||||
return true;
|
||||
}
|
||||
}*/
|
||||
|
||||
@Override
|
||||
public boolean doesRenderOnFire() {
|
||||
|
@ -126,28 +136,28 @@ public class EntityCloud extends FlyingEntity implements ICloudEntity, IAnimals,
|
|||
}
|
||||
|
||||
@Override
|
||||
public void onStruckByLightning(EntityLightningBolt lightningBolt) {
|
||||
public void onStruckByLightning(LightningEntity lightningBolt) {
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public IEntityLivingData onInitialSpawn(DifficultyInstance difficulty, IEntityLivingData pack) {
|
||||
if (world.random.nextInt(20) == 0 && canRainHere()) {
|
||||
public EntityData initialize(IWorld world, LocalDifficulty difficulty, SpawnType type, @Nullable EntityData data, @Nullable CompoundTag tag) {
|
||||
if (random.nextInt(20) == 0 && canRainHere()) {
|
||||
setRaining();
|
||||
if (world.random.nextInt(20) == 0) {
|
||||
if (random.nextInt(20) == 0) {
|
||||
setIsThundering(true);
|
||||
}
|
||||
}
|
||||
|
||||
setCloudSize(1 + random.nextInt(4));
|
||||
|
||||
return super.onInitialSpawn(difficulty, pack);
|
||||
return super.initialize(world, difficulty, type, data, tag);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void collideWithEntity(Entity other) {
|
||||
if (other instanceof EntityCloud || other instanceof PlayerEntity) {
|
||||
if (other.posY > posY) {
|
||||
if (other instanceof CloudEntity || other instanceof PlayerEntity) {
|
||||
if (other.y > y) {
|
||||
return;
|
||||
}
|
||||
|
||||
|
@ -158,16 +168,16 @@ public class EntityCloud extends FlyingEntity implements ICloudEntity, IAnimals,
|
|||
@Override
|
||||
public void applyEntityCollision(Entity other) {
|
||||
if (other instanceof PlayerEntity) {
|
||||
if (Predicates.INTERACT_WITH_CLOUDS.test((PlayerEntity)other)) {
|
||||
if (EquinePredicates.INTERACT_WITH_CLOUDS.test((PlayerEntity)other)) {
|
||||
super.applyEntityCollision(other);
|
||||
}
|
||||
} else if (other instanceof EntityCloud) {
|
||||
} else if (other instanceof CloudEntity) {
|
||||
super.applyEntityCollision(other);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onUpdate() {
|
||||
public void tick() {
|
||||
Box boundingbox = getBoundingBox();
|
||||
|
||||
if (getIsRaining()) {
|
||||
|
@ -175,11 +185,11 @@ public class EntityCloud extends FlyingEntity implements ICloudEntity, IAnimals,
|
|||
for (int i = 0; i < 30 * getCloudSize(); i++) {
|
||||
double x = MathHelper.nextDouble(random, boundingbox.minX, boundingbox.maxX);
|
||||
double y = getBoundingBox().minY + getHeight()/2;
|
||||
double z = MathHelper.nextDouble(rand, boundingbox.minZ, boundingbox.maxZ);
|
||||
double z = MathHelper.nextDouble(random, boundingbox.minZ, boundingbox.maxZ);
|
||||
|
||||
int particleId = canSnowHere(new BlockPos(x, y, z)) ? ParticleTypes.ITEM_SNOWBALL.getType() : UParticles.RAIN_DROPS;
|
||||
ParticleEffect particleId = canSnowHere(new BlockPos(x, y, z)) ? ParticleTypes.ITEM_SNOWBALL : UParticles.RAIN_DROPS;
|
||||
|
||||
ParticleTypeRegistry.getTnstance().spawnParticle(particleId, false, x, y, z, 0, 0, 0);
|
||||
world.addParticle(particleId, x, y, z, 0, 0, 0);
|
||||
}
|
||||
|
||||
Box rainedArea = boundingbox
|
||||
|
@ -194,6 +204,7 @@ public class EntityCloud extends FlyingEntity implements ICloudEntity, IAnimals,
|
|||
}
|
||||
}
|
||||
|
||||
double width = getDimensions(getPose()).width;
|
||||
BlockPos pos = getGroundPosition(
|
||||
x + random.nextFloat() * width,
|
||||
z + random.nextFloat() * width
|
||||
|
@ -215,39 +226,41 @@ public class EntityCloud extends FlyingEntity implements ICloudEntity, IAnimals,
|
|||
world.setBlockState(pos, Blocks.AIR.getDefaultState());
|
||||
}
|
||||
|
||||
if (rand.nextInt(20) == 0) {
|
||||
if (random.nextInt(20) == 0) {
|
||||
BlockPos below = pos.down();
|
||||
state = world.getBlockState(below);
|
||||
if (state.getBlock() != null) {
|
||||
if (world.canBlockFreezeWater(below)) {
|
||||
Biome biome = world.getBiome(below);
|
||||
|
||||
if (biome.canSetIce(world, below)) {
|
||||
world.setBlockState(below, Blocks.ICE.getDefaultState());
|
||||
}
|
||||
|
||||
if (world.canSnowAt(pos, false)) {
|
||||
if (biome.canSetSnow(world, pos)) {
|
||||
world.setBlockState(pos, Blocks.SNOW.getDefaultState());
|
||||
}
|
||||
|
||||
if (state.getBlock() instanceof FarmlandBlock) {
|
||||
int moisture = state.getValue(FarmlandBlock.MOISTURE);
|
||||
int moisture = state.get(FarmlandBlock.MOISTURE);
|
||||
|
||||
if (moisture < 7) {
|
||||
world.setBlockState(below, state.with(FarmlandBlock.MOISTURE, moisture + 1));
|
||||
}
|
||||
} else if (state.getBlock() instanceof CropBlock) {
|
||||
int age = state.getValue(CropBlock.AGE);
|
||||
int age = state.get(CropBlock.AGE);
|
||||
|
||||
if (age < 7) {
|
||||
world.setBlockState(below, state.with(CropBlock.AGE, age + 1), 2);
|
||||
}
|
||||
}
|
||||
|
||||
state.getBlock().fillWithRain(world, below);
|
||||
state.getBlock().onRainTick(world, below);
|
||||
}
|
||||
}
|
||||
|
||||
if (setRainTimer(getRainTimer() - 1) == 0) {
|
||||
if (!getStationary()) {
|
||||
pomf();
|
||||
spawnHurtParticles();
|
||||
|
||||
if (getCloudSize() > 1) {
|
||||
setIsRaining(false);
|
||||
|
@ -266,20 +279,20 @@ public class EntityCloud extends FlyingEntity implements ICloudEntity, IAnimals,
|
|||
}
|
||||
}
|
||||
|
||||
rotationPitch = 0;
|
||||
rotationYawHead = 0;
|
||||
rotationYaw = 0;
|
||||
pitch = 0;
|
||||
headYaw = 0;
|
||||
yaw = 0;
|
||||
|
||||
for (Entity i : world.getEntitiesInAABBexcluding(this, boundingbox
|
||||
.grow(1 / (1 + getCloudSize())), Predicates.ENTITY_INTERACT_WITH_CLOUDS)) {
|
||||
if (i.posY > posY + 0.5) {
|
||||
for (Entity i : world.getEntities(this, boundingbox
|
||||
.expand(1 / (1 + getCloudSize())), EquinePredicates.ENTITY_INTERACT_WITH_CLOUDS)) {
|
||||
if (i.y > y + 0.5) {
|
||||
applyGravityCompensation(i);
|
||||
}
|
||||
}
|
||||
|
||||
if (isBurning() && !dead) {
|
||||
if (isOnFire() && !dead) {
|
||||
for (int i = 0; i < 5; i++) {
|
||||
world.spawnParticle(ParticleTypes.CLOUD,
|
||||
world.addParticle(ParticleTypes.CLOUD,
|
||||
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);
|
||||
|
@ -290,47 +303,48 @@ public class EntityCloud extends FlyingEntity implements ICloudEntity, IAnimals,
|
|||
setVelocity(0, 0, 0);
|
||||
}
|
||||
|
||||
super.onUpdate();
|
||||
super.tick();
|
||||
|
||||
double motionFactor = (1 + getCloudSize() / 4);
|
||||
|
||||
motionX /= motionFactor;
|
||||
motionZ /= motionFactor;
|
||||
Vec3d vel = this.getVelocity();
|
||||
this.setVelocity(vel.x / motionFactor, vel.y, vel.z / motionFactor);
|
||||
|
||||
|
||||
hurtTime = 0;
|
||||
}
|
||||
|
||||
@Override
|
||||
public double getMountedYOffset() {
|
||||
return getEntityBoundingBox().maxY - getEntityBoundingBox().minY - 0.25;
|
||||
public double getMountedHeightOffset() {
|
||||
return getBoundingBox().maxY - getBoundingBox().minY - 0.25;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void moveRelative(float strafe, float up, float forward, float friction) {
|
||||
public void travel(Vec3d motion) {
|
||||
if (!getStationary()) {
|
||||
super.moveRelative(strafe, up, forward, friction);
|
||||
super.travel(motion);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onCollideWithPlayer(PlayerEntity player) {
|
||||
if (player.posY >= posY) {
|
||||
public void onPlayerCollision(PlayerEntity player) {
|
||||
if (player.y >= y) {
|
||||
if (applyGravityCompensation(player)) {
|
||||
double difX = player.posX - player.lastTickPosX;
|
||||
double difZ = player.posZ - player.lastTickPosZ;
|
||||
double difY = player.posY - player.lastTickPosY;
|
||||
double difX = player.x - player.prevX;
|
||||
double difZ = player.z - player.prevZ;
|
||||
double difY = player.y - player.prevY;
|
||||
|
||||
player.distanceWalkedModified = (float)(player.distanceWalkedModified + MathHelper.sqrt(difX * difX + difZ * difZ) * 0.6);
|
||||
player.distanceWalkedOnStepModified = (float)(player.distanceWalkedOnStepModified + MathHelper.sqrt(difX * difX + difY * difY + difZ * difZ) * 0.6);
|
||||
player.horizontalSpeed = (float)(player.horizontalSpeed + MathHelper.sqrt(difX * difX + difZ * difZ) * 0.6);
|
||||
player.distanceWalked = (float)(player.distanceWalked + MathHelper.sqrt(difX * difX + difY * difY + difZ * difZ) * 0.6);
|
||||
|
||||
if (SpeciesList.instance().getPlayer(player).stepOnCloud()) {
|
||||
SoundType soundtype = SoundType.CLOTH;
|
||||
BlockSoundGroup soundtype = BlockSoundGroup.WOOL;
|
||||
player.playSound(soundtype.getStepSound(), soundtype.getVolume() * 0.15F, soundtype.getPitch());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
super.onCollideWithPlayer(player);
|
||||
super.onPlayerCollision(player);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -352,8 +366,9 @@ public class EntityCloud extends FlyingEntity implements ICloudEntity, IAnimals,
|
|||
distance = 0;
|
||||
}
|
||||
|
||||
getVelocity().y -= 0.002;
|
||||
getVelocity().y += (Math.signum(distance) * 0.699999988079071D - getVelocity().y) * 0.10000000149011612D;
|
||||
Vec3d vel = getVelocity();
|
||||
|
||||
setVelocity(vel.x, vel.y - 0.002 + (Math.signum(distance) * 0.699999988079071D - vel.y) * 0.10000000149011612D, vel.z);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -369,7 +384,7 @@ public class EntityCloud extends FlyingEntity implements ICloudEntity, IAnimals,
|
|||
}
|
||||
|
||||
protected float getMinimumFlyingHeight() {
|
||||
float ground = world.getDimension().getAverageGroundLevel();
|
||||
float ground = world.getBiome(getBlockPos()).getDepth();
|
||||
float cloud = world.getDimension().getCloudHeight();
|
||||
|
||||
float min = Math.min(ground, cloud);
|
||||
|
@ -384,12 +399,8 @@ public class EntityCloud extends FlyingEntity implements ICloudEntity, IAnimals,
|
|||
|
||||
@Override
|
||||
public void handleStatus(byte type) {
|
||||
if (type == 2) {
|
||||
if (!isOnFire()) {
|
||||
for (int i = 0; i < 50 * getCloudSize(); i++) {
|
||||
ParticleTypeRegistry.getTnstance().getEmitter().emitDiggingParticles(this, UBlocks.normal_cloud.getDefaultState());
|
||||
}
|
||||
}
|
||||
if (type == 2 && !isOnFire()) {
|
||||
spawnHurtParticles();
|
||||
}
|
||||
super.handleStatus(type);
|
||||
}
|
||||
|
@ -407,14 +418,13 @@ public class EntityCloud extends FlyingEntity implements ICloudEntity, IAnimals,
|
|||
}
|
||||
}
|
||||
|
||||
pomf();
|
||||
spawnHurtParticles();
|
||||
}
|
||||
|
||||
public void pomf() {
|
||||
public void spawnHurtParticles() {
|
||||
for (int i = 0; i < 50 * getCloudSize(); i++) {
|
||||
ParticleTypeRegistry.getTnstance().getEmitter().emitDiggingParticles(this, UBlocks.normal_cloud.getDefaultState());
|
||||
ParticleEmitter.instance().emitDiggingParticles(this, UBlocks.normal_cloud);
|
||||
}
|
||||
|
||||
playHurtSound(DamageSource.GENERIC);
|
||||
}
|
||||
|
||||
|
@ -423,33 +433,31 @@ public class EntityCloud extends FlyingEntity implements ICloudEntity, IAnimals,
|
|||
Entity attacker = source.getAttacker();
|
||||
|
||||
if (attacker instanceof PlayerEntity) {
|
||||
return onAttackByPlayer(source, amount, (PlayerEntity)attacker);
|
||||
return damage(source, amount, (PlayerEntity)attacker);
|
||||
}
|
||||
|
||||
return source == DamageSource.IN_WALL || super.damage(source, amount);
|
||||
}
|
||||
|
||||
private boolean onAttackByPlayer(DamageSource source, float amount, PlayerEntity player) {
|
||||
private boolean damage(DamageSource source, float amount, PlayerEntity player) {
|
||||
|
||||
ItemStack stack = player.getMainHandStack();
|
||||
|
||||
boolean canFly = EnchantmentHelper.getEnchantments(stack).containsKey(Enchantments.FEATHER_FALLING)
|
||||
|| Predicates.INTERACT_WITH_CLOUDS.test(player);
|
||||
|| EquinePredicates.INTERACT_WITH_CLOUDS.test(player);
|
||||
boolean stat = getStationary();
|
||||
|
||||
if (stat || canFly) {
|
||||
if (!isOnFire()) {
|
||||
for (int i = 0; i < 50 * getCloudSize(); i++) {
|
||||
ParticleTypeRegistry.getTnstance().getEmitter().emitDiggingParticles(this, UBlocks.normal_cloud.getDefaultState());
|
||||
}
|
||||
spawnHurtParticles();
|
||||
}
|
||||
|
||||
if (stack != null && stack.getItem() instanceof ItemSword) {
|
||||
return super.attackEntityFrom(source, amount);
|
||||
} else if (stack != null && stack.getItem() instanceof ItemSpade) {
|
||||
return super.attackEntityFrom(source, amount * 1.5f);
|
||||
if (stack != null && stack.getItem() instanceof SwordItem) {
|
||||
return super.damage(source, amount);
|
||||
} else if (stack != null && stack.getItem() instanceof ShovelItem) {
|
||||
return super.damage(source, amount * 1.5f);
|
||||
} else if (canFly) {
|
||||
if (player.y < y || !world.isAirBlock(getPosition())) {
|
||||
if (player.y < y || !world.isAir(getBlockPos())) {
|
||||
targetAltitude = y + 5;
|
||||
} else if (player.y > y) {
|
||||
targetAltitude = y - 5;
|
||||
|
@ -475,89 +483,95 @@ public class EntityCloud extends FlyingEntity implements ICloudEntity, IAnimals,
|
|||
clearItemFloatingState();
|
||||
}
|
||||
|
||||
@FUF(reason = "There is no TickEvent.EntityTickEvent. Waiting on mixins...")
|
||||
//@FUF(reason = "There is no TickEvent.EntityTickEvent. Waiting on mixins...")
|
||||
protected void clearItemFloatingState() {
|
||||
Box bounds = getEntityBoundingBox().grow(1 / (1 + getCloudSize())).grow(5);
|
||||
Box bounds = getBoundingBox().expand(1 / (1 + getCloudSize())).expand(5);
|
||||
|
||||
for (Entity i : world.getEntitiesInAABBexcluding(this, bounds, this::entityIsFloatingItem)) {
|
||||
for (Entity i : world.getEntities(this, bounds, this::entityIsFloatingItem)) {
|
||||
i.setNoGravity(false);
|
||||
}
|
||||
}
|
||||
|
||||
private boolean entityIsFloatingItem(Entity e) {
|
||||
return e instanceof ItemEntity
|
||||
&& Predicates.ITEM_INTERACT_WITH_CLOUDS.test((ItemEntity)e);
|
||||
&& EquinePredicates.ITEM_INTERACT_WITH_CLOUDS.test((ItemEntity)e);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void dropFewItems(boolean hitByPlayer, int looting) {
|
||||
protected void dropEquipment(DamageSource source, int looting, boolean hitByPlayer) {
|
||||
if (hitByPlayer) {
|
||||
Item item = getDropItem();
|
||||
int amount = 13 + world.rand.nextInt(3);
|
||||
int amount = 13 + world.random.nextInt(3);
|
||||
|
||||
dropItem(item, amount * (1 + looting));
|
||||
dropItem(UItems.cloud_matter, amount * (1 + looting));
|
||||
|
||||
if (world.rand.nextBoolean()) {
|
||||
if (world.random.nextBoolean()) {
|
||||
dropItem(UItems.dew_drop, 3 + looting);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public EntityItem entityDropItem(ItemStack stack, float offsetY) {
|
||||
EntityItem item = super.entityDropItem(stack, offsetY);
|
||||
public ItemEntity dropItem(ItemConvertible stack, int amount) {
|
||||
ItemEntity item = super.dropItem(stack, amount);
|
||||
|
||||
SpeciesList.instance().getEntity(item).setSpecies(Race.PEGASUS);
|
||||
item.setNoGravity(true);
|
||||
item.motionY = 0;
|
||||
item.setVelocity(0, 0, 0);
|
||||
|
||||
return item;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void readEntityFromNBT(NBTTagCompound tag) {
|
||||
super.readEntityFromNBT(tag);
|
||||
public void readCustomDataFromTag(CompoundTag tag) {
|
||||
super.readCustomDataFromTag(tag);
|
||||
|
||||
setRainTimer(tag.getInteger("RainTimer"));
|
||||
setRainTimer(tag.getInt("RainTimer"));
|
||||
setIsThundering(tag.getBoolean("IsThundering"));
|
||||
setCloudSize(tag.getByte("CloudSize"));
|
||||
setStationary(tag.getBoolean("IsStationary"));
|
||||
}
|
||||
|
||||
@Override
|
||||
public void writeEntityToNBT(NBTTagCompound tag) {
|
||||
super.writeEntityToNBT(tag);
|
||||
public void writeCustomDataToTag(CompoundTag tag) {
|
||||
super.writeCustomDataToTag(tag);
|
||||
|
||||
tag.setInteger("RainTimer", getRainTimer());
|
||||
tag.setBoolean("IsThundering", getIsThundering());
|
||||
tag.setByte("CloudSize", (byte)getCloudSize());
|
||||
tag.setBoolean("IsStationary", getStationary());
|
||||
tag.putInt("RainTimer", getRainTimer());
|
||||
tag.putBoolean("IsThundering", getIsThundering());
|
||||
tag.putByte("CloudSize", (byte)getCloudSize());
|
||||
tag.putBoolean("IsStationary", getStationary());
|
||||
}
|
||||
|
||||
protected boolean applyGravityCompensation(Entity entity) {
|
||||
int floatStrength = getFloatStrength(entity);
|
||||
|
||||
if (!isRidingOrBeingRiddenBy(entity) && floatStrength > 0) {
|
||||
if (!isConnectedThroughVehicle(entity) && floatStrength > 0) {
|
||||
|
||||
double boundModifier = entity.fallDistance > 80 ? 80 : MathHelper.floor(entity.fallDistance * 10) / 10;
|
||||
|
||||
entity.onGround = true;
|
||||
entity.motionY += (((floatStrength > 2 ? 1 : floatStrength/2) * 0.699999998079071D) - entity.motionY + boundModifier * 0.7) * 0.10000000149011612D;
|
||||
|
||||
Vec3d motion = entity.getVelocity();
|
||||
double motionX = motion.x;
|
||||
double motionY = motion.y;
|
||||
double motionZ = motion.z;
|
||||
|
||||
motionY += (((floatStrength > 2 ? 1 : floatStrength/2) * 0.699999998079071D) - motionY + boundModifier * 0.7) * 0.10000000149011612D;
|
||||
if (!getStationary()) {
|
||||
entity.motionX += ((motionX - entity.motionX) / getCloudSize()) - 0.002F;
|
||||
motionX += ((motionX - motionX) / getCloudSize()) - 0.002F;
|
||||
}
|
||||
|
||||
if (!getStationary() && entity.motionY > 0.4 && world.rand.nextInt(900) == 0) {
|
||||
spawnThunderbolt(getPosition());
|
||||
if (!getStationary() && motionY > 0.4 && world.random.nextInt(900) == 0) {
|
||||
spawnThunderbolt(getBlockPos());
|
||||
}
|
||||
|
||||
// @FUF(reason = "There is no TickEvents.EntityTickEvent. Waiting on mixins...")
|
||||
if (getStationary() && entity instanceof EntityItem) {
|
||||
entity.motionX /= 8;
|
||||
entity.motionZ /= 8;
|
||||
entity.motionY /= 16;
|
||||
if (getStationary() && entity instanceof ItemEntity) {
|
||||
motionX /= 8;
|
||||
motionZ /= 8;
|
||||
motionY /= 16;
|
||||
entity.setNoGravity(true);
|
||||
}
|
||||
entity.setVelocity(motionX, motionY, motionZ);
|
||||
|
||||
return true;
|
||||
}
|
||||
|
@ -566,13 +580,13 @@ public class EntityCloud extends FlyingEntity implements ICloudEntity, IAnimals,
|
|||
}
|
||||
|
||||
@Override
|
||||
public void move(MoverType type, double x, double y, double z) {
|
||||
setEntityBoundingBox(getEntityBoundingBox().offset(x, y, z));
|
||||
resetPositionToBB();
|
||||
public void move(MovementType type, Vec3d delta) {
|
||||
setBoundingBox(getBoundingBox().offset(delta));
|
||||
moveToBoundingBoxCenter();
|
||||
}
|
||||
|
||||
public int getFloatStrength(Entity entity) {
|
||||
if (Predicates.ENTITY_INTERACT_WITH_CLOUDS.test(entity)) {
|
||||
if (EquinePredicates.ENTITY_INTERACT_WITH_CLOUDS.test(entity)) {
|
||||
return 3;
|
||||
}
|
||||
|
||||
|
@ -596,7 +610,7 @@ public class EntityCloud extends FlyingEntity implements ICloudEntity, IAnimals,
|
|||
}
|
||||
|
||||
private boolean canRainHere() {
|
||||
return world.getBiome(getBlockPos()).canRain();
|
||||
return world.getBiome(getBlockPos()).getRainfall() > 0;
|
||||
}
|
||||
|
||||
private boolean canSnowHere(BlockPos pos) {
|
||||
|
@ -608,16 +622,18 @@ public class EntityCloud extends FlyingEntity implements ICloudEntity, IAnimals,
|
|||
}
|
||||
|
||||
public void spawnThunderbolt(BlockPos pos) {
|
||||
world.addWeatherEffect(new LightningEntity(world, pos.getX(), pos.getY(), pos.getZ(), false));
|
||||
if (world instanceof ServerWorld) {
|
||||
((ServerWorld)world).addLightning(new LightningEntity(world, pos.getX(), pos.getY(), pos.getZ(), false));
|
||||
}
|
||||
}
|
||||
|
||||
private BlockPos getGroundPosition(double x, double z) {
|
||||
BlockPos pos = world.getTopPosition(Heightmap.Type.WORLD_SURFACE, new BlockPos(x, y, z));
|
||||
|
||||
if (pos.getY() >= posY) {
|
||||
while (world.isValid(pos)) {
|
||||
if (pos.getY() >= y) {
|
||||
while (World.isValid(pos)) {
|
||||
pos = pos.down();
|
||||
if (world.getBlockState(pos).isSideSolid(world, pos, Direction.UP)) {
|
||||
if (world.getBlockState(pos).hasSolidTopSurface(world, pos, this)) {
|
||||
return pos.up();
|
||||
}
|
||||
}
|
||||
|
@ -686,7 +702,7 @@ public class EntityCloud extends FlyingEntity implements ICloudEntity, IAnimals,
|
|||
protected void setSize(float width, float height) {
|
||||
if (width != this.width || height != this.height) {
|
||||
super.setSize(width, height);
|
||||
setPosition(posX, posY, posZ);
|
||||
setPosition(x, y, z);
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,101 @@
|
|||
package com.minelittlepony.unicopia.entity;
|
||||
|
||||
import com.google.common.collect.Lists;
|
||||
import com.minelittlepony.unicopia.EquinePredicates;
|
||||
|
||||
import net.minecraft.client.MinecraftClient;
|
||||
import net.minecraft.client.network.ClientPlayerEntity;
|
||||
import net.minecraft.client.world.ClientWorld;
|
||||
import net.minecraft.entity.EntityType;
|
||||
import net.minecraft.entity.player.PlayerEntity;
|
||||
import net.minecraft.item.BlockItem;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.item.SpawnEggItem;
|
||||
import net.minecraft.util.math.Box;
|
||||
import net.minecraft.util.math.Direction;
|
||||
import net.minecraft.util.ActionResult;
|
||||
import net.minecraft.util.Hand;
|
||||
import net.minecraft.util.hit.BlockHitResult;
|
||||
import net.minecraft.util.math.BlockPos;
|
||||
import net.minecraft.util.math.Vec3d;
|
||||
import net.minecraft.world.World;
|
||||
|
||||
public class ConstructionCloudEntity extends CloudEntity {
|
||||
|
||||
public ConstructionCloudEntity(EntityType<ConstructionCloudEntity> type, World world) {
|
||||
super(type, world);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean getStationary() {
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean getOpaque() {
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public ActionResult interactAt(PlayerEntity player, Vec3d vec, Hand hand) {
|
||||
if (!(hasPassengers() || isConnectedThroughVehicle(player)) && hand == Hand.MAIN_HAND) {
|
||||
if (EquinePredicates.INTERACT_WITH_CLOUDS.test(player)) {
|
||||
|
||||
if (player.getItemUseTime() > 0) {
|
||||
return ActionResult.FAIL;
|
||||
}
|
||||
|
||||
ItemStack stack = player.getStackInHand(hand);
|
||||
|
||||
if (stack != null) {
|
||||
if (stack.getItem() instanceof BlockItem || stack.getItem() instanceof SpawnEggItem) {
|
||||
placeBlock(player, stack, hand);
|
||||
return ActionResult.SUCCESS;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return ActionResult.FAIL;
|
||||
}
|
||||
|
||||
private void placeBlock(PlayerEntity player, ItemStack stack, Hand hand) {
|
||||
if (!world.isClient || !(player instanceof ClientPlayerEntity)) {
|
||||
return;
|
||||
}
|
||||
|
||||
MinecraftClient mc = MinecraftClient.getInstance();
|
||||
|
||||
double distance = mc.interactionManager.getReachDistance();
|
||||
|
||||
float ticks = mc.getTickDelta();
|
||||
|
||||
Vec3d eye = player.getCameraPosVec(ticks);
|
||||
Vec3d look = player.getOppositeRotationVector(ticks);
|
||||
Vec3d ray = eye.add(look.x * distance, look.y * distance, look.z * distance);
|
||||
|
||||
float s = 0.5F;
|
||||
Box bounds = getBoundingBox().shrink(0, s, 0).shrink(0, -s, 0);
|
||||
|
||||
BlockHitResult hit = Box.rayTrace(Lists.newArrayList(bounds), eye, ray, BlockPos.ORIGIN);
|
||||
|
||||
if (hit != null) {
|
||||
Direction direction = hit.getSide();
|
||||
|
||||
mc.hitResult = hit = new BlockHitResult(hit.getPos(), direction, new BlockPos(hit.getPos()), false);
|
||||
|
||||
int oldCount = stack.getCount();
|
||||
ActionResult result = mc.interactionManager.interactBlock(((ClientPlayerEntity)player), (ClientWorld)player.world, hand, hit);
|
||||
|
||||
if (result == ActionResult.SUCCESS) {
|
||||
player.swingHand(hand);
|
||||
|
||||
if (!stack.isEmpty() && (stack.getCount() != oldCount || mc.interactionManager.hasCreativeInventory())) {
|
||||
mc.gameRenderer.firstPersonRenderer.resetEquipProgress(hand);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
}
|
|
@ -1,104 +0,0 @@
|
|||
package com.minelittlepony.unicopia.entity;
|
||||
|
||||
import com.minelittlepony.unicopia.Predicates;
|
||||
|
||||
import net.minecraft.client.Minecraft;
|
||||
import net.minecraft.client.entity.PlayerEntitySP;
|
||||
import net.minecraft.client.multiplayer.WorldClient;
|
||||
import net.minecraft.entity.EntityList;
|
||||
import net.minecraft.entity.player.PlayerEntity;
|
||||
import net.minecraft.init.Items;
|
||||
import net.minecraft.item.ItemBlock;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.util.EnumActionResult;
|
||||
import net.minecraft.util.Direction;
|
||||
import net.minecraft.util.EnumHand;
|
||||
import net.minecraft.util.math.Box;
|
||||
import net.minecraft.util.math.BlockPos;
|
||||
import net.minecraft.util.math.RayTraceResult;
|
||||
import net.minecraft.util.math.Vec3d;
|
||||
import net.minecraft.world.World;
|
||||
|
||||
public class EntityConstructionCloud extends EntityCloud {
|
||||
|
||||
public EntityConstructionCloud(World world) {
|
||||
super(world);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean getStationary() {
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean getOpaque() {
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public EnumActionResult applyPlayerInteraction(PlayerEntity player, Vec3d vec, EnumHand hand) {
|
||||
if (!(isBeingRidden() || isRidingOrBeingRiddenBy(player)) && hand == EnumHand.MAIN_HAND) {
|
||||
if (Predicates.INTERACT_WITH_CLOUDS.test(player)) {
|
||||
|
||||
if (player.getItemInUseCount() > 0) {
|
||||
return EnumActionResult.FAIL;
|
||||
}
|
||||
|
||||
ItemStack stack = player.getStackInHand(hand);
|
||||
|
||||
if (stack != null) {
|
||||
if (stack.getItem() instanceof ItemBlock || stack.getItem() == Items.SPAWN_EGG && stack.getItemDamage() == EntityList.getID(EntityCloud.class)) {
|
||||
placeBlock(player, stack, hand);
|
||||
return EnumActionResult.SUCCESS;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return EnumActionResult.FAIL;
|
||||
}
|
||||
|
||||
private void placeBlock(PlayerEntity player, ItemStack stack, EnumHand hand) {
|
||||
if (!world.isClient || !(player instanceof PlayerEntitySP)) {
|
||||
return;
|
||||
}
|
||||
|
||||
Minecraft mc = MinecraftClient.getInstance();
|
||||
|
||||
double distance = mc.playerController.getBlockReachDistance();
|
||||
|
||||
float ticks = mc.getRenderPartialTicks();
|
||||
|
||||
Vec3d eye = player.getPositionEyes(ticks);
|
||||
Vec3d look = player.getLook(ticks);
|
||||
Vec3d ray = eye.add(look.x * distance, look.y * distance, look.z * distance);
|
||||
|
||||
Box bounds = getEntityBoundingBox();
|
||||
|
||||
float s = 0.5F;
|
||||
RayTraceResult trace = bounds
|
||||
.contract(0, s, 0).contract(0, -s, 0)
|
||||
.calculateIntercept(eye, ray);
|
||||
|
||||
if (trace == null) {
|
||||
return;
|
||||
}
|
||||
|
||||
Direction direction = trace.sideHit;
|
||||
|
||||
BlockPos blockPos = new BlockPos(trace.hitVec);
|
||||
|
||||
mc.objectMouseOver = new RayTraceResult(trace.hitVec, direction, blockPos);
|
||||
|
||||
int oldCount = stack.getCount();
|
||||
EnumActionResult result = mc.playerController.processRightClickBlock(((PlayerEntitySP)player), (WorldClient)player.world, blockPos, direction, trace.hitVec, hand);
|
||||
|
||||
if (result == EnumActionResult.SUCCESS) {
|
||||
player.swingArm(hand);
|
||||
|
||||
if (!stack.isEmpty() && (stack.getCount() != oldCount || mc.playerController.isInCreativeMode())) {
|
||||
mc.entityRenderer.itemRenderer.resetEquippedProgress(hand);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
|
@ -5,39 +5,43 @@ import java.util.List;
|
|||
import javax.annotation.Nullable;
|
||||
|
||||
import com.google.common.collect.Lists;
|
||||
import com.minelittlepony.unicopia.Predicates;
|
||||
import com.minelittlepony.unicopia.EquinePredicates;
|
||||
import com.minelittlepony.unicopia.Race;
|
||||
import com.minelittlepony.unicopia.UParticles;
|
||||
import com.minelittlepony.unicopia.USounds;
|
||||
import com.minelittlepony.unicopia.ability.IPower;
|
||||
import com.minelittlepony.unicopia.particles.ParticleEmitter;
|
||||
import com.minelittlepony.util.MagicalDamageSource;
|
||||
|
||||
import net.minecraft.block.Block;
|
||||
import net.minecraft.block.Blocks;
|
||||
import net.minecraft.entity.Entity;
|
||||
import net.minecraft.entity.EntityDimensions;
|
||||
import net.minecraft.entity.EntityType;
|
||||
import net.minecraft.entity.EquipmentSlot;
|
||||
import net.minecraft.entity.ExperienceOrbEntity;
|
||||
import net.minecraft.entity.LivingEntity;
|
||||
import net.minecraft.entity.item.EntityXPOrb;
|
||||
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.effect.StatusEffectInstance;
|
||||
import net.minecraft.entity.effect.StatusEffects;
|
||||
import net.minecraft.entity.player.PlayerEntity;
|
||||
import net.minecraft.init.Blocks;
|
||||
import net.minecraft.init.MobEffects;
|
||||
import net.minecraft.init.SoundEvents;
|
||||
import net.minecraft.inventory.EntityEquipmentSlot;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.nbt.NBTTagCompound;
|
||||
import net.minecraft.network.datasync.TrackedData;
|
||||
import net.minecraft.network.datasync.TrackedDataHandlerRegistry;
|
||||
import net.minecraft.network.datasync.EntityDataManager;
|
||||
import net.minecraft.potion.PotionEffect;
|
||||
import net.minecraft.util.DamageSource;
|
||||
import net.minecraft.util.EnumActionResult;
|
||||
import net.minecraft.util.EnumHand;
|
||||
import net.minecraft.util.EnumHandSide;
|
||||
import net.minecraft.util.EnumParticleTypes;
|
||||
import net.minecraft.util.SoundEvent;
|
||||
import net.minecraft.nbt.CompoundTag;
|
||||
import net.minecraft.particle.BlockStateParticleEffect;
|
||||
import net.minecraft.particle.ParticleTypes;
|
||||
import net.minecraft.sound.SoundEvent;
|
||||
import net.minecraft.sound.SoundEvents;
|
||||
import net.minecraft.util.ActionResult;
|
||||
import net.minecraft.util.Arm;
|
||||
import net.minecraft.util.Hand;
|
||||
import net.minecraft.util.math.Box;
|
||||
import net.minecraft.util.math.MathHelper;
|
||||
import net.minecraft.util.math.Vec3d;
|
||||
import net.minecraft.world.GameRules;
|
||||
import net.minecraft.world.World;
|
||||
import net.minecraftforge.event.ForgeEventFactory;
|
||||
|
||||
public class EntityCuccoon extends LivingEntity implements IMagicals, IInAnimate {
|
||||
|
||||
|
@ -47,12 +51,10 @@ public class EntityCuccoon extends LivingEntity implements IMagicals, IInAnimate
|
|||
|
||||
private boolean captiveLastSneakState;
|
||||
|
||||
public EntityCuccoon(World world) {
|
||||
super(world);
|
||||
setSize(0.6f, 0.6f);
|
||||
|
||||
width = 1.5F;
|
||||
height = 1.6F;
|
||||
public EntityCuccoon(EntityType<EntityCuccoon> type, World world) {
|
||||
super(type, world);
|
||||
//width = 1.5F;
|
||||
//height = 1.6F;
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -62,11 +64,11 @@ public class EntityCuccoon extends LivingEntity implements IMagicals, IInAnimate
|
|||
}
|
||||
|
||||
public int getStruggleCount() {
|
||||
return getDataManager().get(STRUGGLE_COUNT) % 6;
|
||||
return getDataTracker().get(STRUGGLE_COUNT) % 6;
|
||||
}
|
||||
|
||||
public void setStruggleCount(int count) {
|
||||
getDataManager().set(STRUGGLE_COUNT, count % 6);
|
||||
getDataTracker().set(STRUGGLE_COUNT, count % 6);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -81,50 +83,40 @@ public class EntityCuccoon extends LivingEntity implements IMagicals, IInAnimate
|
|||
}
|
||||
|
||||
@Override
|
||||
public boolean attackEntityFrom(DamageSource source, float amount) {
|
||||
public boolean damage(DamageSource source, float amount) {
|
||||
|
||||
if (Predicates.BUGGY.test(source.getTrueSource())) {
|
||||
if (EquinePredicates.BUGGY.test(source.getSource())) {
|
||||
amount = 0;
|
||||
}
|
||||
|
||||
return super.attackEntityFrom(source, amount);
|
||||
return super.damage(source, amount);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected boolean canBeRidden(Entity entity) {
|
||||
return super.canBeRidden(entity)
|
||||
protected boolean canAddPassenger(Entity entity) {
|
||||
return super.canAddPassenger(entity)
|
||||
&& !entity.isSneaking()
|
||||
&& !isBeingRidden()
|
||||
&& !hasPassengers()
|
||||
&& entity instanceof LivingEntity
|
||||
&& !Predicates.BUGGY.test(entity);
|
||||
&& !EquinePredicates.BUGGY.test(entity);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean canRenderOnFire() {
|
||||
public boolean doesRenderOnFire() {
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected boolean canTriggerWalking() {
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public double getMountedYOffset() {
|
||||
public double getMountedHeightOffset() {
|
||||
return 0;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean canPassengerSteer() {
|
||||
return false;
|
||||
}
|
||||
public void tick() {
|
||||
super.tick();
|
||||
|
||||
@Override
|
||||
public void onUpdate() {
|
||||
super.onUpdate();
|
||||
|
||||
if (isBeingRidden()) {
|
||||
Entity passenger = getPassengers().get(0);
|
||||
if (hasPassengers()) {
|
||||
Entity passenger = getPrimaryPassenger();
|
||||
|
||||
boolean sneaking = passenger.isSneaking();
|
||||
|
||||
|
@ -137,76 +129,75 @@ public class EntityCuccoon extends LivingEntity implements IMagicals, IInAnimate
|
|||
if (passenger instanceof LivingEntity) {
|
||||
LivingEntity living = (LivingEntity)passenger;
|
||||
|
||||
if (!living.isPotionActive(MobEffects.REGENERATION) && living.getHealth() < living.getMaxHealth()) {
|
||||
living.addPotionEffect(new PotionEffect(MobEffects.REGENERATION, 20, 2));
|
||||
if (!living.hasStatusEffect(StatusEffects.REGENERATION) && living.getHealth() < living.getHealthMaximum()) {
|
||||
living.addPotionEffect(new StatusEffectInstance(StatusEffects.REGENERATION, 20, 2));
|
||||
}
|
||||
|
||||
if (!living.isPotionActive(MobEffects.SLOWNESS) && living.getHealth() < living.getMaxHealth()) {
|
||||
living.addPotionEffect(new PotionEffect(MobEffects.SLOWNESS, 2000, 4));
|
||||
if (!living.hasStatusEffect(StatusEffects.SLOWNESS) && living.getHealth() < living.getHealthMaximum()) {
|
||||
living.addPotionEffect(new StatusEffectInstance(StatusEffects.SLOWNESS, 2000, 4));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (world.isClient) {
|
||||
double x = posX + width * world.rand.nextFloat() - width/2;
|
||||
double y = posY + height * world.rand.nextFloat();
|
||||
double z = posZ + width * world.rand.nextFloat() - width/2;
|
||||
double x = this.x + width * random.nextFloat() - width/2;
|
||||
double y = this.y + height * random.nextFloat();
|
||||
double z = this.z + width * random.nextFloat() - width/2;
|
||||
|
||||
world.spawnParticle(EnumParticleTypes.DRIP_LAVA, x, y, z, 0, 0, 0);
|
||||
world.addParticle(ParticleTypes.DRIPPING_LAVA, x, y, z, 0, 0, 0);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public EnumActionResult applyPlayerInteraction(PlayerEntity player, Vec3d vec, EnumHand hand) {
|
||||
public ActionResult interactAt(PlayerEntity player, Vec3d vec, Hand hand) {
|
||||
|
||||
if (hand == EnumHand.MAIN_HAND && Predicates.BUGGY.test(player)) {
|
||||
if (hand == Hand.MAIN_HAND && EquinePredicates.BUGGY.test(player)) {
|
||||
|
||||
if (isBeingRidden()) {
|
||||
Entity passenger = getPassengers().get(0);
|
||||
if (hasPassengers()) {
|
||||
Entity passenger = getPrimaryPassenger();
|
||||
|
||||
if (player.canEat(false) || player.getHealth() < player.getMaxHealth()) {
|
||||
if (player.canConsume(false) || player.getHealth() < player.getHealthMaximum()) {
|
||||
DamageSource d = MagicalDamageSource.causePlayerDamage("feed", player);
|
||||
|
||||
|
||||
IPower.spawnParticles(UParticles.CHANGELING_MAGIC, this, 7);
|
||||
|
||||
if (passenger instanceof LivingEntity) {
|
||||
if (player.isPotionActive(MobEffects.NAUSEA)) {
|
||||
((LivingEntity)passenger).addPotionEffect(player.removeActivePotionEffect(MobEffects.NAUSEA));
|
||||
} else if (world.rand.nextInt(2300) == 0) {
|
||||
((LivingEntity)passenger).addPotionEffect(new PotionEffect(MobEffects.WITHER, 20, 1));
|
||||
if (player.hasStatusEffect(StatusEffects.NAUSEA)) {
|
||||
((LivingEntity)passenger).addPotionEffect(player.removePotionEffect(StatusEffects.NAUSEA));
|
||||
} else if (random.nextInt(2300) == 0) {
|
||||
((LivingEntity)passenger).addPotionEffect(new StatusEffectInstance(StatusEffects.WITHER, 20, 1));
|
||||
}
|
||||
}
|
||||
|
||||
if (passenger instanceof PlayerEntity) {
|
||||
if (!player.isPotionActive(MobEffects.HEALTH_BOOST)) {
|
||||
player.addPotionEffect(new PotionEffect(MobEffects.HEALTH_BOOST, 13000, 1));
|
||||
if (!player.hasStatusEffect(StatusEffects.HEALTH_BOOST)) {
|
||||
player.addPotionEffect(new StatusEffectInstance(StatusEffects.HEALTH_BOOST, 13000, 1));
|
||||
}
|
||||
}
|
||||
|
||||
passenger.attackEntityFrom(d, 5);
|
||||
passenger.damage(d, 5);
|
||||
|
||||
if (player.canEat(false)) {
|
||||
player.getFoodStats().addStats(5, 0);
|
||||
if (player.canConsume(false)) {
|
||||
player.getHungerManager().add(5, 0);
|
||||
} else {
|
||||
player.heal(5);
|
||||
}
|
||||
|
||||
return EnumActionResult.SUCCESS;
|
||||
return ActionResult.SUCCESS;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return super.applyPlayerInteraction(player, vec, hand);
|
||||
return super.interactAt(player, vec, hand);
|
||||
}
|
||||
|
||||
public float getBreatheAmount(float stutter) {
|
||||
return MathHelper.sin((ticksExisted + stutter) / 40) / 2
|
||||
return MathHelper.sin((age + stutter) / 40) / 2
|
||||
+ hurtTime / 10F;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean attackable() {
|
||||
public boolean isAttackable() {
|
||||
return false;
|
||||
}
|
||||
|
||||
|
@ -214,23 +205,13 @@ public class EntityCuccoon extends LivingEntity implements IMagicals, IInAnimate
|
|||
if (captive.isSneaking() != captiveLastSneakState) {
|
||||
setStruggleCount(getStruggleCount() + 1);
|
||||
|
||||
for (int k = 0; k < 20; k++) {
|
||||
double d2 = rand.nextGaussian() * 0.02;
|
||||
double d0 = rand.nextGaussian() * 0.02;
|
||||
double d1 = rand.nextGaussian() * 0.02;
|
||||
|
||||
world.spawnParticle(EnumParticleTypes.BLOCK_CRACK,
|
||||
posX + rand.nextFloat() * width * 2 - width,
|
||||
posY + rand.nextFloat() * height,
|
||||
posZ + rand.nextFloat() * width * 2 - width,
|
||||
d2, d0, d1, Block.getStateId(Blocks.SLIME_BLOCK.getDefaultState()));
|
||||
}
|
||||
spawnSlimeParticles();
|
||||
|
||||
captive.playSound(USounds.SLIME_RETRACT, 1, 1);
|
||||
this.hurtTime += 15;
|
||||
|
||||
if (getStruggleCount() == 0) {
|
||||
setDead();
|
||||
remove();
|
||||
|
||||
return true;
|
||||
}
|
||||
|
@ -239,47 +220,53 @@ public class EntityCuccoon extends LivingEntity implements IMagicals, IInAnimate
|
|||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void onDeathUpdate() {
|
||||
if (++deathTime == 20) {
|
||||
if (!world.isClient && (isPlayer() || recentlyHit > 0 && canDropLoot() && world.getGameRules().getBoolean("doMobLoot"))) {
|
||||
int i = ForgeEventFactory.getExperienceDrop(this, attackingPlayer, getExperiencePoints(attackingPlayer));
|
||||
private void spawnSlimeParticles() {
|
||||
EntityDimensions dims = getDimensions(getPose());
|
||||
|
||||
while (i > 0) {
|
||||
int j = EntityXPOrb.getXPSplit(i);
|
||||
for (int k = 0; k < 20; k++) {
|
||||
double d2 = random.nextGaussian() * 0.02;
|
||||
double d0 = random.nextGaussian() * 0.02;
|
||||
double d1 = random.nextGaussian() * 0.02;
|
||||
|
||||
i -= j;
|
||||
|
||||
world.spawnEntity(new EntityXPOrb(world, posX, posY, posZ, j));
|
||||
}
|
||||
|
||||
this.dismountRidingEntity();
|
||||
}
|
||||
|
||||
setDead();
|
||||
|
||||
for (int k = 0; k < 20; k++) {
|
||||
double d2 = rand.nextGaussian() * 0.02;
|
||||
double d0 = rand.nextGaussian() * 0.02;
|
||||
double d1 = rand.nextGaussian() * 0.02;
|
||||
|
||||
world.spawnParticle(EnumParticleTypes.BLOCK_CRACK,
|
||||
posX + rand.nextFloat() * width * 2 - width,
|
||||
posY + rand.nextFloat() * height,
|
||||
posZ + rand.nextFloat() * width * 2 - width,
|
||||
d2, d0, d1, Block.getStateId(Blocks.SLIME_BLOCK.getDefaultState()));
|
||||
}
|
||||
world.addParticle(new BlockStateParticleEffect(ParticleTypes.BLOCK, Blocks.SLIME_BLOCK.getDefaultState()),
|
||||
x + random.nextFloat() * dims.width * 2 - dims.width,
|
||||
y + random.nextFloat() * dims.height,
|
||||
z + random.nextFloat() * dims.width * 2 - dims.width,
|
||||
d2, d0, d1);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void onDeathUpdate() {
|
||||
if (++deathTime == 20) {
|
||||
if (!world.isClient && lastAttackedTicks > 0 && canDropLootAndXp() && world.getGameRules().getBoolean(GameRules.DO_MOB_LOOT)) {
|
||||
int i = getCurrentExperience(attackingPlayer);
|
||||
|
||||
while (i > 0) {
|
||||
int j = ExperienceOrbEntity.roundToOrbSize(i);
|
||||
|
||||
i -= j;
|
||||
|
||||
world.spawnEntity(new ExperienceOrbEntity(world, x, y, z, j));
|
||||
}
|
||||
|
||||
removeAllPassengers();
|
||||
}
|
||||
|
||||
remove();
|
||||
spawnSlimeParticles();
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
@Nullable
|
||||
public Box getCollisionBox(Entity entity) {
|
||||
return entity.canBeCollidedWith() ? entity.getEntityBoundingBox() : null;
|
||||
public Box getHardCollisionBox(Entity entity) {
|
||||
return entity.collides() ? entity.getBoundingBox() : null;
|
||||
}
|
||||
|
||||
@Nullable
|
||||
public Box getCollisionBoundingBox() {
|
||||
return getEntityBoundingBox().shrink(0.2);
|
||||
return getBoundingBox().contract(0.2);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -292,38 +279,27 @@ public class EntityCuccoon extends LivingEntity implements IMagicals, IInAnimate
|
|||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void readEntityFromNBT(NBTTagCompound compound) {
|
||||
super.readEntityFromNBT(compound);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void writeEntityToNBT(NBTTagCompound compound) {
|
||||
super.writeEntityToNBT(compound);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean canInteract(Race race) {
|
||||
return race == Race.CHANGELING;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Iterable<ItemStack> getArmorInventoryList() {
|
||||
public Iterable<ItemStack> getArmorItems() {
|
||||
return armour;
|
||||
}
|
||||
|
||||
@Override
|
||||
public ItemStack getItemStackFromSlot(EntityEquipmentSlot slotIn) {
|
||||
public ItemStack getEquippedStack(EquipmentSlot slot) {
|
||||
return ItemStack.EMPTY;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setItemStackToSlot(EntityEquipmentSlot slotIn, ItemStack stack) {
|
||||
|
||||
public void setEquippedStack(EquipmentSlot slot, ItemStack stack) {
|
||||
}
|
||||
|
||||
@Override
|
||||
public EnumHandSide getPrimaryHand() {
|
||||
return EnumHandSide.LEFT;
|
||||
public Arm getMainArm() {
|
||||
return Arm.LEFT;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -28,7 +28,7 @@ public class EntityFakeClientPlayer extends AbstractClientPlayer implements IOwn
|
|||
@Nullable
|
||||
protected NetworkPlayerInfo getPlayerInfo() {
|
||||
if (playerInfo == null) {
|
||||
NetHandlerPlayClient connection = MinecraftClient.getInstance().getConnection();
|
||||
NetHandlerPlayClient connection = MinecraftClient.instance().getConnection();
|
||||
|
||||
playerInfo = connection.getPlayerInfo(getGameProfile().getId());
|
||||
|
||||
|
|
|
@ -4,20 +4,19 @@ import java.util.List;
|
|||
|
||||
import javax.annotation.Nullable;
|
||||
|
||||
import com.minelittlepony.unicopia.Predicates;
|
||||
import com.minelittlepony.unicopia.EquinePredicates;
|
||||
|
||||
import net.minecraft.entity.Entity;
|
||||
import net.minecraft.entity.EntityType;
|
||||
import net.minecraft.entity.LivingEntity;
|
||||
import net.minecraft.entity.player.PlayerEntity;
|
||||
import net.minecraft.util.EnumActionResult;
|
||||
import net.minecraft.util.EnumHand;
|
||||
import net.minecraft.util.math.Vec3d;
|
||||
import net.minecraft.world.World;
|
||||
|
||||
public class EntityRacingCloud extends EntityCloud {
|
||||
public class EntityRacingCloud extends CloudEntity {
|
||||
|
||||
public EntityRacingCloud(World world) {
|
||||
super(world);
|
||||
public EntityRacingCloud(EntityType<EntityRacingCloud> type, World world) {
|
||||
super(type, world);
|
||||
setCloudSize(1);
|
||||
}
|
||||
|
||||
|
@ -41,7 +40,7 @@ public class EntityRacingCloud extends EntityCloud {
|
|||
@Override
|
||||
public EnumActionResult applyPlayerInteraction(PlayerEntity player, Vec3d vec, EnumHand hand) {
|
||||
if (!(isBeingRidden() || isRidingOrBeingRiddenBy(player)) && hand == EnumHand.MAIN_HAND) {
|
||||
if (Predicates.INTERACT_WITH_CLOUDS.test(player)) {
|
||||
if (EquinePredicates.INTERACT_WITH_CLOUDS.test(player)) {
|
||||
if (!getStationary()) {
|
||||
player.startRiding(this);
|
||||
return EnumActionResult.SUCCESS;
|
||||
|
|
|
@ -5,6 +5,7 @@ import com.minelittlepony.util.MagicalDamageSource;
|
|||
|
||||
import net.minecraft.enchantment.EnchantmentHelper;
|
||||
import net.minecraft.entity.Entity;
|
||||
import net.minecraft.entity.EntityType;
|
||||
import net.minecraft.entity.LivingEntity;
|
||||
import net.minecraft.entity.data.DataTracker;
|
||||
import net.minecraft.entity.data.TrackedData;
|
||||
|
@ -24,8 +25,8 @@ public class EntitySpear extends ArrowEntity implements IAdvancedProjectile {
|
|||
|
||||
private static final TrackedData<Integer> KNOCKBACK = DataTracker.registerData(EntitySpear.class, TrackedDataHandlerRegistry.INTEGER);
|
||||
|
||||
public EntitySpear(World world) {
|
||||
super(world);
|
||||
public EntitySpear(EntityType<EntitySpear> type, World world) {
|
||||
super(type, world);
|
||||
}
|
||||
|
||||
public EntitySpear(World world, double x, double y, double z) {
|
||||
|
|
|
@ -1,199 +0,0 @@
|
|||
package com.minelittlepony.unicopia.entity;
|
||||
|
||||
import com.minelittlepony.unicopia.Predicates;
|
||||
import com.minelittlepony.unicopia.UItems;
|
||||
import com.minelittlepony.unicopia.Unicopia;
|
||||
|
||||
import net.minecraft.block.SoundType;
|
||||
import net.minecraft.entity.EntityLiving;
|
||||
import net.minecraft.entity.player.PlayerEntity;
|
||||
import net.minecraft.init.SoundEvents;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.nbt.NBTTagCompound;
|
||||
import net.minecraft.network.datasync.TrackedData;
|
||||
import net.minecraft.network.datasync.TrackedDataHandlerRegistry;
|
||||
import net.minecraft.network.datasync.EntityDataManager;
|
||||
import net.minecraft.util.DamageSource;
|
||||
import net.minecraft.util.EnumActionResult;
|
||||
import net.minecraft.util.EnumHand;
|
||||
import net.minecraft.util.EnumParticleTypes;
|
||||
import net.minecraft.util.SoundCategory;
|
||||
import net.minecraft.util.math.RayTraceResult;
|
||||
import net.minecraft.util.math.Vec3d;
|
||||
import net.minecraft.world.World;
|
||||
|
||||
public class EntitySpellbook extends EntityLiving implements IMagicals {
|
||||
|
||||
private static final TrackedData<Boolean> OPENED = DataTracker.registerData(EntitySpellbook.class, TrackedDataHandlerRegistry.BOOLEAN);
|
||||
private static final TrackedData<Boolean> ALTERED = DataTracker.registerData(EntitySpellbook.class, TrackedDataHandlerRegistry.BOOLEAN);
|
||||
private static final TrackedData<Byte> OPENED_USER = DataTracker.registerData(EntitySpellbook.class, TrackedDataHandlerRegistry.BYTE);
|
||||
|
||||
public EntitySpellbook(World worldIn) {
|
||||
super(worldIn);
|
||||
setSize(0.6f, 0.6f);
|
||||
enablePersistence();
|
||||
|
||||
if (world.rand.nextInt(3) == 0) {
|
||||
setAltered();
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void initDataTracker() {
|
||||
super.initDataTracker();
|
||||
dataManager.register(OPENED, true);
|
||||
dataManager.register(OPENED_USER, (byte)1);
|
||||
dataManager.register(ALTERED, false);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected boolean canTriggerWalking() {
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isPushedByWater() {
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean canRenderOnFire() {
|
||||
return false;
|
||||
}
|
||||
|
||||
public boolean getIsAltered() {
|
||||
return dataManager.get(ALTERED);
|
||||
}
|
||||
|
||||
public void setAltered() {
|
||||
dataManager.set(ALTERED, true);
|
||||
}
|
||||
|
||||
public boolean getIsOpen() {
|
||||
return dataManager.get(OPENED);
|
||||
}
|
||||
|
||||
public Boolean getUserSetState() {
|
||||
byte state = dataManager.get(OPENED_USER);
|
||||
return state == 1 ? null : state == 2;
|
||||
}
|
||||
|
||||
public void setIsOpen(boolean val) {
|
||||
dataManager.set(OPENED, val);
|
||||
}
|
||||
|
||||
public void setUserSetState(Boolean val) {
|
||||
dataManager.set(OPENED_USER, val == null ? (byte)1 : val == true ? (byte)2 : (byte)0);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onUpdate() {
|
||||
boolean open = getIsOpen();
|
||||
this.isJumping = open && isInWater();
|
||||
super.onUpdate();
|
||||
if (open && world.isClient) {
|
||||
|
||||
for (int offX = -2; offX <= 1; ++offX) {
|
||||
for (int offZ = -2; offZ <= 1; ++offZ) {
|
||||
if (offX > -1 && offX < 1 && offZ == -1) {
|
||||
offZ = 1;
|
||||
}
|
||||
|
||||
if (rand.nextInt(320) == 0) {
|
||||
for (int offY = 0; offY <= 1; ++offY) {
|
||||
world.spawnParticle(EnumParticleTypes.ENCHANTMENT_TABLE,
|
||||
posX, posY, posZ,
|
||||
offX/2F + rand.nextFloat(),
|
||||
offY/2F - rand.nextFloat() + 0.5f,
|
||||
offZ/2F + rand.nextFloat()
|
||||
);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (world.rand.nextInt(30) == 0) {
|
||||
float celest = world.getCelestialAngle(1) * 4;
|
||||
|
||||
boolean isDay = celest > 3 || celest < 1;
|
||||
|
||||
Boolean userState = getUserSetState();
|
||||
|
||||
boolean canToggle = (isDay != open) && (userState == null || userState == isDay);
|
||||
|
||||
if (canToggle) {
|
||||
setUserSetState(null);
|
||||
setIsOpen(isDay);
|
||||
}
|
||||
|
||||
if (userState != null && (isDay == open) && (userState == open)) {
|
||||
setUserSetState(null);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean attackEntityFrom(DamageSource source, float amount) {
|
||||
if (!world.isClient) {
|
||||
setDead();
|
||||
|
||||
SoundType sound = SoundType.WOOD;
|
||||
|
||||
world.playSound(posX, posY, posZ, sound.getBreakSound(), SoundCategory.BLOCKS, sound.getVolume(), sound.getPitch(), true);
|
||||
|
||||
if (world.getGameRules().getBoolean("doTileDrops")) {
|
||||
entityDropItem(new ItemStack(UItems.spellbook), 0);
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public EnumActionResult applyPlayerInteraction(PlayerEntity player, Vec3d vec, EnumHand hand) {
|
||||
if (player.isSneaking()) {
|
||||
boolean open = !getIsOpen();
|
||||
|
||||
setIsOpen(open);
|
||||
setUserSetState(open);
|
||||
|
||||
return EnumActionResult.SUCCESS;
|
||||
}
|
||||
|
||||
if (Predicates.MAGI.test(player)) {
|
||||
|
||||
player.playSound(SoundEvents.BLOCK_FURNACE_FIRE_CRACKLE, 2, 1);
|
||||
|
||||
player.openGui(Unicopia.MODID, 0, world, (int)posX, (int)posY, (int)posZ);
|
||||
|
||||
return EnumActionResult.SUCCESS;
|
||||
}
|
||||
|
||||
return EnumActionResult.PASS;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void readEntityFromNBT(NBTTagCompound compound) {
|
||||
super.readEntityFromNBT(compound);
|
||||
|
||||
setIsOpen(compound.getBoolean("open"));
|
||||
setUserSetState(compound.hasKey("force_open") ? compound.getBoolean("force_open") : null);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void writeEntityToNBT(NBTTagCompound compound) {
|
||||
super.writeEntityToNBT(compound);
|
||||
compound.setBoolean("open", getIsOpen());
|
||||
|
||||
Boolean state = getUserSetState();
|
||||
|
||||
if (state != null) {
|
||||
compound.setBoolean("force_open", state);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public ItemStack getPickedResult(RayTraceResult target) {
|
||||
return new ItemStack(UItems.spellbook);
|
||||
}
|
||||
}
|
|
@ -1,126 +0,0 @@
|
|||
package com.minelittlepony.unicopia.entity;
|
||||
|
||||
import java.util.Iterator;
|
||||
|
||||
import net.minecraft.entity.Entity;
|
||||
import net.minecraft.entity.IEntityLivingData;
|
||||
import net.minecraft.util.ClassInheritanceMultiMap;
|
||||
import net.minecraft.util.math.Box;
|
||||
import net.minecraft.util.math.BlockPos;
|
||||
import net.minecraft.util.math.Vec3d;
|
||||
import net.minecraft.world.DifficultyInstance;
|
||||
import net.minecraft.world.World;
|
||||
import net.minecraft.world.biome.Biome.SpawnListEntry;
|
||||
import net.minecraft.world.chunk.Chunk;
|
||||
|
||||
public class EntityWildCloud extends EntityCloud {
|
||||
|
||||
public static final SpawnListEntry SPAWN_ENTRY_LAND = new SpawnListEntry(EntityWildCloud.class, 1, 1, 15);
|
||||
public static final SpawnListEntry SPAWN_ENTRY_OCEAN = new SpawnListEntry(EntityWildCloud.class, 1, 1, 7);
|
||||
|
||||
public EntityWildCloud(World world) {
|
||||
super(world);
|
||||
|
||||
preventEntitySpawning = true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isNotColliding() {
|
||||
Box boundingbox = getEntityBoundingBox();
|
||||
|
||||
return checkNoEntityCollision(boundingbox, this)
|
||||
&& world.canBlockSeeSky(new BlockPos(this))
|
||||
&& world.getCollisionBoxes(this, boundingbox).isEmpty()
|
||||
&& !world.containsAnyLiquid(boundingbox);
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns true if there are no solid, live entities in the specified Box, excluding the given entity
|
||||
*
|
||||
* @ref World.checkNoEntityCollision(Box area, Entity entity)
|
||||
*/
|
||||
public boolean checkNoEntityCollision(Box area, Entity entity) {
|
||||
|
||||
for (Entity i : world.getEntitiesWithinAABBExcludingEntity(entity, area)) {
|
||||
if (!i.isDead && (i.preventEntitySpawning || i instanceof EntityCloud) && (!entity.isRiding() || !entity.isRidingOrBeingRiddenBy(i))) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean getCanSpawnHere() {
|
||||
int count = 0;
|
||||
|
||||
BlockPos pos = new BlockPos(this);
|
||||
|
||||
Chunk chunk = world.getChunk(pos);
|
||||
for (ClassInheritanceMultiMap<Entity> i : chunk.getEntityLists()) {
|
||||
Iterator<EntityCloud> iter = i.getByClass(EntityCloud.class).iterator();
|
||||
while (iter.hasNext()) {
|
||||
iter.next();
|
||||
|
||||
if (count++ > 2) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return world.getBlockState(pos.down()).canEntitySpawn(this);
|
||||
}
|
||||
|
||||
@Override
|
||||
public IEntityLivingData onInitialSpawn(DifficultyInstance difficulty, IEntityLivingData pack) {
|
||||
pack = super.onInitialSpawn(difficulty, pack);
|
||||
|
||||
if (!(pack instanceof PackData)) {
|
||||
float minSpawnHeight = getMinimumFlyingHeight();
|
||||
|
||||
targetAltitude = getRandomFlyingHeight();
|
||||
|
||||
if (posY < minSpawnHeight) {
|
||||
minSpawnHeight += world.rand.nextInt(Math.max(1, (int)getMaximumFlyingHeight() - (int)minSpawnHeight));
|
||||
|
||||
setLocationAndAngles(posX, minSpawnHeight - 1, posZ, rotationYaw, rotationPitch);
|
||||
collideWithNearbyEntities();
|
||||
}
|
||||
|
||||
if (world.isRainingAt(getPosition())) {
|
||||
setIsRaining(true);
|
||||
}
|
||||
|
||||
if (world.isThundering()) {
|
||||
setIsThundering(true);
|
||||
}
|
||||
|
||||
pack = new PackData(this);
|
||||
} else {
|
||||
PackData packData = (PackData)pack;
|
||||
targetAltitude = packData.leader.targetAltitude;
|
||||
|
||||
Vec3d position = packData.getUnOccupiedPosition(getCloudSize());
|
||||
|
||||
setIsRaining(packData.leader.getIsRaining());
|
||||
setIsThundering(packData.leader.getIsThundering());
|
||||
|
||||
setLocationAndAngles(position.x, position.y, position.z, packData.leader.rotationYaw, packData.leader.rotationPitch);
|
||||
collideWithNearbyEntities();
|
||||
}
|
||||
|
||||
return pack;
|
||||
}
|
||||
|
||||
static class PackData implements IEntityLivingData {
|
||||
|
||||
EntityCloud leader;
|
||||
|
||||
PackData(EntityCloud leader) {
|
||||
this.leader = leader;
|
||||
}
|
||||
|
||||
Vec3d getUnOccupiedPosition(int size) {
|
||||
return leader.getPositionVector();
|
||||
}
|
||||
}
|
||||
}
|
|
@ -1,26 +1,29 @@
|
|||
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;
|
||||
import net.minecraft.entity.Entity;
|
||||
import net.minecraft.entity.EntityType;
|
||||
import net.minecraft.entity.LightningEntity;
|
||||
import net.minecraft.entity.LivingEntity;
|
||||
import net.minecraft.entity.SpawnType;
|
||||
import net.minecraft.entity.mob.MobEntity;
|
||||
import net.minecraft.nbt.CompoundTag;
|
||||
import net.minecraft.network.NetworkThreadUtils;
|
||||
import net.minecraft.network.Packet;
|
||||
import net.minecraft.network.listener.ClientPlayPacketListener;
|
||||
import net.minecraft.sound.SoundCategory;
|
||||
import net.minecraft.util.ThreadExecutor;
|
||||
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.biome.Biome.SpawnEntry;
|
||||
|
||||
public class EntityRainbow extends Entity implements IInAnimate {
|
||||
public class RainbowEntity extends Entity implements IInAnimate {
|
||||
|
||||
public static final SpawnListEntry SPAWN_ENTRY = new SpawnListEntry(EntityRainbow.Spawner.class, 1, 1, 1);
|
||||
public static final SpawnEntry SPAWN_ENTRY = new SpawnEntry(UEntities.RAINBOW_SPAWNER, 1, 1, 1);
|
||||
|
||||
private int ticksAlive;
|
||||
|
||||
|
@ -32,33 +35,23 @@ public class EntityRainbow extends Entity implements IInAnimate {
|
|||
public static final Box SPAWN_COLLISSION_RADIUS = new Box(
|
||||
-RAINBOW_MAX_SIZE, -RAINBOW_MAX_SIZE, -RAINBOW_MAX_SIZE,
|
||||
RAINBOW_MAX_SIZE, RAINBOW_MAX_SIZE, RAINBOW_MAX_SIZE
|
||||
).grow(RAINBOW_MAX_SIZE);
|
||||
).expand(RAINBOW_MAX_SIZE);
|
||||
|
||||
|
||||
public RainbowEntity(EntityType<RainbowEntity> type, World world) {
|
||||
super(type, world);
|
||||
|
||||
public EntityRainbow(World world) {
|
||||
this(world, 0, 0, 0);
|
||||
}
|
||||
float yaw = (int)MathHelper.nextDouble(random, 0, 360);
|
||||
|
||||
public EntityRainbow(World world, double x, double y, double z) {
|
||||
super(world);
|
||||
setPositionAndAngles(0, 0, 0, yaw, 0);
|
||||
|
||||
float yaw = (int)MathHelper.nextDouble((world == null ? rand : world.random), 0, 360);
|
||||
|
||||
setLocationAndAngles(x, y, z, yaw, 0);
|
||||
|
||||
radius = MathHelper.nextDouble(world == null ? rand : world.random, RAINBOW_MIN_SIZE, RAINBOW_MAX_SIZE);
|
||||
radius = MathHelper.nextDouble(random, RAINBOW_MIN_SIZE, RAINBOW_MAX_SIZE);
|
||||
ticksAlive = 10000;
|
||||
|
||||
ignoreFrustumCheck = true;
|
||||
ignoreCameraFrustum = true;
|
||||
|
||||
width = (float)radius;
|
||||
height = width;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean shouldRenderInPass(int pass) {
|
||||
return pass == 1;
|
||||
//width = (float)radius;
|
||||
//height = width;
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -68,10 +61,11 @@ public class EntityRainbow extends Entity implements IInAnimate {
|
|||
|
||||
@Override
|
||||
public void setPosition(double x, double y, double z) {
|
||||
posX = x;
|
||||
posY = y;
|
||||
posZ = z;
|
||||
this.x = x;
|
||||
this.y = y;
|
||||
this.z = z;
|
||||
|
||||
float width = getDimensions(getPose()).width;
|
||||
setBoundingBox(new Box(
|
||||
x - width, y - radius/2, z,
|
||||
x + width, y + radius/2, z
|
||||
|
@ -84,7 +78,7 @@ public class EntityRainbow extends Entity implements IInAnimate {
|
|||
}
|
||||
|
||||
@Override
|
||||
public boolean isInRangeToRenderDist(double distance) {
|
||||
public boolean shouldRenderAtDistance(double distance) {
|
||||
return true;
|
||||
}
|
||||
|
||||
|
@ -101,10 +95,10 @@ public class EntityRainbow extends Entity implements IInAnimate {
|
|||
}
|
||||
|
||||
if (!removed) {
|
||||
Box bounds = SPAWN_COLLISSION_RADIUS.offset(getPosition());
|
||||
Box bounds = SPAWN_COLLISSION_RADIUS.offset(getPos());
|
||||
|
||||
world.getEntities(EntityRainbow.class, bounds).forEach(this::attackCompetitor);
|
||||
world.getEntities(EntityRainbow.Spawner.class, bounds).forEach(this::attackCompetitor);
|
||||
world.getEntities(RainbowEntity.class, bounds).forEach(this::attackCompetitor);
|
||||
world.getEntities(RainbowEntity.Spawner.class, bounds).forEach(this::attackCompetitor);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -133,22 +127,23 @@ public class EntityRainbow extends Entity implements IInAnimate {
|
|||
|
||||
public static class Spawner extends MobEntity {
|
||||
|
||||
public Spawner(World worldIn) {
|
||||
super(worldIn);
|
||||
public Spawner(EntityType<Spawner> type, World world) {
|
||||
super(type, world);
|
||||
this.setInvisible(true);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean getCanSpawnHere() {
|
||||
public boolean canSpawn(IWorld world, SpawnType type) {
|
||||
|
||||
Box bounds = SPAWN_COLLISSION_RADIUS.offset(getPos());
|
||||
|
||||
return super.getCanSpawnHere()
|
||||
&& world.getEntities(EntityRainbow.class, bounds).isEmpty()
|
||||
&& world.getEntities(EntityRainbow.Spawner.class, bounds).isEmpty();
|
||||
return super.canSpawn(world, type)
|
||||
&& world.getEntities(RainbowEntity.class, bounds).isEmpty()
|
||||
&& world.getEntities(RainbowEntity.Spawner.class, bounds).isEmpty();
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getMaxSpawnedInChunk() {
|
||||
public int getLimitPerChunk() {
|
||||
return 1;
|
||||
}
|
||||
|
||||
|
@ -162,14 +157,14 @@ public class EntityRainbow extends Entity implements IInAnimate {
|
|||
}
|
||||
|
||||
public void trySpawnRainbow() {
|
||||
EntityRainbow rainbow = new EntityRainbow(world);
|
||||
RainbowEntity rainbow = UEntities.RAINBOW.create(world);
|
||||
rainbow.setPosition(x, y, z);
|
||||
world.spawnEntity(rainbow);
|
||||
}
|
||||
}
|
||||
|
||||
static class SpawnPacket extends EntitySpawnGlobalS2CPacket {
|
||||
public SpawnPacket(EntityRainbow entity) {
|
||||
public SpawnPacket(RainbowEntity entity) {
|
||||
super(entity);
|
||||
}
|
||||
|
|
@ -0,0 +1,200 @@
|
|||
package com.minelittlepony.unicopia.entity;
|
||||
|
||||
import com.minelittlepony.unicopia.EquinePredicates;
|
||||
import com.minelittlepony.unicopia.UItems;
|
||||
import net.minecraft.container.Container;
|
||||
import net.minecraft.container.NameableContainerProvider;
|
||||
import net.minecraft.entity.EntityType;
|
||||
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.mob.MobEntity;
|
||||
import net.minecraft.entity.player.PlayerEntity;
|
||||
import net.minecraft.entity.player.PlayerInventory;
|
||||
import net.minecraft.nbt.CompoundTag;
|
||||
import net.minecraft.particle.ParticleTypes;
|
||||
import net.minecraft.sound.BlockSoundGroup;
|
||||
import net.minecraft.sound.SoundCategory;
|
||||
import net.minecraft.sound.SoundEvents;
|
||||
import net.minecraft.util.ActionResult;
|
||||
import net.minecraft.util.Hand;
|
||||
import net.minecraft.util.math.Vec3d;
|
||||
import net.minecraft.world.GameRules;
|
||||
import net.minecraft.world.World;
|
||||
|
||||
public class SpellbookEntity extends MobEntity implements NameableContainerProvider, IMagicals {
|
||||
|
||||
private static final TrackedData<Boolean> OPENED = DataTracker.registerData(SpellbookEntity.class, TrackedDataHandlerRegistry.BOOLEAN);
|
||||
private static final TrackedData<Boolean> ALTERED = DataTracker.registerData(SpellbookEntity.class, TrackedDataHandlerRegistry.BOOLEAN);
|
||||
private static final TrackedData<Byte> OPENED_USER = DataTracker.registerData(SpellbookEntity.class, TrackedDataHandlerRegistry.BYTE);
|
||||
|
||||
public SpellbookEntity(EntityType<SpellbookEntity> type, World world) {
|
||||
super(type, world);
|
||||
setPersistent();
|
||||
|
||||
if (world.random.nextInt(3) == 0) {
|
||||
setAltered();
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void initDataTracker() {
|
||||
super.initDataTracker();
|
||||
dataTracker.startTracking(OPENED, true);
|
||||
dataTracker.startTracking(OPENED_USER, (byte)1);
|
||||
dataTracker.startTracking(ALTERED, false);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isPushable() {
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean doesRenderOnFire() {
|
||||
return false;
|
||||
}
|
||||
|
||||
public boolean getIsAltered() {
|
||||
return dataTracker.get(ALTERED);
|
||||
}
|
||||
|
||||
public void setAltered() {
|
||||
dataTracker.set(ALTERED, true);
|
||||
}
|
||||
|
||||
public boolean getIsOpen() {
|
||||
return dataTracker.get(OPENED);
|
||||
}
|
||||
|
||||
public Boolean getUserSetState() {
|
||||
byte state = dataTracker.get(OPENED_USER);
|
||||
return state == 1 ? null : state == 2;
|
||||
}
|
||||
|
||||
public void setIsOpen(boolean val) {
|
||||
dataTracker.set(OPENED, val);
|
||||
}
|
||||
|
||||
public void setUserSetState(Boolean val) {
|
||||
dataTracker.set(OPENED_USER, val == null ? (byte)1 : val == true ? (byte)2 : (byte)0);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void tick() {
|
||||
boolean open = getIsOpen();
|
||||
jumping = open && isInWater();
|
||||
super.tick();
|
||||
if (open && world.isClient) {
|
||||
|
||||
for (int offX = -2; offX <= 1; ++offX) {
|
||||
for (int offZ = -2; offZ <= 1; ++offZ) {
|
||||
if (offX > -1 && offX < 1 && offZ == -1) {
|
||||
offZ = 1;
|
||||
}
|
||||
|
||||
if (random.nextInt(320) == 0) {
|
||||
for (int offY = 0; offY <= 1; ++offY) {
|
||||
world.addParticle(ParticleTypes.ENCHANT,
|
||||
x, y, z,
|
||||
offX/2F + random.nextFloat(),
|
||||
offY/2F - random.nextFloat() + 0.5f,
|
||||
offZ/2F + random.nextFloat()
|
||||
);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (world.random.nextInt(30) == 0) {
|
||||
float celest = world.getStarsBrightness(1) * 4;
|
||||
|
||||
boolean isDay = celest > 3 || celest < 1;
|
||||
|
||||
Boolean userState = getUserSetState();
|
||||
|
||||
boolean canToggle = (isDay != open) && (userState == null || userState == isDay);
|
||||
|
||||
if (canToggle) {
|
||||
setUserSetState(null);
|
||||
setIsOpen(isDay);
|
||||
}
|
||||
|
||||
if (userState != null && (isDay == open) && (userState == open)) {
|
||||
setUserSetState(null);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean damage(DamageSource source, float amount) {
|
||||
if (!world.isClient) {
|
||||
remove();
|
||||
|
||||
BlockSoundGroup sound = BlockSoundGroup.WOOD;
|
||||
|
||||
world.playSound(x, y, z, sound.getBreakSound(), SoundCategory.BLOCKS, sound.getVolume(), sound.getPitch(), true);
|
||||
|
||||
if (world.getGameRules().getBoolean(GameRules.DO_TILE_DROPS)) {
|
||||
dropItem(UItems.spellbook, 1);
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public ActionResult interactAt(PlayerEntity player, Vec3d vec, Hand hand) {
|
||||
if (player.isSneaking()) {
|
||||
boolean open = !getIsOpen();
|
||||
|
||||
setIsOpen(open);
|
||||
setUserSetState(open);
|
||||
|
||||
return ActionResult.SUCCESS;
|
||||
}
|
||||
|
||||
if (EquinePredicates.MAGI.test(player)) {
|
||||
|
||||
player.playSound(SoundEvents.BLOCK_FURNACE_FIRE_CRACKLE, 2, 1);
|
||||
|
||||
player.openContainer(this);
|
||||
|
||||
return ActionResult.SUCCESS;
|
||||
}
|
||||
|
||||
return ActionResult.PASS;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Container createMenu(int id, PlayerInventory inventory, PlayerEntity player) {
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void readCustomDataFromTag(CompoundTag compound) {
|
||||
super.readCustomDataFromTag(compound);
|
||||
|
||||
setIsOpen(compound.getBoolean("open"));
|
||||
setUserSetState(compound.containsKey("force_open") ? compound.getBoolean("force_open") : null);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void writeCustomDataToTag(CompoundTag compound) {
|
||||
super.writeCustomDataToTag(compound);
|
||||
compound.putBoolean("open", getIsOpen());
|
||||
|
||||
Boolean state = getUserSetState();
|
||||
|
||||
if (state != null) {
|
||||
compound.putBoolean("force_open", state);
|
||||
}
|
||||
}
|
||||
|
||||
// TODO:
|
||||
/*@Override
|
||||
public ItemStack getPickStack(HitResult target) {
|
||||
return new ItemStack(UItems.spellbook);
|
||||
}*/
|
||||
}
|
|
@ -7,7 +7,7 @@ import javax.annotation.Nullable;
|
|||
|
||||
import org.apache.commons.lang3.StringUtils;
|
||||
|
||||
import com.minelittlepony.unicopia.Predicates;
|
||||
import com.minelittlepony.unicopia.EquinePredicates;
|
||||
import com.minelittlepony.unicopia.Race;
|
||||
import com.minelittlepony.unicopia.UItems;
|
||||
import com.minelittlepony.unicopia.magic.Affinity;
|
||||
|
@ -41,6 +41,7 @@ import net.minecraft.sound.SoundCategory;
|
|||
import net.minecraft.sound.SoundEvents;
|
||||
import net.minecraft.util.ActionResult;
|
||||
import net.minecraft.util.Hand;
|
||||
import net.minecraft.util.hit.HitResult;
|
||||
import net.minecraft.util.math.BlockPos;
|
||||
import net.minecraft.util.math.Vec3d;
|
||||
import net.minecraft.world.GameRules;
|
||||
|
@ -49,10 +50,6 @@ import net.minecraft.world.explosion.Explosion.DestructionType;
|
|||
|
||||
public class SpellcastEntity extends MobEntityWithAi implements IMagicals, ICaster<LivingEntity>, IInAnimate {
|
||||
|
||||
public static EntityType<SpellcastEntity> TYPE = EntityType.Builder.create(SpellcastEntity::new, EntityCategory.MISC)
|
||||
.setDimensions(0.6F, 0.25F)
|
||||
.build("spell");
|
||||
|
||||
private LivingEntity owner = null;
|
||||
|
||||
public float hoverStart;
|
||||
|
@ -136,20 +133,16 @@ public class SpellcastEntity extends MobEntityWithAi implements IMagicals, ICast
|
|||
dataTracker.startTracking(AFFINITY, Affinity.NEUTRAL.ordinal());
|
||||
}
|
||||
|
||||
@Override
|
||||
public ItemStack getPickedResult(RayTraceResult target) {
|
||||
// TODO:
|
||||
/*@Override
|
||||
public ItemStack getPickedStack(HitResult target) {
|
||||
return SpellRegistry.instance().enchantStack(new ItemStack(getItem()), getEffect().getName());
|
||||
}
|
||||
}*/
|
||||
|
||||
protected Item getItem() {
|
||||
return getAffinity() == Affinity.BAD ? UItems.curse : UItems.spell;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected boolean canTriggerWalking() {
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isPushable() {
|
||||
return false;
|
||||
|
@ -206,7 +199,7 @@ public class SpellcastEntity extends MobEntityWithAi implements IMagicals, ICast
|
|||
if (!hasEffect()) {
|
||||
remove();
|
||||
} else {
|
||||
if (getEffect().getDead()) {
|
||||
if (getEffect().isDead()) {
|
||||
remove();
|
||||
onDeath();
|
||||
} else {
|
||||
|
@ -288,7 +281,7 @@ public class SpellcastEntity extends MobEntityWithAi implements IMagicals, ICast
|
|||
|
||||
@Override
|
||||
public ActionResult interactAt(PlayerEntity player, Vec3d vec, Hand hand) {
|
||||
if (Predicates.MAGI.test(player)) {
|
||||
if (EquinePredicates.MAGI.test(player)) {
|
||||
ItemStack currentItem = player.getStackInHand(Hand.MAIN_HAND);
|
||||
|
||||
if (currentItem != null
|
||||
|
|
|
@ -0,0 +1,139 @@
|
|||
package com.minelittlepony.unicopia.entity;
|
||||
|
||||
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;
|
||||
import net.minecraft.entity.SpawnType;
|
||||
import net.minecraft.nbt.CompoundTag;
|
||||
import net.minecraft.util.math.Box;
|
||||
import net.minecraft.util.math.ChunkPos;
|
||||
import net.minecraft.util.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.biome.Biome.SpawnEntry;
|
||||
import net.minecraft.world.chunk.Chunk;
|
||||
import net.minecraft.world.chunk.WorldChunk;
|
||||
|
||||
public class WildCloudEntity extends CloudEntity {
|
||||
|
||||
public static final SpawnEntry SPAWN_ENTRY_LAND = new SpawnEntry(UEntities.WILD_CLOUD, 1, 1, 15);
|
||||
public static final SpawnEntry SPAWN_ENTRY_OCEAN = new SpawnEntry(UEntities.WILD_CLOUD, 1, 1, 7);
|
||||
|
||||
public WildCloudEntity(EntityType<WildCloudEntity> type, World world) {
|
||||
super(type, world);
|
||||
|
||||
preventEntitySpawning = true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isNotColliding() {
|
||||
Box boundingbox = getBoundingBox();
|
||||
|
||||
return checkNoEntityCollision(boundingbox, this)
|
||||
&& world.isSkyVisible(getBlockPos())
|
||||
&& world.doesNotCollide(this, boundingbox)
|
||||
&& !world.intersectsFluid(boundingbox);
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns true if there are no solid, live entities in the specified Box, excluding the given entity
|
||||
*
|
||||
* @ref World.checkNoEntityCollision(Box area, Entity entity)
|
||||
*/
|
||||
public boolean checkNoEntityCollision(Box area, Entity entity) {
|
||||
|
||||
for (Entity i : world.getEntities(entity, area)) {
|
||||
if (!i.removed && (i.preventEntitySpawning || i instanceof CloudEntity) && (!entity.hasVehicle() || !entity.isConnectedThroughVehicle(i))) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean canSpawn(IWorld world, SpawnType type) {
|
||||
if (type == SpawnType.NATURAL) {
|
||||
int count = 0;
|
||||
|
||||
ChunkPos cpos = new ChunkPos(getBlockPos());
|
||||
|
||||
WorldChunk chunk = world.getChunkManager().getWorldChunk(cpos.x, cpos.z, false);
|
||||
for (TypeFilterableList<Entity> i : chunk.getEntitySectionArray()) {
|
||||
Iterator<CloudEntity> iter = i.getAllOfType(CloudEntity.class).iterator();
|
||||
while (iter.hasNext()) {
|
||||
iter.next();
|
||||
|
||||
if (count++ > 2) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
BlockPos pos = getBlockPos().down();
|
||||
return world.getBlockState(pos).allowsSpawning(world, pos, getType());
|
||||
}
|
||||
|
||||
@Override
|
||||
public EntityData initialize(IWorld world, LocalDifficulty difficulty, SpawnType type, @Nullable EntityData data, @Nullable CompoundTag tag) {
|
||||
data = super.initialize(world, difficulty, type, data, tag);
|
||||
|
||||
if (!(data instanceof PackData)) {
|
||||
float minSpawnHeight = getMinimumFlyingHeight();
|
||||
|
||||
targetAltitude = getRandomFlyingHeight();
|
||||
|
||||
if (y < minSpawnHeight) {
|
||||
minSpawnHeight += world.random.nextInt(Math.max(1, (int)getMaximumFlyingHeight() - (int)minSpawnHeight));
|
||||
|
||||
setPositionAndAngles(x, minSpawnHeight - 1, z, yaw, pitch);
|
||||
collideWithNearbyEntities();
|
||||
}
|
||||
|
||||
if (world.hasRain(getBlockPos())) {
|
||||
setIsRaining(true);
|
||||
}
|
||||
|
||||
if (world.isThundering()) {
|
||||
setIsThundering(true);
|
||||
}
|
||||
|
||||
data = new PackData(this);
|
||||
} else {
|
||||
PackData packData = (PackData)data;
|
||||
targetAltitude = packData.leader.targetAltitude;
|
||||
|
||||
Vec3d position = packData.getUnOccupiedPosition(getCloudSize());
|
||||
|
||||
setIsRaining(packData.leader.getIsRaining());
|
||||
setIsThundering(packData.leader.getIsThundering());
|
||||
|
||||
setPositionAndAngles(position.x, position.y, position.z, packData.leader.yaw, packData.leader.pitch);
|
||||
checkBlockCollision();
|
||||
}
|
||||
|
||||
return data;
|
||||
}
|
||||
|
||||
static class PackData implements EntityData {
|
||||
|
||||
final CloudEntity leader;
|
||||
|
||||
PackData(CloudEntity leader) {
|
||||
this.leader = leader;
|
||||
}
|
||||
|
||||
Vec3d getUnOccupiedPosition(int size) {
|
||||
return leader.getPos();
|
||||
}
|
||||
}
|
||||
}
|
|
@ -1,4 +1,4 @@
|
|||
package com.minelittlepony.unicopia.entity.player;
|
||||
package com.minelittlepony.unicopia.entity.capabilities;
|
||||
|
||||
import javax.annotation.Nonnull;
|
||||
import javax.annotation.Nullable;
|
||||
|
@ -7,7 +7,7 @@ import com.minelittlepony.unicopia.Unicopia;
|
|||
import com.minelittlepony.unicopia.ability.IAbilityReceiver;
|
||||
import com.minelittlepony.unicopia.ability.IData;
|
||||
import com.minelittlepony.unicopia.ability.IPower;
|
||||
import com.minelittlepony.unicopia.ability.powers.PowersRegistry;
|
||||
import com.minelittlepony.unicopia.ability.PowersRegistry;
|
||||
import com.minelittlepony.unicopia.entity.IUpdatable;
|
||||
import com.minelittlepony.unicopia.network.MsgPlayerAbility;
|
||||
import com.minelittlepony.util.InbtSerialisable;
|
|
@ -1,4 +1,4 @@
|
|||
package com.minelittlepony.unicopia.entity.ai;
|
||||
package com.minelittlepony.unicopia.entity.capabilities;
|
||||
|
||||
import java.util.EnumSet;
|
||||
|
|
@ -1,4 +1,4 @@
|
|||
package com.minelittlepony.unicopia.entity.player;
|
||||
package com.minelittlepony.unicopia.entity.capabilities;
|
||||
|
||||
import java.util.Random;
|
||||
|
||||
|
@ -60,7 +60,7 @@ class GravityDelegate implements IUpdatable, IGravity, IFlight, InbtSerialisable
|
|||
|
||||
if (player.hasEffect()) {
|
||||
IMagicEffect effect = player.getEffect();
|
||||
if (!effect.getDead() && effect instanceof IFlyingPredicate) {
|
||||
if (!effect.isDead() && effect instanceof IFlyingPredicate) {
|
||||
return ((IFlyingPredicate)effect).checkCanFly(player);
|
||||
}
|
||||
}
|
||||
|
@ -76,7 +76,7 @@ class GravityDelegate implements IUpdatable, IGravity, IFlight, InbtSerialisable
|
|||
public float getTargetEyeHeight(IPlayer player) {
|
||||
if (player.hasEffect()) {
|
||||
IMagicEffect effect = player.getEffect();
|
||||
if (!effect.getDead() && effect instanceof IHeightPredicate) {
|
||||
if (!effect.isDead() && effect instanceof IHeightPredicate) {
|
||||
float val = ((IHeightPredicate)effect).getTargetEyeHeight(player);
|
||||
if (val > 0) {
|
||||
return val;
|
||||
|
@ -95,7 +95,7 @@ class GravityDelegate implements IUpdatable, IGravity, IFlight, InbtSerialisable
|
|||
public float getTargetBodyHeight(IPlayer player) {
|
||||
if (player.hasEffect()) {
|
||||
IMagicEffect effect = player.getEffect();
|
||||
if (!effect.getDead() && effect instanceof IHeightPredicate) {
|
||||
if (!effect.isDead() && effect instanceof IHeightPredicate) {
|
||||
float val = ((IHeightPredicate)effect).getTargetBodyHeight(player);
|
||||
if (val > 0) {
|
||||
return val;
|
|
@ -1,4 +1,4 @@
|
|||
package com.minelittlepony.unicopia.entity.player;
|
||||
package com.minelittlepony.unicopia.entity.capabilities;
|
||||
|
||||
public interface ICamera {
|
||||
float calculateRoll();
|
|
@ -1,4 +1,4 @@
|
|||
package com.minelittlepony.unicopia.entity.player;
|
||||
package com.minelittlepony.unicopia.entity.capabilities;
|
||||
|
||||
import java.util.UUID;
|
||||
|
||||
|
@ -137,7 +137,7 @@ public interface IPlayer extends ICaster<PlayerEntity>, IRaceContainer<PlayerEnt
|
|||
|
||||
static PlayerEntity fromServer(UUID playerId) {
|
||||
|
||||
MinecraftServer server = FMLCommonHandler.getInstance().getMinecraftServerInstance();
|
||||
MinecraftServer server = FMLCommonHandler.instance().getMinecraftServerInstance();
|
||||
|
||||
if (server == null) {
|
||||
return UClient.instance().getPlayerByUUID(playerId);
|
|
@ -1,4 +1,4 @@
|
|||
package com.minelittlepony.unicopia.entity.item;
|
||||
package com.minelittlepony.unicopia.entity.capabilities;
|
||||
|
||||
import com.minelittlepony.unicopia.Race;
|
||||
import com.minelittlepony.unicopia.entity.IOwned;
|
|
@ -1,4 +1,4 @@
|
|||
package com.minelittlepony.unicopia.entity.living;
|
||||
package com.minelittlepony.unicopia.entity.capabilities;
|
||||
|
||||
import com.minelittlepony.unicopia.Race;
|
||||
import com.minelittlepony.unicopia.entity.IRaceContainer;
|
|
@ -1,4 +1,4 @@
|
|||
package com.minelittlepony.unicopia.entity.player;
|
||||
package com.minelittlepony.unicopia.entity.capabilities;
|
||||
|
||||
import java.util.UUID;
|
||||
|
|
@ -1,4 +1,4 @@
|
|||
package com.minelittlepony.unicopia.entity.player;
|
||||
package com.minelittlepony.unicopia.entity.capabilities;
|
||||
|
||||
class PlayerCamera extends MotionCompositor implements ICamera {
|
||||
|
|
@ -1,4 +1,4 @@
|
|||
package com.minelittlepony.unicopia.entity.player;
|
||||
package com.minelittlepony.unicopia.entity.capabilities;
|
||||
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
|
@ -306,7 +306,7 @@ public class PlayerCapabilities implements IPlayer {
|
|||
public boolean onProjectileImpact(ProjectileEntity projectile) {
|
||||
if (hasEffect()) {
|
||||
IMagicEffect effect = getEffect();
|
||||
if (effect instanceof SpellDisguise && !effect.getDead()) {
|
||||
if (effect instanceof SpellDisguise && !effect.isDead()) {
|
||||
if (((SpellDisguise)effect).getDisguise() == projectile) {
|
||||
return true;
|
||||
}
|
||||
|
@ -379,16 +379,16 @@ public class PlayerCapabilities implements IPlayer {
|
|||
|
||||
player.getHungerManager().add(-health/2, -saturation/2);
|
||||
|
||||
player.addPotionEffect(new StatusEffectInstance(StatusEffects.NAUSEA, 100, 3, true, true));
|
||||
player.addStatusEffectInstance(new StatusEffectInstance(StatusEffects.NAUSEA, 100, 3, true, true));
|
||||
} else {
|
||||
player.addPotionEffect(new StatusEffectInstance(StatusEffects.NAUSEA, 200, 3, true, true));
|
||||
player.addStatusEffectInstance(new StatusEffectInstance(StatusEffects.NAUSEA, 200, 3, true, true));
|
||||
}
|
||||
|
||||
if (player.world.getDifficulty() != Difficulty.PEACEFUL && player.world.random.nextInt(20) == 0) {
|
||||
player.addPotionEffect(new StatusEffectInstance(UEffects.FOOD_POISONING, 3, 2, true, true));
|
||||
player.addStatusEffectInstance(new StatusEffectInstance(UEffects.FOOD_POISONING, 3, 2, true, true));
|
||||
}
|
||||
|
||||
player.addPotionEffect(new StatusEffectInstance(StatusEffects.WEAKNESS, 2000, 2, true, true));
|
||||
player.addStatusEffectInstance(new StatusEffectInstance(StatusEffects.WEAKNESS, 2000, 2, true, true));
|
||||
}
|
||||
}
|
||||
|
|
@ -1,4 +1,4 @@
|
|||
package com.minelittlepony.unicopia.entity.player;
|
||||
package com.minelittlepony.unicopia.entity.capabilities;
|
||||
|
||||
import java.util.Iterator;
|
||||
import java.util.Map;
|
|
@ -1,40 +0,0 @@
|
|||
package com.minelittlepony.unicopia.forgebullshit;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.Optional;
|
||||
import java.util.function.Function;
|
||||
|
||||
import com.google.common.collect.Lists;
|
||||
|
||||
import net.minecraft.world.biome.Biome;
|
||||
|
||||
/**
|
||||
* Provides methods and apis that forge seems to be sorely lacking.
|
||||
*/
|
||||
@Deprecated
|
||||
public class BiomeBS {
|
||||
|
||||
/**
|
||||
* Gets the biome type associated with a given biome.
|
||||
*/
|
||||
public static Optional<BiomeType> getBiomeType(Biome biome) {
|
||||
return Lists.newArrayList(BiomeManager.BiomeType.values()).stream().filter(type ->
|
||||
BiomeManager.getBiomes(type).stream().filter(entry ->
|
||||
entry.biome.equals(biome)
|
||||
).findFirst()
|
||||
.isPresent()
|
||||
).findFirst();
|
||||
}
|
||||
|
||||
/**
|
||||
* Adds a spawn entry for the specified entity if one does not already exist.
|
||||
*/
|
||||
public static void addSpawnEntry(Biome biome, EnumCreatureType list, Class<? extends LivingEntity> type, Function<Biome, SpawnListEntry> func) {
|
||||
List<SpawnListEntry> entries = biome.getSpawnableList(list);
|
||||
|
||||
entries.stream().filter(p -> p.entityClass == type).findFirst().orElseGet(() -> {
|
||||
entries.add(func.apply(biome));
|
||||
return null;
|
||||
});
|
||||
}
|
||||
}
|
|
@ -10,7 +10,7 @@ import com.minelittlepony.unicopia.enchanting.IPage;
|
|||
import com.minelittlepony.unicopia.enchanting.IPageUnlockListener;
|
||||
import com.minelittlepony.unicopia.enchanting.PageState;
|
||||
import com.minelittlepony.unicopia.enchanting.Pages;
|
||||
import com.minelittlepony.unicopia.entity.player.IPlayer;
|
||||
import com.minelittlepony.unicopia.entity.capabilities.IPlayer;
|
||||
|
||||
import net.minecraft.client.Minecraft;
|
||||
import net.minecraft.client.gui.GuiButton;
|
||||
|
@ -171,7 +171,7 @@ public class GuiSpellBook extends GuiContainer implements IPageUnlockListener {
|
|||
drawModalRectWithCustomSizedTexture(left, top, 0, 0, xSize, ySize, 512, 256);
|
||||
} else {
|
||||
if (playerExtension.getWorld().rand.nextInt(100) == 0) {
|
||||
Unicopia.log.fatal("Missing texture " + texture);
|
||||
Unicopia.LOGGER.fatal("Missing texture " + texture);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -2,7 +2,7 @@ package com.minelittlepony.unicopia.inventory.gui;
|
|||
|
||||
import javax.annotation.Nonnull;
|
||||
|
||||
import com.minelittlepony.unicopia.Predicates;
|
||||
import com.minelittlepony.unicopia.EquinePredicates;
|
||||
import com.minelittlepony.unicopia.SpeciesList;
|
||||
import com.minelittlepony.unicopia.Unicopia;
|
||||
import com.minelittlepony.unicopia.enchanting.IPageUnlockListener;
|
||||
|
@ -156,7 +156,7 @@ public class SpellBookContainer extends Container {
|
|||
|
||||
@Override
|
||||
public boolean canUse(PlayerEntity player) {
|
||||
return Predicates.MAGI.test(player);
|
||||
return EquinePredicates.MAGI.test(player);
|
||||
}
|
||||
|
||||
static class SpellbookSlot extends Slot {
|
||||
|
|
|
@ -3,7 +3,7 @@ package com.minelittlepony.unicopia.inventory.gui;
|
|||
import com.minelittlepony.unicopia.enchanting.IPageOwner;
|
||||
import com.minelittlepony.unicopia.enchanting.IPageUnlockListener;
|
||||
import com.minelittlepony.unicopia.enchanting.SpellCraftingEvent;
|
||||
import com.minelittlepony.unicopia.item.ItemSpell;
|
||||
import com.minelittlepony.unicopia.item.MagicGemItem;
|
||||
import com.minelittlepony.unicopia.magic.spells.SpellRegistry;
|
||||
|
||||
import net.minecraft.entity.player.PlayerEntity;
|
||||
|
@ -90,7 +90,7 @@ public class SpellbookResultSlot extends SpellBookContainer.SpellbookSlot {
|
|||
|
||||
@Override
|
||||
public boolean canInsert(ItemStack stack) {
|
||||
return (stack.getItem() instanceof ItemSpell || stack.getItem() instanceof MusicDiscItem)
|
||||
return (stack.getItem() instanceof MagicGemItem || stack.getItem() instanceof MusicDiscItem)
|
||||
&& !SpellRegistry.stackHasEnchantment(stack);
|
||||
}
|
||||
|
||||
|
|
Some files were not shown because too many files have changed in this diff Show more
Loading…
Reference in a new issue