From 1cb8768143919d96c4a1235acdf2893179c0aca3 Mon Sep 17 00:00:00 2001 From: Kino Date: Wed, 1 Nov 2017 21:08:34 -0400 Subject: [PATCH] Aether API fixes/changes It is 100% independent from Aether Legacy. Now, just need to work on it a bit more and it will be ready. --- .../com/legacy/aether/api/AetherRegistry.java | 39 ++++++++++--------- .../legacy/aether/api/moa/AetherMoaType.java | 4 +- .../client/gui/inventory/GuiAetherPerks.java | 4 +- .../common/entities/AetherEntities.java | 12 ++++++ .../tile_entities/TileEntityEnchanter.java | 23 ++++++----- .../tile_entities/TileEntityFreezer.java | 4 +- .../common/world/dungeon/SilverDungeon.java | 4 +- 7 files changed, 53 insertions(+), 37 deletions(-) diff --git a/src/main/java/com/legacy/aether/api/AetherRegistry.java b/src/main/java/com/legacy/aether/api/AetherRegistry.java index 856a9f9..d507ee7 100644 --- a/src/main/java/com/legacy/aether/api/AetherRegistry.java +++ b/src/main/java/com/legacy/aether/api/AetherRegistry.java @@ -14,7 +14,6 @@ import com.legacy.aether.api.enchantments.AetherEnchantmentFuel; import com.legacy.aether.api.freezables.AetherFreezable; import com.legacy.aether.api.freezables.AetherFreezableFuel; import com.legacy.aether.api.moa.AetherMoaType; -import com.legacy.aether.api.moa.MoaProperties; import com.legacy.aether.common.Aether; public class AetherRegistry @@ -40,66 +39,70 @@ public class AetherRegistry this.iFreezableRegistry = PersistentRegistryManager.createRegistry(Aether.locate("freezables"), AetherFreezable.class, null, 0, MAX_REGISTRY_ID, false, null, null, null, null); this.iFreezableFuelRegistry = PersistentRegistryManager.createRegistry(Aether.locate("freezable_fuels"), AetherFreezableFuel.class, null, 0, MAX_REGISTRY_ID, false, null, null, null, null); this.iMoaTypeRegistry = PersistentRegistryManager.createRegistry(Aether.locate("moa_types"), AetherMoaType.class, null, 0, MAX_REGISTRY_ID, false, null, null, null, null); - - initialization(); } - private void initialization() - { - register(new ResourceLocation("aether_legacy", "blue"), new AetherMoaType(0x7777FF, new MoaProperties(3, 100, 0.3F))); - register(new ResourceLocation("aether_legacy", "orange"), new AetherMoaType(-0xC3D78, new MoaProperties(2, 50, 0.6F))); - register(new ResourceLocation("aether_legacy", "white"), new AetherMoaType(0xFFFFFF, new MoaProperties(4, 20, 0.3F))); - register(new ResourceLocation("aether_legacy", "black"), new AetherMoaType(0x222222, new MoaProperties(8, 5, 0.3F))); - } - - public void register(AetherAccessory type) + public AetherAccessory register(AetherAccessory type) { ItemStack stack = type.getAccessoryStack(); ResourceLocation registryName = new ResourceLocation(Aether.modid, stack.getItem().getRegistryName().getResourcePath() + "_meta_" + stack.getMetadata()); this.iAccessoryRegistry.register(type.setRegistryName(registryName)); + + return type; } - public void register(AetherEnchantment type) + public AetherEnchantment register(AetherEnchantment type) { ItemStack stack = type.getInput(); ResourceLocation registryName = new ResourceLocation(Aether.modid, stack.getItem().getRegistryName().getResourcePath() + "_meta_" + stack.getMetadata()); this.iEnchantmentRegistry.register(type.setRegistryName(registryName)); + + return type; } - public void register(AetherEnchantmentFuel type) + public AetherEnchantmentFuel register(AetherEnchantmentFuel type) { ItemStack stack = type.getFuelStack(); ResourceLocation registryName = new ResourceLocation(Aether.modid, stack.getItem().getRegistryName().getResourcePath() + "_meta_" + stack.getMetadata()); this.iEnchantmentFuelRegistry.register(type.setRegistryName(registryName)); + + return type; } - public void register(AetherFreezable type) + public AetherFreezable register(AetherFreezable type) { ItemStack stack = type.getInput(); ResourceLocation registryName = new ResourceLocation(Aether.modid, stack.getItem().getRegistryName().getResourcePath() + "_meta_" + stack.getMetadata()); this.iFreezableRegistry.register(type.setRegistryName(registryName)); + + return type; } - public void register(AetherFreezableFuel type) + public AetherFreezableFuel register(AetherFreezableFuel type) { ItemStack stack = type.getFuelStack(); ResourceLocation registryName = new ResourceLocation(Aether.modid, stack.getItem().getRegistryName().getResourcePath() + "_meta_" + stack.getMetadata()); this.iFreezableFuelRegistry.register(type.setRegistryName(registryName)); + + return type; } - public void register(String modId, String name, AetherMoaType type) + public AetherMoaType register(String modId, String name, AetherMoaType type) { this.iMoaTypeRegistry.register(type.setRegistryName(modId, name)); + + return type; } - public void register(ResourceLocation registryName, AetherMoaType type) + public AetherMoaType register(ResourceLocation registryName, AetherMoaType type) { this.iMoaTypeRegistry.register(type.setRegistryName(registryName)); + + return type; } public boolean isAccessory(ItemStack stack) diff --git a/src/main/java/com/legacy/aether/api/moa/AetherMoaType.java b/src/main/java/com/legacy/aether/api/moa/AetherMoaType.java index 3604ee3..b7bb228 100644 --- a/src/main/java/com/legacy/aether/api/moa/AetherMoaType.java +++ b/src/main/java/com/legacy/aether/api/moa/AetherMoaType.java @@ -3,8 +3,6 @@ package com.legacy.aether.api.moa; import net.minecraft.creativetab.CreativeTabs; import net.minecraft.util.ResourceLocation; -import com.legacy.aether.common.registry.creative_tabs.AetherCreativeTabs; - public class AetherMoaType extends net.minecraftforge.fml.common.registry.IForgeRegistryEntry.Impl { @@ -19,7 +17,7 @@ public class AetherMoaType extends net.minecraftforge.fml.common.registry.IForge this.hexColor = hexColor; this.properties = properties; - this.creativeTab = AetherCreativeTabs.misc; + this.creativeTab = CreativeTabs.MISC; } public AetherMoaType(int hexColor, MoaProperties properties, CreativeTabs creativeTab) diff --git a/src/main/java/com/legacy/aether/client/gui/inventory/GuiAetherPerks.java b/src/main/java/com/legacy/aether/client/gui/inventory/GuiAetherPerks.java index 9316a5a..8e6aba6 100644 --- a/src/main/java/com/legacy/aether/client/gui/inventory/GuiAetherPerks.java +++ b/src/main/java/com/legacy/aether/client/gui/inventory/GuiAetherPerks.java @@ -10,7 +10,7 @@ import net.minecraft.client.gui.inventory.GuiInventory; import org.lwjgl.input.Keyboard; -import com.legacy.aether.api.AetherRegistry; +import com.legacy.aether.common.entities.AetherEntities; import com.legacy.aether.common.entities.passive.mountable.EntityMoa; import com.legacy.aether.common.networking.AetherNetworkingManager; import com.legacy.aether.common.networking.packets.PacketPerkChanged; @@ -48,7 +48,7 @@ public class GuiAetherPerks extends GuiScreen this.player = PlayerAether.get(this.mc.thePlayer); this.moaSkin = this.player.donatorMoaSkin; - this.moa = this.player.thePlayer.getRidingEntity() instanceof EntityMoa ? (EntityMoa) this.player.thePlayer.getRidingEntity() : new EntityMoa(this.mc.theWorld, AetherRegistry.getInstance().getMoaType(2)); + this.moa = this.player.thePlayer.getRidingEntity() instanceof EntityMoa ? (EntityMoa) this.player.thePlayer.getRidingEntity() : new EntityMoa(this.mc.theWorld, AetherEntities.WHITE_MOA); } @Override diff --git a/src/main/java/com/legacy/aether/common/entities/AetherEntities.java b/src/main/java/com/legacy/aether/common/entities/AetherEntities.java index 66b08a0..491dfa0 100644 --- a/src/main/java/com/legacy/aether/common/entities/AetherEntities.java +++ b/src/main/java/com/legacy/aether/common/entities/AetherEntities.java @@ -1,8 +1,12 @@ package com.legacy.aether.common.entities; import net.minecraft.entity.Entity; +import net.minecraft.util.ResourceLocation; import net.minecraftforge.fml.common.registry.EntityRegistry; +import com.legacy.aether.api.AetherRegistry; +import com.legacy.aether.api.moa.AetherMoaType; +import com.legacy.aether.api.moa.MoaProperties; import com.legacy.aether.common.Aether; import com.legacy.aether.common.entities.block.EntityFloatingBlock; import com.legacy.aether.common.entities.block.EntityTNTPresent; @@ -36,10 +40,13 @@ import com.legacy.aether.common.entities.projectile.crystals.EntityThunderBall; import com.legacy.aether.common.entities.projectile.darts.EntityDartEnchanted; import com.legacy.aether.common.entities.projectile.darts.EntityDartGolden; import com.legacy.aether.common.entities.projectile.darts.EntityDartPoison; +import com.legacy.aether.common.registry.creative_tabs.AetherCreativeTabs; public class AetherEntities { + public static AetherMoaType BLUE_MOA, ORANGE_MOA, WHITE_MOA, BLACK_MOA; + public static void initialization() { register(EntityMoa.class, "moa", 0, 0x9fc3f7, 0x343e44); @@ -81,6 +88,11 @@ public class AetherEntities register(EntityLightningKnife.class, "lightning_knife", 30); register(EntityParachute.class, "parachute", 31); + BLUE_MOA = AetherRegistry.getInstance().register(new ResourceLocation("aether_legacy", "blue"), new AetherMoaType(0x7777FF, new MoaProperties(3, 100, 0.3F), AetherCreativeTabs.misc)); + ORANGE_MOA = AetherRegistry.getInstance().register(new ResourceLocation("aether_legacy", "orange"), new AetherMoaType(-0xC3D78, new MoaProperties(2, 50, 0.6F), AetherCreativeTabs.misc)); + WHITE_MOA = AetherRegistry.getInstance().register(new ResourceLocation("aether_legacy", "white"), new AetherMoaType(0xFFFFFF, new MoaProperties(4, 20, 0.3F), AetherCreativeTabs.misc)); + BLACK_MOA = AetherRegistry.getInstance().register(new ResourceLocation("aether_legacy", "black"), new AetherMoaType(0x222222, new MoaProperties(8, 5, 0.3F), AetherCreativeTabs.misc)); + DataSerializerRegistry.initialize(); } diff --git a/src/main/java/com/legacy/aether/common/tile_entities/TileEntityEnchanter.java b/src/main/java/com/legacy/aether/common/tile_entities/TileEntityEnchanter.java index c1bcab3..f08284e 100644 --- a/src/main/java/com/legacy/aether/common/tile_entities/TileEntityEnchanter.java +++ b/src/main/java/com/legacy/aether/common/tile_entities/TileEntityEnchanter.java @@ -60,7 +60,7 @@ public class TileEntityEnchanter extends AetherTileEntity if (this.currentEnchantment != null) { - if (this.getStackInSlot(0) == null || AetherRegistry.getInstance().getEnchantment(this.getStackInSlot(0)).equals(this.currentEnchantment)) + if (this.getStackInSlot(0) == null || AetherRegistry.getInstance().hasEnchantment(this.getStackInSlot(0)) && AetherRegistry.getInstance().getEnchantment(this.getStackInSlot(0)).equals(this.currentEnchantment)) { this.currentEnchantment = null; this.enchantmentProgress = 0; @@ -111,17 +111,20 @@ public class TileEntityEnchanter extends AetherTileEntity } else { - ItemStack itemstack = this.getStackInSlot(0); - AetherEnchantment enchantment = AetherRegistry.getInstance().getEnchantment(itemstack); - - if (enchantment != null) + if (this.getStackInSlot(0) != null) { - if (this.getStackInSlot(2) == null || enchantment.getOutput().getItem() == this.getStackInSlot(2).getItem() && enchantment.getOutput().getMetadata() == this.getStackInSlot(2).getMetadata()) + ItemStack itemstack = this.getStackInSlot(0); + AetherEnchantment enchantment = AetherRegistry.getInstance().getEnchantment(itemstack); + + if (enchantment != null) { - this.currentEnchantment = enchantment; - this.enchantmentTime = this.currentEnchantment.getTimeRequired(); - this.addEnchantmentWeight(itemstack); - this.enchantmentTime = AetherHooks.onSetEnchantmentTime(this, this.currentEnchantment, this.enchantmentTime); + if (this.getStackInSlot(2) == null || enchantment.getOutput().getItem() == this.getStackInSlot(2).getItem() && enchantment.getOutput().getMetadata() == this.getStackInSlot(2).getMetadata()) + { + this.currentEnchantment = enchantment; + this.enchantmentTime = this.currentEnchantment.getTimeRequired(); + this.addEnchantmentWeight(itemstack); + this.enchantmentTime = AetherHooks.onSetEnchantmentTime(this, this.currentEnchantment, this.enchantmentTime); + } } } } diff --git a/src/main/java/com/legacy/aether/common/tile_entities/TileEntityFreezer.java b/src/main/java/com/legacy/aether/common/tile_entities/TileEntityFreezer.java index ac834d2..60574c0 100644 --- a/src/main/java/com/legacy/aether/common/tile_entities/TileEntityFreezer.java +++ b/src/main/java/com/legacy/aether/common/tile_entities/TileEntityFreezer.java @@ -60,7 +60,7 @@ public class TileEntityFreezer extends AetherTileEntity if (this.currentFreezable != null) { - if (this.getStackInSlot(0) == null || AetherRegistry.getInstance().getFreezable(this.getStackInSlot(0)).equals(this.currentFreezable)) + if (this.getStackInSlot(0) == null || AetherRegistry.getInstance().hasFreezable(this.getStackInSlot(0)) && AetherRegistry.getInstance().getFreezable(this.getStackInSlot(0)).equals(this.currentFreezable)) { this.currentFreezable = null; this.freezeProgress = 0; @@ -108,7 +108,7 @@ public class TileEntityFreezer extends AetherTileEntity } } } - else + else if (this.getStackInSlot(0) != null) { ItemStack itemstack = this.getStackInSlot(0); AetherFreezable freezable = AetherRegistry.getInstance().getFreezable(itemstack); diff --git a/src/main/java/com/legacy/aether/common/world/dungeon/SilverDungeon.java b/src/main/java/com/legacy/aether/common/world/dungeon/SilverDungeon.java index b876953..92736ae 100644 --- a/src/main/java/com/legacy/aether/common/world/dungeon/SilverDungeon.java +++ b/src/main/java/com/legacy/aether/common/world/dungeon/SilverDungeon.java @@ -11,11 +11,11 @@ import net.minecraft.tileentity.TileEntityChest; import net.minecraft.util.math.BlockPos; import net.minecraft.world.World; -import com.legacy.aether.api.AetherRegistry; import com.legacy.aether.common.blocks.BlocksAether; import com.legacy.aether.common.blocks.dungeon.BlockDungeonBase; import com.legacy.aether.common.blocks.util.EnumCloudType; import com.legacy.aether.common.blocks.util.EnumStoneType; +import com.legacy.aether.common.entities.AetherEntities; import com.legacy.aether.common.entities.bosses.valkyrie_queen.EntityValkyrieQueen; import com.legacy.aether.common.items.ItemMoaEgg; import com.legacy.aether.common.items.ItemsAether; @@ -455,7 +455,7 @@ public class SilverDungeon extends AetherDungeon case 2 : return new ItemStack(ItemsAether.dart_shooter); case 3 : - return ItemMoaEgg.getStackFromType(AetherRegistry.getInstance().getMoaType(2)); + return ItemMoaEgg.getStackFromType(AetherEntities.WHITE_MOA); case 4 : return new ItemStack(ItemsAether.ambrosium_shard, random.nextInt(10) + 1); case 5 :