diff --git a/.gitignore b/.gitignore index 6e337fc088..5e80e0ae57 100644 --- a/.gitignore +++ b/.gitignore @@ -36,89 +36,3 @@ addon.local.gradle.kts addon.late.local.gradle addon.late.local.gradle.kts layout.json -src/main/resources/assets/tinker/textures/items/textures to draw/_sword_accessory.png -src/main/resources/assets/tinker/textures/items/textures to draw/_shuriken.png -src/main/resources/assets/tinker/textures/items/textures to draw/_shuriken (2).png -src/main/resources/assets/tinker/textures/items/textures to draw/_shovel_handle.png -src/main/resources/assets/tinker/textures/items/textures to draw/_scythe_handle.png -src/main/resources/assets/tinker/textures/items/textures to draw/_scythe_binding.png -src/main/resources/assets/tinker/textures/items/textures to draw/_scythe_accessory.png -src/main/resources/assets/tinker/textures/items/textures to draw/_rod.png -src/main/resources/assets/tinker/textures/items/textures to draw/_rapier_handle.png -src/main/resources/assets/tinker/textures/items/textures to draw/_rapier_accessory.png -src/main/resources/assets/tinker/textures/items/textures to draw/_pickaxe_handle.png -src/main/resources/assets/tinker/textures/items/textures to draw/_pickaxe_accessory.png -src/main/resources/assets/tinker/textures/items/textures to draw/_medium_guard.png -src/main/resources/assets/tinker/textures/items/textures to draw/_mattock_handle.png -src/main/resources/assets/tinker/textures/items/textures to draw/_lumberaxe_handle.png -src/main/resources/assets/tinker/textures/items/textures to draw/_lumberaxe_binding.png -src/main/resources/assets/tinker/textures/items/textures to draw/_longsword_handle.png -src/main/resources/assets/tinker/textures/items/textures to draw/_longsword_accessory.png -src/main/resources/assets/tinker/textures/items/textures to draw/_large_guard.png -src/main/resources/assets/tinker/textures/items/textures to draw/_knife_handle.png -src/main/resources/assets/tinker/textures/items/textures to draw/_knife_blade.png -src/main/resources/assets/tinker/textures/items/textures to draw/_knife_blade (2).png -src/main/resources/assets/tinker/textures/items/textures to draw/_javelin_head_broken.png -src/main/resources/assets/tinker/textures/items/textures to draw/_javelin_head.png -src/main/resources/assets/tinker/textures/items/textures to draw/_javelin_handle.png -src/main/resources/assets/tinker/textures/items/textures to draw/_javelin_accessory.png -src/main/resources/assets/tinker/textures/items/textures to draw/_hammer_handle_broken.png -src/main/resources/assets/tinker/textures/items/textures to draw/_hammer_handle.png -src/main/resources/assets/tinker/textures/items/textures to draw/_full_guard.png -src/main/resources/assets/tinker/textures/items/textures to draw/_frypan_handle.png -src/main/resources/assets/tinker/textures/items/textures to draw/_excavator_handle.png -src/main/resources/assets/tinker/textures/items/textures to draw/_excavator_grip.png -src/main/resources/assets/tinker/textures/items/textures to draw/_dagger_handle.png -src/main/resources/assets/tinker/textures/items/textures to draw/_dagger_blade_broken.png -src/main/resources/assets/tinker/textures/items/textures to draw/_dagger_blade.png -src/main/resources/assets/tinker/textures/items/textures to draw/_dagger_accessory.png -src/main/resources/assets/tinker/textures/items/textures to draw/_cutlass_handle.png -src/main/resources/assets/tinker/textures/items/textures to draw/_cutlass_guard.png -src/main/resources/assets/tinker/textures/items/textures to draw/_cutlass_blade_broken.png -src/main/resources/assets/tinker/textures/items/textures to draw/_cutlass_blade.png -src/main/resources/assets/tinker/textures/items/textures to draw/_crossbow_limb.png -src/main/resources/assets/tinker/textures/items/textures to draw/_crossbow_bow_3.png -src/main/resources/assets/tinker/textures/items/textures to draw/_crossbow_bow_2.png -src/main/resources/assets/tinker/textures/items/textures to draw/_crossbow_bow_1.png -src/main/resources/assets/tinker/textures/items/textures to draw/_crossbow_bow.png -src/main/resources/assets/tinker/textures/items/textures to draw/_crossbow_body.png -src/main/resources/assets/tinker/textures/items/textures to draw/_crossbow_body (2).png -src/main/resources/assets/tinker/textures/items/textures to draw/_crossbow_binding.png -src/main/resources/assets/tinker/textures/items/textures to draw/_crossbar.png -src/main/resources/assets/tinker/textures/items/textures to draw/_cleaver_handle.png -src/main/resources/assets/tinker/textures/items/textures to draw/_cleaver_guard.png -src/main/resources/assets/tinker/textures/items/textures to draw/_chisel_head_broken.png -src/main/resources/assets/tinker/textures/items/textures to draw/_chisel_head.png -src/main/resources/assets/tinker/textures/items/textures to draw/_chisel_head (2).png -src/main/resources/assets/tinker/textures/items/textures to draw/_chisel_handle.png -src/main/resources/assets/tinker/textures/items/textures to draw/_bow_top_3.png -src/main/resources/assets/tinker/textures/items/textures to draw/_bow_top_3 (2).png -src/main/resources/assets/tinker/textures/items/textures to draw/_bow_top_2.png -src/main/resources/assets/tinker/textures/items/textures to draw/_bow_top_2 (2).png -src/main/resources/assets/tinker/textures/items/textures to draw/_bow_top_1.png -src/main/resources/assets/tinker/textures/items/textures to draw/_bow_top_1 (2).png -src/main/resources/assets/tinker/textures/items/textures to draw/_bow_top.png -src/main/resources/assets/tinker/textures/items/textures to draw/_bow_top (2).png -src/main/resources/assets/tinker/textures/items/textures to draw/_bow_limb.png -src/main/resources/assets/tinker/textures/items/textures to draw/_bow_grip.png -src/main/resources/assets/tinker/textures/items/textures to draw/_bow_bottom_3.png -src/main/resources/assets/tinker/textures/items/textures to draw/_bow_bottom_3 (2).png -src/main/resources/assets/tinker/textures/items/textures to draw/_bow_bottom_2.png -src/main/resources/assets/tinker/textures/items/textures to draw/_bow_bottom_2 (2).png -src/main/resources/assets/tinker/textures/items/textures to draw/_bow_bottom_1.png -src/main/resources/assets/tinker/textures/items/textures to draw/_bow_bottom_1 (2).png -src/main/resources/assets/tinker/textures/items/textures to draw/_bow_bottom.png -src/main/resources/assets/tinker/textures/items/textures to draw/_bow_bottom (2).png -src/main/resources/assets/tinker/textures/items/textures to draw/_binding.png -src/main/resources/assets/tinker/textures/items/textures to draw/_battlesign_handle.png -src/main/resources/assets/tinker/textures/items/textures to draw/_battleaxe_head_broken.png -src/main/resources/assets/tinker/textures/items/textures to draw/_battleaxe_head.png -src/main/resources/assets/tinker/textures/items/textures to draw/_battleaxe_handle.png -src/main/resources/assets/tinker/textures/items/textures to draw/_battleaxe_fronthead_broken.png -src/main/resources/assets/tinker/textures/items/textures to draw/_battleaxe_fronthead.png -src/main/resources/assets/tinker/textures/items/textures to draw/_battleaxe_front.png -src/main/resources/assets/tinker/textures/items/textures to draw/_battleaxe_binding.png -src/main/resources/assets/tinker/textures/items/textures to draw/_battleaxe_backhead.png -src/main/resources/assets/tinker/textures/items/textures to draw/_battleaxe_back.png -src/main/resources/assets/tinker/textures/items/textures to draw/_axe_handle.png -src/main/resources/assets/tinker/textures/items/textures to draw/_arrow_shaft.png diff --git a/src/main/java/twilightforest/TFCommonProxy.java b/src/main/java/twilightforest/TFCommonProxy.java index c43111fd32..9d16e61686 100644 --- a/src/main/java/twilightforest/TFCommonProxy.java +++ b/src/main/java/twilightforest/TFCommonProxy.java @@ -39,6 +39,10 @@ public int getCakeBlockRenderID() { return 0; } + public int getChestBlockRenderID() { + return 0; + } + public int getComplexBlockRenderID() { return 0; } @@ -75,6 +79,10 @@ public int getKnightmetalBlockRenderID() { return 0; } + public int getFieryMetalBlockRenderID() { + return 0; + } + public int getHugeLilyPadBlockRenderID() { return 0; } @@ -142,6 +150,14 @@ public ModelBiped getFieryArmorModel(int armorSlot) { return null; } + public ModelBiped getTrophyArmorModel(int boss) { + return null; + } + + public ModelBiped getCritterArmorModel(int boss) { + return null; + } + public void doBlockAnnihilateEffect(World worldObj, int blockX, int blockY, int blockZ) {} } diff --git a/src/main/java/twilightforest/TFEventListener.java b/src/main/java/twilightforest/TFEventListener.java index bf93b21f0b..dbce21c0a0 100644 --- a/src/main/java/twilightforest/TFEventListener.java +++ b/src/main/java/twilightforest/TFEventListener.java @@ -1,5 +1,7 @@ package twilightforest; +import java.io.File; +import java.io.IOException; import java.util.ArrayList; import java.util.HashMap; @@ -34,14 +36,15 @@ import net.minecraftforge.event.entity.living.LivingHurtEvent; import net.minecraftforge.event.entity.player.BonemealEvent; import net.minecraftforge.event.entity.player.EntityItemPickupEvent; +import net.minecraftforge.event.entity.player.PlayerEvent; import net.minecraftforge.event.entity.player.PlayerInteractEvent; import net.minecraftforge.event.entity.player.PlayerInteractEvent.Action; import net.minecraftforge.event.world.BlockEvent.BreakEvent; import net.minecraftforge.event.world.BlockEvent.HarvestDropsEvent; import net.minecraftforge.event.world.WorldEvent; -import baubles.common.container.InventoryBaubles; -import baubles.common.lib.PlayerHandler; +import com.google.common.io.Files; + import cpw.mods.fml.common.FMLLog; import cpw.mods.fml.common.eventhandler.Event.Result; import cpw.mods.fml.common.eventhandler.SubscribeEvent; @@ -61,6 +64,7 @@ import twilightforest.entity.EntityTFPinchBeetle; import twilightforest.entity.EntityTFYeti; import twilightforest.integration.TFBaublesIntegration; +import twilightforest.item.ItemTFPhantomArmor; import twilightforest.item.TFItems; import twilightforest.world.ChunkProviderTwilightForest; import twilightforest.world.TFWorldChunkManager; @@ -71,6 +75,9 @@ */ public class TFEventListener { + public static String fileName = "tf"; + public static String fileNameBackup = "tfback"; + protected HashMap playerKeepsMap = new HashMap<>(); protected HashMap playerBaublesMap = new HashMap<>(); private boolean isBreakingWithGiantPick = false; @@ -102,6 +109,9 @@ public void pickupItem(EntityItemPickupEvent event) { case 2 -> event.entityPlayer.triggerAchievement(TFAchievementPage.twilightKillLich); case 3 -> event.entityPlayer.triggerAchievement(TFAchievementPage.twilightProgressUrghast); case 4 -> event.entityPlayer.triggerAchievement(TFAchievementPage.twilightProgressGlacier); + case 5 -> event.entityPlayer.triggerAchievement(TFAchievementPage.twilightProgressLabyrinth); + case 6 -> event.entityPlayer.triggerAchievement(TFAchievementPage.twilightProgressKnights); + case 7 -> event.entityPlayer.triggerAchievement(TFAchievementPage.twilightProgressYeti); } // mazebreaker } else if (item == TFItems.mazebreakerPick) { @@ -421,24 +431,19 @@ public void entityHurts(LivingHurtEvent event) { EntityTFCharmEffect effect = new EntityTFCharmEffect( player.worldObj, player, - charm1 ? TFItems.charmOfLife1 : TFItems.charmOfLife2); + charm1 ? TFItems.charmOfLife1 : TFItems.charmOfLife2, + 0); player.worldObj.spawnEntityInWorld(effect); EntityTFCharmEffect effect2 = new EntityTFCharmEffect( player.worldObj, player, - charm1 ? TFItems.charmOfLife1 : TFItems.charmOfLife2); - effect2.offset = (float) Math.PI; + charm1 ? TFItems.charmOfLife1 : TFItems.charmOfLife2, + (float) Math.PI); player.worldObj.spawnEntityInWorld(effect2); // sound - player.worldObj.playSoundEffect( - player.posX + 0.5D, - player.posY + 0.5D, - player.posZ + 0.5D, - "mob.zombie.unfect", - 1.5F, - 1.0F); + player.worldObj.playSoundEffect(player.posX, player.posY, player.posZ, "mob.zombie.unfect", 1.5F, 1.0F); } } @@ -570,6 +575,17 @@ public void livingDies(LivingDeathEvent event) { } playerKeepsMap.put(player.getCommandSenderName(), keepInventory); } + + // check for phantom armor + for (int i = 0; i < 4; i++) { + if (player.inventory.armorInventory[i] != null + && player.inventory.armorInventory[i].getItem() instanceof ItemTFPhantomArmor) { + InventoryPlayer keepInventory = retrieveOrMakeKeepInventory(player); + keepInventory.armorInventory[i] = ItemStack.copyItemStack(player.inventory.armorInventory[i]); + player.inventory.armorInventory[i] = null; + playerKeepsMap.put(player.getCommandSenderName(), keepInventory); + } + } } if (playerKeepsMap.size() > 1) { @@ -599,6 +615,51 @@ private void keepAllArmor(EntityPlayer player, InventoryPlayer keepInventory) { } } + @SubscribeEvent + public void playerLoad(PlayerEvent.LoadFromFile event) { + playerLoadDo(event.entityPlayer, event.playerDirectory); + } + + private void playerLoadDo(EntityPlayer player, File directory) { + File file1, file2; + + // look for normal files first + file1 = getPlayerFile(fileName, directory, player.getCommandSenderName()); + file2 = getPlayerFile(fileNameBackup, directory, player.getCommandSenderName()); + + // look for uuid files when normal file missing + if (!file1.exists()) { + File filep = getPlayerFileUUID(fileName, directory, player.getGameProfile().getId().toString()); + if (filep.exists()) { + try { + Files.copy(filep, file1); + System.out.println( + "Using and converting UUID Charm of Keeping savefile for " + player.getCommandSenderName()); + filep.delete(); + File fb = getPlayerFileUUID(fileNameBackup, directory, player.getGameProfile().getId().toString()); + if (fb.exists()) fb.delete(); + } catch (IOException e) {} + } + } + + TFPlayerHandler.loadPlayerKeepInventory(player, file1, file2); + } + + public static File getPlayerFile(String suffix, File playerDirectory, String playername) { + if ("dat".equals(suffix)) throw new IllegalArgumentException("The suffix 'dat' is reserved"); + return new File(playerDirectory, playername + "." + suffix); + } + + public File getPlayerFileUUID(String suffix, File playerDirectory, String playerUUID) { + if ("dat".equals(suffix)) throw new IllegalArgumentException("The suffix 'dat' is reserved"); + return new File(playerDirectory, playerUUID + "." + suffix); + } + + @SubscribeEvent + public void playerSave(PlayerEvent.SaveToFile event) { + TFBaublesIntegration.playerSaveDo(event.entityPlayer, event.playerDirectory); + } + /** * Maybe we kept some stuff for the player! */ @@ -627,35 +688,25 @@ public void onPlayerRespawn(PlayerRespawnEvent event) { } } - if (TwilightForestMod.areBaublesLoaded && baublesInventory != null) { - InventoryBaubles inventoryBaubles = PlayerHandler.getPlayerBaubles(player); - for (int i = 0; i < inventoryBaubles.getSizeInventory(); i++) { - if (baublesInventory[i] != null) inventoryBaubles.setInventorySlotContents(i, baublesInventory[i]); - } - } + TFBaublesIntegration.restoreBaubles(player, baublesInventory); // spawn effect thingers if (keepInventory.getItemStack() != null) { EntityTFCharmEffect effect = new EntityTFCharmEffect( player.worldObj, player, - keepInventory.getItemStack().getItem()); + keepInventory.getItemStack().getItem(), + 0); player.worldObj.spawnEntityInWorld(effect); EntityTFCharmEffect effect2 = new EntityTFCharmEffect( player.worldObj, player, - keepInventory.getItemStack().getItem()); - effect2.offset = (float) Math.PI; + keepInventory.getItemStack().getItem(), + (float) Math.PI); player.worldObj.spawnEntityInWorld(effect2); - player.worldObj.playSoundEffect( - player.posX + 0.5D, - player.posY + 0.5D, - player.posZ + 0.5D, - "mob.zombie.unfect", - 1.5F, - 1.0F); + player.worldObj.playSoundEffect(player.posX, player.posY, player.posZ, "mob.zombie.unfect", 1.5F, 1.0F); } playerKeepsMap.remove(player.getCommandSenderName()); playerBaublesMap.remove(player.getCommandSenderName()); @@ -668,18 +719,8 @@ public void onPlayerRespawn(PlayerRespawnEvent event) { @SubscribeEvent public void onPlayerLogout(PlayerLoggedOutEvent event) { EntityPlayer player = event.player; - if (playerKeepsMap.containsKey(player.getCommandSenderName())) { - FMLLog.warning( - "[TwilightForest] Mod was keeping inventory items in reserve for player %s but they logged out! Items are being dropped.", - player.getCommandSenderName()); - InventoryPlayer keepInventory = playerKeepsMap.get(player.getCommandSenderName()); - - // set player to the player logging out - keepInventory.player = player; - keepInventory.dropAllItems(); - + if (playerKeepsMap.containsKey(player.getCommandSenderName())) playerKeepsMap.remove(player.getCommandSenderName()); - } } /** diff --git a/src/main/java/twilightforest/TFPlayerHandler.java b/src/main/java/twilightforest/TFPlayerHandler.java new file mode 100644 index 0000000000..3c6e1b7fa4 --- /dev/null +++ b/src/main/java/twilightforest/TFPlayerHandler.java @@ -0,0 +1,126 @@ +package twilightforest; + +import java.io.File; +import java.io.FileInputStream; +import java.io.FileOutputStream; +import java.util.HashMap; + +import net.minecraft.entity.player.EntityPlayer; +import net.minecraft.entity.player.InventoryPlayer; +import net.minecraft.nbt.CompressedStreamTools; +import net.minecraft.nbt.NBTTagCompound; +import net.minecraft.nbt.NBTTagList; + +import com.google.common.io.Files; + +import twilightforest.integration.TFBaublesIntegration; + +public class TFPlayerHandler { + + protected static HashMap playerKeepsMap = new HashMap<>(); + + public static void clearPlayerMaps(EntityPlayer player) { + playerKeepsMap.remove(player.getCommandSenderName()); + TFBaublesIntegration.clearPlayerMap(player); + } + + public static InventoryPlayer getPlayerKeepInventory(EntityPlayer player) { + if (!playerKeepsMap.containsKey(player.getCommandSenderName())) { + InventoryPlayer inventory = new InventoryPlayer(player); + playerKeepsMap.put(player.getCommandSenderName(), inventory); + } + return playerKeepsMap.get(player.getCommandSenderName()); + } + + public static void setPlayerKeepInventory(EntityPlayer player, InventoryPlayer inventory) { + playerKeepsMap.put(player.getCommandSenderName(), inventory); + } + + public static void loadPlayerKeepInventory(EntityPlayer player, File file1, File file2) { + if (player != null && !player.worldObj.isRemote) { + try { + NBTTagCompound data = null; + boolean save = false; + if (file1 != null && file1.exists()) { + try { + FileInputStream fileinputstream = new FileInputStream(file1); + data = CompressedStreamTools.readCompressed(fileinputstream); + fileinputstream.close(); + } catch (Exception e) { + e.printStackTrace(); + } + } + + if (file1 == null || !file1.exists() || data == null || data.hasNoTags()) { + System.out.println( + "Data not found for " + player.getCommandSenderName() + ". Trying to load backup data."); + if (file2 != null && file2.exists()) { + try { + FileInputStream fileinputstream = new FileInputStream(file2); + data = CompressedStreamTools.readCompressed(fileinputstream); + fileinputstream.close(); + save = true; + } catch (Exception e) { + e.printStackTrace(); + } + } + } + + if (data != null) { + InventoryPlayer keepInventory = new InventoryPlayer(player); + keepInventory.readFromNBT(data.getTagList("KeepInventory", 10)); + playerKeepsMap.put(player.getCommandSenderName(), keepInventory); + + TFBaublesIntegration.loadPlayerKeepBaubles(player, data); + + if (save) savePlayerKeepInventory(player, file1, file2); + } + } catch (Exception exception1) { + System.out.println("Error loading keep inventory"); + exception1.printStackTrace(); + } + } + } + + public static void savePlayerKeepInventory(EntityPlayer player, File file1, File file2) { + if (player != null && !player.worldObj.isRemote) { + try { + if (file1 != null && file1.exists()) { + try { + Files.copy(file1, file2); + } catch (Exception e) { + System.out.println( + "Could not backup old keep inventory file for player " + player.getCommandSenderName()); + } + } + + try { + if (file1 != null) { + InventoryPlayer inventory = getPlayerKeepInventory(player); + NBTTagCompound data = new NBTTagCompound(); + data.setTag("KeepInventory", inventory.writeToNBT(new NBTTagList())); + + TFBaublesIntegration.savePlayerKeepBaubles(player, data); + + FileOutputStream fileoutputstream = new FileOutputStream(file1); + CompressedStreamTools.writeCompressed(data, fileoutputstream); + fileoutputstream.close(); + + } + } catch (Exception e) { + System.out + .println("Could not save keep inventory file for player " + player.getCommandSenderName()); + e.printStackTrace(); + if (file1.exists()) { + try { + file1.delete(); + } catch (Exception e2) {} + } + } + } catch (Exception exception1) { + System.out.println("Error saving keep inventory"); + exception1.printStackTrace(); + } + } + } +} diff --git a/src/main/java/twilightforest/TFTreasure.java b/src/main/java/twilightforest/TFTreasure.java index 0f4a43b190..e6b8c38231 100644 --- a/src/main/java/twilightforest/TFTreasure.java +++ b/src/main/java/twilightforest/TFTreasure.java @@ -260,7 +260,7 @@ protected void fill(int i) { uncommon.add(Items.melon_seeds, 4); uncommon.add(Items.pumpkin_seeds, 4); uncommon.add(Items.arrow, 12); - uncommon.add(TFBlocks.firefly, 4); + uncommon.add(new ItemStack(TFItems.critter, 4, 0)); rare.add(Blocks.web, 3); rare.add(Items.shears, 1); rare.add(Items.saddle, 1); @@ -278,7 +278,7 @@ protected void fill(int i) { common.add(TFItems.mazeWafer, 12); common.add(Items.gunpowder, 4); common.add(TFItems.ironwoodIngot, 4); - common.add(TFBlocks.firefly, 5); + common.add(new ItemStack(TFItems.critter, 5, 0)); common.add(Items.milk_bucket, 1); uncommon.add(TFItems.steeleafIngot, 6); uncommon.add(TFItems.steeleafLegs, 1); @@ -306,7 +306,7 @@ protected void fill(int i) { uncommon.add(Items.paper, 5); uncommon.add(Items.iron_ingot, 6); uncommon.add(TFItems.ironwoodIngot, 8); - uncommon.add(TFBlocks.firefly, 5); + uncommon.add(new ItemStack(TFItems.critter, 5, 0)); uncommon.add(TFItems.charmOfKeeping1, 1); rare.add(TFItems.steeleafIngot, 8); rare.add(Items.golden_apple, 1); @@ -471,7 +471,7 @@ protected void fill(int i) { uncommon.add(Blocks.redstone_lamp, 3); uncommon.add(Items.iron_ingot, 6); uncommon.add(TFItems.ironwoodIngot, 8); - uncommon.add(TFBlocks.firefly, 5); + uncommon.add(new ItemStack(TFItems.critter, 5, 0)); uncommon.add(TFItems.charmOfKeeping1, 1); rare.add(TFItems.steeleafIngot, 8); rare.add(Items.diamond, 2); @@ -484,7 +484,7 @@ protected void fill(int i) { common.add(TFItems.experiment115, 12); common.add(Items.gunpowder, 4); common.add(TFItems.ironwoodIngot, 4); - common.add(TFBlocks.firefly, 5); + common.add(new ItemStack(TFItems.critter, 5, 0)); common.add(Items.redstone, 12); common.add(Items.glowstone_dust, 12); uncommon.add(TFItems.steeleafIngot, 6); @@ -518,7 +518,7 @@ protected void fill(int i) { common.add(Items.water_bucket, 1); common.add(Items.milk_bucket, 1); common.add(Items.melon_seeds, 5); - uncommon.add(new ItemStack(TFBlocks.firefly, 12)); + uncommon.add(new ItemStack(TFItems.critter, 12, 0)); uncommon.add(new ItemStack(TFBlocks.sapling, 4, 0)); uncommon.add(new ItemStack(TFBlocks.sapling, 4, 1)); uncommon.add(new ItemStack(TFBlocks.sapling, 4, 2)); @@ -544,7 +544,7 @@ protected void fill(int i) { uncommon.add(Items.bucket, 1); uncommon.add(Items.iron_ingot, 6); uncommon.add(TFItems.ironwoodIngot, 6); - uncommon.add(TFBlocks.firefly, 5); + uncommon.add(new ItemStack(TFItems.critter, 5, 0)); uncommon.add(TFItems.charmOfKeeping1, 1); uncommon.add(TFItems.armorShard, 3); rare.add(TFItems.knightMetal, 8); @@ -568,7 +568,7 @@ protected void fill(int i) { common.add(TFItems.mazeWafer, 12); common.add(Items.gunpowder, 4); common.add(TFItems.ironwoodIngot, 4); - common.add(TFBlocks.firefly, 5); + common.add(new ItemStack(TFItems.critter, 5, 0)); common.add(Items.milk_bucket, 1); uncommon.add(TFItems.steeleafIngot, 6); uncommon.add(TFItems.steeleafLegs, 1); @@ -596,6 +596,7 @@ protected void fill(int i) { uncommon.addRandomEnchanted(TFItems.phantomPlate, 20); rare.addRandomEnchanted(TFItems.phantomHelm, 30); rare.addRandomEnchanted(TFItems.phantomPlate, 30); + rare.add(new ItemStack(TFItems.trophy, 1, 6)); } case 18 -> { // aurora cache @@ -608,7 +609,7 @@ protected void fill(int i) { common.add(TFItems.ironwoodIngot, 2); uncommon.add(TFBlocks.auroraBlock, 12); uncommon.add(TFItems.ironwoodIngot, 6); - uncommon.add(TFBlocks.firefly, 5); + uncommon.add(new ItemStack(TFItems.critter, 5, 0)); uncommon.add(TFItems.charmOfKeeping1, 1); uncommon.add(TFItems.arcticFur, 3); rare.add(TFItems.arcticFur, 8); @@ -629,7 +630,7 @@ protected void fill(int i) { common.add(Blocks.packed_ice, 4); common.add(TFItems.mazeWafer, 12); common.add(TFItems.iceBomb, 4); - common.add(TFBlocks.firefly, 5); + common.add(new ItemStack(TFItems.critter, 5, 0)); uncommon.add(TFItems.arcticFur, 6); uncommon.add(TFItems.arcticLegs, 1); uncommon.add(TFItems.arcticPlate, 1); diff --git a/src/main/java/twilightforest/TwilightForestMod.java b/src/main/java/twilightforest/TwilightForestMod.java index 8e94100f50..0bcc703416 100644 --- a/src/main/java/twilightforest/TwilightForestMod.java +++ b/src/main/java/twilightforest/TwilightForestMod.java @@ -372,6 +372,9 @@ public void postInit(FMLPostInitializationEvent evt) { TFNeiIntegration.hideItem(new ItemStack(TFBlocks.doorTime)); TFNeiIntegration.hideItem(new ItemStack(TFBlocks.doorTrans)); TFNeiIntegration.hideItem(new ItemStack(TFBlocks.doorTwilight)); + TFNeiIntegration.hideItem(new ItemStack(TFBlocks.firefly)); + TFNeiIntegration.hideItem(new ItemStack(TFBlocks.cicada)); + TFNeiIntegration.hideItem(new ItemStack(TFBlocks.moonworm)); for (int i = 0; i < 16; i++) TFNeiIntegration.hideItem(new ItemStack(TFBlocks.oldNagastone, 1, i)); } diff --git a/src/main/java/twilightforest/block/BlockTFBossSpawner.java b/src/main/java/twilightforest/block/BlockTFBossSpawner.java index 552d882c02..ec00b32262 100644 --- a/src/main/java/twilightforest/block/BlockTFBossSpawner.java +++ b/src/main/java/twilightforest/block/BlockTFBossSpawner.java @@ -16,9 +16,11 @@ import cpw.mods.fml.relauncher.Side; import cpw.mods.fml.relauncher.SideOnly; +import twilightforest.tileentity.TileEntityTFAlphaYetiSpawner; import twilightforest.tileentity.TileEntityTFHydraSpawner; import twilightforest.tileentity.TileEntityTFKnightPhantomsSpawner; import twilightforest.tileentity.TileEntityTFLichSpawner; +import twilightforest.tileentity.TileEntityTFMinoshroomSpawner; import twilightforest.tileentity.TileEntityTFNagaSpawner; import twilightforest.tileentity.TileEntityTFSnowQueenSpawner; import twilightforest.tileentity.TileEntityTFTowerBossSpawner; @@ -58,6 +60,8 @@ public TileEntity createTileEntity(World world, int meta) { case 3 -> new TileEntityTFTowerBossSpawner(); case 4 -> new TileEntityTFKnightPhantomsSpawner(); case 5 -> new TileEntityTFSnowQueenSpawner(); + case 6 -> new TileEntityTFMinoshroomSpawner(); + case 7 -> new TileEntityTFAlphaYetiSpawner(); default -> null; }; } @@ -90,12 +94,14 @@ public boolean isOpaqueCube() { */ @Override public void getSubBlocks(Item item, CreativeTabs tab, List list) { - list.add(new ItemStack(item, 1, 0)); - list.add(new ItemStack(item, 1, 1)); - list.add(new ItemStack(item, 1, 2)); - list.add(new ItemStack(item, 1, 3)); - list.add(new ItemStack(item, 1, 4)); - list.add(new ItemStack(item, 1, 5)); + list.add(new ItemStack(item, 1, 0)); // Naga + list.add(new ItemStack(item, 1, 1)); // Lich + list.add(new ItemStack(item, 1, 6)); // Minoshroom + list.add(new ItemStack(item, 1, 2)); // Hydra + list.add(new ItemStack(item, 1, 4)); // Knight Phantoms + list.add(new ItemStack(item, 1, 3)); // Ur-Ghast + list.add(new ItemStack(item, 1, 7)); // Alpha Yeti + list.add(new ItemStack(item, 1, 5)); // Snow Queen } /** diff --git a/src/main/java/twilightforest/block/BlockTFBurntThorns.java b/src/main/java/twilightforest/block/BlockTFBurntThorns.java index 14eec5f5de..01d5b650f1 100644 --- a/src/main/java/twilightforest/block/BlockTFBurntThorns.java +++ b/src/main/java/twilightforest/block/BlockTFBurntThorns.java @@ -3,6 +3,7 @@ import net.minecraft.block.Block; import net.minecraft.entity.Entity; import net.minecraft.entity.EntityLivingBase; +import net.minecraft.entity.IProjectile; import net.minecraft.entity.player.EntityPlayer; import net.minecraft.world.IBlockAccess; import net.minecraft.world.World; @@ -27,7 +28,7 @@ protected BlockTFBurntThorns() { */ public void onEntityCollidedWithBlock(World world, int x, int y, int z, Entity entity) { // dissolve - if (!world.isRemote && entity instanceof EntityLivingBase) { + if (!world.isRemote && (entity instanceof EntityLivingBase || entity instanceof IProjectile)) { int metadata = world.getBlockMetadata(x, y, z); world.playAuxSFX(2001, x, y, z, Block.getIdFromBlock(this) + (metadata << 12)); world.setBlockToAir(x, y, z); diff --git a/src/main/java/twilightforest/block/BlockTFChest.java b/src/main/java/twilightforest/block/BlockTFChest.java new file mode 100644 index 0000000000..f162f57c05 --- /dev/null +++ b/src/main/java/twilightforest/block/BlockTFChest.java @@ -0,0 +1,65 @@ +package twilightforest.block; + +import net.minecraft.block.BlockChest; +import net.minecraft.client.renderer.texture.IIconRegister; +import net.minecraft.tileentity.TileEntity; +import net.minecraft.world.World; + +import cpw.mods.fml.relauncher.Side; +import cpw.mods.fml.relauncher.SideOnly; +import twilightforest.TwilightForestMod; +import twilightforest.item.TFItems; +import twilightforest.tileentity.TileEntityTFChest; + +public class BlockTFChest extends BlockChest { + + public enum WoodType { + TWILIGHT, + CANOPY, + MANGROVE, + DARKWOOD, + TIME, + TRANS, + MINING, + SORT, + NULL + } + + private WoodType material = WoodType.CANOPY; + + protected BlockTFChest(int type, WoodType material) { + super(type); + this.material = material; + this.setHardness(2.5F); + this.setStepSound(soundTypeWood); + this.setCreativeTab(TFItems.creativeTab); + } + + public WoodType getWoodType() { + return material; + } + + @Override + @SideOnly(Side.CLIENT) + public void registerBlockIcons(IIconRegister reg) { + this.blockIcon = reg + .registerIcon(TwilightForestMod.ID + ":wood/planks_" + BlockTFWood.names[material.ordinal()] + "_0"); + } + + /** + * The type of render function that is called for this block + */ + @Override + public int getRenderType() { + return TwilightForestMod.proxy.getChestBlockRenderID(); + } + + /** + * Returns a new instance of a block's tile entity class. Called on placing the block. + */ + public TileEntity createNewTileEntity(World worldIn, int meta) { + TileEntityTFChest tileentitychest = new TileEntityTFChest(); + return tileentitychest; + } + +} diff --git a/src/main/java/twilightforest/block/BlockTFCicada.java b/src/main/java/twilightforest/block/BlockTFCicada.java index 0b01d8cdde..30268e59da 100644 --- a/src/main/java/twilightforest/block/BlockTFCicada.java +++ b/src/main/java/twilightforest/block/BlockTFCicada.java @@ -1,6 +1,13 @@ package twilightforest.block; +import net.minecraft.client.Minecraft; +import net.minecraft.client.audio.ISound; +import net.minecraft.entity.Entity; +import net.minecraft.entity.player.EntityPlayer; +import net.minecraft.init.Items; import net.minecraft.tileentity.TileEntity; +import net.minecraft.util.ChunkCoordinates; +import net.minecraft.world.Explosion; import net.minecraft.world.World; import twilightforest.tileentity.TileEntityTFCicada; @@ -11,6 +18,8 @@ public class BlockTFCicada extends BlockTFCritter { protected BlockTFCicada() { super(); + this.dropItem = Items.dye; + this.dropMeta = 2; } @Override @@ -18,4 +27,64 @@ public TileEntity createTileEntity(World world, int metadata) { return new TileEntityTFCicada(); } + /** + * Triggered whenever an entity collides with this block (enters into the block). Args: world, x, y, z, entity + */ + @Override + public void onEntityCollidedWithBlock(World world, int x, int y, int z, Entity entity) { + super.onEntityCollidedWithBlock(world, x, y, z, entity); + // stopSinging(worldIn, x, y, z); + } + + @Override + public boolean dropCritterIfCantStay(World world, int x, int y, int z) { + stopSinging(world, x, y, z); + return super.dropCritterIfCantStay(world, x, y, z); + } + + /** + * Called when the block is attempted to be harvested + */ + public void onBlockHarvested(World worldIn, int x, int y, int z, int meta, EntityPlayer player) { + stopSinging(worldIn, x, y, z); + } + + /** + * Called right before the block is destroyed by a player. Args: world, x, y, z, metaData + */ + public void onBlockDestroyedByPlayer(World worldIn, int x, int y, int z, int meta) { + stopSinging(worldIn, x, y, z); + } + + /** + * Called upon the block being destroyed by an explosion + */ + public void onBlockDestroyedByExplosion(World worldIn, int x, int y, int z, Explosion explosionIn) { + stopSinging(worldIn, x, y, z); + } + + /** + * Called upon block activation (right click on the block.) + */ + public boolean onBlockActivated(World worldIn, int x, int y, int z, EntityPlayer player, int side, float subX, + float subY, float subZ) { + if (super.onBlockActivated(worldIn, x, y, z, player, side, subX, subY, subZ)) { + stopSinging(worldIn, x, y, z); + return true; + } + return false; + } + + public void stopSinging(World worldIn, int x, int y, int z) { + ChunkCoordinates chunkcoordinates = new ChunkCoordinates(x, y, z); + Minecraft mc = Minecraft.getMinecraft(); + ISound isound = (ISound) mc.renderGlobal.mapSoundPositions.get(chunkcoordinates); + + while (isound != null) { + mc.getSoundHandler().stopSound(isound); + mc.renderGlobal.mapSoundPositions.remove(chunkcoordinates); + isound = (ISound) mc.renderGlobal.mapSoundPositions.get(chunkcoordinates); + } + } + } diff --git a/src/main/java/twilightforest/block/BlockTFCompressed.java b/src/main/java/twilightforest/block/BlockTFCompressed.java index 11f6e318f2..5b1b7b8c95 100644 --- a/src/main/java/twilightforest/block/BlockTFCompressed.java +++ b/src/main/java/twilightforest/block/BlockTFCompressed.java @@ -1,9 +1,24 @@ package twilightforest.block; +import static net.minecraftforge.common.util.ForgeDirection.UP; + import net.minecraft.block.BlockCompressed; import net.minecraft.block.material.MapColor; +import net.minecraft.client.renderer.texture.IIconRegister; +import net.minecraft.entity.Entity; +import net.minecraft.entity.EntityLivingBase; +import net.minecraft.entity.player.EntityPlayer; +import net.minecraft.util.AxisAlignedBB; +import net.minecraft.util.DamageSource; +import net.minecraft.util.IIcon; +import net.minecraft.world.IBlockAccess; +import net.minecraft.world.World; +import net.minecraftforge.common.util.ForgeDirection; +import cpw.mods.fml.relauncher.Side; +import cpw.mods.fml.relauncher.SideOnly; import twilightforest.TwilightForestMod; +import twilightforest.client.renderer.BetterIconFlipped; import twilightforest.item.TFItems; public class BlockTFCompressed extends BlockCompressed { @@ -16,7 +31,10 @@ public enum BlockType { STEELEAF } - private BlockType type; + public BlockType type; + + public IIcon[] fieryPattern; + public IIcon[] fieryCore; // 0 - single, 1 - horizontal, 2 - vertical, 3 - cross, 4 - full protected BlockTFCompressed(BlockType blockType) { super(typeToMapColor(blockType)); @@ -39,6 +57,7 @@ protected BlockTFCompressed(BlockType blockType) { textureName = "carminite_block"; break; case FIERY_METAL: + this.setLightLevel(0.5F); hardness = 5.0F; resistance = 10.0F; stepSound = soundTypeMetal; @@ -89,4 +108,182 @@ private static MapColor typeToMapColor(BlockType blockType) { return mapColor; } + /** + * Returns a bounding box from the pool of bounding boxes (this means this box can change after the pool has been + * cleared to be reused) + */ + public AxisAlignedBB getCollisionBoundingBoxFromPool(World worldIn, int x, int y, int z) { + if (this.type == BlockType.FIERY_METAL) return AxisAlignedBB.getBoundingBox( + (double) x, + (double) y, + (double) z, + (double) (x + 1), + (double) (y + 0.99f), + (double) (z + 1)); + else return super.getCollisionBoundingBoxFromPool(worldIn, x, y, z); + } + + /** + * Triggered whenever an entity collides with this block (enters into the block). Args: world, x, y, z, entity + */ + public void onEntityCollidedWithBlock(World worldIn, int x, int y, int z, Entity entityIn) { + if (this.type == BlockType.FIERY_METAL) { + if (entityIn.isSneaking()) return; + if (entityIn instanceof EntityPlayer && ((EntityPlayer) entityIn).inventory.armorInventory[0] != null + && ((EntityPlayer) entityIn).inventory.armorInventory[0].getItem() == TFItems.fieryBoots) + return; + if (entityIn instanceof EntityLivingBase && ((EntityLivingBase) entityIn).getEquipmentInSlot(1) != null + && ((EntityLivingBase) entityIn).getEquipmentInSlot(1).getItem() == TFItems.fieryBoots) + return; + entityIn.attackEntityFrom(DamageSource.inFire, 1); + } + } + + /** + * Block's chance to react to an entity falling on it. + */ + @Override + public void onFallenUpon(World worldIn, int x, int y, int z, Entity entityIn, float fallDistance) { + switch (type) { + case ARCTIC_FUR: + entityIn.fallDistance *= 0.25; + break; + case STEELEAF: + entityIn.fallDistance *= 0.75; + break; + default: + break; + } + } + + /** + * Determines if this block can be used as the base of a beacon. + * + * @param world The current world + * @param x X Position + * @param y Y Position + * @param z Z position + * @param beaconX Beacons X Position + * @param beaconY Beacons Y Position + * @param beaconZ Beacons Z Position + * @return True, to support the beacon, and make it active with this block. + */ + public boolean isBeaconBase(IBlockAccess worldObj, int x, int y, int z, int beaconX, int beaconY, int beaconZ) { + return true; + } + + /** + * Currently only called by fire when it is on top of this block. Returning true will prevent the fire from + * naturally dying during updating. Also prevents firing from dying from rain. + * + * @param world The current world + * @param x The blocks X position + * @param y The blocks Y position + * @param z The blocks Z position + * @param metadata The blocks current metadata + * @param side The face that the fire is coming from + * @return True if this block sustains fire, meaning it will never go out. + */ + public boolean isFireSource(World world, int x, int y, int z, ForgeDirection side) { + if (this.type == BlockType.FIERY_METAL && side == UP) return true; + return false; + } + + /** + * How bright to render this block based on the light its receiving. Args: iBlockAccess, x, y, z + */ + @SideOnly(Side.CLIENT) + public int getMixedBrightnessForBlock(IBlockAccess worldIn, int x, int y, int z) { + if (this.type == BlockType.FIERY_METAL) return 255; + return super.getMixedBrightnessForBlock(worldIn, x, y, z); + } + + /** + * Returns a integer with hex for 0xrrggbb with this color multiplied against the blocks color. Note only called + * when first determining what to render. + */ + @SideOnly(Side.CLIENT) + public int colorMultiplier(IBlockAccess worldIn, int x, int y, int z) { + if (this.type == BlockType.FIERY_METAL) return 0xffffff; + return super.colorMultiplier(worldIn, x, y, z); + } + + public boolean canConnectFieryTo(IBlockAccess worldIn, int x, int y, int z) { + return worldIn.getBlock(x, y, z) == TFBlocks.fieryMetalStorage; + } + + /** + * If this block doesn't render as an ordinary block it will return False (examples: signs, buttons, stairs, etc) + */ + @Override + public boolean renderAsNormalBlock() { + return this.type != BlockType.FIERY_METAL; + } + + /** + * Is this block (a) opaque and (b) a full 1m cube? This determines whether or not to render the shared face of two + * adjacent blocks and also whether the player can attach torches, redstone wire, etc to this block. + */ + @Override + public boolean isOpaqueCube() { + return true; + } + + /** + * Return true if the block is a normal, solid cube. This determines indirect power state, entity ejection from + * blocks, and a few others. + * + * @param world The current world + * @param x X Position + * @param y Y position + * @param z Z position + * @return True if the block is a full cube + */ + @Override + public boolean isNormalCube(IBlockAccess world, int x, int y, int z) { + return true; + } + + /** + * Checks if the block is a solid face on the given side, used by placement logic. + * + * @param world The current world + * @param x X Position + * @param y Y position + * @param z Z position + * @param side The side to check + * @return True if the block is solid on the specified side. + */ + @Override + public boolean isSideSolid(IBlockAccess world, int x, int y, int z, ForgeDirection side) { + if (this.type == BlockType.FIERY_METAL) return side == ForgeDirection.UP; + return true; + } + + /** + * The type of render function that is called for this block + */ + @Override + public int getRenderType() { + if (this.type == BlockType.FIERY_METAL) return TwilightForestMod.proxy.getFieryMetalBlockRenderID(); + else return super.getRenderType(); + } + + @SideOnly(Side.CLIENT) + public void registerBlockIcons(IIconRegister reg) { + this.fieryPattern = new IIcon[4]; + this.fieryPattern[0] = reg.registerIcon(TwilightForestMod.ID + ":fiery_pattern"); + this.fieryPattern[1] = new BetterIconFlipped(this.fieryPattern[0], true, false); + this.fieryPattern[2] = new BetterIconFlipped(this.fieryPattern[0], false, true); + this.fieryPattern[3] = new BetterIconFlipped(this.fieryPattern[0], true, true); + + this.fieryCore = new IIcon[5]; + this.fieryCore[0] = reg.registerIcon(TwilightForestMod.ID + ":fiery_block_inner"); + this.fieryCore[1] = reg.registerIcon(TwilightForestMod.ID + ":fiery_block_inner_horizontal"); + this.fieryCore[2] = reg.registerIcon(TwilightForestMod.ID + ":fiery_block_inner_vertical"); + this.fieryCore[3] = reg.registerIcon(TwilightForestMod.ID + ":fiery_block_inner_cross"); + this.fieryCore[4] = reg.registerIcon(TwilightForestMod.ID + ":fiery_block_inner_full"); + super.registerBlockIcons(reg); + } + } diff --git a/src/main/java/twilightforest/block/BlockTFCritter.java b/src/main/java/twilightforest/block/BlockTFCritter.java index eb78910e4c..3b53850601 100644 --- a/src/main/java/twilightforest/block/BlockTFCritter.java +++ b/src/main/java/twilightforest/block/BlockTFCritter.java @@ -6,11 +6,17 @@ import static net.minecraftforge.common.util.ForgeDirection.WEST; import java.util.List; +import java.util.Random; import net.minecraft.block.Block; import net.minecraft.block.material.Material; import net.minecraft.client.renderer.texture.IIconRegister; import net.minecraft.creativetab.CreativeTabs; +import net.minecraft.entity.Entity; +import net.minecraft.entity.IProjectile; +import net.minecraft.entity.item.EntityItem; +import net.minecraft.entity.player.EntityPlayer; +import net.minecraft.init.Items; import net.minecraft.item.Item; import net.minecraft.item.ItemStack; import net.minecraft.tileentity.TileEntity; @@ -25,6 +31,9 @@ public abstract class BlockTFCritter extends Block { + protected Item dropItem = Items.glowstone_dust; + protected int dropMeta = 0; + protected BlockTFCritter() { super(Material.circuits); this.setHardness(0.0F); @@ -33,6 +42,27 @@ protected BlockTFCritter() { this.stepSound = new StepSoundTFInsect("squish", 0.25F, 0.6F); } + /** + * Triggered whenever an entity collides with this block (enters into the block). Args: world, x, y, z, entity + */ + public void onEntityCollidedWithBlock(World world, int x, int y, int z, Entity entity) { + // squish + if (!world.isRemote && (entity instanceof IProjectile)) { + int metadata = world.getBlockMetadata(x, y, z); + world.playAuxSFX(2001, x, y, z, Block.getIdFromBlock(this) + (metadata << 12)); + world.setBlockToAir(x, y, z); + double dx = this.getBlockBoundsMinX() + + world.rand.nextDouble() * (this.getBlockBoundsMaxX() - this.getBlockBoundsMinX()); + double dy = this.getBlockBoundsMinY() + + world.rand.nextDouble() * (this.getBlockBoundsMaxY() - this.getBlockBoundsMinY()); + double dz = this.getBlockBoundsMinZ() + + world.rand.nextDouble() * (this.getBlockBoundsMaxZ() - this.getBlockBoundsMinZ()); + EntityItem entityitem = new EntityItem(world, x + dx, y + dy, z + dz, new ItemStack(dropItem, 1, dropMeta)); + entityitem.delayBeforeCanPickup = 10; + world.spawnEntityInWorld(entityitem); + } + } + // Updates the blocks bounds based on its current state. Args: world, x, y, z @Override public void setBlockBoundsBasedOnState(IBlockAccess world, int x, int y, int z) { @@ -255,7 +285,51 @@ public boolean hasTileEntity(int metadata) { */ @Override public void getSubBlocks(Item item, CreativeTabs par2CreativeTabs, List itemList) { - itemList.add(new ItemStack(item, 1, 0)); + // itemList.add(new ItemStack(item, 1, 0)); + // We're using an item instead + } + + @Override + public Item getItemDropped(int meta, Random random, int fortune) { + return TFItems.critter; + } + + /** + * Determines the damage on the item the block drops. Used in cloth and wood. + */ + @Override + public int damageDropped(int par1) { + int metadata = 0; + if (this == TFBlocks.cicada) metadata = 1; + else if (this == TFBlocks.moonworm) metadata = 2; + return metadata; + } + + /** + * Gets an item for the block being called on. Args: world, x, y, z + */ + @SideOnly(Side.CLIENT) + public Item getItem(World p_149694_1_, int p_149694_2_, int p_149694_3_, int p_149694_4_) { + return TFItems.critter; + } + + @SideOnly(Side.CLIENT) + @Override + public int getDamageValue(World worldIn, int x, int y, int z) { + return this.damageDropped(0); + } + + /** + * Called upon block activation (right click on the block.) + */ + public boolean onBlockActivated(World worldIn, int x, int y, int z, EntityPlayer player, int side, float subX, + float subY, float subZ) { + if (player.isSneaking() && player.inventory.armorInventory[3] == null) { + player.inventory.armorInventory[3] = new ItemStack(TFItems.critter, 1, this.damageDropped(0)); + if (!player.capabilities.isCreativeMode) worldIn.setBlockToAir(x, y, z); + return true; + } + return false; } /** diff --git a/src/main/java/twilightforest/block/BlockTFFirefly.java b/src/main/java/twilightforest/block/BlockTFFirefly.java index d7af5871ee..475bb03a61 100644 --- a/src/main/java/twilightforest/block/BlockTFFirefly.java +++ b/src/main/java/twilightforest/block/BlockTFFirefly.java @@ -12,7 +12,7 @@ public class BlockTFFirefly extends BlockTFCritter { // public static Random rand = new Random(); - protected BlockTFFirefly() { + public BlockTFFirefly() { super(); this.setLightLevel(0.9375F); } diff --git a/src/main/java/twilightforest/block/BlockTFMoonworm.java b/src/main/java/twilightforest/block/BlockTFMoonworm.java index 81dc651eca..78de43d0b3 100644 --- a/src/main/java/twilightforest/block/BlockTFMoonworm.java +++ b/src/main/java/twilightforest/block/BlockTFMoonworm.java @@ -2,6 +2,7 @@ import java.util.Random; +import net.minecraft.init.Items; import net.minecraft.tileentity.TileEntity; import net.minecraft.world.IBlockAccess; import net.minecraft.world.World; @@ -14,6 +15,8 @@ public class BlockTFMoonworm extends BlockTFCritter { protected BlockTFMoonworm() { super(); + this.dropItem = Items.dye; + this.dropMeta = 10; } /** diff --git a/src/main/java/twilightforest/block/BlockTFNagastone.java b/src/main/java/twilightforest/block/BlockTFNagastone.java index 5fe8de8374..99aa30a7d6 100644 --- a/src/main/java/twilightforest/block/BlockTFNagastone.java +++ b/src/main/java/twilightforest/block/BlockTFNagastone.java @@ -170,7 +170,6 @@ public boolean placePerfectFitBody(World world, int x, int y, int z) { */ public boolean placePerfectFitHead(World world, int x, int y, int z) { int connect = getOnlyNSEWConnection(world, x, y, z); - if (connect != -1) { // if the first connection is n/s/e/w, and the second connection is not, we win! // System.out.println("Got a perfect head fit : " + connect); diff --git a/src/main/java/twilightforest/block/BlockTFThornRose.java b/src/main/java/twilightforest/block/BlockTFThornRose.java index cc758a614b..5343433cee 100644 --- a/src/main/java/twilightforest/block/BlockTFThornRose.java +++ b/src/main/java/twilightforest/block/BlockTFThornRose.java @@ -2,6 +2,7 @@ import net.minecraft.block.Block; import net.minecraft.block.material.Material; +import net.minecraft.init.Blocks; import net.minecraft.util.AxisAlignedBB; import net.minecraft.world.World; import net.minecraftforge.common.util.ForgeDirection; @@ -74,18 +75,19 @@ public void onNeighborBlockChange(World world, int x, int y, int z, Block block) * Can this block stay at this position. Similar to canPlaceBlockAt except gets checked often with plants. */ public boolean canBlockStay(World world, int x, int y, int z) { - boolean supported = false; - for (ForgeDirection dir : ForgeDirection.VALID_DIRECTIONS) { int dx = x + dir.offsetX; int dy = y + dir.offsetY; int dz = z + dir.offsetZ; - if (world.getBlock(dx, dy, dz).canSustainLeaves(world, dx, dy, dz)) { - supported = true; + Block block = world.getBlock(dx, dy, dz); + if (block.canSustainLeaves(world, dx, dy, dz) || block.isLeaves(world, dx, dy, dz) + || (dir == ForgeDirection.DOWN + && block.canSustainPlant(world, dx, dy, dz, ForgeDirection.UP, Blocks.red_flower))) { + return true; } } - return supported; + return false; } } diff --git a/src/main/java/twilightforest/block/BlockTFTrophy.java b/src/main/java/twilightforest/block/BlockTFTrophy.java index afd74f63b6..2e79f560cc 100644 --- a/src/main/java/twilightforest/block/BlockTFTrophy.java +++ b/src/main/java/twilightforest/block/BlockTFTrophy.java @@ -21,6 +21,15 @@ import cpw.mods.fml.relauncher.Side; import cpw.mods.fml.relauncher.SideOnly; +import twilightforest.entity.boss.EntityTFHydra; +import twilightforest.entity.boss.EntityTFKnightPhantom; +import twilightforest.entity.boss.EntityTFLich; +import twilightforest.entity.boss.EntityTFMinoshroom; +import twilightforest.entity.boss.EntityTFNaga; +import twilightforest.entity.boss.EntityTFSnowQueen; +import twilightforest.entity.boss.EntityTFUrGhast; +import twilightforest.entity.boss.EntityTFYetiAlpha; +import twilightforest.entity.passive.EntityTFQuestRam; import twilightforest.item.TFItems; import twilightforest.tileentity.TileEntityTFTrophy; @@ -32,6 +41,7 @@ public class BlockTFTrophy extends BlockContainer { public BlockTFTrophy() { super(Material.circuits); + this.setStepSound(soundTypeCloth); this.setBlockBounds(0.25F, 0.0F, 0.25F, 0.75F, 0.5F, 0.75F); } @@ -88,6 +98,41 @@ public void setBlockBoundsBasedOnState(IBlockAccess par1IBlockAccess, int x, int } else if (trophy != null && trophy.func_145904_a() == 3) { // urghast bounds this.setBlockBounds(0.25F, 0.5F, 0.25F, 0.75F, 1F, 0.75F); + } else if (trophy != null && trophy.func_145904_a() == 7) { + // alpha yeti skull bounds + float pixel = 1f / 16; + switch (meta) { + default -> this + .setBlockBounds(pixel * 3.2f, 0.0F, pixel * 3.2f, 1 - pixel * 3.2f, 0.665F, 1 - pixel * 3.2f); + case 2 -> this.setBlockBounds( + pixel * 3.2f, + pixel * 4, + pixel * 4.4f * 2, + 1 - pixel * 3.2f, + 0.67F + pixel * 4, + 1.0f); + case 3 -> this.setBlockBounds( + pixel * 3.2f, + pixel * 4, + 0.0f, + 1 - pixel * 3.2f, + 0.67F + pixel * 4, + 1.0f - pixel * 4.4f * 2); + case 4 -> this.setBlockBounds( + pixel * 4.4f * 2, + pixel * 4, + pixel * 3.2f, + 1.0f, + 0.67F + pixel * 4, + 1 - pixel * 3.2f); + case 5 -> this.setBlockBounds( + 0.0f, + pixel * 4, + pixel * 3.2f, + 1.0f - pixel * 4.4f * 2, + 0.67F + pixel * 4, + 1 - pixel * 3.2f); + } } else { // normal skull bounds switch (meta) { @@ -145,6 +190,14 @@ public int damageDropped(int par1) { return par1; } + /** + * Gets an item for the block being called on. Args: world, x, y, z + */ + @SideOnly(Side.CLIENT) + public Item getItem(World p_149694_1_, int p_149694_2_, int p_149694_3_, int p_149694_4_) { + return TFItems.trophy; + } + /** * Called when the block is attempted to be harvested */ @@ -212,4 +265,60 @@ public void registerBlockIcons(IIconRegister par1IconRegister) { // don't load anything } + /** + * Called upon block activation (right click on the block.) + */ + @Override + public boolean onBlockActivated(World worldIn, int x, int y, int z, EntityPlayer player, int side, float subX, + float subY, float subZ) { + if (player.isSneaking() && player.inventory.armorInventory[3] == null) { + player.inventory.armorInventory[3] = new ItemStack( + TFItems.trophy, + 1, + this.getDamageValue(worldIn, x, y, z)); + if (!player.capabilities.isCreativeMode) worldIn.setBlockToAir(x, y, z); + return true; + } else { + String sound; + switch (((TileEntitySkull) worldIn.getTileEntity(x, y, z)).func_145904_a()) { + default: + case 0: + sound = new EntityTFHydra(worldIn).getTrophySound(); + break; + case 1: + sound = new EntityTFNaga(worldIn).getTrophySound(); + break; + case 2: + sound = new EntityTFLich(worldIn).getTrophySound(); + break; + case 3: + sound = new EntityTFUrGhast(worldIn).getTrophySound(); + break; + case 4: + sound = new EntityTFSnowQueen(worldIn).getTrophySound(); + break; + case 5: + sound = new EntityTFMinoshroom(worldIn).getTrophySound(); + break; + case 6: + sound = new EntityTFKnightPhantom(worldIn).getTrophySound(); + break; + case 7: + sound = new EntityTFYetiAlpha(worldIn).getTrophySound(); + break; + case 8: + sound = new EntityTFQuestRam(worldIn).getTrophySound(); + break; + } + worldIn.playSoundEffect( + (double) x + 0.5D, + (double) y + 0.5D, + (double) z + 0.5D, + sound, + 1.0F, + worldIn.rand.nextFloat() * 0.1F + 0.9F); + return true; + } + } + } diff --git a/src/main/java/twilightforest/block/BlockTFTrophyPedestal.java b/src/main/java/twilightforest/block/BlockTFTrophyPedestal.java index 908826666f..a767a26bd4 100644 --- a/src/main/java/twilightforest/block/BlockTFTrophyPedestal.java +++ b/src/main/java/twilightforest/block/BlockTFTrophyPedestal.java @@ -16,10 +16,12 @@ import net.minecraft.item.ItemStack; import net.minecraft.stats.StatFileWriter; import net.minecraft.stats.StatisticsFile; +import net.minecraft.tileentity.TileEntitySkull; import net.minecraft.util.AxisAlignedBB; import net.minecraft.util.ChatComponentText; import net.minecraft.util.IIcon; import net.minecraft.util.MathHelper; +import net.minecraft.util.StatCollector; import net.minecraft.world.IBlockAccess; import net.minecraft.world.World; @@ -185,10 +187,35 @@ public void onNeighborBlockChange(World par1World, int x, int y, int z, Block my if (isTrophyOnTop(par1World, x, y, z)) { par1World.scheduleBlockUpdate(x, y, z, this, 1); } + updateComparators(par1World, x, y, z); } } + private void updateComparators(World par1World, int x, int y, int z) { + for (int i = 1; i <= 4; i++) { + int neighbourX = x; + int neighbourZ = z; + switch (i) { + case 1: + neighbourX++; + break; + case 2: + neighbourX--; + break; + case 3: + neighbourZ++; + break; + case 4: + neighbourZ--; + break; + } + Block neighbour = par1World.getBlock(neighbourX, y, neighbourZ); + if (neighbour == Blocks.powered_comparator || neighbour == Blocks.unpowered_comparator) + par1World.scheduleBlockUpdate(neighbourX, y, neighbourZ, neighbour, 1); + } + } + /** * Called when the block is placed in the world. */ @@ -261,7 +288,8 @@ private void warnIneligiblePlayers(World world, int x, int y, int z) { for (EntityPlayer player : nearbyPlayers) { if (!isPlayerEligible(player)) { - player.addChatMessage(new ChatComponentText("You are unworthy.")); + player.addChatMessage( + new ChatComponentText(StatCollector.translateToLocal("chat.tf.pedestalunworthy"))); } } } @@ -353,14 +381,55 @@ public int tickRate(World world) { */ @Override public float getPlayerRelativeBlockHardness(EntityPlayer par1EntityPlayer, World world, int x, int y, int z) { - // not breakable if meta > 0 + // not breakable if meta > 7 int meta = world.getBlockMetadata(x, y, z); - if (meta > 0) { + if (meta > 7) { return -1; } else { return super.getPlayerRelativeBlockHardness(par1EntityPlayer, world, x, y, z); } } + /** + * If this returns true, then comparators facing away from this block will use the value from + * getComparatorInputOverride instead of the actual redstone signal strength. + */ + @Override + public boolean hasComparatorInputOverride() { + return true; + } + + /** + * If hasComparatorInputOverride returns true, the return value from this is used instead of the redstone signal + * strength when this block inputs to a comparator. + */ + @Override + public int getComparatorInputOverride(World worldIn, int x, int y, int z, int side) { + if (worldIn.getBlock(x, y + 1, z) == TFBlocks.trophy) { + // Gives power proportionally to boss' order (might change later) + switch (((TileEntitySkull) worldIn.getTileEntity(x, y + 1, z)).func_145904_a()) { + case 8: + return 1; // Questing Ram + case 1: + return 5; // Naga + case 2: + return 6; // Lich + case 5: + return 7; // Minoshroom + case 0: + return 8; // Hydra + case 6: + return 9; // Knight Phantom + case 3: + return 10; // Ur-Ghast + case 7: + return 11; // Alpha Yeti + case 4: + return 12; // Snow Queen + } + } + return 0; + } + } diff --git a/src/main/java/twilightforest/block/BlockTFWispyCloud.java b/src/main/java/twilightforest/block/BlockTFWispyCloud.java index 73eaae6920..04ad14126e 100644 --- a/src/main/java/twilightforest/block/BlockTFWispyCloud.java +++ b/src/main/java/twilightforest/block/BlockTFWispyCloud.java @@ -1,10 +1,18 @@ package twilightforest.block; +import java.util.ArrayList; import java.util.Random; +import net.minecraft.block.Block; import net.minecraft.block.BlockBreakable; import net.minecraft.block.material.Material; import net.minecraft.client.renderer.texture.IIconRegister; +import net.minecraft.enchantment.EnchantmentHelper; +import net.minecraft.entity.player.EntityPlayer; +import net.minecraft.item.ItemStack; +import net.minecraft.stats.StatList; +import net.minecraft.world.World; +import net.minecraftforge.event.ForgeEventFactory; import cpw.mods.fml.relauncher.Side; import cpw.mods.fml.relauncher.SideOnly; @@ -14,7 +22,7 @@ public class BlockTFWispyCloud extends BlockBreakable { protected BlockTFWispyCloud() { - super("", Material.craftedSnow, false); + super("", Material.ice, false); this.setStepSound(soundTypeCloth); this.setCreativeTab(TFItems.creativeTab); @@ -43,6 +51,25 @@ protected boolean canSilkHarvest() { return true; } + /** + * Called when the player destroys a block with an item that can harvest it. (i, j, k) are the coordinates of the + * block and l is the block's subtype/damage. + */ + public void harvestBlock(World worldIn, EntityPlayer player, int x, int y, int z, int meta) { + player.addStat(StatList.mineBlockStatArray[Block.getIdFromBlock(this)], 1); + player.addExhaustion(0.025F); + + if (this.canSilkHarvest(worldIn, player, x, y, z, meta) && EnchantmentHelper.getSilkTouchModifier(player)) { + ArrayList items = new ArrayList(); + ItemStack itemstack = this.createStackedBlock(meta); + + if (itemstack != null) items.add(itemstack); + + ForgeEventFactory.fireBlockHarvesting(items, worldIn, this, x, y, z, meta, 0, 1.0f, true, player); + for (ItemStack is : items) this.dropBlockAsItem(worldIn, x, y, z, is); + } + } + /** * Returns the quantity of items to drop on block destruction. */ diff --git a/src/main/java/twilightforest/block/TFBlocks.java b/src/main/java/twilightforest/block/TFBlocks.java index 0bd99be2a6..128df76f63 100644 --- a/src/main/java/twilightforest/block/TFBlocks.java +++ b/src/main/java/twilightforest/block/TFBlocks.java @@ -7,6 +7,8 @@ import cpw.mods.fml.common.registry.GameRegistry; import twilightforest.TwilightForestMod; +import twilightforest.block.BlockTFChest.WoodType; +import twilightforest.item.ItemBlockTFCritter; import twilightforest.item.ItemBlockTFMeta; import twilightforest.item.ItemBlockTFNagastone; @@ -40,6 +42,22 @@ public class TFBlocks { public static Block trapdoorTrans; public static Block trapdoorMine; public static Block trapdoorSort; + public static Block chestTwilight; + public static Block chestCanopy; + public static Block chestMangrove; + public static Block chestDarkwood; + public static Block chestTime; + public static Block chestTrans; + public static Block chestMine; + public static Block chestSort; + public static Block trappedChestTwilight; + public static Block trappedChestCanopy; + public static Block trappedChestMangrove; + public static Block trappedChestDarkwood; + public static Block trappedChestTime; + public static Block trappedChestTrans; + public static Block trappedChestMine; + public static Block trappedChestSort; public static Block leaves; public static Block firefly; public static Block portal; @@ -154,6 +172,22 @@ public static void registerBlocks() { trapdoorTrans = (new BlockTFTrapDoor(5)).setBlockName("TFTrapDoorTrans"); trapdoorMine = (new BlockTFTrapDoor(6)).setBlockName("TFTrapDoorMine"); trapdoorSort = (new BlockTFTrapDoor(7)).setBlockName("TFTrapDoorSort"); + chestTwilight = (new BlockTFChest(0, WoodType.TWILIGHT)).setBlockName("TFChestTwilight"); + chestCanopy = (new BlockTFChest(0, WoodType.CANOPY)).setBlockName("TFChestCanopy"); + chestMangrove = (new BlockTFChest(0, WoodType.MANGROVE)).setBlockName("TFChestMangrove"); + chestDarkwood = (new BlockTFChest(0, WoodType.DARKWOOD)).setBlockName("TFChestDarkwood"); + chestTime = (new BlockTFChest(0, WoodType.TIME)).setBlockName("TFChestTime"); + chestTrans = (new BlockTFChest(0, WoodType.TRANS)).setBlockName("TFChestTrans"); + chestMine = (new BlockTFChest(0, WoodType.MINING)).setBlockName("TFChestMine"); + chestSort = (new BlockTFChest(0, WoodType.SORT)).setBlockName("TFChestSort"); + trappedChestTwilight = (new BlockTFChest(1, WoodType.TWILIGHT)).setBlockName("TFChestTrapTwilight"); + trappedChestCanopy = (new BlockTFChest(1, WoodType.CANOPY)).setBlockName("TFChestTrapCanopy"); + trappedChestMangrove = (new BlockTFChest(1, WoodType.MANGROVE)).setBlockName("TFChestTrapMangrove"); + trappedChestDarkwood = (new BlockTFChest(1, WoodType.DARKWOOD)).setBlockName("TFChestTrapDarkwood"); + trappedChestTime = (new BlockTFChest(1, WoodType.TIME)).setBlockName("TFChestTrapTime"); + trappedChestTrans = (new BlockTFChest(1, WoodType.TRANS)).setBlockName("TFChestTrapTrans"); + trappedChestMine = (new BlockTFChest(1, WoodType.MINING)).setBlockName("TFChestTrapMine"); + trappedChestSort = (new BlockTFChest(1, WoodType.SORT)).setBlockName("TFChestTrapSort"); leaves = (new BlockTFLeaves()).setBlockName("TFLeaves").setBlockTextureName("leaves_oak"); firefly = (new BlockTFFirefly()).setBlockName("TFFirefly"); cicada = (new BlockTFCicada()).setBlockName("TFCicada"); @@ -288,10 +322,26 @@ public static void registerBlocks() { registerMyBlock(trapdoorTrans); registerMyBlock(trapdoorMine); registerMyBlock(trapdoorSort); + registerMyBlock(chestTwilight); + registerMyBlock(chestCanopy); + registerMyBlock(chestMangrove); + registerMyBlock(chestDarkwood); + registerMyBlock(chestTime); + registerMyBlock(chestTrans); + registerMyBlock(chestMine); + registerMyBlock(chestSort); + registerMyBlock(trappedChestTwilight); + registerMyBlock(trappedChestCanopy); + registerMyBlock(trappedChestMangrove); + registerMyBlock(trappedChestDarkwood); + registerMyBlock(trappedChestTime); + registerMyBlock(trappedChestTrans); + registerMyBlock(trappedChestMine); + registerMyBlock(trappedChestSort); registerMyBlock(root); registerMyBlock(leaves); - registerMyBlock(firefly, ItemBlock.class); - registerMyBlock(cicada, ItemBlock.class); + registerMyBlock(firefly, ItemBlockTFCritter.class); + registerMyBlock(cicada, ItemBlockTFCritter.class); registerMyBlock(portal, ItemBlock.class); registerMyBlock(mazestone); registerMyBlock(hedge); @@ -317,7 +367,7 @@ public static void registerBlocks() { registerMyBlock(nagastonePillarWeathered); registerMyBlock(spiralStoneBricks); registerMyBlock(sapling); - registerMyBlock(moonworm, ItemBlock.class); + registerMyBlock(moonworm, ItemBlockTFCritter.class); registerMyBlock(magicLog); registerMyBlock(magicLeaves); registerMyBlock(magicLogSpecial); @@ -366,12 +416,12 @@ public static void registerBlocks() { registerMyBlock(trollVidr, ItemBlock.class); registerMyBlock(unripeTrollBer, ItemBlock.class); registerMyBlock(trollBer, ItemBlock.class); - registerMyBlock(knightmetalStorage, ItemBlock.class); - registerMyBlock(arcticFurStorage, ItemBlock.class); - registerMyBlock(carminiteStorage, ItemBlock.class); - registerMyBlock(fieryMetalStorage, ItemBlock.class); - registerMyBlock(ironwoodStorage, ItemBlock.class); - registerMyBlock(steeleafStorage, ItemBlock.class); + registerMyBlock(knightmetalStorage, twilightforest.item.ItemBlockTFCompressed.class); + registerMyBlock(arcticFurStorage, twilightforest.item.ItemBlockTFCompressed.class); + registerMyBlock(carminiteStorage, twilightforest.item.ItemBlockTFCompressed.class); + registerMyBlock(fieryMetalStorage, twilightforest.item.ItemBlockTFCompressed.class); + registerMyBlock(ironwoodStorage, twilightforest.item.ItemBlockTFCompressed.class); + registerMyBlock(steeleafStorage, twilightforest.item.ItemBlockTFCompressed.class); registerMyBlock(hugeLilyPad, twilightforest.item.ItemBlockTFHugeLilyPad.class); registerMyBlock(hugeWaterLily, twilightforest.item.ItemBlockTFHugeWaterLily.class); registerMyBlock(slider); diff --git a/src/main/java/twilightforest/client/TFClientProxy.java b/src/main/java/twilightforest/client/TFClientProxy.java index 7eb8863ccd..1f07702fba 100644 --- a/src/main/java/twilightforest/client/TFClientProxy.java +++ b/src/main/java/twilightforest/client/TFClientProxy.java @@ -8,6 +8,7 @@ import net.minecraft.client.model.ModelWolf; import net.minecraft.client.particle.EntityFX; import net.minecraft.client.particle.EntitySmokeFX; +import net.minecraft.client.renderer.entity.RenderItem; import net.minecraft.client.renderer.entity.RenderSnowball; import net.minecraft.init.Items; import net.minecraft.item.Item; @@ -29,6 +30,7 @@ import twilightforest.client.model.ModelTFBlockGoblin; import twilightforest.client.model.ModelTFBoar; import twilightforest.client.model.ModelTFBunny; +import twilightforest.client.model.ModelTFCritterArmor; import twilightforest.client.model.ModelTFDeathTome; import twilightforest.client.model.ModelTFDeer; import twilightforest.client.model.ModelTFFieryArmor; @@ -64,6 +66,7 @@ import twilightforest.client.model.ModelTFTowerBoss; import twilightforest.client.model.ModelTFTowerGolem; import twilightforest.client.model.ModelTFTroll; +import twilightforest.client.model.ModelTFTrophyArmor; import twilightforest.client.model.ModelTFWraith; import twilightforest.client.model.ModelTFYeti; import twilightforest.client.model.ModelTFYetiAlpha; @@ -79,19 +82,23 @@ import twilightforest.client.particle.EntityTFSnowGuardianFX; import twilightforest.client.particle.EntityTFSnowWarningFX; import twilightforest.client.renderer.TFFieryItemRenderer; +import twilightforest.client.renderer.TFFieryMetalBlockRenderer; import twilightforest.client.renderer.TFGiantBlockRenderer; import twilightforest.client.renderer.TFGiantItemRenderer; import twilightforest.client.renderer.TFIceItemRenderer; import twilightforest.client.renderer.TFMagicMapRenderer; import twilightforest.client.renderer.TFMazeMapRenderer; import twilightforest.client.renderer.TileEntityTFCakeRenderer; +import twilightforest.client.renderer.TileEntityTFChestRenderer; import twilightforest.client.renderer.TileEntityTFCicadaRenderer; import twilightforest.client.renderer.TileEntityTFFireflyRenderer; import twilightforest.client.renderer.TileEntityTFMoonwormRenderer; import twilightforest.client.renderer.TileEntityTFTrophyRenderer; import twilightforest.client.renderer.blocks.RenderBlockTFCake; import twilightforest.client.renderer.blocks.RenderBlockTFCastleMagic; +import twilightforest.client.renderer.blocks.RenderBlockTFChest; import twilightforest.client.renderer.blocks.RenderBlockTFCritters; +import twilightforest.client.renderer.blocks.RenderBlockTFFieryMetal; import twilightforest.client.renderer.blocks.RenderBlockTFFireflyJar; import twilightforest.client.renderer.blocks.RenderBlockTFHugeLilyPad; import twilightforest.client.renderer.blocks.RenderBlockTFKnightMetal; @@ -111,7 +118,6 @@ import twilightforest.client.renderer.entity.RenderTFBoar; import twilightforest.client.renderer.entity.RenderTFBunny; import twilightforest.client.renderer.entity.RenderTFChainBlock; -import twilightforest.client.renderer.entity.RenderTFCharm; import twilightforest.client.renderer.entity.RenderTFCubeOfAnnihilation; import twilightforest.client.renderer.entity.RenderTFDeer; import twilightforest.client.renderer.entity.RenderTFFallingIce; @@ -160,6 +166,7 @@ import twilightforest.client.renderer.entity.RenderTFYeti; import twilightforest.item.TFItems; import twilightforest.tileentity.TileEntityTFCake; +import twilightforest.tileentity.TileEntityTFChest; import twilightforest.tileentity.TileEntityTFCicada; import twilightforest.tileentity.TileEntityTFFirefly; import twilightforest.tileentity.TileEntityTFMoonworm; @@ -169,7 +176,8 @@ public class TFClientProxy extends TFCommonProxy { int critterRenderID; int plantRenderID; - int blockCakeRenderID; + int cakeRenderID; + int chestRenderID; int blockComplexRenderID; int nagastoneRenderID; int newNagastoneRenderID; @@ -180,6 +188,7 @@ public class TFClientProxy extends TFCommonProxy { int pedestalRenderID; int thornsRenderID; int knightmetalBlockRenderID; + int fieryMetalBlockRenderID; int hugeLilyPadBlockRenderID; int castleMagicBlockRenderID; @@ -188,6 +197,9 @@ public class TFClientProxy extends TFCommonProxy { ModelBiped[] yetiArmorModel; ModelBiped[] arcticArmorModel; ModelBiped[] fieryArmorModel; + ModelBiped[] trophyArmorModel; + ModelBiped[] critterArmorModel; + TFClientEvents clientEvents; boolean isDangerOverlayShown; @@ -441,9 +453,8 @@ public void doOnLoadRegistration() { RenderingRegistry.registerEntityRenderingHandler( twilightforest.entity.EntityTFMoonwormShot.class, new RenderTFMoonwormShot()); - RenderingRegistry.registerEntityRenderingHandler( - twilightforest.entity.EntityTFCharmEffect.class, - new RenderTFCharm(TFItems.charmOfLife1.getIconFromDamage(0))); + RenderingRegistry + .registerEntityRenderingHandler(twilightforest.entity.EntityTFCharmEffect.class, new RenderItem()); RenderingRegistry.registerEntityRenderingHandler( twilightforest.entity.boss.EntityTFLichBomb.class, new RenderSnowball(Items.magma_cream)); @@ -494,6 +505,7 @@ public void doOnLoadRegistration() { ClientRegistry.bindTileEntitySpecialRenderer(TileEntityTFMoonworm.class, new TileEntityTFMoonwormRenderer()); ClientRegistry.bindTileEntitySpecialRenderer(TileEntityTFTrophy.class, new TileEntityTFTrophyRenderer()); ClientRegistry.bindTileEntitySpecialRenderer(TileEntityTFCake.class, new TileEntityTFCakeRenderer()); + ClientRegistry.bindTileEntitySpecialRenderer(TileEntityTFChest.class, new TileEntityTFChestRenderer()); // map item renderer MinecraftForgeClient.registerItemRenderer( @@ -524,6 +536,10 @@ public void doOnLoadRegistration() { MinecraftForgeClient.registerItemRenderer(TFItems.fieryLegs, fieryRenderer); MinecraftForgeClient.registerItemRenderer(TFItems.fieryBoots, fieryRenderer); + MinecraftForgeClient.registerItemRenderer( + Item.getItemFromBlock(TFBlocks.fieryMetalStorage), + new TFFieryMetalBlockRenderer()); + // ice item renderers TFIceItemRenderer iceRenderer = new TFIceItemRenderer(mc.gameSettings, mc.getTextureManager()); MinecraftForgeClient.registerItemRenderer(TFItems.iceSword, iceRenderer); @@ -531,8 +547,11 @@ public void doOnLoadRegistration() { MinecraftForgeClient.registerItemRenderer(TFItems.iceBow, iceRenderer); // block render ids - blockCakeRenderID = RenderingRegistry.getNextAvailableRenderId(); - RenderingRegistry.registerBlockHandler(new RenderBlockTFCake(blockCakeRenderID)); + cakeRenderID = RenderingRegistry.getNextAvailableRenderId(); + RenderingRegistry.registerBlockHandler(new RenderBlockTFCake(cakeRenderID)); + + chestRenderID = RenderingRegistry.getNextAvailableRenderId(); + RenderingRegistry.registerBlockHandler(new RenderBlockTFChest(chestRenderID)); blockComplexRenderID = RenderingRegistry.getNextAvailableRenderId(); RenderingRegistry.registerBlockHandler(new RenderBlockTFFireflyJar(blockComplexRenderID)); @@ -567,6 +586,9 @@ public void doOnLoadRegistration() { knightmetalBlockRenderID = RenderingRegistry.getNextAvailableRenderId(); RenderingRegistry.registerBlockHandler(new RenderBlockTFKnightMetal(knightmetalBlockRenderID)); + fieryMetalBlockRenderID = RenderingRegistry.getNextAvailableRenderId(); + RenderingRegistry.registerBlockHandler(new RenderBlockTFFieryMetal(fieryMetalBlockRenderID)); + hugeLilyPadBlockRenderID = RenderingRegistry.getNextAvailableRenderId(); RenderingRegistry.registerBlockHandler(new RenderBlockTFHugeLilyPad(hugeLilyPadBlockRenderID)); @@ -602,6 +624,22 @@ public void doOnLoadRegistration() { fieryArmorModel[2] = new ModelTFFieryArmor(2, 0.5F); fieryArmorModel[3] = new ModelTFFieryArmor(3, 0.5F); + trophyArmorModel = new ModelBiped[9]; + trophyArmorModel[0] = new ModelTFTrophyArmor(0, 0.5F); + trophyArmorModel[1] = new ModelTFTrophyArmor(1, 0.5F); + trophyArmorModel[2] = new ModelTFTrophyArmor(2, 0.5F); + trophyArmorModel[3] = new ModelTFTrophyArmor(3, 0.5F); + trophyArmorModel[4] = new ModelTFTrophyArmor(4, 0.5F); + trophyArmorModel[5] = new ModelTFTrophyArmor(5, 0.5F); + trophyArmorModel[6] = new ModelTFTrophyArmor(6, 0.5F); + trophyArmorModel[7] = new ModelTFTrophyArmor(7, 0.5F); + trophyArmorModel[8] = new ModelTFTrophyArmor(8, 0.5F); + + critterArmorModel = new ModelBiped[3]; + critterArmorModel[0] = new ModelTFCritterArmor(0, 0.5F); + critterArmorModel[1] = new ModelTFCritterArmor(1, 0.5F); + critterArmorModel[2] = new ModelTFCritterArmor(2, 0.5F); + } public int getCritterBlockRenderID() { @@ -613,7 +651,11 @@ public int getPlantBlockRenderID() { } public int getCakeBlockRenderID() { - return blockCakeRenderID; + return cakeRenderID; + } + + public int getChestBlockRenderID() { + return chestRenderID; } public int getComplexBlockRenderID() { @@ -656,6 +698,10 @@ public int getKnightmetalBlockRenderID() { return knightmetalBlockRenderID; } + public int getFieryMetalBlockRenderID() { + return fieryMetalBlockRenderID; + } + public int getHugeLilyPadBlockRenderID() { return hugeLilyPadBlockRenderID; } @@ -754,6 +800,14 @@ public ModelBiped getFieryArmorModel(int armorSlot) { return this.fieryArmorModel[armorSlot]; } + public ModelBiped getTrophyArmorModel(int boss) { + return this.trophyArmorModel[boss]; + } + + public ModelBiped getCritterArmorModel(int critter) { + return this.critterArmorModel[critter]; + } + public boolean isDangerOverlayShown() { return isDangerOverlayShown; } diff --git a/src/main/java/twilightforest/client/model/ModelTFChest.java b/src/main/java/twilightforest/client/model/ModelTFChest.java new file mode 100644 index 0000000000..5ff6dfd2a0 --- /dev/null +++ b/src/main/java/twilightforest/client/model/ModelTFChest.java @@ -0,0 +1,17 @@ +package twilightforest.client.model; + +import net.minecraft.client.model.ModelChest; +import net.minecraft.client.model.ModelRenderer; + +public class ModelTFChest extends ModelChest { + + public ModelTFChest() { + super(); + chestLid = (new ModelRenderer(this, 0, 0)).setTextureSize(64, 64); + this.chestLid.addBox(0.0F, -5.0F, -14.0F, 14, 5, 14, 0.01F); + this.chestLid.rotationPointX = 1.0F; + this.chestLid.rotationPointY = 7.0F; + this.chestLid.rotationPointZ = 15.0F; + } + +} diff --git a/src/main/java/twilightforest/client/model/ModelTFCritterArmor.java b/src/main/java/twilightforest/client/model/ModelTFCritterArmor.java new file mode 100644 index 0000000000..f34c22891d --- /dev/null +++ b/src/main/java/twilightforest/client/model/ModelTFCritterArmor.java @@ -0,0 +1,77 @@ +package twilightforest.client.model; + +import net.minecraft.client.model.ModelBiped; +import net.minecraft.client.model.ModelRenderer; +import net.minecraft.entity.Entity; +import net.minecraft.entity.EntityLivingBase; + +public class ModelTFCritterArmor extends ModelBiped { + + ModelRenderer critterBody; + + public ModelTFCritterArmor(int critter, float expand) { + super(expand); + this.bipedHead = new ModelRenderer(this, 0, 0); + this.bipedHead.setRotationPoint(0, 0, 0); + + this.critterBody = new ModelRenderer(this, 0, 0); + this.critterBody.setRotationPoint(0, 0, 0); + + this.bipedHead.showModel = true; + this.bipedHeadwear.showModel = false; + this.bipedBody.showModel = false; + this.bipedRightArm.showModel = false; + this.bipedLeftArm.showModel = false; + this.bipedRightLeg.showModel = false; + this.bipedLeftLeg.showModel = false; + + switch (critter) { + case 0 -> { // Firefly + ModelTFFirefly fireflyModel = new ModelTFFirefly(); + critterBody.addChild(fireflyModel.fatbody); + critterBody.addChild(fireflyModel.skinnybody); + critterBody.addChild(fireflyModel.legs); + critterBody.rotateAngleY = (float) Math.PI; // 180 degrees + } + case 1 -> { // Cicada + ModelTFCicada cicadaModel = new ModelTFCicada(); + critterBody.addChild(cicadaModel.fatbody); + critterBody.addChild(cicadaModel.skinnybody); + critterBody.addChild(cicadaModel.legs); + critterBody.addChild(cicadaModel.eye1); + critterBody.addChild(cicadaModel.eye2); + critterBody.addChild(cicadaModel.wings); + critterBody.rotateAngleY = (float) Math.PI; // 180 degrees + } + case 2 -> { // Moonworm + ModelTFMoonworm moonwormModel = new ModelTFMoonworm(); + critterBody.addChild(moonwormModel.head); + critterBody.addChild(moonwormModel.Shape1); + critterBody.addChild(moonwormModel.Shape2); + critterBody.addChild(moonwormModel.Shape3); + critterBody.rotateAngleY = (float) Math.PI * 3 / 2; // 270 degrees + } + } + critterBody.offsetY = -1.0f; + critterBody.offsetZ = 0.0f; + bipedHead.addChild(critterBody); + } + + /** + * Sets the models various rotation angles then renders the model. + */ + @Override + public void render(Entity par1Entity, float par2, float par3, float par4, float par5, float par6, float par7) { + + if (par1Entity != null) { + this.isSneak = par1Entity.isSneaking(); + } + + if (par1Entity != null && par1Entity instanceof EntityLivingBase) { + this.heldItemRight = ((EntityLivingBase) par1Entity).getHeldItem() != null ? 1 : 0; + } + + super.render(par1Entity, par2, par3, par4, par5, par6, par7); + } + +} diff --git a/src/main/java/twilightforest/client/model/ModelTFLargeChest.java b/src/main/java/twilightforest/client/model/ModelTFLargeChest.java new file mode 100644 index 0000000000..87a5f856a2 --- /dev/null +++ b/src/main/java/twilightforest/client/model/ModelTFLargeChest.java @@ -0,0 +1,17 @@ +package twilightforest.client.model; + +import net.minecraft.client.model.ModelLargeChest; +import net.minecraft.client.model.ModelRenderer; + +public class ModelTFLargeChest extends ModelLargeChest { + + public ModelTFLargeChest() { + super(); + this.chestLid = (new ModelRenderer(this, 0, 0)).setTextureSize(128, 64); + this.chestLid.addBox(0.0F, -5.0F, -14.0F, 30, 5, 14, 0.01F); + this.chestLid.rotationPointX = 1.0F; + this.chestLid.rotationPointY = 7.0F; + this.chestLid.rotationPointZ = 15.0F; + } + +} diff --git a/src/main/java/twilightforest/client/model/ModelTFQuestRam.java b/src/main/java/twilightforest/client/model/ModelTFQuestRam.java index 392aff5127..4c9d05c1b0 100644 --- a/src/main/java/twilightforest/client/model/ModelTFQuestRam.java +++ b/src/main/java/twilightforest/client/model/ModelTFQuestRam.java @@ -20,19 +20,19 @@ public class ModelTFQuestRam extends ModelBase { // fields - ModelRenderer frontbody; - ModelRenderer rearbody; - ModelRenderer leg1; - ModelRenderer haunch1; - ModelRenderer leg2; - ModelRenderer haunch2; - ModelRenderer leg3; - ModelRenderer haunch3; - ModelRenderer leg4; - ModelRenderer haunch4; - ModelRenderer neck; - ModelRenderer nose; - ModelRenderer head; + public ModelRenderer frontbody; + public ModelRenderer rearbody; + public ModelRenderer leg1; + public ModelRenderer haunch1; + public ModelRenderer leg2; + public ModelRenderer haunch2; + public ModelRenderer leg3; + public ModelRenderer haunch3; + public ModelRenderer leg4; + public ModelRenderer haunch4; + public ModelRenderer neck; + public ModelRenderer nose; + public ModelRenderer head; ModelRenderer[] segments; boolean[] segmentEnabled; diff --git a/src/main/java/twilightforest/client/model/ModelTFTrophyArmor.java b/src/main/java/twilightforest/client/model/ModelTFTrophyArmor.java new file mode 100644 index 0000000000..47de8f2dd5 --- /dev/null +++ b/src/main/java/twilightforest/client/model/ModelTFTrophyArmor.java @@ -0,0 +1,170 @@ +package twilightforest.client.model; + +import net.minecraft.client.model.ModelBiped; +import net.minecraft.client.model.ModelRenderer; +import net.minecraft.entity.Entity; +import net.minecraft.entity.EntityLivingBase; + +import org.lwjgl.opengl.GL11; + +public class ModelTFTrophyArmor extends ModelBiped { + + private int boss = 0; + private int time = 0; + + public ModelTFTrophyArmor(int boss, float expand) { + super(expand); + this.boss = boss; + + this.bipedHead = new ModelRenderer(this, 0, 0); + this.bipedHead.setRotationPoint(0, 0, 0); + + this.bipedHead.showModel = true; + this.bipedHeadwear.showModel = false; + this.bipedBody.showModel = false; + this.bipedRightArm.showModel = false; + this.bipedLeftArm.showModel = false; + this.bipedRightLeg.showModel = false; + this.bipedLeftLeg.showModel = false; + + switch (boss) { + case 0 -> { // Hydra + ModelTFHydraHead hydraHeadModel = new ModelTFHydraHead(); + hydraHeadModel.head.offsetY = -1.0f; + hydraHeadModel.head.offsetZ = 1.1f; + bipedHead.addChild(hydraHeadModel.head); + } + case 1 -> { // Naga + ModelTFNaga nagaHeadModel = new ModelTFNaga(); + nagaHeadModel.head.offsetY = -0.25f; + bipedHead.addChild(nagaHeadModel.head); + } + case 2 -> { // Lich + ModelTFLich lichModel = new ModelTFLich(); + bipedHead = lichModel.bipedHead; + bipedHeadwear = lichModel.bipedHeadwear; + bipedHeadwear.showModel = true; + } + case 3 -> { // Ur-Ghast + ModelTFTowerBoss urGhastModel = new ModelTFTowerBoss(); + urGhastModel.body.offsetY = -1f; + bipedHead.addChild(urGhastModel.body); + } + case 4 -> { // Snow Queen + ModelTFSnowQueen snowQueenModel = new ModelTFSnowQueen(); + bipedHead = snowQueenModel.bipedHead; + bipedHeadwear = snowQueenModel.bipedHeadwear; + bipedHeadwear.showModel = true; + } + case 5 -> { // Minoshroom + ModelTFMinoshroom minoshroomModel = new ModelTFMinoshroom(); + bipedHead = minoshroomModel.bipedHead; + } + case 6 -> { // Knight Phantom + ModelTFKnightlyArmor knightPhantomArmorModel = new ModelTFKnightlyArmor(0, 0.5F); + bipedHead = knightPhantomArmorModel.bipedHead; + ModelRenderer skeletonHead = new ModelRenderer(this, 0, 16); + skeletonHead.addBox(-4.0F, -8.0F, -4.0F, 8, 8, 8); + skeletonHead.setRotationPoint(0.0F, 0.0F, 0.0F); + bipedHead.addChild(skeletonHead); + } + case 7 -> { // Alpha Yeti + ModelTFYetiAlpha alphaYetiModel = new ModelTFYetiAlpha().trophySetup(); + alphaYetiModel.bipedBody.offsetY = 0.75f; + bipedHead.addChild(alphaYetiModel.bipedBody); + } + case 8 -> { // Questing Ram + ModelTFQuestRam questingRamModel = new ModelTFQuestRam(); + questingRamModel.head.offsetY = 0.525f; + questingRamModel.head.offsetZ = 0.75f; + bipedHead.addChild(questingRamModel.head); + } + } + } + + /** + * Sets the models various rotation angles then renders the model. + */ + @Override + public void render(Entity par1Entity, float par2, float par3, float par4, float par5, float par6, float par7) { + + if (par1Entity != null) { + this.isSneak = par1Entity.isSneaking(); + } + + if (par1Entity != null && par1Entity instanceof EntityLivingBase) { + this.heldItemRight = ((EntityLivingBase) par1Entity).getHeldItem() != null ? 1 : 0; + } + + float scale = 1.0f; + float dX = 0.0f; + float dY = 0.0f; + float dZ = 0.0f; + + switch (boss) { + case 0 -> { // Hydra + scale = 0.3f * 1.06f; + dX = 0.0f; + dY = 0.0f; + dZ = 0.0f; + } + case 1 -> { // Naga + scale = 0.5f * 1.06f; + dX = 0.0f; + dY = 0.005f; + dZ = 0.0f; + } + case 2, 4 -> { // Lich, Snow Queen + scale = 1.06f; + dX = 0.0f; + dY = 0.005f; + dZ = 0.0f; + } + case 3 -> { // Ur-Ghast + bipedHead = new ModelRenderer(this, 0, 0); + ModelTFTowerBoss urGhastModel = new ModelTFTowerBoss(); + urGhastModel.body.offsetY = -1f; + urGhastModel.setRotationAngles(0.0F, 0, time, 0, 0.0F, 0.0625F, par1Entity); + time++; + bipedHead.addChild(urGhastModel.body); + scale = 0.5f * 1.06f; + dX = 0.0f; + dY = 0.005f; + dZ = 0.0f; + } + case 5 -> { // Minoshroom + scale = 1.06f; + dX = 0.0f; + dY = 0.005f; + dZ = 0.565f; + } + case 6 -> { // Knight Phantom + scale = 1.0f; + dX = 0.0f; + dY = 0.0f; + dZ = 0.0f; + } + case 7 -> { // Alpha Yeti + scale = 0.23f; + dX = 0.0f; + dY = 0.005f; + dZ = 0.0f; + } + case 8 -> { // Questing Ram + scale = 0.75f; + dX = 0.0f; + dY = 0.0f; + dZ = 0.0f; + } + } + + GL11.glScalef(scale, scale, scale); + GL11.glTranslatef(dX, dY, dZ); + + super.render(par1Entity, par2, par3, par4, par5, par6, par7); + + GL11.glScalef(1 / scale, 1 / scale, 1 / scale); + GL11.glTranslatef(-dX, -dY, -dZ); + } + +} diff --git a/src/main/java/twilightforest/client/model/ModelTFYetiAlpha.java b/src/main/java/twilightforest/client/model/ModelTFYetiAlpha.java index 2f40416629..4f28264e44 100644 --- a/src/main/java/twilightforest/client/model/ModelTFYetiAlpha.java +++ b/src/main/java/twilightforest/client/model/ModelTFYetiAlpha.java @@ -72,6 +72,32 @@ public ModelTFYetiAlpha() { } + public ModelTFYetiAlpha trophySetup() { + this.bipedBody = new ModelRenderer(this, 80, 0); + this.bipedBody.addBox(-24.0F, -60.0F, -18.0F, 48, 54, 36); + this.bipedBody.setRotationPoint(0.0F, -6.0F, 0.0F); + + this.mouth = new ModelRenderer(this, 121, 50); + this.mouth.addBox(-17.0F, -7.0F, -1.5F, 34, 29, 2); + this.mouth.setRotationPoint(0.0F, -37.0F, -18.0F); + this.bipedBody.addChild(mouth); + + this.rightEye = new ModelRenderer(this, 64, 0); + this.rightEye.addBox(-6.0F, -6.0F, -1.5F, 12, 12, 2); + this.rightEye.setRotationPoint(-14.0F, -50.0F, -18.0F); + this.bipedBody.addChild(rightEye); + + this.leftEye = new ModelRenderer(this, 64, 0); + this.leftEye.addBox(-6.0F, -6.0F, -1.5F, 12, 12, 2); + this.leftEye.setRotationPoint(14.0F, -50.0F, -18.0F); + this.bipedBody.addChild(leftEye); + + addPairHorns(-58.0F, 35F); + addPairHorns(-46.0F, 15F); + addPairHorns(-36.0F, -5F); + return this; + } + /** * Add a pair of horns */ diff --git a/src/main/java/twilightforest/client/renderer/TFFieryMetalBlockRenderer.java b/src/main/java/twilightforest/client/renderer/TFFieryMetalBlockRenderer.java new file mode 100644 index 0000000000..ac6908c398 --- /dev/null +++ b/src/main/java/twilightforest/client/renderer/TFFieryMetalBlockRenderer.java @@ -0,0 +1,57 @@ +package twilightforest.client.renderer; + +import net.minecraft.block.Block; +import net.minecraft.client.renderer.RenderBlocks; +import net.minecraft.client.renderer.Tessellator; +import net.minecraft.item.ItemStack; +import net.minecraftforge.client.IItemRenderer; + +import org.lwjgl.opengl.GL11; + +import twilightforest.block.BlockTFCompressed; +import twilightforest.block.TFBlocks; +import twilightforest.client.renderer.blocks.RenderBlockTFFieryMetal; + +public class TFFieryMetalBlockRenderer implements IItemRenderer { + + @Override + public boolean handleRenderType(ItemStack item, ItemRenderType type) { + return type == ItemRenderType.EQUIPPED; + } + + public void renderInventoryItem(RenderBlocks renderer, ItemStack item) { + int metadata = item.getItemDamage(); + renderInvSimpleBlock(renderer, TFBlocks.fieryMetalStorage, metadata); + } + + @Override + public void renderItem(ItemRenderType type, ItemStack item, Object... data) { + switch (type) { + case EQUIPPED: + GL11.glTranslatef(0.5F, 0.5F, 0.5F); + renderInventoryItem((RenderBlocks) data[0], item); + break; + default: + break; + } + } + + @Override + public boolean shouldUseRenderHelper(ItemRenderType type, ItemStack item, ItemRendererHelper helper) { + return true; + } + + public static void renderInvSimpleBlock(RenderBlocks renderblocks, Block par1Block, int meta) { + Tessellator tessellator = Tessellator.instance; + + GL11.glTranslatef(-0.5F, -0.5F, -0.5F); + GL11.glColor4f(1.0F, 1.0F, 1.0F, 1.0F); + + renderblocks.setRenderBounds(0, 0, 0, 1, 1, 1); + RenderBlockTFFieryMetal.renderInvBlock(renderblocks, (BlockTFCompressed) par1Block, meta, tessellator); + + GL11.glTranslatef(0.5F, 0.5F, 0.5F); + + par1Block.setBlockBoundsForItemRender(); + } +} diff --git a/src/main/java/twilightforest/client/renderer/TileEntityTFChestRenderer.java b/src/main/java/twilightforest/client/renderer/TileEntityTFChestRenderer.java new file mode 100644 index 0000000000..21b3838b0e --- /dev/null +++ b/src/main/java/twilightforest/client/renderer/TileEntityTFChestRenderer.java @@ -0,0 +1,155 @@ +package twilightforest.client.renderer; + +import net.minecraft.block.Block; +import net.minecraft.block.BlockChest; +import net.minecraft.client.model.ModelChest; +import net.minecraft.client.renderer.tileentity.TileEntitySpecialRenderer; +import net.minecraft.tileentity.TileEntity; +import net.minecraft.tileentity.TileEntityChest; +import net.minecraft.util.ResourceLocation; + +import org.lwjgl.opengl.GL11; +import org.lwjgl.opengl.GL12; + +import cpw.mods.fml.common.FMLLog; +import cpw.mods.fml.relauncher.Side; +import cpw.mods.fml.relauncher.SideOnly; +import twilightforest.TwilightForestMod; +import twilightforest.block.BlockTFChest; +import twilightforest.block.BlockTFChest.WoodType; +import twilightforest.client.model.ModelTFChest; +import twilightforest.client.model.ModelTFLargeChest; +import twilightforest.tileentity.TileEntityTFChest; + +@SideOnly(Side.CLIENT) +public class TileEntityTFChestRenderer extends TileEntitySpecialRenderer { + + public static final String[] names = { "twilight", "canopy", "mangrove", "darkwood", "time", "trans", "mining", + "sort" }; + private static final ResourceLocation[] doubleTextures = new ResourceLocation[names.length]; + private static final ResourceLocation[] textures = new ResourceLocation[names.length]; + private ModelChest modelChest = new ModelTFChest(); + private ModelChest modelLargeChest = new ModelTFLargeChest(); + + public TileEntityTFChestRenderer() { + for (int i = 0; i < names.length; i++) { + doubleTextures[i] = new ResourceLocation(TwilightForestMod.MODEL_DIR + "chest/" + names[i] + "_double.png"); + textures[i] = new ResourceLocation(TwilightForestMod.MODEL_DIR + "chest/" + names[i] + ".png"); + } + } + + public void renderTileEntityAt(TileEntityChest tileEntity, double x, double y, double z, float f) { + int i; + + if (!tileEntity.hasWorldObj()) { + i = 0; + } else { + Block block = tileEntity.getBlockType(); + i = tileEntity.getBlockMetadata(); + + if (block instanceof BlockChest && i == 0) { + try { + ((BlockChest) block).func_149954_e( + tileEntity.getWorldObj(), + tileEntity.xCoord, + tileEntity.yCoord, + tileEntity.zCoord); + } catch (ClassCastException e) { + FMLLog.severe( + "Attempted to render a chest at %d, %d, %d that was not a chest", + tileEntity.xCoord, + tileEntity.yCoord, + tileEntity.zCoord); + } + i = tileEntity.getBlockMetadata(); + } + + tileEntity.checkForAdjacentChests(); + } + + BlockTFChest.WoodType type = (((TileEntityTFChest) tileEntity).cachedMaterial == WoodType.NULL) + ? ((BlockTFChest) tileEntity.getWorldObj() + .getBlock(tileEntity.xCoord, tileEntity.yCoord, tileEntity.zCoord)).getWoodType() + : ((TileEntityTFChest) tileEntity).cachedMaterial; + + if (tileEntity.adjacentChestZNeg == null && tileEntity.adjacentChestXNeg == null) { + ModelChest modelchest; + + if (tileEntity.adjacentChestXPos == null && tileEntity.adjacentChestZPos == null) { + modelchest = this.modelChest; + this.bindTexture(textures[type.ordinal()]); + } else { + modelchest = this.modelLargeChest; + this.bindTexture(doubleTextures[type.ordinal()]); + } + + GL11.glPushMatrix(); + GL11.glEnable(GL12.GL_RESCALE_NORMAL); + GL11.glColor4f(1.0F, 1.0F, 1.0F, 1.0F); + GL11.glTranslatef((float) x, (float) y + 1.0F, (float) z + 1.0F); + GL11.glScalef(1.0F, -1.0F, -1.0F); + GL11.glTranslatef(0.5F, 0.5F, 0.5F); + short short1 = 0; + + if (i == 2) { + short1 = 180; + } + + if (i == 3) { + short1 = 0; + } + + if (i == 4) { + short1 = 90; + } + + if (i == 5) { + short1 = -90; + } + + if (i == 2 && tileEntity.adjacentChestXPos != null) { + GL11.glTranslatef(1.0F, 0.0F, 0.0F); + } + + if (i == 5 && tileEntity.adjacentChestZPos != null) { + GL11.glTranslatef(0.0F, 0.0F, -1.0F); + } + + GL11.glRotatef((float) short1, 0.0F, 1.0F, 0.0F); + GL11.glTranslatef(-0.5F, -0.5F, -0.5F); + float f1 = tileEntity.prevLidAngle + (tileEntity.lidAngle - tileEntity.prevLidAngle) * f; + float f2; + + if (tileEntity.adjacentChestZNeg != null) { + f2 = tileEntity.adjacentChestZNeg.prevLidAngle + + (tileEntity.adjacentChestZNeg.lidAngle - tileEntity.adjacentChestZNeg.prevLidAngle) * f; + + if (f2 > f1) { + f1 = f2; + } + } + + if (tileEntity.adjacentChestXNeg != null) { + f2 = tileEntity.adjacentChestXNeg.prevLidAngle + + (tileEntity.adjacentChestXNeg.lidAngle - tileEntity.adjacentChestXNeg.prevLidAngle) * f; + + if (f2 > f1) { + f1 = f2; + } + } + + f1 = 1.0F - f1; + f1 = 1.0F - f1 * f1 * f1; + modelchest.chestLid.rotateAngleX = -(f1 * (float) Math.PI / 2.0F); + modelchest.renderAll(); + GL11.glDisable(GL12.GL_RESCALE_NORMAL); + GL11.glPopMatrix(); + GL11.glColor4f(1.0F, 1.0F, 1.0F, 1.0F); + } + } + + public void renderTileEntityAt(TileEntity p_147500_1_, double p_147500_2_, double p_147500_4_, double p_147500_6_, + float p_147500_8_) { + this.renderTileEntityAt((TileEntityChest) p_147500_1_, p_147500_2_, p_147500_4_, p_147500_6_, p_147500_8_); + } +} diff --git a/src/main/java/twilightforest/client/renderer/TileEntityTFMoonwormRenderer.java b/src/main/java/twilightforest/client/renderer/TileEntityTFMoonwormRenderer.java index 85d60d673e..a2d2bd82a6 100644 --- a/src/main/java/twilightforest/client/renderer/TileEntityTFMoonwormRenderer.java +++ b/src/main/java/twilightforest/client/renderer/TileEntityTFMoonwormRenderer.java @@ -22,14 +22,14 @@ public TileEntityTFMoonwormRenderer() { @Override public void renderTileEntityAt(TileEntity tileentity, double d, double d1, double d2, float f) { - renderTileEntityFireflyAt((TileEntityTFMoonworm) tileentity, d, d1, d2, f); + renderTileEntityMoonwormAt((TileEntityTFMoonworm) tileentity, d, d1, d2, f); } /** - * Render a cute firefly! + * Render a cute moonworm! */ - private void renderTileEntityFireflyAt(TileEntityTFMoonworm tileentity, double d, double d1, double d2, + private void renderTileEntityMoonwormAt(TileEntityTFMoonworm tileentity, double d, double d1, double d2, float partialTime) { GL11.glPushMatrix(); int facing = tileentity.getBlockMetadata(); @@ -65,7 +65,7 @@ private void renderTileEntityFireflyAt(TileEntityTFMoonworm tileentity, double d moonwormModel.setLivingAnimations(tileentity, partialTime); - // render the firefly body + // render the moonworm body moonwormModel.render(0.0625f); GL11.glPopMatrix(); diff --git a/src/main/java/twilightforest/client/renderer/TileEntityTFTrophyRenderer.java b/src/main/java/twilightforest/client/renderer/TileEntityTFTrophyRenderer.java index 21ecc9a50b..428c85eb2b 100644 --- a/src/main/java/twilightforest/client/renderer/TileEntityTFTrophyRenderer.java +++ b/src/main/java/twilightforest/client/renderer/TileEntityTFTrophyRenderer.java @@ -8,10 +8,15 @@ import twilightforest.TwilightForestMod; import twilightforest.client.model.ModelTFHydraHead; +import twilightforest.client.model.ModelTFKnightPhantom2; +import twilightforest.client.model.ModelTFKnightlyArmor; import twilightforest.client.model.ModelTFLich; +import twilightforest.client.model.ModelTFMinoshroom; import twilightforest.client.model.ModelTFNaga; +import twilightforest.client.model.ModelTFQuestRam; import twilightforest.client.model.ModelTFSnowQueen; import twilightforest.client.model.ModelTFTowerBoss; +import twilightforest.client.model.ModelTFYetiAlpha; import twilightforest.tileentity.TileEntityTFTrophy; public class TileEntityTFTrophyRenderer extends TileEntitySpecialRenderer { @@ -31,6 +36,23 @@ public class TileEntityTFTrophyRenderer extends TileEntitySpecialRenderer { private ModelTFSnowQueen snowQueenModel; private static final ResourceLocation textureLocSnowQueen = new ResourceLocation( TwilightForestMod.MODEL_DIR + "snowqueen.png"); + private ModelTFMinoshroom minoshroomModel; + private static final ResourceLocation textureLocMinoshroom = new ResourceLocation( + TwilightForestMod.MODEL_DIR + "minoshroomtaur.png"); + private ModelTFKnightPhantom2 knightPhantomModel; + private ModelTFKnightlyArmor knightPhantomArmorModel; + private static final ResourceLocation textureLocKnightPhantom = new ResourceLocation( + TwilightForestMod.MODEL_DIR + "phantomskeleton.png"); + private static final ResourceLocation textureLocKnightPhantomArmor = new ResourceLocation( + TwilightForestMod.ARMOR_DIR + "phantom_1.png"); + private ModelTFYetiAlpha alphaYetiModel; + private static final ResourceLocation textureLocAlphaYeti = new ResourceLocation( + TwilightForestMod.MODEL_DIR + "yetialpha.png"); + private ModelTFQuestRam questingRamModel; + private static final ResourceLocation textureLocQuestingRam = new ResourceLocation( + TwilightForestMod.MODEL_DIR + "questram.png"); + private static final ResourceLocation textureLocQuestingRamLines = new ResourceLocation( + TwilightForestMod.MODEL_DIR + "questram_lines.png"); public TileEntityTFTrophyRenderer() { hydraHeadModel = new ModelTFHydraHead(); @@ -38,6 +60,11 @@ public TileEntityTFTrophyRenderer() { lichModel = new ModelTFLich(); urGhastModel = new ModelTFTowerBoss(); snowQueenModel = new ModelTFSnowQueen(); + minoshroomModel = new ModelTFMinoshroom(); + knightPhantomModel = new ModelTFKnightPhantom2(); + knightPhantomArmorModel = new ModelTFKnightlyArmor(0, 0.5F); + alphaYetiModel = new ModelTFYetiAlpha().trophySetup(); + questingRamModel = new ModelTFQuestRam(); } @Override @@ -79,6 +106,10 @@ public void renderTileEntityAt(TileEntity tileentity, double x, double y, double case 2 -> renderLichHead(rotation, onGround); case 3 -> renderUrGhastHead(trophy, rotation, onGround, partialTime); case 4 -> renderSnowQueenHead(rotation, onGround); + case 5 -> renderMinoshroomHead(rotation, onGround); + case 6 -> renderKnightPhantomHead(rotation, onGround); + case 7 -> renderAlphaYetiHead(rotation, onGround); + case 8 -> renderQuestingRamHead(rotation, onGround); } GL11.glPopMatrix(); @@ -145,7 +176,7 @@ private void renderLichHead(float rotation, boolean onGround) { GL11.glTranslatef(0, onGround ? 1.75F : 1.5F, onGround ? 0F : 0.24F); - // render the naga head + // render the lich head lichModel.bipedHead.render(0.0625F); lichModel.bipedHeadwear.render(0.0625F); } @@ -166,7 +197,7 @@ private void renderUrGhastHead(TileEntityTFTrophy trophy, float rotation, boolea GL11.glTranslatef(0, onGround ? 1F : 1F, onGround ? 0F : 0F); - // render the naga head + // render the ur-ghast head urGhastModel.render(null, 0.0F, 0, trophy.ticksExisted + partialTime, 0, 0.0F, 0.0625F); } @@ -186,9 +217,99 @@ private void renderSnowQueenHead(float rotation, boolean onGround) { GL11.glTranslatef(0, onGround ? 1.5F : 1.25F, onGround ? 0F : 0.24F); - // render the naga head + // render the snow queen head snowQueenModel.bipedHead.render(0.0625F); snowQueenModel.bipedHeadwear.render(0.0625F); } + private void renderMinoshroomHead(float rotation, boolean onGround) { + + // GL11.glScalef(0.5f, 0.5f, 0.5f); + + this.bindTexture(textureLocMinoshroom); + + GL11.glScalef(1f, -1f, -1f); + + // we seem to be getting a 180 degree rotation here + GL11.glRotatef(rotation, 0F, 1F, 0F); + GL11.glRotatef(180F, 0F, 1F, 0F); + + GL11.glTranslatef(0, -0.625f, 0.57f); + + GL11.glTranslatef(0, onGround ? 1.5F : 1.25F, onGround ? 0F : 0.24F); + + // render the minoshroom head + minoshroomModel.bipedHead.render(0.0625F); + minoshroomModel.bipedHeadwear.render(0.0625F); + } + + private void renderKnightPhantomHead(float rotation, boolean onGround) { + + float scale = 0.89f; + GL11.glScalef(scale, scale, scale); + + GL11.glTranslatef(0, 0.97f, 0); + + this.bindTexture(textureLocKnightPhantom); + + GL11.glScalef(1f, -1f, -1f); + + // we seem to be getting a 180 degree rotation here + GL11.glRotatef(rotation, 0F, 1F, 0F); + GL11.glRotatef(180F, 0F, 1F, 0F); + + GL11.glTranslatef(0, onGround ? 1.5F : 1.22F, onGround ? 0F : 0.28F); + + // render the knight phantom head + knightPhantomModel.bipedHead.render(0.0625F); + + this.bindTexture(textureLocKnightPhantomArmor); + + // render the knight phantom armor + knightPhantomArmorModel.bipedHead.render(0.0625F); + knightPhantomArmorModel.bipedHeadwear.render(0.0625F); + } + + private void renderAlphaYetiHead(float rotation, boolean onGround) { + + float scale = 0.2f; + GL11.glScalef(scale, scale, scale); + + GL11.glTranslatef(0, -1.8f, 0); + + this.bindTexture(textureLocAlphaYeti); + + GL11.glScalef(1f, -1f, -1f); + + // we seem to be getting a 180 degree rotation here + GL11.glRotatef(rotation, 0F, 1F, 0F); + GL11.glRotatef(180F, 0F, 1F, 0F); + + GL11.glTranslatef(0, onGround ? 1.5F : 0.2F, onGround ? 0F : 1.385F); + + // render the alpha yeti head + alphaYetiModel.bipedBody.render(0.0625F); + } + + private void renderQuestingRamHead(float rotation, boolean onGround) { + + float scale = 0.65f; + GL11.glScalef(scale, scale, scale); + + this.bindTexture(textureLocQuestingRam); + + GL11.glScalef(1f, -1f, -1f); + + // we seem to be getting a 180 degree rotation here + GL11.glRotatef(rotation, 0F, 1F, 0F); + GL11.glRotatef(180F, 0F, 1F, 0F); + + GL11.glTranslatef(0, -0.25f, 0.67f); + + GL11.glTranslatef(0, onGround ? 1.5F : 1.175F, onGround ? 0.05F : 0.41F); + + // render the questing ram head + questingRamModel.head.render(0.0625F); + } + } diff --git a/src/main/java/twilightforest/client/renderer/blocks/RenderBlockTFChest.java b/src/main/java/twilightforest/client/renderer/blocks/RenderBlockTFChest.java new file mode 100644 index 0000000000..ac60bf6399 --- /dev/null +++ b/src/main/java/twilightforest/client/renderer/blocks/RenderBlockTFChest.java @@ -0,0 +1,51 @@ +package twilightforest.client.renderer.blocks; + +import net.minecraft.block.Block; +import net.minecraft.client.renderer.RenderBlocks; +import net.minecraft.client.renderer.tileentity.TileEntityRendererDispatcher; +import net.minecraft.world.IBlockAccess; + +import org.lwjgl.opengl.GL11; +import org.lwjgl.opengl.GL12; + +import cpw.mods.fml.client.registry.ISimpleBlockRenderingHandler; +import twilightforest.block.BlockTFChest; +import twilightforest.tileentity.TileEntityTFChest; + +public class RenderBlockTFChest implements ISimpleBlockRenderingHandler { + + final int renderID; + + public RenderBlockTFChest(int blockChestRenderID) { + this.renderID = blockChestRenderID; + } + + @Override + public void renderInventoryBlock(Block block, int metadata, int modelID, RenderBlocks renderer) { + GL11.glRotatef(90.0F, 0.0F, 1.0F, 0.0F); + GL11.glTranslatef(-0.5F, -0.5F, -0.5F); + TileEntityRendererDispatcher.instance.renderTileEntityAt( + new TileEntityTFChest(((BlockTFChest) block).getWoodType()), + 0.0D, + 0.0D, + 0.0D, + 0.0F); + GL11.glEnable(GL12.GL_RESCALE_NORMAL); + } + + @Override + public boolean renderWorldBlock(IBlockAccess world, int x, int y, int z, Block block, int modelId, + RenderBlocks renderer) { + return false; + } + + @Override + public boolean shouldRender3DInInventory(int modelId) { + return true; + } + + @Override + public int getRenderId() { + return renderID; + } +} diff --git a/src/main/java/twilightforest/client/renderer/blocks/RenderBlockTFFieryMetal.java b/src/main/java/twilightforest/client/renderer/blocks/RenderBlockTFFieryMetal.java new file mode 100644 index 0000000000..243f82f5da --- /dev/null +++ b/src/main/java/twilightforest/client/renderer/blocks/RenderBlockTFFieryMetal.java @@ -0,0 +1,287 @@ +package twilightforest.client.renderer.blocks; + +import net.minecraft.block.Block; +import net.minecraft.client.renderer.RenderBlocks; +import net.minecraft.client.renderer.Tessellator; +import net.minecraft.util.IIcon; +import net.minecraft.world.IBlockAccess; + +import org.lwjgl.opengl.GL11; + +import cpw.mods.fml.client.registry.ISimpleBlockRenderingHandler; +import twilightforest.block.BlockTFCompressed; + +public class RenderBlockTFFieryMetal implements ISimpleBlockRenderingHandler { + + final int renderID; + + public RenderBlockTFFieryMetal(int blockComplexRenderID) { + this.renderID = blockComplexRenderID; + } + + @Override + public void renderInventoryBlock(Block block, int metadata, int modelID, RenderBlocks renderer) { + renderInvJar(renderer, block, metadata); + } + + @Override + public boolean renderWorldBlock(IBlockAccess world, int x, int y, int z, Block block, int modelId, + RenderBlocks renderer) { + return renderGlowingEdgeBlock(renderer, world, x, y, z, (BlockTFCompressed) block); + } + + @Override + public boolean shouldRender3DInInventory(int modelId) { + return true; + } + + @Override + public int getRenderId() { + return renderID; + } + + public static boolean renderGlowingEdgeBlock(RenderBlocks renderblocks, IBlockAccess world, int x, int y, int z, + BlockTFCompressed block) { + float p = 1F / 16F; + float m = (1.0f - p) / 2; + float s = 0.001f; + + renderblocks.enableAO = true; + + renderblocks.aoBrightnessXYNP = 255; + renderblocks.aoBrightnessXYPP = 255; + renderblocks.aoBrightnessYZPN = 255; + renderblocks.aoBrightnessYZPP = 255; + renderblocks.aoLightValueScratchXYNP = 1.0F; + renderblocks.aoLightValueScratchXYPP = 1.0F; + renderblocks.aoLightValueScratchYZPN = 1.0F; + renderblocks.aoLightValueScratchYZPP = 1.0F; + + renderblocks.aoLightValueScratchXYZNPN = renderblocks.aoLightValueScratchXYNP; + renderblocks.aoBrightnessXYZNPN = renderblocks.aoBrightnessXYNP; + renderblocks.aoLightValueScratchXYZPPN = renderblocks.aoLightValueScratchXYPP; + renderblocks.aoBrightnessXYZPPN = renderblocks.aoBrightnessXYPP; + renderblocks.aoLightValueScratchXYZNPP = renderblocks.aoLightValueScratchXYNP; + renderblocks.aoBrightnessXYZNPP = renderblocks.aoBrightnessXYNP; + renderblocks.aoLightValueScratchXYZPPP = renderblocks.aoLightValueScratchXYPP; + renderblocks.aoBrightnessXYZPPP = renderblocks.aoBrightnessXYPP; + + renderblocks.colorRedTopLeft = renderblocks.colorRedBottomLeft = renderblocks.colorRedBottomRight = renderblocks.colorRedTopRight = 1.0f; + renderblocks.colorGreenTopLeft = renderblocks.colorGreenBottomLeft = renderblocks.colorGreenBottomRight = renderblocks.colorGreenTopRight = 1.0f; + renderblocks.colorBlueTopLeft = renderblocks.colorBlueBottomLeft = renderblocks.colorBlueBottomRight = renderblocks.colorBlueTopRight = 1.0f; + + // middle + renderblocks.renderAllFaces = true; + renderblocks.setRenderBounds(p, p, p, 1.0f - p, 1.0f - p, 1.0f - p); + renderInnerPart(renderblocks, world, x, y, z, block); + renderblocks.renderAllFaces = false; + + for (int rx = -1; rx <= 1; rx++) { + for (int ry = -1; ry <= 1; ry++) { + for (int rz = -1; rz <= 1; rz++) { + int moveAxis = Math.abs(rx) + Math.abs(ry) + Math.abs(rz); + if (moveAxis == 1 || moveAxis == 2) if (block.canConnectFieryTo(world, x + rx, y + ry, z + rz)) { + if (moveAxis == 2) { + int neighbours = 0; + if (rx != 0) neighbours += (block.canConnectFieryTo(world, x + rx, y, z)) ? 1 : 0; + if (ry != 0) neighbours += (block.canConnectFieryTo(world, x, y + ry, z)) ? 1 : 0; + if (rz != 0) neighbours += (block.canConnectFieryTo(world, x, y, z + rz)) ? 1 : 0; + if (neighbours != 2) continue; + } + renderblocks.renderAllFaces = true; + float minX = (rx == 0) ? p : m + m * rx; + float minY = (ry == 0) ? p : m + m * ry; + float minZ = (rz == 0) ? p : m + m * rz; + float maxX = (rx == 0) ? 1.0f - p : m + m * rx + p; + float maxY = (ry == 0) ? 1.0f - p : m + m * ry + p; + float maxZ = (rz == 0) ? 1.0f - p : m + m * rz + p; + renderblocks.setRenderBounds(minX, minY, minZ, maxX, maxY, maxZ); + renderInnerPart(renderblocks, world, x, y, z, block); + renderblocks.renderAllFaces = false; + } else { + // edge + if (moveAxis == 1) { + renderblocks.setRenderBounds( + (world.getBlock(x, y, z).isBlockSolid(world, x, y, z, 0) ? 0 : s), + (world.getBlock(x, y, z).isBlockSolid(world, x, y, z, 0) ? 0 : s), + (world.getBlock(x, y, z).isBlockSolid(world, x, y, z, 0) ? 0 : s), + 1 - (world.getBlock(x, y, z).isBlockSolid(world, x, y, z, 0) ? 0 : s), + 1 - (world.getBlock(x, y, z).isBlockSolid(world, x, y, z, 0) ? 0 : s), + 1 - (world.getBlock(x, y, z).isBlockSolid(world, x, y, z, 0) ? 0 : s)); + renderblocks.renderFromInside = true; + boolean flipTextures = (x + y + z) % 2 == 0; + if (rx != 0) { + if (rx == -1) renderblocks + .renderFaceXNeg(block, x, y, z, block.fieryPattern[flipTextures ? 0 : 1]); + else renderblocks + .renderFaceXPos(block, x, y, z, block.fieryPattern[flipTextures ? 3 : 2]); + } else { + if (ry != 0) { + if (ry == -1) renderblocks + .renderFaceYNeg(block, x, y, z, block.fieryPattern[flipTextures ? 2 : 0]); + else renderblocks + .renderFaceYPos(block, x, y, z, block.fieryPattern[flipTextures ? 3 : 1]); + } else { + if (rz == -1) renderblocks + .renderFaceZNeg(block, x, y, z, block.fieryPattern[flipTextures ? 1 : 0]); + else renderblocks + .renderFaceZPos(block, x, y, z, block.fieryPattern[flipTextures ? 2 : 3]); + } + } + renderblocks.renderFromInside = false; + } + } + } + } + } + + block.setBlockBoundsForItemRender(); + + renderblocks.enableAO = false; + return true; + } + + public static void renderInnerPart(RenderBlocks renderblocks, IBlockAccess world, int x, int y, int z, + BlockTFCompressed block) { + boolean neighbourU = block.canConnectFieryTo(world, x, y + 1, z); + boolean neighbourD = block.canConnectFieryTo(world, x, y - 1, z); + boolean neighbourN = block.canConnectFieryTo(world, x + 1, y, z); + boolean neighbourS = block.canConnectFieryTo(world, x - 1, y, z); + boolean neighbourE = block.canConnectFieryTo(world, x, y, z + 1); + boolean neighbourW = block.canConnectFieryTo(world, x, y, z - 1); + boolean neighbourUN = neighbourU && neighbourN && block.canConnectFieryTo(world, x + 1, y + 1, z); + boolean neighbourUS = neighbourU && neighbourS && block.canConnectFieryTo(world, x - 1, y + 1, z); + boolean neighbourUE = neighbourU && neighbourE && block.canConnectFieryTo(world, x, y + 1, z + 1); + boolean neighbourUW = neighbourU && neighbourW && block.canConnectFieryTo(world, x, y + 1, z - 1); + boolean neighbourDN = neighbourD && neighbourN && block.canConnectFieryTo(world, x + 1, y - 1, z); + boolean neighbourDS = neighbourD && neighbourS && block.canConnectFieryTo(world, x - 1, y - 1, z); + boolean neighbourDE = neighbourD && neighbourE && block.canConnectFieryTo(world, x, y - 1, z + 1); + boolean neighbourDW = neighbourD && neighbourW && block.canConnectFieryTo(world, x, y - 1, z - 1); + boolean neighbourNE = neighbourN && neighbourE && block.canConnectFieryTo(world, x + 1, y, z + 1); + boolean neighbourNW = neighbourN && neighbourW && block.canConnectFieryTo(world, x + 1, y, z - 1); + boolean neighbourSE = neighbourS && neighbourE && block.canConnectFieryTo(world, x - 1, y, z + 1); + boolean neighbourSW = neighbourS && neighbourW && block.canConnectFieryTo(world, x - 1, y, z - 1); + boolean neighboursUD = neighbourU || neighbourD; + boolean neighboursNS = neighbourN || neighbourS; + boolean neighboursEW = neighbourE || neighbourW; + IIcon icon; + + // X faces + if (neighboursUD) { + if (neighboursEW) { + if (neighbourUE || neighbourUW || neighbourDE || neighbourDW) icon = block.fieryCore[4]; + else icon = block.fieryCore[3]; + } else icon = block.fieryCore[2]; + } else { + if (neighboursEW) icon = block.fieryCore[1]; + else icon = block.fieryCore[0]; + } + renderblocks.renderFaceXPos(block, x, y, z, icon); + renderblocks.renderFaceXNeg(block, x, y, z, icon); + + // Z faces + if (neighboursUD) { + if (neighboursNS) { + if (neighbourUN || neighbourUS || neighbourDN || neighbourDS) icon = block.fieryCore[4]; + else icon = block.fieryCore[3]; + } else icon = block.fieryCore[2]; + } else { + if (neighboursNS) icon = block.fieryCore[1]; + else icon = block.fieryCore[0]; + } + renderblocks.renderFaceZPos(block, x, y, z, icon); + renderblocks.renderFaceZNeg(block, x, y, z, icon); + + // Y faces + if (neighboursEW) { + if (neighboursNS) { + if (neighbourNE || neighbourNW || neighbourSE || neighbourSW) icon = block.fieryCore[4]; + else icon = block.fieryCore[3]; + } else icon = block.fieryCore[2]; + } else { + if (neighboursNS) icon = block.fieryCore[1]; + else icon = block.fieryCore[0]; + } + renderblocks.renderFaceYPos(block, x, y, z, icon); + renderblocks.renderFaceYNeg(block, x, y, z, icon); + } + + public static void renderInvJar(RenderBlocks renderblocks, Block par1Block, int meta) { + Tessellator tessellator = Tessellator.instance; + + GL11.glTranslatef(-0.5F, -0.5F, -0.5F); + GL11.glColor4f(1.0F, 1.0F, 1.0F, 1.0F); + + float p = 1F / 16F; + + // middle + renderblocks.setRenderBounds(p, p, p, 1 - p, 1 - p, 1 - p); + renderInvBlock(renderblocks, par1Block, meta, tessellator); + + // outline + renderblocks.setRenderBounds(0, 0, 0, 1, 1, 1); + renderInvOutline(renderblocks, (BlockTFCompressed) par1Block, meta, tessellator); + + GL11.glTranslatef(0.5F, 0.5F, 0.5F); + + par1Block.setBlockBoundsForItemRender(); + } + + public static void renderInvBlock(RenderBlocks renderblocks, Block par1Block, int meta, Tessellator tessellator) { + tessellator.startDrawingQuads(); + tessellator.setNormal(0.0F, 1.0F, 0.0F); + renderblocks.renderFaceYNeg(par1Block, 0.0D, 0.0D, 0.0D, par1Block.getIcon(0, meta)); + tessellator.draw(); + tessellator.startDrawingQuads(); + tessellator.setNormal(0.0F, 1.0F, 0.0F); + renderblocks.renderFaceYPos(par1Block, 0.0D, 0.0D, 0.0D, par1Block.getIcon(1, meta)); + tessellator.draw(); + tessellator.startDrawingQuads(); + tessellator.setNormal(0.0F, 1.0F, 0.0F); + renderblocks.renderFaceXPos(par1Block, 0.0D, 0.0D, 0.0D, par1Block.getIcon(2, meta)); + tessellator.draw(); + tessellator.startDrawingQuads(); + tessellator.setNormal(0.0F, 1.0F, 0.0F); + renderblocks.renderFaceXNeg(par1Block, 0.0D, 0.0D, 0.0D, par1Block.getIcon(3, meta)); + tessellator.draw(); + tessellator.startDrawingQuads(); + tessellator.setNormal(0.0F, 1.0F, 0.0F); + renderblocks.renderFaceZNeg(par1Block, 0.0D, 0.0D, 0.0D, par1Block.getIcon(4, meta)); + tessellator.draw(); + tessellator.startDrawingQuads(); + tessellator.setNormal(0.0F, 1.0F, 0.0F); + renderblocks.renderFaceZPos(par1Block, 0.0D, 0.0D, 0.0D, par1Block.getIcon(5, meta)); + tessellator.draw(); + } + + protected static void renderInvOutline(RenderBlocks renderblocks, BlockTFCompressed block, int meta, + Tessellator tessellator) { + renderblocks.renderFromInside = true; + tessellator.startDrawingQuads(); + tessellator.setNormal(0.0F, 1.0F, 0.0F); + renderblocks.renderFaceYNeg(block, 0.0D, 0.0D, 0.0D, block.fieryPattern[2]); + tessellator.draw(); + tessellator.startDrawingQuads(); + tessellator.setNormal(0.0F, 1.0F, 0.0F); + renderblocks.renderFaceYPos(block, 0.0D, 0.0D, 0.0D, block.fieryPattern[3]); + tessellator.draw(); + tessellator.startDrawingQuads(); + tessellator.setNormal(0.0F, 1.0F, 0.0F); + renderblocks.renderFaceXPos(block, 0.0D, 0.0D, 0.0D, block.fieryPattern[0]); + tessellator.draw(); + tessellator.startDrawingQuads(); + tessellator.setNormal(0.0F, 1.0F, 0.0F); + renderblocks.renderFaceXNeg(block, 0.0D, 0.0D, 0.0D, block.fieryPattern[3]); + tessellator.draw(); + tessellator.startDrawingQuads(); + tessellator.setNormal(0.0F, 1.0F, 0.0F); + renderblocks.renderFaceZNeg(block, 0.0D, 0.0D, 0.0D, block.fieryPattern[2]); + tessellator.draw(); + tessellator.startDrawingQuads(); + tessellator.setNormal(0.0F, 1.0F, 0.0F); + renderblocks.renderFaceZPos(block, 0.0D, 0.0D, 0.0D, block.fieryPattern[1]); + tessellator.draw(); + renderblocks.renderFromInside = false; + } + +} diff --git a/src/main/java/twilightforest/client/renderer/entity/RenderTFCharm.java b/src/main/java/twilightforest/client/renderer/entity/RenderTFCharm.java deleted file mode 100644 index 3c09946893..0000000000 --- a/src/main/java/twilightforest/client/renderer/entity/RenderTFCharm.java +++ /dev/null @@ -1,79 +0,0 @@ -package twilightforest.client.renderer.entity; - -import net.minecraft.client.renderer.Tessellator; -import net.minecraft.client.renderer.entity.Render; -import net.minecraft.client.renderer.texture.TextureMap; -import net.minecraft.entity.Entity; -import net.minecraft.util.IIcon; -import net.minecraft.util.ResourceLocation; - -import org.lwjgl.opengl.GL11; -import org.lwjgl.opengl.GL12; - -import cpw.mods.fml.relauncher.Side; -import cpw.mods.fml.relauncher.SideOnly; -import twilightforest.entity.EntityTFCharmEffect; -import twilightforest.item.TFItems; - -@SideOnly(Side.CLIENT) -public class RenderTFCharm extends Render { - - /** - * Have the icon index (in items.png) that will be used to render the image. Currently, eggs and snowballs uses this - * classes. - */ - private IIcon itemIcon; - - public RenderTFCharm(IIcon par1) { - this.itemIcon = par1; - } - - /** - * Actually renders the given argument. This is a synthetic bridge method, always casting down its argument and then - * handing it off to a worker function which does the actual work. In all probabilty, the class Render is generic - * (Render 0) { - // this.itemIcon = Items.itemsList[charm.getItemID()].getIconFromDamage(0); - this.itemIcon = TFItems.charmOfKeeping1.getIconFromDamage(0); - } - } - - GL11.glPushMatrix(); - GL11.glTranslatef((float) par2, (float) par4, (float) par6); - GL11.glEnable(GL12.GL_RESCALE_NORMAL); - GL11.glScalef(0.5F, 0.5F, 0.5F); - this.bindEntityTexture(par1Entity); - Tessellator var10 = Tessellator.instance; - - this.func_77026_a(var10, this.itemIcon); - GL11.glDisable(GL12.GL_RESCALE_NORMAL); - GL11.glPopMatrix(); - } - - private void func_77026_a(Tessellator par1Tessellator, IIcon par2Icon) { - float f = par2Icon.getMinU(); - float f1 = par2Icon.getMaxU(); - float f2 = par2Icon.getMinV(); - float f3 = par2Icon.getMaxV(); - float f4 = 1.0F; - float f5 = 0.5F; - float f6 = 0.25F; - GL11.glRotatef(180.0F - this.renderManager.playerViewY, 0.0F, 1.0F, 0.0F); - GL11.glRotatef(-this.renderManager.playerViewX, 1.0F, 0.0F, 0.0F); - par1Tessellator.startDrawingQuads(); - par1Tessellator.setNormal(0.0F, 1.0F, 0.0F); - par1Tessellator.addVertexWithUV(0.0F - f5, 0.0F - f6, 0.0D, f, f3); - par1Tessellator.addVertexWithUV(f4 - f5, 0.0F - f6, 0.0D, f1, f3); - par1Tessellator.addVertexWithUV(f4 - f5, f4 - f6, 0.0D, f1, f2); - par1Tessellator.addVertexWithUV(0.0F - f5, f4 - f6, 0.0D, f, f2); - par1Tessellator.draw(); - } - - protected ResourceLocation getEntityTexture(Entity par1Entity) { - return TextureMap.locationItemsTexture; - } -} diff --git a/src/main/java/twilightforest/entity/EntityTFAdherent.java b/src/main/java/twilightforest/entity/EntityTFAdherent.java index 60faaa6875..a25f667b5d 100644 --- a/src/main/java/twilightforest/entity/EntityTFAdherent.java +++ b/src/main/java/twilightforest/entity/EntityTFAdherent.java @@ -20,6 +20,7 @@ import net.minecraft.world.World; import twilightforest.TFAchievementPage; +import twilightforest.TwilightForestMod; import twilightforest.item.TFItems; public class EntityTFAdherent extends EntityMob implements IRangedAttackMob, ITFCharger { @@ -84,7 +85,8 @@ protected void dropFewItems(boolean hitByPlayer, int looting) { @Override public void onDeath(DamageSource damageSource) { super.onDeath(damageSource); - if (damageSource.getEntity() instanceof EntityPlayer) { + if (damageSource.getEntity() instanceof EntityPlayer + && ((EntityPlayer) damageSource.getEntity()).dimension == TwilightForestMod.dimensionID) { ((EntityPlayer) damageSource.getEntity()).triggerAchievement(TFAchievementPage.twilightHunter); } } diff --git a/src/main/java/twilightforest/entity/EntityTFBlockGoblin.java b/src/main/java/twilightforest/entity/EntityTFBlockGoblin.java index 0923fe61ca..d2250a27f8 100644 --- a/src/main/java/twilightforest/entity/EntityTFBlockGoblin.java +++ b/src/main/java/twilightforest/entity/EntityTFBlockGoblin.java @@ -119,7 +119,8 @@ protected Item getDropItemId() { @Override public void onDeath(DamageSource par1DamageSource) { super.onDeath(par1DamageSource); - if (par1DamageSource.getEntity() instanceof EntityPlayer) { + if (par1DamageSource.getEntity() instanceof EntityPlayer + && ((EntityPlayer) par1DamageSource.getEntity()).dimension == TwilightForestMod.dimensionID) { ((EntityPlayer) par1DamageSource.getEntity()).triggerAchievement(TFAchievementPage.twilightHunter); } } diff --git a/src/main/java/twilightforest/entity/EntityTFBoggard.java b/src/main/java/twilightforest/entity/EntityTFBoggard.java index 0260789279..850468a547 100644 --- a/src/main/java/twilightforest/entity/EntityTFBoggard.java +++ b/src/main/java/twilightforest/entity/EntityTFBoggard.java @@ -163,7 +163,8 @@ public boolean isTargetLookingAtMe() { @Override public void onDeath(DamageSource par1DamageSource) { super.onDeath(par1DamageSource); - if (par1DamageSource.getEntity() instanceof EntityPlayer) { + if (par1DamageSource.getEntity() instanceof EntityPlayer + && ((EntityPlayer) par1DamageSource.getEntity()).dimension == TwilightForestMod.dimensionID) { ((EntityPlayer) par1DamageSource.getEntity()).triggerAchievement(TFAchievementPage.twilightHunter); // are we in a level 1 hill? int chunkX = MathHelper.floor_double(posX) >> 4; diff --git a/src/main/java/twilightforest/entity/EntityTFCharmEffect.java b/src/main/java/twilightforest/entity/EntityTFCharmEffect.java index 87400cbce9..a3ec2abe75 100644 --- a/src/main/java/twilightforest/entity/EntityTFCharmEffect.java +++ b/src/main/java/twilightforest/entity/EntityTFCharmEffect.java @@ -1,20 +1,23 @@ package twilightforest.entity; -import net.minecraft.entity.Entity; import net.minecraft.entity.EntityLivingBase; +import net.minecraft.entity.item.EntityItem; +import net.minecraft.entity.player.EntityPlayer; import net.minecraft.item.Item; +import net.minecraft.item.ItemStack; import net.minecraft.nbt.NBTTagCompound; +import net.minecraft.util.DamageSource; import net.minecraft.util.MathHelper; import net.minecraft.util.Vec3; import net.minecraft.world.World; import twilightforest.item.TFItems; -public class EntityTFCharmEffect extends Entity { +public class EntityTFCharmEffect extends EntityItem { private static final int DATA_OWNER = 17; private static final int DATA_ITEMID = 16; - private static final double DISTANCE = 1.75; + private static final double DISTANCE = 1; private EntityLivingBase orbiting; private double newPosX; private double newPosY; @@ -22,8 +25,7 @@ public class EntityTFCharmEffect extends Entity { private double newRotationYaw; private double newRotationPitch; private int newPosRotationIncrements; - - public float offset; + private float offset = 0; // client constructor public EntityTFCharmEffect(World par1World) { @@ -31,29 +33,32 @@ public EntityTFCharmEffect(World par1World) { this.setSize(0.25F, 0.25F); this.setItemID(TFItems.charmOfLife1); + // this.setEntityItemStack(new ItemStack(TFItems.charmOfLife1)); } // server constructor - public EntityTFCharmEffect(World par1World, EntityLivingBase par2EntityLiving, Item item) { + public EntityTFCharmEffect(World par1World, EntityLivingBase par2EntityLiving, Item item, float offset) { super(par1World); this.setSize(0.25F, 0.25F); this.orbiting = par2EntityLiving; - // this.setOwner(orbiting.getEntityName()); + if (this.orbiting instanceof EntityPlayer) this.setOwner(((EntityPlayer) orbiting).getDisplayName()); this.setItemID(item); + this.setEntityItemStack(new ItemStack(item)); Vec3 look = Vec3.createVectorHelper(DISTANCE, 0, 0); + this.offset = offset; + look.rotateAroundY(offset); this.setLocationAndAngles( par2EntityLiving.posX, - par2EntityLiving.posY + par2EntityLiving.getEyeHeight(), + par2EntityLiving.posY + par2EntityLiving.getEyeHeight() - 0.5d, par2EntityLiving.posZ, par2EntityLiving.rotationYaw, par2EntityLiving.rotationPitch); - this.posX += look.xCoord * DISTANCE; - // this.posY += look.yCoord * DISTANCE; - this.posZ += look.zCoord * DISTANCE; - this.setPosition(this.posX, this.posY, this.posZ); + this.posX += look.xCoord; + this.posY += look.yCoord; + this.posZ += look.zCoord; this.yOffset = 0.0F; } @@ -65,7 +70,7 @@ public void onUpdate() { this.lastTickPosX = this.posX; this.lastTickPosY = this.posY; this.lastTickPosZ = this.posZ; - super.onUpdate(); + this.onEntityUpdate(); if (this.newPosRotationIncrements > 0) { double var1 = this.posX + (this.newPosX - this.posX) / (double) this.newPosRotationIncrements; @@ -89,7 +94,7 @@ public void onUpdate() { if (this.orbiting != null && !worldObj.isRemote) { this.setLocationAndAngles( orbiting.posX, - orbiting.posY + orbiting.getEyeHeight(), + orbiting.posY + orbiting.getEyeHeight() - 0.5d, orbiting.posZ, orbiting.rotationYaw, orbiting.rotationPitch); @@ -97,18 +102,15 @@ public void onUpdate() { Vec3 look = Vec3.createVectorHelper(DISTANCE, 0, 0); look.rotateAroundY(rotation); this.posX += look.xCoord; - // this.posY += Math.sin(this.ticksExisted / 3.0F + offset); + this.posY += Math.sin(this.ticksExisted / 3.0F + offset) / 8; this.posZ += look.zCoord; - - this.setPosition(this.posX, this.posY, this.posZ); - } if (this.getItemID() > 0) { for (int i = 0; i < 3; i++) { - double dx = posX + 0.5 * (rand.nextDouble() - rand.nextDouble()); - double dy = posY + 0.5 * (rand.nextDouble() - rand.nextDouble()); - double dz = posZ + 0.5 * (rand.nextDouble() - rand.nextDouble()); + double dx = posX + 0.25 * (rand.nextDouble() - rand.nextDouble()); + double dy = posY + 0.25 * (rand.nextDouble() - rand.nextDouble()); + double dz = posZ + 0.25 * (rand.nextDouble() - rand.nextDouble()); worldObj.spawnParticle("iconcrack_" + this.getItemID(), dx, dy, dz, 0, 0.2, 0); } @@ -136,6 +138,7 @@ public void setPositionAndRotation2(double par1, double par3, double par5, float protected void entityInit() { this.dataWatcher.addObject(DATA_ITEMID, 0); this.dataWatcher.addObject(DATA_OWNER, ""); + super.entityInit(); } public String getOwnerName() { @@ -155,19 +158,65 @@ public int getItemID() { } public void setItemID(Item charmOfLife1) { - // this.dataWatcher.updateObject(DATA_ITEMID, Integer.valueOf(charmOfLife1)); + this.dataWatcher.updateObject(DATA_ITEMID, Item.getIdFromItem(charmOfLife1)); + } + + public void setItemID(int id) { + this.dataWatcher.updateObject(DATA_ITEMID, id); } @Override - protected void readEntityFromNBT(NBTTagCompound par1NBTTagCompound) { + public void readEntityFromNBT(NBTTagCompound par1NBTTagCompound) { + super.readEntityFromNBT(par1NBTTagCompound); par1NBTTagCompound.setString("Owner", this.getOwnerName()); par1NBTTagCompound.setShort("ItemID", (short) this.getItemID()); } @Override - protected void writeEntityToNBT(NBTTagCompound par1NBTTagCompound) { + public void writeEntityToNBT(NBTTagCompound par1NBTTagCompound) { this.setOwner(par1NBTTagCompound.getString("Owner")); - // this.setItemID(par1NBTTagCompound.getShort("ItemID")); + this.setItemID(par1NBTTagCompound.getShort("ItemID")); + super.writeEntityToNBT(par1NBTTagCompound); + } + + /** + * Called by a player entity when they collide with an entity + */ + public void onCollideWithPlayer(EntityPlayer entityIn) { + // Can't pick it up + } + + /** + * Tries to merge this item with the item passed as the parameter. Returns true if successful. Either this item or + * the other item will be removed from the world. + */ + public boolean combineItems(EntityItem p_70289_1_) { + // No, we don't + return false; + } + + /** + * Returns if this entity is in water and will end up adding the waters velocity to the entity + */ + public boolean handleWaterMovement() { + // Magic is not affected by water + return false; + } + + /** + * Will deal the specified amount of damage to the entity if the entity isn't immune to fire damage. Args: + * amountDamage + */ + protected void dealFireDamage(int amount) { + // No, we don't + } + + /** + * Called when the entity is attacked. + */ + public boolean attackEntityFrom(DamageSource source, float amount) { + // Can't be attacked, magic + return false; } } diff --git a/src/main/java/twilightforest/entity/EntityTFDeathTome.java b/src/main/java/twilightforest/entity/EntityTFDeathTome.java index 665cd2b1a9..9940708246 100644 --- a/src/main/java/twilightforest/entity/EntityTFDeathTome.java +++ b/src/main/java/twilightforest/entity/EntityTFDeathTome.java @@ -16,6 +16,7 @@ import net.minecraft.world.World; import twilightforest.TFAchievementPage; +import twilightforest.TwilightForestMod; import twilightforest.entity.ai.EntityAITFMagicAttack; import twilightforest.item.TFItems; @@ -133,7 +134,8 @@ protected void dropRareDrop(int par1) { @Override public void onDeath(DamageSource par1DamageSource) { super.onDeath(par1DamageSource); - if (par1DamageSource.getEntity() instanceof EntityPlayer) { + if (par1DamageSource.getEntity() instanceof EntityPlayer + && ((EntityPlayer) par1DamageSource.getEntity()).dimension == TwilightForestMod.dimensionID) { ((EntityPlayer) par1DamageSource.getEntity()).triggerAchievement(TFAchievementPage.twilightHunter); } } diff --git a/src/main/java/twilightforest/entity/EntityTFFireBeetle.java b/src/main/java/twilightforest/entity/EntityTFFireBeetle.java index 4de6f156c5..36be21f3a8 100644 --- a/src/main/java/twilightforest/entity/EntityTFFireBeetle.java +++ b/src/main/java/twilightforest/entity/EntityTFFireBeetle.java @@ -20,6 +20,7 @@ import cpw.mods.fml.relauncher.Side; import cpw.mods.fml.relauncher.SideOnly; import twilightforest.TFAchievementPage; +import twilightforest.TwilightForestMod; import twilightforest.entity.ai.EntityAITFBreathAttack; public class EntityTFFireBeetle extends EntityMob implements IBreathAttacker { @@ -204,7 +205,8 @@ public int getBrightnessForRender(float par1) { @Override public void onDeath(DamageSource par1DamageSource) { super.onDeath(par1DamageSource); - if (par1DamageSource.getEntity() instanceof EntityPlayer) { + if (par1DamageSource.getEntity() instanceof EntityPlayer + && ((EntityPlayer) par1DamageSource.getEntity()).dimension == TwilightForestMod.dimensionID) { ((EntityPlayer) par1DamageSource.getEntity()).triggerAchievement(TFAchievementPage.twilightHunter); } } diff --git a/src/main/java/twilightforest/entity/EntityTFHarbingerCube.java b/src/main/java/twilightforest/entity/EntityTFHarbingerCube.java index 4007eeb854..8bf8445403 100644 --- a/src/main/java/twilightforest/entity/EntityTFHarbingerCube.java +++ b/src/main/java/twilightforest/entity/EntityTFHarbingerCube.java @@ -14,6 +14,7 @@ import net.minecraft.world.World; import twilightforest.TFAchievementPage; +import twilightforest.TwilightForestMod; import twilightforest.item.TFItems; public class EntityTFHarbingerCube extends EntityMob { @@ -44,7 +45,8 @@ protected void applyEntityAttributes() { @Override public void onDeath(DamageSource damageSource) { super.onDeath(damageSource); - if (damageSource.getEntity() instanceof EntityPlayer) { + if (damageSource.getEntity() instanceof EntityPlayer + && ((EntityPlayer) damageSource.getEntity()).dimension == TwilightForestMod.dimensionID) { ((EntityPlayer) damageSource.getEntity()).triggerAchievement(TFAchievementPage.twilightHunter); } } diff --git a/src/main/java/twilightforest/entity/EntityTFHedgeSpider.java b/src/main/java/twilightforest/entity/EntityTFHedgeSpider.java index 910a006970..a766fabb6e 100644 --- a/src/main/java/twilightforest/entity/EntityTFHedgeSpider.java +++ b/src/main/java/twilightforest/entity/EntityTFHedgeSpider.java @@ -9,6 +9,7 @@ import twilightforest.TFAchievementPage; import twilightforest.TFFeature; +import twilightforest.TwilightForestMod; /** * The hedge spider is just like a normal spider, but it can spawn in the daytime. @@ -60,7 +61,8 @@ protected boolean isValidLightLevel() { @Override public void onDeath(DamageSource par1DamageSource) { super.onDeath(par1DamageSource); - if (par1DamageSource.getEntity() instanceof EntityPlayer) { + if (par1DamageSource.getEntity() instanceof EntityPlayer + && ((EntityPlayer) par1DamageSource.getEntity()).dimension == TwilightForestMod.dimensionID) { ((EntityPlayer) par1DamageSource.getEntity()).triggerAchievement(TFAchievementPage.twilightHunter); // are in a hedge maze? int chunkX = MathHelper.floor_double(posX) >> 4; diff --git a/src/main/java/twilightforest/entity/EntityTFHelmetCrab.java b/src/main/java/twilightforest/entity/EntityTFHelmetCrab.java index 5bb94eaccc..c68a0031ca 100644 --- a/src/main/java/twilightforest/entity/EntityTFHelmetCrab.java +++ b/src/main/java/twilightforest/entity/EntityTFHelmetCrab.java @@ -19,6 +19,7 @@ import net.minecraft.world.World; import twilightforest.TFAchievementPage; +import twilightforest.TwilightForestMod; import twilightforest.item.TFItems; public class EntityTFHelmetCrab extends EntityMob { @@ -117,7 +118,8 @@ protected void dropFewItems(boolean flag, int i) { @Override public void onDeath(DamageSource par1DamageSource) { super.onDeath(par1DamageSource); - if (par1DamageSource.getEntity() instanceof EntityPlayer) { + if (par1DamageSource.getEntity() instanceof EntityPlayer + && ((EntityPlayer) par1DamageSource.getEntity()).dimension == TwilightForestMod.dimensionID) { ((EntityPlayer) par1DamageSource.getEntity()).triggerAchievement(TFAchievementPage.twilightHunter); } } diff --git a/src/main/java/twilightforest/entity/EntityTFHostileWolf.java b/src/main/java/twilightforest/entity/EntityTFHostileWolf.java index 2c9abdf1ce..9f3172543d 100644 --- a/src/main/java/twilightforest/entity/EntityTFHostileWolf.java +++ b/src/main/java/twilightforest/entity/EntityTFHostileWolf.java @@ -14,6 +14,7 @@ import twilightforest.TFAchievementPage; import twilightforest.TFFeature; +import twilightforest.TwilightForestMod; public class EntityTFHostileWolf extends EntityWolf implements IMob { @@ -52,7 +53,8 @@ public void onUpdate() { @Override public void onDeath(DamageSource par1DamageSource) { super.onDeath(par1DamageSource); - if (par1DamageSource.getEntity() instanceof EntityPlayer) { + if (par1DamageSource.getEntity() instanceof EntityPlayer + && ((EntityPlayer) par1DamageSource.getEntity()).dimension == TwilightForestMod.dimensionID) { ((EntityPlayer) par1DamageSource.getEntity()).triggerAchievement(TFAchievementPage.twilightHunter); } } diff --git a/src/main/java/twilightforest/entity/EntityTFIceExploder.java b/src/main/java/twilightforest/entity/EntityTFIceExploder.java index 17c0de1aea..b7246a053c 100644 --- a/src/main/java/twilightforest/entity/EntityTFIceExploder.java +++ b/src/main/java/twilightforest/entity/EntityTFIceExploder.java @@ -113,7 +113,8 @@ public float getEyeHeight() { @Override public void onDeath(DamageSource damageSource) { super.onDeath(damageSource); - if (damageSource.getEntity() instanceof EntityPlayer) { + if (damageSource.getEntity() instanceof EntityPlayer + && ((EntityPlayer) damageSource.getEntity()).dimension == TwilightForestMod.dimensionID) { ((EntityPlayer) damageSource.getEntity()).triggerAchievement(TFAchievementPage.twilightHunter); } } diff --git a/src/main/java/twilightforest/entity/EntityTFIceShooter.java b/src/main/java/twilightforest/entity/EntityTFIceShooter.java index 3a25d559a2..c031da5c10 100644 --- a/src/main/java/twilightforest/entity/EntityTFIceShooter.java +++ b/src/main/java/twilightforest/entity/EntityTFIceShooter.java @@ -109,7 +109,8 @@ protected String getDeathSound() { @Override public void onDeath(DamageSource par1DamageSource) { super.onDeath(par1DamageSource); - if (par1DamageSource.getEntity() instanceof EntityPlayer) { + if (par1DamageSource.getEntity() instanceof EntityPlayer + && ((EntityPlayer) par1DamageSource.getEntity()).dimension == TwilightForestMod.dimensionID) { ((EntityPlayer) par1DamageSource.getEntity()).triggerAchievement(TFAchievementPage.twilightHunter); } } diff --git a/src/main/java/twilightforest/entity/EntityTFKobold.java b/src/main/java/twilightforest/entity/EntityTFKobold.java index bd620ca970..868b218695 100644 --- a/src/main/java/twilightforest/entity/EntityTFKobold.java +++ b/src/main/java/twilightforest/entity/EntityTFKobold.java @@ -151,7 +151,8 @@ public void onLivingUpdate() { @Override public void onDeath(DamageSource par1DamageSource) { super.onDeath(par1DamageSource); - if (par1DamageSource.getEntity() instanceof EntityPlayer) { + if (par1DamageSource.getEntity() instanceof EntityPlayer + && ((EntityPlayer) par1DamageSource.getEntity()).dimension == TwilightForestMod.dimensionID) { ((EntityPlayer) par1DamageSource.getEntity()).triggerAchievement(TFAchievementPage.twilightHunter); } } diff --git a/src/main/java/twilightforest/entity/EntityTFMinotaur.java b/src/main/java/twilightforest/entity/EntityTFMinotaur.java index 8fda0b2b2f..b6477b2306 100644 --- a/src/main/java/twilightforest/entity/EntityTFMinotaur.java +++ b/src/main/java/twilightforest/entity/EntityTFMinotaur.java @@ -19,6 +19,7 @@ import net.minecraft.world.World; import twilightforest.TFAchievementPage; +import twilightforest.TwilightForestMod; import twilightforest.entity.ai.EntityAITFChargeAttack; import twilightforest.item.TFItems; @@ -189,7 +190,8 @@ protected void dropRareDrop(int par1) { @Override public void onDeath(DamageSource par1DamageSource) { super.onDeath(par1DamageSource); - if (par1DamageSource.getEntity() instanceof EntityPlayer) { + if (par1DamageSource.getEntity() instanceof EntityPlayer + && ((EntityPlayer) par1DamageSource.getEntity()).dimension == TwilightForestMod.dimensionID) { ((EntityPlayer) par1DamageSource.getEntity()).triggerAchievement(TFAchievementPage.twilightHunter); } } diff --git a/src/main/java/twilightforest/entity/EntityTFMosquitoSwarm.java b/src/main/java/twilightforest/entity/EntityTFMosquitoSwarm.java index 8e67a1f2e0..6301a3141c 100644 --- a/src/main/java/twilightforest/entity/EntityTFMosquitoSwarm.java +++ b/src/main/java/twilightforest/entity/EntityTFMosquitoSwarm.java @@ -2,6 +2,7 @@ import net.minecraft.entity.Entity; import net.minecraft.entity.EntityLivingBase; +import net.minecraft.entity.EnumCreatureAttribute; import net.minecraft.entity.SharedMonsterAttributes; import net.minecraft.entity.ai.EntityAIAttackOnCollide; import net.minecraft.entity.ai.EntityAIHurtByTarget; @@ -120,9 +121,18 @@ public int getMaxSpawnedInChunk() { @Override public void onDeath(DamageSource par1DamageSource) { super.onDeath(par1DamageSource); - if (par1DamageSource.getEntity() instanceof EntityPlayer) { + if (par1DamageSource.getEntity() instanceof EntityPlayer + && ((EntityPlayer) par1DamageSource.getEntity()).dimension == TwilightForestMod.dimensionID) { ((EntityPlayer) par1DamageSource.getEntity()).triggerAchievement(TFAchievementPage.twilightHunter); } } + /** + * Get this Entity's EnumCreatureAttribute + */ + @Override + public EnumCreatureAttribute getCreatureAttribute() { + return EnumCreatureAttribute.ARTHROPOD; + } + } diff --git a/src/main/java/twilightforest/entity/EntityTFPinchBeetle.java b/src/main/java/twilightforest/entity/EntityTFPinchBeetle.java index b73e4e9c83..864881791e 100644 --- a/src/main/java/twilightforest/entity/EntityTFPinchBeetle.java +++ b/src/main/java/twilightforest/entity/EntityTFPinchBeetle.java @@ -19,6 +19,7 @@ import cpw.mods.fml.relauncher.Side; import cpw.mods.fml.relauncher.SideOnly; import twilightforest.TFAchievementPage; +import twilightforest.TwilightForestMod; import twilightforest.entity.ai.EntityAITFChargeAttack; import twilightforest.entity.ai.EntityAITFKidnapRider; @@ -146,7 +147,8 @@ public void onLivingUpdate() { @Override public void onDeath(DamageSource par1DamageSource) { super.onDeath(par1DamageSource); - if (par1DamageSource.getEntity() instanceof EntityPlayer) { + if (par1DamageSource.getEntity() instanceof EntityPlayer + && ((EntityPlayer) par1DamageSource.getEntity()).dimension == TwilightForestMod.dimensionID) { ((EntityPlayer) par1DamageSource.getEntity()).triggerAchievement(TFAchievementPage.twilightHunter); } } diff --git a/src/main/java/twilightforest/entity/EntityTFRedcap.java b/src/main/java/twilightforest/entity/EntityTFRedcap.java index 7268582815..285811426a 100644 --- a/src/main/java/twilightforest/entity/EntityTFRedcap.java +++ b/src/main/java/twilightforest/entity/EntityTFRedcap.java @@ -159,7 +159,8 @@ public void readEntityFromNBT(NBTTagCompound par1NBTTagCompound) { @Override public void onDeath(DamageSource par1DamageSource) { super.onDeath(par1DamageSource); - if (par1DamageSource.getSourceOfDamage() instanceof EntityPlayer) { + if (par1DamageSource.getSourceOfDamage() instanceof EntityPlayer + && ((EntityPlayer) par1DamageSource.getEntity()).dimension == TwilightForestMod.dimensionID) { ((EntityPlayer) par1DamageSource.getSourceOfDamage()).triggerAchievement(TFAchievementPage.twilightHunter); // are we in a level 1 hill? int chunkX = MathHelper.floor_double(posX) >> 4; diff --git a/src/main/java/twilightforest/entity/EntityTFRedcapSapper.java b/src/main/java/twilightforest/entity/EntityTFRedcapSapper.java index 6085790797..ab47fd0403 100644 --- a/src/main/java/twilightforest/entity/EntityTFRedcapSapper.java +++ b/src/main/java/twilightforest/entity/EntityTFRedcapSapper.java @@ -9,6 +9,7 @@ import twilightforest.TFAchievementPage; import twilightforest.TFFeature; +import twilightforest.TwilightForestMod; import twilightforest.entity.ai.EntityAITFRedcapPlantTNT; import twilightforest.item.TFItems; @@ -61,7 +62,8 @@ public ItemStack getPick() { @Override public void onDeath(DamageSource par1DamageSource) { super.onDeath(par1DamageSource); - if (par1DamageSource.getEntity() instanceof EntityPlayer) { + if (par1DamageSource.getEntity() instanceof EntityPlayer + && ((EntityPlayer) par1DamageSource.getEntity()).dimension == TwilightForestMod.dimensionID) { ((EntityPlayer) par1DamageSource.getEntity()).triggerAchievement(TFAchievementPage.twilightHunter); // are we in a level 2 hill? int chunkX = MathHelper.floor_double(posX) >> 4; diff --git a/src/main/java/twilightforest/entity/EntityTFSkeletonDruid.java b/src/main/java/twilightforest/entity/EntityTFSkeletonDruid.java index a0c11b5a5d..f5f440ecc8 100644 --- a/src/main/java/twilightforest/entity/EntityTFSkeletonDruid.java +++ b/src/main/java/twilightforest/entity/EntityTFSkeletonDruid.java @@ -1,12 +1,16 @@ package twilightforest.entity; +import java.util.Calendar; + import net.minecraft.block.Block; import net.minecraft.entity.EntityLivingBase; import net.minecraft.entity.EnumCreatureAttribute; +import net.minecraft.entity.IEntityLivingData; import net.minecraft.entity.IRangedAttackMob; import net.minecraft.entity.SharedMonsterAttributes; import net.minecraft.entity.ai.EntityAIArrowAttack; +import net.minecraft.entity.ai.EntityAIAttackOnCollide; import net.minecraft.entity.ai.EntityAIFleeSun; import net.minecraft.entity.ai.EntityAIHurtByTarget; import net.minecraft.entity.ai.EntityAILookIdle; @@ -17,8 +21,10 @@ import net.minecraft.entity.ai.EntityAIWatchClosest; import net.minecraft.entity.monster.EntityMob; import net.minecraft.entity.player.EntityPlayer; +import net.minecraft.init.Blocks; import net.minecraft.init.Items; import net.minecraft.item.Item; +import net.minecraft.item.ItemHoe; import net.minecraft.item.ItemStack; import net.minecraft.util.DamageSource; import net.minecraft.util.MathHelper; @@ -26,10 +32,18 @@ import net.minecraft.world.World; import twilightforest.TFAchievementPage; +import twilightforest.TwilightForestMod; import twilightforest.item.TFItems; public class EntityTFSkeletonDruid extends EntityMob implements IRangedAttackMob { + private EntityAIArrowAttack aiArrowAttack = new EntityAIArrowAttack(this, 1.0D, 60, 10.0F); + private EntityAIAttackOnCollide aiAttackOnCollide = new EntityAIAttackOnCollide( + this, + EntityPlayer.class, + 1.2D, + false); + public EntityTFSkeletonDruid(World world) { super(world); // texture = TwilightForestMod.MODEL_DIR + "skeletondruid.png"; @@ -38,14 +52,18 @@ public EntityTFSkeletonDruid(World world) { this.tasks.addTask(1, new EntityAISwimming(this)); this.tasks.addTask(2, new EntityAIRestrictSun(this)); this.tasks.addTask(3, new EntityAIFleeSun(this, 1.0D)); - this.tasks.addTask(4, new EntityAIArrowAttack(this, 1.0D, 60, 10.0F)); - this.tasks.addTask(5, new EntityAIWander(this, 1.0D)); - this.tasks.addTask(6, new EntityAIWatchClosest(this, EntityPlayer.class, 8.0F)); + // this.tasks.addTask(4, new EntityAIArrowAttack(this, 1.0D, 60, 10.0F)); + this.tasks.addTask(4, new EntityAIWander(this, 1.0D)); + this.tasks.addTask(5, new EntityAIWatchClosest(this, EntityPlayer.class, 8.0F)); this.tasks.addTask(6, new EntityAILookIdle(this)); this.targetTasks.addTask(1, new EntityAIHurtByTarget(this, false)); this.targetTasks.addTask(2, new EntityAINearestAttackableTarget(this, EntityPlayer.class, 0, true)); - this.setCurrentItemOrArmor(0, new ItemStack(Items.golden_hoe)); + if (world != null && !world.isRemote) { + this.setCombatTask(); + } + + // this.setCurrentItemOrArmor(0, new ItemStack(Items.golden_hoe)); } @@ -134,11 +152,61 @@ public EnumCreatureAttribute getCreatureAttribute() { @Override public void onDeath(DamageSource par1DamageSource) { super.onDeath(par1DamageSource); - if (par1DamageSource.getEntity() instanceof EntityPlayer) { + if (par1DamageSource.getEntity() instanceof EntityPlayer + && ((EntityPlayer) par1DamageSource.getEntity()).dimension == TwilightForestMod.dimensionID) { ((EntityPlayer) par1DamageSource.getEntity()).triggerAchievement(TFAchievementPage.twilightHunter); } } + /** + * Makes entity wear random armor based on difficulty + */ + protected void addRandomArmor() { + super.addRandomArmor(); + this.setCurrentItemOrArmor(0, new ItemStack(Items.golden_hoe)); + } + + public IEntityLivingData onSpawnWithEgg(IEntityLivingData p_110161_1_) { + p_110161_1_ = super.onSpawnWithEgg(p_110161_1_); + + // this.tasks.addTask(4, this.aiArrowAttack); + this.addRandomArmor(); + // this.enchantEquipment(); + + this.setCanPickUpLoot( + this.rand.nextFloat() < 0.55F * this.worldObj.func_147462_b(this.posX, this.posY, this.posZ)); + + this.setCombatTask(); + + if (this.getEquipmentInSlot(4) == null) { + Calendar calendar = this.worldObj.getCurrentDate(); + + if (calendar.get(2) + 1 == 10 && calendar.get(5) == 31 && this.rand.nextFloat() < 0.25F) { + this.setCurrentItemOrArmor( + 4, + new ItemStack(this.rand.nextFloat() < 0.1F ? Blocks.lit_pumpkin : Blocks.pumpkin)); + this.equipmentDropChances[4] = 0.0F; + } + } + + return p_110161_1_; + } + + /** + * sets this entity's combat AI. + */ + public void setCombatTask() { + this.tasks.removeTask(this.aiAttackOnCollide); + this.tasks.removeTask(this.aiArrowAttack); + ItemStack itemstack = this.getHeldItem(); + + if (itemstack != null && itemstack.getItem() instanceof ItemHoe) { + this.tasks.addTask(4, this.aiArrowAttack); + } else { + this.tasks.addTask(4, this.aiAttackOnCollide); + } + } + /** * Attack the specified entity using a ranged attack. */ diff --git a/src/main/java/twilightforest/entity/EntityTFSlimeBeetle.java b/src/main/java/twilightforest/entity/EntityTFSlimeBeetle.java index bf70abd769..244e6fe422 100644 --- a/src/main/java/twilightforest/entity/EntityTFSlimeBeetle.java +++ b/src/main/java/twilightforest/entity/EntityTFSlimeBeetle.java @@ -21,6 +21,7 @@ import cpw.mods.fml.relauncher.Side; import cpw.mods.fml.relauncher.SideOnly; import twilightforest.TFAchievementPage; +import twilightforest.TwilightForestMod; import twilightforest.entity.ai.EntityAITFMagicAttack; public class EntityTFSlimeBeetle extends EntityMob { @@ -121,7 +122,8 @@ public void onLivingUpdate() { @Override public void onDeath(DamageSource par1DamageSource) { super.onDeath(par1DamageSource); - if (par1DamageSource.getEntity() instanceof EntityPlayer) { + if (par1DamageSource.getEntity() instanceof EntityPlayer + && ((EntityPlayer) par1DamageSource.getEntity()).dimension == TwilightForestMod.dimensionID) { ((EntityPlayer) par1DamageSource.getEntity()).triggerAchievement(TFAchievementPage.twilightHunter); } } diff --git a/src/main/java/twilightforest/entity/EntityTFSwarmSpider.java b/src/main/java/twilightforest/entity/EntityTFSwarmSpider.java index 8649744131..5a0d901939 100644 --- a/src/main/java/twilightforest/entity/EntityTFSwarmSpider.java +++ b/src/main/java/twilightforest/entity/EntityTFSwarmSpider.java @@ -11,6 +11,7 @@ import twilightforest.TFAchievementPage; import twilightforest.TFFeature; +import twilightforest.TwilightForestMod; public class EntityTFSwarmSpider extends EntitySpider { @@ -167,7 +168,8 @@ public void readEntityFromNBT(NBTTagCompound nbttagcompound) { @Override public void onDeath(DamageSource par1DamageSource) { super.onDeath(par1DamageSource); - if (par1DamageSource.getEntity() instanceof EntityPlayer) { + if (par1DamageSource.getEntity() instanceof EntityPlayer + && ((EntityPlayer) par1DamageSource.getEntity()).dimension == TwilightForestMod.dimensionID) { ((EntityPlayer) par1DamageSource.getEntity()).triggerAchievement(TFAchievementPage.twilightHunter); // are we in a hedge maze? int chunkX = MathHelper.floor_double(posX) >> 4; diff --git a/src/main/java/twilightforest/entity/EntityTFTroll.java b/src/main/java/twilightforest/entity/EntityTFTroll.java index 8425ddd049..00f11aee62 100644 --- a/src/main/java/twilightforest/entity/EntityTFTroll.java +++ b/src/main/java/twilightforest/entity/EntityTFTroll.java @@ -27,6 +27,7 @@ import net.minecraft.world.WorldServer; import twilightforest.TFAchievementPage; +import twilightforest.TwilightForestMod; import twilightforest.block.TFBlocks; import twilightforest.entity.ai.EntityAITFCollideAttackFixed; import twilightforest.entity.boss.EntityTFIceBomb; @@ -186,7 +187,8 @@ private void ripenBer(int offset, int cx, int cy, int cz) { @Override public void onDeath(DamageSource damageSource) { super.onDeath(damageSource); - if (damageSource.getEntity() instanceof EntityPlayer) { + if (damageSource.getEntity() instanceof EntityPlayer + && ((EntityPlayer) damageSource.getEntity()).dimension == TwilightForestMod.dimensionID) { ((EntityPlayer) damageSource.getEntity()).triggerAchievement(TFAchievementPage.twilightHunter); } diff --git a/src/main/java/twilightforest/entity/EntityTFWraith.java b/src/main/java/twilightforest/entity/EntityTFWraith.java index 13eaa8683f..42aa4041b3 100644 --- a/src/main/java/twilightforest/entity/EntityTFWraith.java +++ b/src/main/java/twilightforest/entity/EntityTFWraith.java @@ -239,7 +239,8 @@ protected Item getDropItem() { @Override public void onDeath(DamageSource damageSource) { super.onDeath(damageSource); - if (damageSource.getEntity() instanceof EntityPlayer) { + if (damageSource.getEntity() instanceof EntityPlayer + && ((EntityPlayer) damageSource.getEntity()).dimension == TwilightForestMod.dimensionID) { ((EntityPlayer) damageSource.getEntity()).triggerAchievement(TFAchievementPage.twilightHunter); // are we in a level 3 hill? int chunkX = MathHelper.floor_double(posX) >> 4; diff --git a/src/main/java/twilightforest/entity/EntityTFYeti.java b/src/main/java/twilightforest/entity/EntityTFYeti.java index 298b161569..a631c7dc8a 100644 --- a/src/main/java/twilightforest/entity/EntityTFYeti.java +++ b/src/main/java/twilightforest/entity/EntityTFYeti.java @@ -18,6 +18,7 @@ import net.minecraft.world.World; import twilightforest.TFAchievementPage; +import twilightforest.TwilightForestMod; import twilightforest.biomes.TFBiomeBase; import twilightforest.entity.ai.EntityAITFThrowRider; import twilightforest.item.TFItems; @@ -123,6 +124,7 @@ public boolean interact(EntityPlayer par1EntityPlayer) { @Override public boolean attackEntityAsMob(Entity par1Entity) { if (this.riddenByEntity == null && par1Entity.ridingEntity == null) { + this.playSound(TwilightForestMod.ID + ":mob.yeti.grab", 4F, 0.75F + rand.nextFloat() * 0.25F); par1Entity.mountEntity(this); } @@ -232,13 +234,14 @@ public boolean canRiderInteract() { @Override public void onDeath(DamageSource par1DamageSource) { super.onDeath(par1DamageSource); - if (par1DamageSource.getEntity() instanceof EntityPlayer) { + if (par1DamageSource.getEntity() instanceof EntityPlayer + && ((EntityPlayer) par1DamageSource.getEntity()).dimension == TwilightForestMod.dimensionID) { ((EntityPlayer) par1DamageSource.getEntity()).triggerAchievement(TFAchievementPage.twilightHunter); } } /** - * We're allowed to spawn in bright light only in sniw + * We're allowed to spawn in bright light only in snow */ @Override public boolean getCanSpawnHere() { @@ -273,4 +276,28 @@ protected Item getDropItem() { return TFItems.arcticFur; } + /** + * Returns the sound this mob makes while it's alive. + */ + @Override + protected String getLivingSound() { + return TwilightForestMod.ID + ":mob.yeti.growl"; + } + + /** + * Returns the sound this mob makes when it is hurt. + */ + @Override + protected String getHurtSound() { + return TwilightForestMod.ID + ":mob.yeti.hurt"; + } + + /** + * Returns the sound this mob makes on death. + */ + @Override + protected String getDeathSound() { + return TwilightForestMod.ID + ":mob.yeti.death"; + } + } diff --git a/src/main/java/twilightforest/entity/ai/EntityAITFThrowRider.java b/src/main/java/twilightforest/entity/ai/EntityAITFThrowRider.java index 8787370e9c..b148c50b2d 100644 --- a/src/main/java/twilightforest/entity/ai/EntityAITFThrowRider.java +++ b/src/main/java/twilightforest/entity/ai/EntityAITFThrowRider.java @@ -60,6 +60,11 @@ public void startExecuting() { } + theEntityCreature.playSound( + TwilightForestMod.ID + ":mob.yeti.throw", + 4F, + 0.75F + this.theEntityCreature.rand.nextFloat() * 0.25F); + FMLLog.finer("[TwilightForest] throw!"); this.throwTimer = 0; } diff --git a/src/main/java/twilightforest/entity/boss/EntityTFHydra.java b/src/main/java/twilightforest/entity/boss/EntityTFHydra.java index cd86623c9a..c0a88be70c 100644 --- a/src/main/java/twilightforest/entity/boss/EntityTFHydra.java +++ b/src/main/java/twilightforest/entity/boss/EntityTFHydra.java @@ -17,7 +17,9 @@ import net.minecraft.entity.player.EntityPlayer; import net.minecraft.init.Blocks; import net.minecraft.nbt.NBTTagCompound; +import net.minecraft.nbt.NBTTagList; import net.minecraft.util.AxisAlignedBB; +import net.minecraft.util.ChunkCoordinates; import net.minecraft.util.DamageSource; import net.minecraft.util.MathHelper; import net.minecraft.world.EnumDifficulty; @@ -26,6 +28,7 @@ import twilightforest.TFAchievementPage; import twilightforest.TFFeature; import twilightforest.TwilightForestMod; +import twilightforest.block.TFBlocks; import twilightforest.item.TFItems; import twilightforest.world.ChunkProviderTwilightForest; import twilightforest.world.TFWorldChunkManager; @@ -33,6 +36,10 @@ public class EntityTFHydra extends EntityLiving implements IBossDisplayData, IEntityMultiPart, IMob { + private ChunkCoordinates homePosition = new ChunkCoordinates(0, 0, 0); + /** If -1 there is no maximum distance */ + private float maximumHomeDistance = -1.0F; + private static int TICKS_BEFORE_HEALING = 1000; private static int HEAD_RESPAWN_TICKS = 100; private static int HEAD_MAX_DAMAGE = 120; @@ -285,7 +292,7 @@ public void onLivingUpdate() { } } } - + despawnIfInvalid(); } @Override @@ -307,12 +314,51 @@ public void setSpawnHeads(boolean flag) { } } + protected void despawnIfInvalid() { + // check to see if we're valid + if (!worldObj.isRemote && worldObj.difficultySetting == EnumDifficulty.PEACEFUL) { + despawnMe(); + } + } + + /** + * Despawn the hydra, and restore the boss spawner at our home location, if set + */ + protected void despawnMe() { + if (this.hasHome()) { + ChunkCoordinates home = this.getHomePosition(); + worldObj.setBlock(home.posX, home.posY, home.posZ, TFBlocks.bossSpawner, 2, 2); + } + this.deathTime = 200; // For heads and stuff to despawn + setDead(); + } + + private ChunkCoordinates getHomePosition() { + return homePosition; + } + + private boolean hasHome() { + return maximumHomeDistance > -1; + } + + public void setHomeArea(int hx, int hy, int hz, int i) { + homePosition = new ChunkCoordinates(hx, hy, hz); + maximumHomeDistance = i; + } + + public void detachHome() { + this.maximumHomeDistance = -1.0F; + } + /** * Save to disk. */ @Override public void writeEntityToNBT(NBTTagCompound nbttagcompound) { super.writeEntityToNBT(nbttagcompound); + ChunkCoordinates home = this.getHomePosition(); + nbttagcompound.setTag("Home", newDoubleNBTList(home.posX, home.posY, home.posZ)); + nbttagcompound.setBoolean("HasHome", this.hasHome()); nbttagcompound.setBoolean("SpawnHeads", shouldSpawnHeads()); nbttagcompound.setByte("NumHeads", (byte) countActiveHeads()); } @@ -323,6 +369,16 @@ public void writeEntityToNBT(NBTTagCompound nbttagcompound) { @Override public void readEntityFromNBT(NBTTagCompound nbttagcompound) { super.readEntityFromNBT(nbttagcompound); + if (nbttagcompound.hasKey("Home", 9)) { + NBTTagList nbttaglist = nbttagcompound.getTagList("Home", 6); + int hx = (int) nbttaglist.func_150309_d(0); + int hy = (int) nbttaglist.func_150309_d(1); + int hz = (int) nbttaglist.func_150309_d(2); + this.setHomeArea(hx, hy, hz, 20); + } + if (!nbttagcompound.getBoolean("HasHome")) { + this.detachHome(); + } setSpawnHeads(nbttagcompound.getBoolean("SpawnHeads")); activateNumberOfHeads(nbttagcompound.getByte("NumHeads")); } @@ -919,6 +975,13 @@ protected String getLivingSound() { return TwilightForestMod.ID + ":mob.hydra.growl"; } + /** + * Basically a public getter for living sounds + */ + public String getTrophySound() { + return this.getLivingSound(); + } + /** * Returns the sound this mob makes when it is hurt. */ @@ -949,7 +1012,8 @@ protected float getSoundVolume() { @Override public void onDeath(DamageSource par1DamageSource) { super.onDeath(par1DamageSource); - if (par1DamageSource.getEntity() instanceof EntityPlayer) { + if (par1DamageSource.getEntity() instanceof EntityPlayer + && ((EntityPlayer) par1DamageSource.getEntity()).dimension == TwilightForestMod.dimensionID) { ((EntityPlayer) par1DamageSource.getEntity()).triggerAchievement(TFAchievementPage.twilightHunter); ((EntityPlayer) par1DamageSource.getEntity()).triggerAchievement(TFAchievementPage.twilightKillHydra); } diff --git a/src/main/java/twilightforest/entity/boss/EntityTFIceBomb.java b/src/main/java/twilightforest/entity/boss/EntityTFIceBomb.java index 25c3337cee..f4cbd717b2 100644 --- a/src/main/java/twilightforest/entity/boss/EntityTFIceBomb.java +++ b/src/main/java/twilightforest/entity/boss/EntityTFIceBomb.java @@ -12,6 +12,7 @@ import net.minecraft.potion.PotionEffect; import net.minecraft.util.MathHelper; import net.minecraft.util.MovingObjectPosition; +import net.minecraft.util.Vec3; import net.minecraft.world.World; import twilightforest.TwilightForestMod; @@ -64,7 +65,8 @@ private void doTerrainEffects() { for (int x = -range; x <= range; x++) { for (int y = -range; y <= range; y++) { for (int z = -range; z <= range; z++) { - this.doTerrainEffect(ix + x, iy + y, iz + z); + if (Vec3.createVectorHelper(x, y, z).lengthVector() <= range + 0.5d) + this.doTerrainEffect(ix + x, iy + y, iz + z); } } } @@ -82,7 +84,10 @@ private void doTerrainEffect(int x, int y, int z) { } if (this.worldObj.isAirBlock(x, y, z) && Blocks.snow_layer.canPlaceBlockAt(this.worldObj, x, y, z)) { this.worldObj.setBlock(x, y, z, Blocks.snow_layer); - } + } else + if (this.worldObj.getBlock(x, y, z) == Blocks.snow_layer && this.worldObj.getBlockMetadata(x, y, z) < 7) { + this.worldObj.setBlockMetadataWithNotify(x, y, z, this.worldObj.getBlockMetadata(x, y, z) + 1, 2); + } } /** diff --git a/src/main/java/twilightforest/entity/boss/EntityTFKnightPhantom.java b/src/main/java/twilightforest/entity/boss/EntityTFKnightPhantom.java index d71e56d13f..0b308aa6ef 100644 --- a/src/main/java/twilightforest/entity/boss/EntityTFKnightPhantom.java +++ b/src/main/java/twilightforest/entity/boss/EntityTFKnightPhantom.java @@ -26,7 +26,9 @@ import twilightforest.TFFeature; import twilightforest.TFTreasure; import twilightforest.TwilightForestMod; +import twilightforest.block.TFBlocks; import twilightforest.item.TFItems; +import twilightforest.tileentity.TileEntityTFKnightPhantomsSpawner; import twilightforest.world.ChunkProviderTwilightForest; import twilightforest.world.TFWorldChunkManager; import twilightforest.world.WorldProviderTwilightForest; @@ -117,6 +119,7 @@ public boolean attackEntityFrom(DamageSource par1DamageSource, float par2) { * use this to react to sunlight and start to burn. */ public void onLivingUpdate() { + despawnIfInvalid(); super.onLivingUpdate(); if (this.isChargingAtPlayer()) { @@ -144,6 +147,29 @@ public void onLivingUpdate() { } } + protected void despawnIfInvalid() { + // check to see if we're valid + if (!worldObj.isRemote && worldObj.difficultySetting == EnumDifficulty.PEACEFUL) { + despawnMe(); + } + } + + /** + * Despawn the knight phantom, and restore the boss spawner at our home location, if set + */ + protected void despawnMe() { + if (this.hasHome()) { + ChunkCoordinates home = this.getHomePosition(); + if (worldObj.getBlock(home.posX, home.posY, home.posZ) != TFBlocks.bossSpawner) { + worldObj.setBlock(home.posX, home.posY, home.posZ, TFBlocks.bossSpawner, 4, 2); + TileEntityTFKnightPhantomsSpawner spawner = (TileEntityTFKnightPhantomsSpawner) worldObj + .getTileEntity(home.posX, home.posY, home.posZ); + spawner.knightsCount = getNearbyKnights().size(); + } + } + setDead(); + } + // handles entity death timer, experience orb and particle creation @Override protected void onDeathUpdate() { @@ -168,7 +194,8 @@ protected void onDeathUpdate() { @Override public void onDeath(DamageSource damageSource) { super.onDeath(damageSource); - if (damageSource.getEntity() instanceof EntityPlayer) { + if (damageSource.getEntity() instanceof EntityPlayer + && ((EntityPlayer) damageSource.getEntity()).dimension == TwilightForestMod.dimensionID) { ((EntityPlayer) damageSource.getEntity()).triggerAchievement(TFAchievementPage.twilightHunter); ((EntityPlayer) damageSource.getEntity()).triggerAchievement(TFAchievementPage.twilightProgressKnights); } @@ -612,6 +639,13 @@ protected String getLivingSound() { return TwilightForestMod.ID + ":mob.wraith.wraith"; } + /** + * Basically a public getter for living sounds + */ + public String getTrophySound() { + return this.getLivingSound(); + } + @Override protected String getHurtSound() { return TwilightForestMod.ID + ":mob.wraith.wraith"; diff --git a/src/main/java/twilightforest/entity/boss/EntityTFLich.java b/src/main/java/twilightforest/entity/boss/EntityTFLich.java index c93e8098cd..24b2a91c2c 100644 --- a/src/main/java/twilightforest/entity/boss/EntityTFLich.java +++ b/src/main/java/twilightforest/entity/boss/EntityTFLich.java @@ -21,14 +21,19 @@ import net.minecraft.init.Items; import net.minecraft.item.ItemStack; import net.minecraft.nbt.NBTTagCompound; +import net.minecraft.nbt.NBTTagList; import net.minecraft.util.AxisAlignedBB; +import net.minecraft.util.ChunkCoordinates; import net.minecraft.util.DamageSource; import net.minecraft.util.MathHelper; import net.minecraft.util.Vec3; +import net.minecraft.world.EnumDifficulty; import net.minecraft.world.World; import twilightforest.TFAchievementPage; import twilightforest.TFFeature; +import twilightforest.TwilightForestMod; +import twilightforest.block.TFBlocks; import twilightforest.entity.EntityTFSwarmSpider; import twilightforest.item.TFItems; import twilightforest.world.ChunkProviderTwilightForest; @@ -162,6 +167,24 @@ private void dropGoldThing() { this.entityDropItem(goldThing, 0); } + protected void despawnIfInvalid() { + // check to see if we're valid + if (!worldObj.isRemote && worldObj.difficultySetting == EnumDifficulty.PEACEFUL) { + despawnMe(); + } + } + + /** + * Despawn the lich, and restore the boss spawner at our home location, if set + */ + protected void despawnMe() { + if (this.hasHome()) { + ChunkCoordinates home = this.getHomePosition(); + worldObj.setBlock(home.posX, home.posY, home.posZ, TFBlocks.bossSpawner, 1, 2); + } + setDead(); + } + /** * Sets the Entity inside a web block. We are immune to webs. */ @@ -214,6 +237,7 @@ public int getPhase() { */ @Override public void onLivingUpdate() { + despawnIfInvalid(); // determine the hand position float angle = ((renderYawOffset * 3.141593F) / 180F); @@ -981,6 +1005,13 @@ protected String getLivingSound() { return "mob.blaze.breathe"; } + /** + * Basically a public getter for living sounds + */ + public String getTrophySound() { + return this.getLivingSound(); + } + /** * Returns the sound this mob makes when it is hurt. */ @@ -1000,6 +1031,9 @@ protected String getDeathSound() { @Override public void writeEntityToNBT(NBTTagCompound nbttagcompound) { super.writeEntityToNBT(nbttagcompound); + ChunkCoordinates home = this.getHomePosition(); + nbttagcompound.setTag("Home", newDoubleNBTList(home.posX, home.posY, home.posZ)); + nbttagcompound.setBoolean("HasHome", this.hasHome()); nbttagcompound.setBoolean("ShadowClone", isShadowClone()); nbttagcompound.setByte("ShieldStrength", getShieldStrength()); nbttagcompound.setByte("MinionsToSummon", getMinionsToSummon()); @@ -1008,6 +1042,16 @@ public void writeEntityToNBT(NBTTagCompound nbttagcompound) { @Override public void readEntityFromNBT(NBTTagCompound nbttagcompound) { super.readEntityFromNBT(nbttagcompound); + if (nbttagcompound.hasKey("Home", 9)) { + NBTTagList nbttaglist = nbttagcompound.getTagList("Home", 6); + int hx = (int) nbttaglist.func_150309_d(0); + int hy = (int) nbttaglist.func_150309_d(1); + int hz = (int) nbttaglist.func_150309_d(2); + this.setHomeArea(hx, hy, hz, 20); + } + if (!nbttagcompound.getBoolean("HasHome")) { + this.detachHome(); + } setShadowClone(nbttagcompound.getBoolean("ShadowClone")); setShieldStrength(nbttagcompound.getByte("ShieldStrength")); setMinionsToSummon(nbttagcompound.getByte("MinionsToSummon")); @@ -1019,7 +1063,8 @@ public void readEntityFromNBT(NBTTagCompound nbttagcompound) { @Override public void onDeath(DamageSource par1DamageSource) { super.onDeath(par1DamageSource); - if (par1DamageSource.getEntity() instanceof EntityPlayer) { + if (par1DamageSource.getEntity() instanceof EntityPlayer + && ((EntityPlayer) par1DamageSource.getEntity()).dimension == TwilightForestMod.dimensionID) { ((EntityPlayer) par1DamageSource.getEntity()).triggerAchievement(TFAchievementPage.twilightHunter); ((EntityPlayer) par1DamageSource.getEntity()).triggerAchievement(TFAchievementPage.twilightKillLich); diff --git a/src/main/java/twilightforest/entity/boss/EntityTFLichMinion.java b/src/main/java/twilightforest/entity/boss/EntityTFLichMinion.java index c37842be21..4ff1923d44 100644 --- a/src/main/java/twilightforest/entity/boss/EntityTFLichMinion.java +++ b/src/main/java/twilightforest/entity/boss/EntityTFLichMinion.java @@ -15,6 +15,7 @@ import net.minecraft.world.World; import twilightforest.TFAchievementPage; +import twilightforest.TwilightForestMod; public class EntityTFLichMinion extends EntityZombie { @@ -108,7 +109,8 @@ private void findNewMaster() { @Override public void onDeath(DamageSource par1DamageSource) { super.onDeath(par1DamageSource); - if (par1DamageSource.getEntity() instanceof EntityPlayer) { + if (par1DamageSource.getEntity() instanceof EntityPlayer + && ((EntityPlayer) par1DamageSource.getEntity()).dimension == TwilightForestMod.dimensionID) { ((EntityPlayer) par1DamageSource.getEntity()).triggerAchievement(TFAchievementPage.twilightHunter); } } diff --git a/src/main/java/twilightforest/entity/boss/EntityTFMinoshroom.java b/src/main/java/twilightforest/entity/boss/EntityTFMinoshroom.java index 4d71d5f4d3..a1e8e60b63 100644 --- a/src/main/java/twilightforest/entity/boss/EntityTFMinoshroom.java +++ b/src/main/java/twilightforest/entity/boss/EntityTFMinoshroom.java @@ -3,8 +3,13 @@ import net.minecraft.entity.SharedMonsterAttributes; import net.minecraft.item.Item; import net.minecraft.item.ItemStack; +import net.minecraft.nbt.NBTTagCompound; +import net.minecraft.nbt.NBTTagList; +import net.minecraft.util.ChunkCoordinates; +import net.minecraft.world.EnumDifficulty; import net.minecraft.world.World; +import twilightforest.block.TFBlocks; import twilightforest.entity.EntityTFMinotaur; import twilightforest.item.TFItems; @@ -48,6 +53,9 @@ protected void dropFewItems(boolean par1, int par2) { for (int i = 0; i < numDrops; ++i) { this.dropItem(TFItems.meefStroganoff, 1); } + + // trophy + this.entityDropItem(new ItemStack(TFItems.trophy, 1, 5), 0); } /** @@ -58,6 +66,53 @@ protected boolean canDespawn() { return false; } + @Override + public void onLivingUpdate() { + despawnIfInvalid(); + super.onLivingUpdate(); + } + + protected void despawnIfInvalid() { + // check to see if we're valid + if (!worldObj.isRemote && worldObj.difficultySetting == EnumDifficulty.PEACEFUL) { + despawnMe(); + } + } + + /** + * Despawn the minoshroom, and restore the boss spawner at our home location, if set + */ + protected void despawnMe() { + if (this.hasHome()) { + ChunkCoordinates home = this.getHomePosition(); + worldObj.setBlock(home.posX, home.posY, home.posZ, TFBlocks.bossSpawner, 6, 2); + } + setDead(); + } + + @Override + public void writeEntityToNBT(NBTTagCompound nbttagcompound) { + super.writeEntityToNBT(nbttagcompound); + ChunkCoordinates home = this.getHomePosition(); + nbttagcompound.setTag("Home", newDoubleNBTList(home.posX, home.posY, home.posZ)); + nbttagcompound.setBoolean("HasHome", this.hasHome()); + } + + @Override + public void readEntityFromNBT(NBTTagCompound nbttagcompound) { + super.readEntityFromNBT(nbttagcompound); + if (nbttagcompound.hasKey("Home", 9)) { + NBTTagList nbttaglist = nbttagcompound.getTagList("Home", 6); + int hx = (int) nbttaglist.func_150309_d(0); + int hy = (int) nbttaglist.func_150309_d(1); + int hz = (int) nbttaglist.func_150309_d(2); + this.setHomeArea(hx, hy, hz, 20); + } + if (!nbttagcompound.getBoolean("HasHome")) { + this.detachHome(); + } + } + /** * Drop the equipment for this entity. */ @@ -67,4 +122,11 @@ protected void dropEquipment(boolean par1, int par2) { } + /** + * Basically a public getter for living sounds + */ + public String getTrophySound() { + return this.getLivingSound(); + } + } diff --git a/src/main/java/twilightforest/entity/boss/EntityTFNaga.java b/src/main/java/twilightforest/entity/boss/EntityTFNaga.java index 59f65b4dfc..2cf6e05da1 100644 --- a/src/main/java/twilightforest/entity/boss/EntityTFNaga.java +++ b/src/main/java/twilightforest/entity/boss/EntityTFNaga.java @@ -447,6 +447,13 @@ protected String getLivingSound() { : TwilightForestMod.ID + ":mob.naga.rattle"; } + /** + * Basically a public getter for living sounds + */ + public String getTrophySound() { + return this.getLivingSound(); + } + /** * Returns the sound this mob makes when it is hurt. */ @@ -1073,7 +1080,8 @@ public void readEntityFromNBT(NBTTagCompound nbttagcompound) { @Override public void onDeath(DamageSource par1DamageSource) { super.onDeath(par1DamageSource); - if (par1DamageSource.getEntity() instanceof EntityPlayer) { + if (par1DamageSource.getEntity() instanceof EntityPlayer + && ((EntityPlayer) par1DamageSource.getEntity()).dimension == TwilightForestMod.dimensionID) { ((EntityPlayer) par1DamageSource.getEntity()).triggerAchievement(TFAchievementPage.twilightHunter); ((EntityPlayer) par1DamageSource.getEntity()).triggerAchievement(TFAchievementPage.twilightKillNaga); } diff --git a/src/main/java/twilightforest/entity/boss/EntityTFSnowQueen.java b/src/main/java/twilightforest/entity/boss/EntityTFSnowQueen.java index 87a8f48bd6..b92296ea8c 100644 --- a/src/main/java/twilightforest/entity/boss/EntityTFSnowQueen.java +++ b/src/main/java/twilightforest/entity/boss/EntityTFSnowQueen.java @@ -23,15 +23,20 @@ import net.minecraft.init.Items; import net.minecraft.item.Item; import net.minecraft.item.ItemStack; +import net.minecraft.nbt.NBTTagCompound; +import net.minecraft.nbt.NBTTagList; import net.minecraft.util.AxisAlignedBB; +import net.minecraft.util.ChunkCoordinates; import net.minecraft.util.DamageSource; import net.minecraft.util.MathHelper; import net.minecraft.util.Vec3; +import net.minecraft.world.EnumDifficulty; import net.minecraft.world.World; import twilightforest.TFAchievementPage; import twilightforest.TFFeature; import twilightforest.TwilightForestMod; +import twilightforest.block.TFBlocks; import twilightforest.entity.IBreathAttacker; import twilightforest.entity.ai.EntityAITFHoverBeam; import twilightforest.entity.ai.EntityAITFHoverSummon; @@ -122,6 +127,13 @@ protected String getLivingSound() { return TwilightForestMod.ID + ":mob.ice.noise"; } + /** + * Basically a public getter for living sounds + */ + public String getTrophySound() { + return this.getLivingSound(); + } + /** * Returns the sound this mob makes when it is hurt. */ @@ -162,6 +174,7 @@ public IEntityLivingData onSpawnWithEgg(IEntityLivingData par1EntityLivingData) * use this to react to sunlight and start to burn. */ public void onLivingUpdate() { + despawnIfInvalid(); super.onLivingUpdate(); // make snow particles for (int i = 0; i < 3; i++) { @@ -243,6 +256,47 @@ public void onLivingUpdate() { } + protected void despawnIfInvalid() { + // check to see if we're valid + if (!worldObj.isRemote && worldObj.difficultySetting == EnumDifficulty.PEACEFUL) { + despawnMe(); + } + } + + /** + * Despawn the snow queen, and restore the boss spawner at our home location, if set + */ + protected void despawnMe() { + if (this.hasHome()) { + ChunkCoordinates home = this.getHomePosition(); + worldObj.setBlock(home.posX, home.posY, home.posZ, TFBlocks.bossSpawner, 5, 2); + } + setDead(); + } + + @Override + public void writeEntityToNBT(NBTTagCompound nbttagcompound) { + super.writeEntityToNBT(nbttagcompound); + ChunkCoordinates home = this.getHomePosition(); + nbttagcompound.setTag("Home", newDoubleNBTList(home.posX, home.posY, home.posZ)); + nbttagcompound.setBoolean("HasHome", this.hasHome()); + } + + @Override + public void readEntityFromNBT(NBTTagCompound nbttagcompound) { + super.readEntityFromNBT(nbttagcompound); + if (nbttagcompound.hasKey("Home", 9)) { + NBTTagList nbttaglist = nbttagcompound.getTagList("Home", 6); + int hx = (int) nbttaglist.func_150309_d(0); + int hy = (int) nbttaglist.func_150309_d(1); + int hz = (int) nbttaglist.func_150309_d(2); + this.setHomeArea(hx, hy, hz, 20); + } + if (!nbttagcompound.getBoolean("HasHome")) { + this.detachHome(); + } + } + // Keep ice shield position updated @Override public void onUpdate() { @@ -326,7 +380,8 @@ private void dropBow() { @Override public void onDeath(DamageSource par1DamageSource) { super.onDeath(par1DamageSource); - if (par1DamageSource.getEntity() instanceof EntityPlayer) { + if (par1DamageSource.getEntity() instanceof EntityPlayer + && ((EntityPlayer) par1DamageSource.getEntity()).dimension == TwilightForestMod.dimensionID) { ((EntityPlayer) par1DamageSource.getEntity()).triggerAchievement(TFAchievementPage.twilightHunter); ((EntityPlayer) par1DamageSource.getEntity()).triggerAchievement(TFAchievementPage.twilightProgressGlacier); diff --git a/src/main/java/twilightforest/entity/boss/EntityTFUrGhast.java b/src/main/java/twilightforest/entity/boss/EntityTFUrGhast.java index cc17e9bc41..5f38620bd1 100644 --- a/src/main/java/twilightforest/entity/boss/EntityTFUrGhast.java +++ b/src/main/java/twilightforest/entity/boss/EntityTFUrGhast.java @@ -8,6 +8,7 @@ import net.minecraft.entity.effect.EntityLightningBolt; import net.minecraft.entity.player.EntityPlayer; import net.minecraft.nbt.NBTTagCompound; +import net.minecraft.nbt.NBTTagList; import net.minecraft.server.MinecraftServer; import net.minecraft.util.AxisAlignedBB; import net.minecraft.util.ChunkCoordinates; @@ -110,12 +111,17 @@ protected boolean canDespawn() { return false; } + @Override + public void onLivingUpdate() { + despawnIfInvalid(); + super.onLivingUpdate(); + } + /** * Keep health updated */ @Override public void onUpdate() { - super.onUpdate(); // extra death explosions @@ -138,6 +144,24 @@ public void onUpdate() { } } + protected void despawnIfInvalid() { + // check to see if we're valid + if (!worldObj.isRemote && worldObj.difficultySetting == EnumDifficulty.PEACEFUL) { + despawnMe(); + } + } + + /** + * Despawn the minoshroom, and restore the boss spawner at our home location, if set + */ + protected void despawnMe() { + if (this.hasHome()) { + ChunkCoordinates home = this.getHomePosition(); + worldObj.setBlock(home.posX, home.posY, home.posZ, TFBlocks.bossSpawner, 3, 2); + } + setDead(); + } + /** * Called when the entity is attacked. */ @@ -759,6 +783,13 @@ protected float getSoundPitch() { return (this.rand.nextFloat() - this.rand.nextFloat()) * 0.2F + 0.5F; } + /** + * Basically a public getter for living sounds + */ + public String getTrophySound() { + return this.getLivingSound(); + } + /** * Needed for boss health bar on the client */ @@ -770,12 +801,25 @@ protected float getSoundPitch() { @Override public void writeEntityToNBT(NBTTagCompound nbttagcompound) { nbttagcompound.setBoolean("inTantrum", this.isInTantrum()); + ChunkCoordinates home = this.getHomePosition(); + nbttagcompound.setTag("Home", newDoubleNBTList(home.posX, home.posY, home.posZ)); + nbttagcompound.setBoolean("HasHome", this.hasHome()); super.writeEntityToNBT(nbttagcompound); } @Override public void readEntityFromNBT(NBTTagCompound nbttagcompound) { super.readEntityFromNBT(nbttagcompound); + if (nbttagcompound.hasKey("Home", 9)) { + NBTTagList nbttaglist = nbttagcompound.getTagList("Home", 6); + int hx = (int) nbttaglist.func_150309_d(0); + int hy = (int) nbttaglist.func_150309_d(1); + int hz = (int) nbttaglist.func_150309_d(2); + this.setHomeArea(hx, hy, hz, 20); + } + if (!nbttagcompound.getBoolean("HasHome")) { + this.detachHome(); + } this.setInTantrum(nbttagcompound.getBoolean("inTantrum")); } @@ -798,7 +842,8 @@ protected void onDeathUpdate() { @Override public void onDeath(DamageSource par1DamageSource) { super.onDeath(par1DamageSource); - if (par1DamageSource.getEntity() instanceof EntityPlayer) { + if (par1DamageSource.getEntity() instanceof EntityPlayer + && ((EntityPlayer) par1DamageSource.getEntity()).dimension == TwilightForestMod.dimensionID) { ((EntityPlayer) par1DamageSource.getEntity()).triggerAchievement(TFAchievementPage.twilightHunter); ((EntityPlayer) par1DamageSource.getEntity()).triggerAchievement(TFAchievementPage.twilightProgressUrghast); diff --git a/src/main/java/twilightforest/entity/boss/EntityTFYetiAlpha.java b/src/main/java/twilightforest/entity/boss/EntityTFYetiAlpha.java index 8d4b2209cf..b43aea9033 100644 --- a/src/main/java/twilightforest/entity/boss/EntityTFYetiAlpha.java +++ b/src/main/java/twilightforest/entity/boss/EntityTFYetiAlpha.java @@ -17,6 +17,7 @@ import net.minecraft.entity.player.EntityPlayer; import net.minecraft.init.Blocks; import net.minecraft.item.Item; +import net.minecraft.item.ItemStack; import net.minecraft.nbt.NBTTagCompound; import net.minecraft.nbt.NBTTagList; import net.minecraft.util.AxisAlignedBB; @@ -24,11 +25,13 @@ import net.minecraft.util.DamageSource; import net.minecraft.util.MathHelper; import net.minecraft.util.Vec3; +import net.minecraft.world.EnumDifficulty; import net.minecraft.world.World; import twilightforest.TFAchievementPage; import twilightforest.TFFeature; import twilightforest.TwilightForestMod; +import twilightforest.block.TFBlocks; import twilightforest.entity.ai.EntityAIStayNearHome; import twilightforest.entity.ai.EntityAITFThrowRider; import twilightforest.entity.ai.EntityAITFYetiRampage; @@ -60,7 +63,19 @@ public EntityTFYetiAlpha(World par1World) { this.tasks.addTask(7, new EntityAIWatchClosest(this, EntityPlayer.class, 8.0F)); this.tasks.addTask(8, new EntityAILookIdle(this)); this.targetTasks.addTask(1, new EntityAIHurtByTarget(this, false)); - this.targetTasks.addTask(2, new EntityAINearestAttackableTarget(this, EntityPlayer.class, 0, false)); + this.targetTasks.addTask(2, new EntityAINearestAttackableTarget(this, EntityPlayer.class, 0, false) { + + /** + * Execute a one shot task or start executing a continuous task + */ + @Override + public void startExecuting() { + this.taskOwner + .playSound(TwilightForestMod.ID + ":mob.yeti.alert", 4F, 0.75F + rand.nextFloat() * 0.25F); + this.taskOwner.setAttackTarget(this.targetEntity); + super.startExecuting(); + } + }); this.experienceValue = 317; @@ -98,6 +113,7 @@ protected void applyEntityAttributes() { */ @Override public void onLivingUpdate() { + despawnIfInvalid(); if (this.riddenByEntity != null) { // stop player sneaking so that they can't dismount! @@ -106,8 +122,6 @@ public void onLivingUpdate() { this.riddenByEntity.setSneaking(false); } - } else { - } super.onLivingUpdate(); @@ -157,6 +171,24 @@ public void onLivingUpdate() { } + protected void despawnIfInvalid() { + // check to see if we're valid + if (!worldObj.isRemote && worldObj.difficultySetting == EnumDifficulty.PEACEFUL) { + despawnMe(); + } + } + + /** + * Despawn the alpha yeti, and restore the boss spawner at our home location, if set + */ + protected void despawnMe() { + if (this.hasHome()) { + ChunkCoordinates home = this.getHomePosition(); + worldObj.setBlock(home.posX, home.posY, home.posZ, TFBlocks.bossSpawner, 7, 2); + } + setDead(); + } + private void addSnowEffect(float rotation, float hgt) { double px = 3F * Math.cos(rotation); double py = hgt % 5F; @@ -195,6 +227,7 @@ public boolean interact(EntityPlayer par1EntityPlayer) { @Override public boolean attackEntityAsMob(Entity par1Entity) { if (this.riddenByEntity == null && par1Entity.ridingEntity == null) { + this.playSound(TwilightForestMod.ID + ":mob.yeti.grab", 4F, 0.75F + rand.nextFloat() * 0.25F); par1Entity.mountEntity(this); } @@ -238,6 +271,9 @@ protected void dropFewItems(boolean flag, int looting) { this.dropItem(bombs, 1); } + // trophy + this.entityDropItem(new ItemStack(TFItems.trophy, 1, 7), 0); + } @Override @@ -409,7 +445,10 @@ public void attackEntityWithRangedAttack(EntityLivingBase target, float par2) { float f1 = MathHelper.sqrt_double(d0 * d0 + d2 * d2) * 0.2F; ice.setThrowableHeading(d0, d1 + (double) f1, d2, 0.75F, 12.0F); - this.playSound("random.bow", 1.0F, 1.0F / (this.getRNG().nextFloat() * 0.4F + 0.8F)); + this.playSound( + TwilightForestMod.ID + ":mob.yeti.pant", + 1.0F, + 1.0F / (this.getRNG().nextFloat() * 0.4F + 0.8F)); this.worldObj.spawnEntityInWorld(ice); } } @@ -426,6 +465,7 @@ public boolean canRampage() { * Set whether this yeti is currently in rampage mode. */ public void setRampaging(boolean par1) { + if (par1) this.playSound(TwilightForestMod.ID + ":mob.yeti.roar", 4F, 0.75F + rand.nextFloat() * 0.25F); this.getDataWatcher().updateObject(RAMPAGE_FLAG, (byte) (par1 ? 1 : 0)); } @@ -459,7 +499,10 @@ protected void fall(float par1) { if (this.isRampaging()) { // make jump effects - this.playSound("random.bow", 1.0F, 1.0F / (this.getRNG().nextFloat() * 0.4F + 0.8F)); + this.playSound( + TwilightForestMod.ID + ":mob.yeti.pant", + 1.0F, + 1.0F / (this.getRNG().nextFloat() * 0.4F + 0.8F)); int i = MathHelper.floor_double(this.posX); int j = MathHelper.floor_double(this.posY - 0.20000000298023224D - (double) this.yOffset); @@ -498,7 +541,8 @@ private void hitNearbyEntities() { @Override public void onDeath(DamageSource par1DamageSource) { super.onDeath(par1DamageSource); - if (par1DamageSource.getEntity() instanceof EntityPlayer) { + if (par1DamageSource.getEntity() instanceof EntityPlayer + && ((EntityPlayer) par1DamageSource.getEntity()).dimension == TwilightForestMod.dimensionID) { ((EntityPlayer) par1DamageSource.getEntity()).triggerAchievement(TFAchievementPage.twilightHunter); ((EntityPlayer) par1DamageSource.getEntity()).triggerAchievement(TFAchievementPage.twilightProgressYeti); } @@ -545,4 +589,35 @@ public void readEntityFromNBT(NBTTagCompound nbttagcompound) { } } + /** + * Returns the sound this mob makes while it's alive. + */ + @Override + protected String getLivingSound() { + return TwilightForestMod.ID + ":mob.yeti.growl"; + } + + /** + * Basically a public getter for living sounds + */ + public String getTrophySound() { + return this.getLivingSound(); + } + + /** + * Returns the sound this mob makes when it is hurt. + */ + @Override + protected String getHurtSound() { + return TwilightForestMod.ID + ":mob.yeti.hurt"; + } + + /** + * Returns the sound this mob makes on death. + */ + @Override + protected String getDeathSound() { + return TwilightForestMod.ID + ":mob.yeti.death"; + } + } diff --git a/src/main/java/twilightforest/entity/passive/EntityTFBighorn.java b/src/main/java/twilightforest/entity/passive/EntityTFBighorn.java index 6e57f275e1..d4cde514f7 100644 --- a/src/main/java/twilightforest/entity/passive/EntityTFBighorn.java +++ b/src/main/java/twilightforest/entity/passive/EntityTFBighorn.java @@ -10,6 +10,7 @@ import net.minecraft.world.World; import twilightforest.TFAchievementPage; +import twilightforest.TwilightForestMod; public class EntityTFBighorn extends EntitySheep { @@ -65,7 +66,8 @@ public EntitySheep createChild(EntityAgeable entityanimal) { @Override public void onDeath(DamageSource par1DamageSource) { super.onDeath(par1DamageSource); - if (par1DamageSource.getEntity() instanceof EntityPlayer) { + if (par1DamageSource.getEntity() instanceof EntityPlayer + && ((EntityPlayer) par1DamageSource.getEntity()).dimension == TwilightForestMod.dimensionID) { ((EntityPlayer) par1DamageSource.getEntity()).triggerAchievement(TFAchievementPage.twilightHunter); } } diff --git a/src/main/java/twilightforest/entity/passive/EntityTFBoar.java b/src/main/java/twilightforest/entity/passive/EntityTFBoar.java index 2c6533ac3d..69a6cdad19 100644 --- a/src/main/java/twilightforest/entity/passive/EntityTFBoar.java +++ b/src/main/java/twilightforest/entity/passive/EntityTFBoar.java @@ -7,6 +7,7 @@ import net.minecraft.world.World; import twilightforest.TFAchievementPage; +import twilightforest.TwilightForestMod; public class EntityTFBoar extends EntityPig { @@ -35,7 +36,8 @@ public EntityPig createChild(EntityAgeable entityanimal) { @Override public void onDeath(DamageSource par1DamageSource) { super.onDeath(par1DamageSource); - if (par1DamageSource.getEntity() instanceof EntityPlayer) { + if (par1DamageSource.getEntity() instanceof EntityPlayer + && ((EntityPlayer) par1DamageSource.getEntity()).dimension == TwilightForestMod.dimensionID) { ((EntityPlayer) par1DamageSource.getEntity()).triggerAchievement(TFAchievementPage.twilightHunter); } } diff --git a/src/main/java/twilightforest/entity/passive/EntityTFBunny.java b/src/main/java/twilightforest/entity/passive/EntityTFBunny.java index b44c68e71e..7dcab05988 100644 --- a/src/main/java/twilightforest/entity/passive/EntityTFBunny.java +++ b/src/main/java/twilightforest/entity/passive/EntityTFBunny.java @@ -18,6 +18,7 @@ import net.minecraft.world.World; import twilightforest.TFAchievementPage; +import twilightforest.TwilightForestMod; public class EntityTFBunny extends EntityCreature implements IAnimals { @@ -164,7 +165,8 @@ public float getBlockPathWeight(int par1, int par2, int par3) { @Override public void onDeath(DamageSource par1DamageSource) { super.onDeath(par1DamageSource); - if (par1DamageSource.getEntity() instanceof EntityPlayer) { + if (par1DamageSource.getEntity() instanceof EntityPlayer + && ((EntityPlayer) par1DamageSource.getEntity()).dimension == TwilightForestMod.dimensionID) { ((EntityPlayer) par1DamageSource.getEntity()).triggerAchievement(TFAchievementPage.twilightHunter); } } diff --git a/src/main/java/twilightforest/entity/passive/EntityTFDeer.java b/src/main/java/twilightforest/entity/passive/EntityTFDeer.java index 94fc55cb78..94e5e165aa 100644 --- a/src/main/java/twilightforest/entity/passive/EntityTFDeer.java +++ b/src/main/java/twilightforest/entity/passive/EntityTFDeer.java @@ -10,6 +10,7 @@ import net.minecraft.world.World; import twilightforest.TFAchievementPage; +import twilightforest.TwilightForestMod; import twilightforest.item.TFItems; /** @@ -111,7 +112,8 @@ public EntityCow createChild(EntityAgeable entityanimal) { @Override public void onDeath(DamageSource par1DamageSource) { super.onDeath(par1DamageSource); - if (par1DamageSource.getEntity() instanceof EntityPlayer) { + if (par1DamageSource.getEntity() instanceof EntityPlayer + && ((EntityPlayer) par1DamageSource.getEntity()).dimension == TwilightForestMod.dimensionID) { ((EntityPlayer) par1DamageSource.getEntity()).triggerAchievement(TFAchievementPage.twilightHunter); } } diff --git a/src/main/java/twilightforest/entity/passive/EntityTFPenguin.java b/src/main/java/twilightforest/entity/passive/EntityTFPenguin.java index 0c369e132c..3d0bb4e223 100644 --- a/src/main/java/twilightforest/entity/passive/EntityTFPenguin.java +++ b/src/main/java/twilightforest/entity/passive/EntityTFPenguin.java @@ -19,6 +19,7 @@ import net.minecraft.world.World; import twilightforest.TFAchievementPage; +import twilightforest.TwilightForestMod; public class EntityTFPenguin extends EntityTFBird { @@ -74,7 +75,8 @@ public boolean isBreedingItem(ItemStack par1ItemStack) { @Override public void onDeath(DamageSource par1DamageSource) { super.onDeath(par1DamageSource); - if (par1DamageSource.getEntity() instanceof EntityPlayer) { + if (par1DamageSource.getEntity() instanceof EntityPlayer + && ((EntityPlayer) par1DamageSource.getEntity()).dimension == TwilightForestMod.dimensionID) { ((EntityPlayer) par1DamageSource.getEntity()).triggerAchievement(TFAchievementPage.twilightHunter); } } diff --git a/src/main/java/twilightforest/entity/passive/EntityTFQuestRam.java b/src/main/java/twilightforest/entity/passive/EntityTFQuestRam.java index 282b79b751..66604ac5e4 100644 --- a/src/main/java/twilightforest/entity/passive/EntityTFQuestRam.java +++ b/src/main/java/twilightforest/entity/passive/EntityTFQuestRam.java @@ -134,6 +134,9 @@ private void rewardQuest() { func_145778_a(Item.getItemFromBlock(Blocks.lapis_block), 1, 1.0F); func_145778_a(TFItems.crumbleHorn, 1, 1.0F); + // trophy + entityDropItem(new ItemStack(TFItems.trophy, 1, 8), 0); + rewardNearbyPlayers(this.worldObj, this.posX, this.posY, this.posZ); } @@ -348,6 +351,13 @@ protected String getLivingSound() { return "mob.sheep.say"; } + /** + * Basically a public getter for living sounds + */ + public String getTrophySound() { + return this.getLivingSound(); + } + /** * Returns the sound this mob makes when it is hurt. */ diff --git a/src/main/java/twilightforest/entity/passive/EntityTFSquirrel.java b/src/main/java/twilightforest/entity/passive/EntityTFSquirrel.java index 1984b0cba7..cc9d3b6638 100644 --- a/src/main/java/twilightforest/entity/passive/EntityTFSquirrel.java +++ b/src/main/java/twilightforest/entity/passive/EntityTFSquirrel.java @@ -17,6 +17,7 @@ import net.minecraft.world.World; import twilightforest.TFAchievementPage; +import twilightforest.TwilightForestMod; public class EntityTFSquirrel extends EntityCreature implements IAnimals { @@ -109,7 +110,8 @@ protected boolean canDespawn() { @Override public void onDeath(DamageSource par1DamageSource) { super.onDeath(par1DamageSource); - if (par1DamageSource.getEntity() instanceof EntityPlayer) { + if (par1DamageSource.getEntity() instanceof EntityPlayer + && ((EntityPlayer) par1DamageSource.getEntity()).dimension == TwilightForestMod.dimensionID) { ((EntityPlayer) par1DamageSource.getEntity()).triggerAchievement(TFAchievementPage.twilightHunter); } } diff --git a/src/main/java/twilightforest/entity/passive/EntityTFTinyBird.java b/src/main/java/twilightforest/entity/passive/EntityTFTinyBird.java index 6918a560b3..a4cdff6988 100644 --- a/src/main/java/twilightforest/entity/passive/EntityTFTinyBird.java +++ b/src/main/java/twilightforest/entity/passive/EntityTFTinyBird.java @@ -192,7 +192,8 @@ public float getBlockPathWeight(int par1, int par2, int par3) { @Override public void onDeath(DamageSource par1DamageSource) { super.onDeath(par1DamageSource); - if (par1DamageSource.getEntity() instanceof EntityPlayer) { + if (par1DamageSource.getEntity() instanceof EntityPlayer + && ((EntityPlayer) par1DamageSource.getEntity()).dimension == TwilightForestMod.dimensionID) { ((EntityPlayer) par1DamageSource.getEntity()).triggerAchievement(TFAchievementPage.twilightHunter); } } diff --git a/src/main/java/twilightforest/integration/TFBaublesIntegration.java b/src/main/java/twilightforest/integration/TFBaublesIntegration.java index 3a5b92aa75..02dbe853ef 100644 --- a/src/main/java/twilightforest/integration/TFBaublesIntegration.java +++ b/src/main/java/twilightforest/integration/TFBaublesIntegration.java @@ -1,15 +1,55 @@ package twilightforest.integration; +import java.io.File; +import java.util.HashMap; + import net.minecraft.entity.player.EntityPlayer; import net.minecraft.item.Item; import net.minecraft.item.ItemStack; +import net.minecraft.nbt.NBTTagCompound; import baubles.common.container.InventoryBaubles; import baubles.common.lib.PlayerHandler; +import twilightforest.TFEventListener; import twilightforest.TwilightForestMod; public class TFBaublesIntegration { + public static HashMap playerBaublesMap = new HashMap<>(); + + public static void clearPlayerMap(EntityPlayer player) { + if (TwilightForestMod.areBaublesLoaded) { + playerBaublesMap.remove(player.getCommandSenderName()); + } + } + + public static InventoryBaubles getPlayerKeepBaubles(EntityPlayer player) { + if (!playerBaublesMap.containsKey(player.getCommandSenderName())) { + InventoryBaubles inventory = new InventoryBaubles(player); + playerBaublesMap.put(player.getCommandSenderName(), inventory); + } + return playerBaublesMap.get(player.getCommandSenderName()); + } + + public static void setPlayerKeepBaubles(EntityPlayer player, InventoryBaubles inventory) { + playerBaublesMap.put(player.getCommandSenderName(), inventory); + } + + public static void loadPlayerKeepBaubles(EntityPlayer player, NBTTagCompound data) { + if (TwilightForestMod.areBaublesLoaded) { + InventoryBaubles keepBaubles = new InventoryBaubles(player); + keepBaubles.readNBT(data); + playerBaublesMap.put(player.getCommandSenderName(), keepBaubles); + } + } + + public static void savePlayerKeepBaubles(EntityPlayer player, NBTTagCompound data) { + if (TwilightForestMod.areBaublesLoaded) { + InventoryBaubles inventory = getPlayerKeepBaubles(player); + inventory.saveNBT(data); + } + } + public static Boolean consumeBaublesItem(EntityPlayer player, Item item) { if (TwilightForestMod.areBaublesLoaded) { InventoryBaubles inventoryBaubles = PlayerHandler.getPlayerBaubles(player); @@ -42,4 +82,21 @@ public static ItemStack[] keepAllBaubles(EntityPlayer player) { return baublesInventory; } + public static void restoreBaubles(EntityPlayer player, ItemStack[] baublesInventory) { + if (TwilightForestMod.areBaublesLoaded && baublesInventory != null) { + InventoryBaubles inventoryBaubles = PlayerHandler.getPlayerBaubles(player); + for (int i = 0; i < inventoryBaubles.getSizeInventory(); i++) { + if (baublesInventory[i] != null) inventoryBaubles.setInventorySlotContents(i, baublesInventory[i]); + } + } + } + + public static void playerSaveDo(EntityPlayer player, File directory) { + PlayerHandler.savePlayerBaubles( + player, + TFEventListener.getPlayerFile(TFEventListener.fileName, directory, player.getCommandSenderName()), + TFEventListener + .getPlayerFile(TFEventListener.fileNameBackup, directory, player.getCommandSenderName())); + } + } diff --git a/src/main/java/twilightforest/integration/TFThaumcraftIntegration.java b/src/main/java/twilightforest/integration/TFThaumcraftIntegration.java index 3aed2eedd7..2ccb4d5243 100644 --- a/src/main/java/twilightforest/integration/TFThaumcraftIntegration.java +++ b/src/main/java/twilightforest/integration/TFThaumcraftIntegration.java @@ -232,6 +232,7 @@ public static void registerThaumcraftIntegration() { // blocks registerTCObjectTag(TFBlocks.firefly, -1, (new AspectList()).add(Aspect.FLIGHT, 1).add(Aspect.LIGHT, 2)); + registerTCObjectTag(TFItems.critter, 0, (new AspectList()).add(Aspect.FLIGHT, 1).add(Aspect.LIGHT, 2)); registerTCObjectTag(TFBlocks.leaves, -1, (new AspectList()).add(Aspect.PLANT, 2)); registerTCObjectTag( TFBlocks.mazestone, @@ -241,6 +242,7 @@ public static void registerThaumcraftIntegration() { registerTCObjectTag(TFBlocks.hedge, 1, (new AspectList()).add(Aspect.PLANT, 3).add(Aspect.DARKNESS, 1)); registerTCObjectTag(TFBlocks.root, -1, (new AspectList()).add(Aspect.TREE, 2)); registerTCObjectTag(TFBlocks.cicada, -1, (new AspectList()).add(Aspect.SENSES, 2)); + registerTCObjectTag(TFItems.critter, 1, (new AspectList()).add(Aspect.SENSES, 2)); registerTCObjectTag( TFBlocks.uncraftingTable, -1, @@ -346,6 +348,7 @@ public static void registerThaumcraftIntegration() { registerTCObjectTag(TFBlocks.plant, 14, (new AspectList()).add(Aspect.PLANT, 2)); registerTCObjectTag(TFBlocks.sapling, -1, (new AspectList()).add(Aspect.PLANT, 4).add(Aspect.TREE, 2)); registerTCObjectTag(TFBlocks.moonworm, -1, (new AspectList()).add(Aspect.DARKNESS, 2).add(Aspect.LIGHT, 2)); + registerTCObjectTag(TFItems.critter, 2, (new AspectList()).add(Aspect.DARKNESS, 2).add(Aspect.LIGHT, 2)); registerTCObjectTag( TFBlocks.shield, -1, diff --git a/src/main/java/twilightforest/item/ItemBlockTFCompressed.java b/src/main/java/twilightforest/item/ItemBlockTFCompressed.java new file mode 100644 index 0000000000..801cd8b3d6 --- /dev/null +++ b/src/main/java/twilightforest/item/ItemBlockTFCompressed.java @@ -0,0 +1,32 @@ +package twilightforest.item; + +import java.util.List; + +import net.minecraft.block.Block; +import net.minecraft.entity.player.EntityPlayer; +import net.minecraft.item.ItemBlock; +import net.minecraft.item.ItemStack; +import net.minecraft.util.StatCollector; + +import cpw.mods.fml.relauncher.Side; +import cpw.mods.fml.relauncher.SideOnly; + +public class ItemBlockTFCompressed extends ItemBlock { + + public ItemBlockTFCompressed(Block block) { + super(block); + hasSubtypes = true; + } + + /** + * allows items to add custom lines of information to the mouseover description + */ + @Override + @SideOnly(Side.CLIENT) + public void addInformation(ItemStack par1ItemStack, EntityPlayer par2EntityPlayer, List par3List, + boolean par4) { + super.addInformation(par1ItemStack, par2EntityPlayer, par3List, par4); + par3List.add(StatCollector.translateToLocal("itemBlock.compressed.tooltip")); + } + +} diff --git a/src/main/java/twilightforest/item/ItemBlockTFCritter.java b/src/main/java/twilightforest/item/ItemBlockTFCritter.java new file mode 100644 index 0000000000..cefc9bb6a4 --- /dev/null +++ b/src/main/java/twilightforest/item/ItemBlockTFCritter.java @@ -0,0 +1,29 @@ +package twilightforest.item; + +import java.util.List; + +import net.minecraft.block.Block; +import net.minecraft.entity.player.EntityPlayer; +import net.minecraft.item.ItemBlock; +import net.minecraft.item.ItemStack; +import net.minecraft.util.EnumChatFormatting; +import net.minecraft.util.StatCollector; + +import cpw.mods.fml.relauncher.Side; +import cpw.mods.fml.relauncher.SideOnly; + +public class ItemBlockTFCritter extends ItemBlock { + + public ItemBlockTFCritter(Block block) { + super(block); + } + + /** + * allows items to add custom lines of information to the mouseover description + */ + @SideOnly(Side.CLIENT) + @Override + public void addInformation(ItemStack itemStack, EntityPlayer player, List list, boolean par4) { + list.add(EnumChatFormatting.ITALIC + StatCollector.translateToLocal("item.outdated.tooltip")); + } +} diff --git a/src/main/java/twilightforest/item/ItemTFChainBlock.java b/src/main/java/twilightforest/item/ItemTFChainBlock.java index 7c240611f0..1fe0844ef7 100644 --- a/src/main/java/twilightforest/item/ItemTFChainBlock.java +++ b/src/main/java/twilightforest/item/ItemTFChainBlock.java @@ -26,6 +26,8 @@ public class ItemTFChainBlock extends ItemTool { // which items have launched which blocks? private HashMap launchedBlocksMap = new HashMap<>(); + private IIcon ring; + protected ItemTFChainBlock() { super(6, TFItems.TOOL_KNIGHTLY, Sets.newHashSet(Blocks.stone)); this.maxStackSize = 1; @@ -127,6 +129,7 @@ public void setLaunchedBlock(ItemStack stack, EntityTFChainBlock launchedCube) { public void registerIcons(IIconRegister par1IconRegister) { this.itemIcon = par1IconRegister .registerIcon(TwilightForestMod.ID + ":" + this.getUnlocalizedName().substring(5)); + this.ring = par1IconRegister.registerIcon(TwilightForestMod.ID + ":" + "chainBlockRing"); } /** @@ -145,7 +148,7 @@ public IIcon getIcon(ItemStack stack, int renderPass, EntityPlayer player, ItemS if (this.doesChainHaveBlock(stack)) { return this.itemIcon; } else { - return TFItems.knightmetalRing.getIconIndex(stack); + return this.ring; } } diff --git a/src/main/java/twilightforest/item/ItemTFCritter.java b/src/main/java/twilightforest/item/ItemTFCritter.java new file mode 100644 index 0000000000..b93a192eb4 --- /dev/null +++ b/src/main/java/twilightforest/item/ItemTFCritter.java @@ -0,0 +1,176 @@ +package twilightforest.item; + +import java.util.List; + +import net.minecraft.block.Block; +import net.minecraft.client.model.ModelBiped; +import net.minecraft.client.renderer.texture.IIconRegister; +import net.minecraft.creativetab.CreativeTabs; +import net.minecraft.entity.Entity; +import net.minecraft.entity.EntityLivingBase; +import net.minecraft.entity.player.EntityPlayer; +import net.minecraft.item.Item; +import net.minecraft.item.ItemArmor; +import net.minecraft.item.ItemStack; +import net.minecraft.util.IIcon; +import net.minecraft.world.World; + +import cpw.mods.fml.relauncher.Side; +import cpw.mods.fml.relauncher.SideOnly; +import twilightforest.TwilightForestMod; +import twilightforest.block.BlockTFCritter; +import twilightforest.block.BlockTFFirefly; +import twilightforest.block.TFBlocks; + +public class ItemTFCritter extends ItemArmor { + + private static final String[] critterTypes = new String[] { "firefly", "cicada", "moonworm" }; + private static final Block[] critterBlocks = new Block[] { TFBlocks.firefly, TFBlocks.cicada, TFBlocks.moonworm }; + public static final String[] critterTextures = new String[] { "firefly-tiny", "cicada-model", "moonworm" }; + public IIcon[] critterIcons; + + public ItemTFCritter() { + super(TFItems.ARMOR_DECORATIVE, 0, 0); + this.setCreativeTab(TFItems.creativeTab); + this.setMaxDamage(0); + this.setHasSubtypes(true); + this.maxStackSize = 64; + } + + /** + * returns a list of items with the same ID, but different meta (eg: dye returns 16 items) + */ + public void getSubItems(Item par1, CreativeTabs par2CreativeTabs, List par3List) { + for (int j = 0; j < critterTypes.length; ++j) { + par3List.add(new ItemStack(par1, 1, j)); + } + } + + /** + * Callback for item usage. If the item does something special on right clicking, he will have one of those. Return + * True if something happen and false if it don't. This is for ITEMS, not BLOCKS + */ + public boolean onItemUse(ItemStack itemStack, EntityPlayer player, World world, int x, int y, int z, int direction, + float par8, float par9, float par10) { + if (!world.getBlock(x, y, z).getMaterial().isSolid()) { + return false; + } else { + switch (direction) { + default: + case 0: + --y; + break; + case 1: + ++y; + break; + case 2: + --z; + break; + case 3: + ++z; + break; + case 4: + --x; + break; + case 5: + ++x; + break; + } + + if (!player.canPlayerEdit(x, y, z, direction, itemStack)) { + return false; + } else { + BlockTFCritter block = new BlockTFFirefly(); + if (!block.canPlaceBlockAt(world, x, y, z)) { + return false; + } else { + if (world.setBlock( + x, + y, + z, + critterBlocks[itemStack.getItemDamage() % critterTypes.length], + 6 - direction, + 3)) { + world.playSound(x, y, z, "mob.slime.big", 0.25F, 0.6F, true); + --itemStack.stackSize; + return true; + } + return false; + } + } + } + } + + /** + * Returns the unlocalized name of this item. This version accepts an ItemStack so different stacks can have + * different names based on their damage or NBT. + */ + public String getUnlocalizedName(ItemStack par1ItemStack) { + return critterBlocks[par1ItemStack.getItemDamage() % critterTypes.length].getUnlocalizedName(); + } + + /** + * Properly register icon source + */ + @Override + @SideOnly(Side.CLIENT) + public void registerIcons(IIconRegister par1IconRegister) { + this.critterIcons = new IIcon[critterTypes.length]; + + for (int i = 0; i < critterTypes.length; ++i) { + this.critterIcons[i] = critterBlocks[i].getIcon(3, 0); + } + } + + /** + * Gets an icon index based on an item's damage value + */ + @SideOnly(Side.CLIENT) + public IIcon getIconFromDamage(int par1) { + if (par1 < 0 || par1 >= critterTypes.length) { + par1 = 0; + } + + return this.critterIcons[par1]; + } + + /** + * Returns 0 for /terrain.png, 1 for /gui/items.png + */ + @Override + @SideOnly(Side.CLIENT) + public int getSpriteNumber() { + return 0; // Since we're using a block texture, not an item one + } + + /** + * Called by RenderBiped and RenderPlayer to determine the armor texture that should be use for the currently + * equiped item. This will only be called on instances of ItemArmor. + * + * Returning null from this function will use the default value. + * + * @param stack ItemStack for the equpt armor + * @param entity The entity wearing the armor + * @param slot The slot the armor is in + * @param type The subtype, can be null or "overlay" + * @return Path of texture to bind, or null to use default + */ + @Override + public String getArmorTexture(ItemStack stack, Entity entity, int slot, String type) { + return TwilightForestMod.MODEL_DIR + critterTextures[stack.getItemDamage()] + ".png"; + } + + /** + * Override this method to have an item handle its own armor rendering. + * + * @param entityLiving The entity wearing the armor + * @param itemStack The itemStack to render the model of + * @param armorSlot 0=head, 1=torso, 2=legs, 3=feet + * + * @return A ModelBiped to render instead of the default + */ + @SideOnly(Side.CLIENT) + public ModelBiped getArmorModel(EntityLivingBase entityLiving, ItemStack itemStack, int armorSlot) { + return TwilightForestMod.proxy.getCritterArmorModel(itemStack.getItemDamage()); + } +} diff --git a/src/main/java/twilightforest/item/ItemTFCrumbleHorn.java b/src/main/java/twilightforest/item/ItemTFCrumbleHorn.java index e13aceff5f..9067ea5e16 100644 --- a/src/main/java/twilightforest/item/ItemTFCrumbleHorn.java +++ b/src/main/java/twilightforest/item/ItemTFCrumbleHorn.java @@ -135,14 +135,20 @@ private int crumbleBlock(World world, EntityPlayer player, int dx, int dy, int d if (currentID != Blocks.air) { int currentMeta = world.getBlockMetadata(dx, dy, dz); - if (currentID == Blocks.stone && world.rand.nextInt(CHANCE_CRUMBLE) == 0) { - world.setBlock(dx, dy, dz, Blocks.cobblestone, 0, 3); + if (currentID == Blocks.stonebrick && currentMeta == 0 && world.rand.nextInt(CHANCE_CRUMBLE) == 0) { + world.setBlock(dx, dy, dz, Blocks.stonebrick, 2, 3); world.playAuxSFX(2001, dx, dy, dz, Block.getIdFromBlock(currentID) + (currentMeta << 12)); cost++; } - if (currentID == Blocks.stonebrick && currentMeta == 0 && world.rand.nextInt(CHANCE_CRUMBLE) == 0) { - world.setBlock(dx, dy, dz, Blocks.stonebrick, 2, 3); + if (currentID == Blocks.monster_egg && currentMeta == 0 && world.rand.nextInt(CHANCE_CRUMBLE) == 0) { + world.setBlock(dx, dy, dz, Blocks.monster_egg, 1, 3); + world.playAuxSFX(2001, dx, dy, dz, Block.getIdFromBlock(currentID) + (currentMeta << 12)); + cost++; + } + + if (currentID == Blocks.monster_egg && currentMeta == 2 && world.rand.nextInt(CHANCE_CRUMBLE) == 0) { + world.setBlock(dx, dy, dz, Blocks.monster_egg, 4, 3); world.playAuxSFX(2001, dx, dy, dz, Block.getIdFromBlock(currentID) + (currentMeta << 12)); cost++; } @@ -153,13 +159,132 @@ private int crumbleBlock(World world, EntityPlayer player, int dx, int dy, int d cost++; } - if (currentID == Blocks.cobblestone && world.rand.nextInt(CHANCE_CRUMBLE) == 0) { + if (currentID == TFBlocks.underBrick && currentMeta == 0 && world.rand.nextInt(CHANCE_CRUMBLE) == 0) { + world.setBlock(dx, dy, dz, TFBlocks.underBrick, 2, 3); + world.playAuxSFX(2001, dx, dy, dz, Block.getIdFromBlock(currentID) + (currentMeta << 12)); + cost++; + } + + if (currentID == TFBlocks.towerWood && currentMeta == 0 && world.rand.nextInt(CHANCE_CRUMBLE) == 0) { + world.setBlock(dx, dy, dz, TFBlocks.towerWood, 2, 3); + world.playAuxSFX(2001, dx, dy, dz, Block.getIdFromBlock(currentID) + (currentMeta << 12)); + cost++; + } + + if (currentID == TFBlocks.deadrock && currentMeta == 0 && world.rand.nextInt(CHANCE_CRUMBLE) == 0) { + world.setBlock(dx, dy, dz, TFBlocks.deadrock, 2, 3); + world.playAuxSFX(2001, dx, dy, dz, Block.getIdFromBlock(currentID) + (currentMeta << 12)); + cost++; + } + + if (currentID == TFBlocks.castleBlock && currentMeta == 0 && world.rand.nextInt(CHANCE_CRUMBLE) == 0) { + world.setBlock(dx, dy, dz, TFBlocks.castleBlock, 2, 3); + world.playAuxSFX(2001, dx, dy, dz, Block.getIdFromBlock(currentID) + (currentMeta << 12)); + cost++; + } + + if (currentID == TFBlocks.nagastonePillar && world.rand.nextInt(CHANCE_CRUMBLE) == 0) { + world.setBlock(dx, dy, dz, TFBlocks.nagastonePillarWeathered, currentMeta, 3); + world.playAuxSFX(2001, dx, dy, dz, Block.getIdFromBlock(currentID) + (currentMeta << 12)); + cost++; + } + + if (currentID == TFBlocks.nagastoneEtched && currentMeta == 0 && world.rand.nextInt(CHANCE_CRUMBLE) == 0) { + world.setBlockMetadataWithNotify(dx, dy, dz, 2, 3); + world.playAuxSFX(2001, dx, dy, dz, Block.getIdFromBlock(currentID) + (currentMeta << 12)); + cost++; + } + + if (currentID == TFBlocks.nagastoneStairsLeft && world.rand.nextInt(CHANCE_CRUMBLE) == 0) { + world.setBlock(dx, dy, dz, TFBlocks.nagastoneStairsWeatheredLeft, currentMeta, 3); + world.playAuxSFX(2001, dx, dy, dz, Block.getIdFromBlock(currentID) + (currentMeta << 12)); + cost++; + } + + if (currentID == TFBlocks.nagastoneStairsRight && world.rand.nextInt(CHANCE_CRUMBLE) == 0) { + world.setBlock(dx, dy, dz, TFBlocks.nagastoneStairsWeatheredRight, currentMeta, 3); + world.playAuxSFX(2001, dx, dy, dz, Block.getIdFromBlock(currentID) + (currentMeta << 12)); + cost++; + } + + if (currentID == Blocks.stone && world.rand.nextInt(CHANCE_CRUMBLE) == 0) { + world.setBlock(dx, dy, dz, Blocks.cobblestone, 0, 3); + world.playAuxSFX(2001, dx, dy, dz, Block.getIdFromBlock(currentID) + (currentMeta << 12)); + cost++; + } + + if (currentID == Blocks.ice && world.rand.nextInt(CHANCE_CRUMBLE) == 0) { + world.setBlock(dx, dy, dz, Blocks.water, 0, 1); + world.playAuxSFX(2001, dx, dy, dz, Block.getIdFromBlock(currentID) + (currentMeta << 12)); + cost++; + } + + if ((currentID == Blocks.cobblestone || currentID == Blocks.stone_stairs + || (currentID == Blocks.double_stone_slab && currentMeta == 3)) + && world.rand.nextInt(CHANCE_CRUMBLE) == 0) { world.setBlock(dx, dy, dz, Blocks.gravel, 0, 3); world.playAuxSFX(2001, dx, dy, dz, Block.getIdFromBlock(currentID) + (currentMeta << 12)); cost++; } - if (currentID == Blocks.gravel || currentID == Blocks.dirt) { + if (currentID == Blocks.stone_slab && (currentMeta == 0 || currentMeta == 8) + && world.rand.nextInt(CHANCE_CRUMBLE) == 0) { + world.setBlockMetadataWithNotify(dx, dy, dz, currentMeta + 3, 3); + world.playAuxSFX(2001, dx, dy, dz, Block.getIdFromBlock(currentID) + (currentMeta << 12)); + cost++; + } + + if (currentID == Blocks.double_stone_slab && currentMeta == 0 && world.rand.nextInt(CHANCE_CRUMBLE) == 0) { + world.setBlockMetadataWithNotify(dx, dy, dz, 3, 3); + world.playAuxSFX(2001, dx, dy, dz, Block.getIdFromBlock(currentID) + (currentMeta << 12)); + cost++; + } + + if (currentID == Blocks.stone_slab && (currentMeta == 1 || currentMeta == 9) + && world.rand.nextInt(CHANCE_CRUMBLE) == 0) { + if (world.rand.nextBoolean()) world.setBlock(dx, dy, dz, Blocks.sand, 0, 3); + else world.setBlockToAir(dx, dy, dz); + world.playAuxSFX(2001, dx, dy, dz, Block.getIdFromBlock(currentID) + (currentMeta << 12)); + cost++; + } + + if (currentID == Blocks.stone_slab && (currentMeta == 3 || currentMeta == 11) + && world.rand.nextInt(CHANCE_CRUMBLE) == 0) { + if (world.rand.nextBoolean()) world.setBlock(dx, dy, dz, Blocks.gravel, 0, 3); + else world.setBlockToAir(dx, dy, dz); + world.playAuxSFX(2001, dx, dy, dz, Block.getIdFromBlock(currentID) + (currentMeta << 12)); + cost++; + } + + if (((currentID == Blocks.sandstone && currentMeta == 0) || currentID == Blocks.sandstone_stairs + || (currentID == Blocks.double_stone_slab && currentMeta == 1)) + && world.rand.nextInt(CHANCE_CRUMBLE) == 0) { + world.setBlock(dx, dy, dz, Blocks.sand, 0, 3); + world.playAuxSFX(2001, dx, dy, dz, Block.getIdFromBlock(currentID) + (currentMeta << 12)); + cost++; + } + + if (currentID == Blocks.sandstone && currentMeta > 0 && world.rand.nextInt(CHANCE_CRUMBLE) == 0) { + world.setBlock(dx, dy, dz, Blocks.sandstone, 0, 3); + world.playAuxSFX(2001, dx, dy, dz, Block.getIdFromBlock(currentID) + (currentMeta << 12)); + cost++; + } + + if ((currentID == Blocks.grass || currentID == Blocks.mycelium + || (currentID == Blocks.dirt && currentMeta == 2)) && world.rand.nextInt(CHANCE_CRUMBLE) == 0) { + world.setBlock(dx, dy, dz, Blocks.dirt, 0, 3); + world.playAuxSFX(2001, dx, dy, dz, Block.getIdFromBlock(currentID) + (currentMeta << 12)); + cost++; + } + + if (currentID == Blocks.gravel || (currentID == Blocks.dirt && currentMeta != 2) + || currentID == Blocks.sand + || currentID == Blocks.clay + || currentID == Blocks.glass + || currentID == Blocks.glass_pane + || currentID == Blocks.stained_glass + || currentID == Blocks.stained_glass_pane + || currentID == Blocks.glowstone) { if (currentID.canHarvestBlock(player, currentMeta) && world.rand.nextInt(CHANCE_HARVEST) == 0) { world.setBlock(dx, dy, dz, Blocks.air, 0, 3); currentID.harvestBlock(world, player, dx, dy, dz, currentMeta); diff --git a/src/main/java/twilightforest/item/ItemTFKnightlyArmor.java b/src/main/java/twilightforest/item/ItemTFKnightlyArmor.java index 8918616e66..fef68a41aa 100644 --- a/src/main/java/twilightforest/item/ItemTFKnightlyArmor.java +++ b/src/main/java/twilightforest/item/ItemTFKnightlyArmor.java @@ -33,11 +33,11 @@ public EnumRarity getRarity(ItemStack par1ItemStack) { /** * Called by RenderBiped and RenderPlayer to determine the armor texture that should be use for the currently - * equiped item. This will only be called on instances of ItemArmor. + * equipped item. This will only be called on instances of ItemArmor. * * Returning null from this function will use the default value. * - * @param stack ItemStack for the equpt armor + * @param stack ItemStack for the equipped armor * @param entity The entity wearing the armor * @param slot The slot the armor is in * @param layer The render layer, either 1 or 2, 2 is only used for CLOTH armor by default diff --git a/src/main/java/twilightforest/item/ItemTFPhantomArmor.java b/src/main/java/twilightforest/item/ItemTFPhantomArmor.java index 594efbaf3d..896731a2f0 100644 --- a/src/main/java/twilightforest/item/ItemTFPhantomArmor.java +++ b/src/main/java/twilightforest/item/ItemTFPhantomArmor.java @@ -7,10 +7,12 @@ import net.minecraft.creativetab.CreativeTabs; import net.minecraft.entity.Entity; import net.minecraft.entity.EntityLivingBase; +import net.minecraft.entity.player.EntityPlayer; import net.minecraft.item.EnumRarity; import net.minecraft.item.Item; import net.minecraft.item.ItemArmor; import net.minecraft.item.ItemStack; +import net.minecraft.util.StatCollector; import cpw.mods.fml.relauncher.Side; import cpw.mods.fml.relauncher.SideOnly; @@ -78,6 +80,17 @@ public void registerIcons(IIconRegister par1IconRegister) { .registerIcon(TwilightForestMod.ID + ":" + this.getUnlocalizedName().substring(5)); } + /** + * allows items to add custom lines of information to the mouseover description + */ + @Override + @SideOnly(Side.CLIENT) + public void addInformation(ItemStack par1ItemStack, EntityPlayer par2EntityPlayer, List par3List, + boolean par4) { + super.addInformation(par1ItemStack, par2EntityPlayer, par3List, par4); + par3List.add(StatCollector.translateToLocal(getUnlocalizedName() + ".tooltip")); + } + /** * Override this method to have an item handle its own armor rendering. * diff --git a/src/main/java/twilightforest/item/ItemTFTrophy.java b/src/main/java/twilightforest/item/ItemTFTrophy.java index be09034d1b..245a0f6172 100644 --- a/src/main/java/twilightforest/item/ItemTFTrophy.java +++ b/src/main/java/twilightforest/item/ItemTFTrophy.java @@ -2,11 +2,15 @@ import java.util.List; +import net.minecraft.client.model.ModelBiped; import net.minecraft.client.renderer.texture.IIconRegister; import net.minecraft.creativetab.CreativeTabs; +import net.minecraft.entity.Entity; +import net.minecraft.entity.EntityLivingBase; import net.minecraft.entity.player.EntityPlayer; import net.minecraft.item.EnumRarity; import net.minecraft.item.Item; +import net.minecraft.item.ItemArmor; import net.minecraft.item.ItemStack; import net.minecraft.nbt.NBTTagCompound; import net.minecraft.tileentity.TileEntity; @@ -20,18 +24,23 @@ import twilightforest.TwilightForestMod; import twilightforest.block.TFBlocks; -public class ItemTFTrophy extends ItemTF { +public class ItemTFTrophy extends ItemArmor { - private static final String[] trophyTypes = new String[] { "hydra", "naga", "lich", "ur-ghast", "snowQueen" }; + private static final String[] trophyTypes = new String[] { "hydra", "naga", "lich", "ur-ghast", "snowQueen", + "minoshroom", "knightPhantom", "alphaYeti", "questingRam" }; public static final String[] trophyTextures = new String[] { "hydraTrophy", "nagaTrophy", "lichTrophy", - "urGhastTrophy", "snowQueenTrophy" }; + "urGhastTrophy", "snowQueenTrophy", "minoshroomTrophy", "knightPhantomTrophy", "alphaYetiTrophy", + "questingRamTrophy" }; + private static final String[] armorTextures = new String[] { "hydra4", "nagahead", "twilightlich64", "towerboss", + "snowqueen", "minoshroomtaur", "phantomtrophy", "yetialpha", "questram" }; public IIcon[] trophyIcons; public ItemTFTrophy() { - super(); + super(TFItems.ARMOR_DECORATIVE, 0, 0); this.setCreativeTab(TFItems.creativeTab); this.setMaxDamage(0); this.setHasSubtypes(true); + this.maxStackSize = 64; } /** @@ -163,4 +172,35 @@ public IIcon getIconFromDamage(int par1) { return this.trophyIcons[par1]; } + + /** + * Called by RenderBiped and RenderPlayer to determine the armor texture that should be use for the currently + * equiped item. This will only be called on instances of ItemArmor. + * + * Returning null from this function will use the default value. + * + * @param stack ItemStack for the equpt armor + * @param entity The entity wearing the armor + * @param slot The slot the armor is in + * @param type The subtype, can be null or "overlay" + * @return Path of texture to bind, or null to use default + */ + @Override + public String getArmorTexture(ItemStack stack, Entity entity, int slot, String type) { + return TwilightForestMod.MODEL_DIR + armorTextures[stack.getItemDamage()] + ".png"; + } + + /** + * Override this method to have an item handle its own armor rendering. + * + * @param entityLiving The entity wearing the armor + * @param itemStack The itemStack to render the model of + * @param armorSlot 0=head, 1=torso, 2=legs, 3=feet + * + * @return A ModelBiped to render instead of the default + */ + @SideOnly(Side.CLIENT) + public ModelBiped getArmorModel(EntityLivingBase entityLiving, ItemStack itemStack, int armorSlot) { + return TwilightForestMod.proxy.getTrophyArmorModel(itemStack.getItemDamage()); + } } diff --git a/src/main/java/twilightforest/item/TFItems.java b/src/main/java/twilightforest/item/TFItems.java index fe9e2ffc68..58091501b1 100644 --- a/src/main/java/twilightforest/item/TFItems.java +++ b/src/main/java/twilightforest/item/TFItems.java @@ -26,6 +26,8 @@ public class TFItems { .addArmorMaterial("YETI", 20, new int[] { 4, 7, 6, 3 }, 15); public static ItemArmor.ArmorMaterial ARMOR_ARCTIC = EnumHelper .addArmorMaterial("ARCTIC", 10, new int[] { 2, 7, 5, 2 }, 8); + public static ItemArmor.ArmorMaterial ARMOR_DECORATIVE = EnumHelper + .addArmorMaterial("DECORATIVE", 0, new int[] { 0, 0, 0, 0 }, 0); public static Item.ToolMaterial TOOL_IRONWOOD = EnumHelper.addToolMaterial("IRONWOOD", 2, 512, 6.5F, 2, 25); public static Item.ToolMaterial TOOL_FIERY = EnumHelper.addToolMaterial("FIERY", 4, 1024, 9F, 4, 10); @@ -68,6 +70,7 @@ public class TFItems { public static Item hydraChop; public static Item fieryBlood; public static Item trophy; + public static Item critter; public static Item fieryIngot; public static Item fieryHelm; public static Item fieryPlate; @@ -232,6 +235,7 @@ public static void registerItems() { .setUnlocalizedName("hydraChop"); fieryBlood = new ItemTF().makeRare().setUnlocalizedName("fieryBlood"); trophy = new ItemTFTrophy().setUnlocalizedName("trophy"); + critter = new ItemTFCritter().setUnlocalizedName("critter"); fieryIngot = new ItemTF().makeRare().setUnlocalizedName("fieryIngot"); fieryHelm = new ItemTFFieryArmor(ARMOR_FIERY, fieryRenderID, 0).setUnlocalizedName("fieryHelm") .setMaxStackSize(1); @@ -374,6 +378,7 @@ public static void registerItems() { registerTFItem(hydraChop, "Hydra Chop"); registerTFItem(fieryBlood, "Fiery Blood"); registerTFItem(trophy, "Hydra Trophy"); + registerTFItem(critter, "Firefly"); registerTFItem(fieryIngot, "Fiery Ingot"); registerTFItem(fieryHelm, "Fiery Helm"); registerTFItem(fieryPlate, "Fiery Plate"); diff --git a/src/main/java/twilightforest/item/TFRecipes.java b/src/main/java/twilightforest/item/TFRecipes.java index b984079a9e..2f70b9319c 100644 --- a/src/main/java/twilightforest/item/TFRecipes.java +++ b/src/main/java/twilightforest/item/TFRecipes.java @@ -2,6 +2,7 @@ import static net.minecraftforge.oredict.RecipeSorter.Category.SHAPELESS; +import net.minecraft.block.Block; import net.minecraft.enchantment.Enchantment; import net.minecraft.init.Blocks; import net.minecraft.init.Items; @@ -40,6 +41,16 @@ public static void registerRecipes() { OreDictionary.registerOre("ingotSteeleaf", new ItemStack(TFItems.steeleafIngot)); OreDictionary.registerOre("oreKnightmetal", new ItemStack(TFItems.shardCluster)); OreDictionary.registerOre("ingotKnightmetal", new ItemStack(TFItems.knightMetal)); + OreDictionary.registerOre("fieryEssence", new ItemStack(TFItems.fieryBlood)); + OreDictionary.registerOre("fieryEssence", new ItemStack(TFItems.fieryTears)); + + // in order for all critters recipes to work + OreDictionary.registerOre("firefly", new ItemStack(TFBlocks.firefly, 1, OreDictionary.WILDCARD_VALUE)); + OreDictionary.registerOre("firefly", new ItemStack(TFItems.critter, 1, 0)); + OreDictionary.registerOre("cicada", new ItemStack(TFBlocks.cicada, 1, OreDictionary.WILDCARD_VALUE)); + OreDictionary.registerOre("cicada", new ItemStack(TFItems.critter, 1, 1)); + OreDictionary.registerOre("moonworm", new ItemStack(TFBlocks.moonworm, 1, OreDictionary.WILDCARD_VALUE)); + OreDictionary.registerOre("moonworm", new ItemStack(TFItems.critter, 1, 2)); // nagastone stuff OreDictionary.registerOre( @@ -110,6 +121,12 @@ public static void registerRecipes() { new ItemStack(TFBlocks.woodenStairsDarkwood, 8, 0), new ItemStack(TFBlocks.woodenStairsTime, 8, 0), new ItemStack(TFBlocks.woodenStairsTrans, 8, 0), new ItemStack(TFBlocks.woodenStairsMine, 8, 0), new ItemStack(TFBlocks.woodenStairsSort, 8, 0) }; + Block[] chests = new Block[] { TFBlocks.chestTwilight, TFBlocks.chestCanopy, TFBlocks.chestMangrove, + TFBlocks.chestDarkwood, TFBlocks.chestTime, TFBlocks.chestTrans, TFBlocks.chestMine, + TFBlocks.chestSort }; + Block[] trappedChests = new Block[] { TFBlocks.trappedChestTwilight, TFBlocks.trappedChestCanopy, + TFBlocks.trappedChestMangrove, TFBlocks.trappedChestDarkwood, TFBlocks.trappedChestTime, + TFBlocks.trappedChestTrans, TFBlocks.trappedChestMine, TFBlocks.trappedChestSort }; for (int i = 0; i < doors.length; i++) { GameRegistry.addRecipe( new ItemStack(doors[i], 1, 0), @@ -122,8 +139,19 @@ public static void registerRecipes() { GameRegistry.addRecipe( new ItemStack(TFBlocks.woodenSlab, 6, i), new Object[] { "###", '#', new ItemStack(TFBlocks.planks, 1, i) }); + GameRegistry.addRecipe( + new ItemStack(chests[i], 2), + new Object[] { "###", "#0#", "###", '#', new ItemStack(TFBlocks.planks, 1, i), '0', + new ItemStack(Blocks.chest) }); + GameRegistry.addShapelessRecipe( + new ItemStack(trappedChests[i]), + new Object[] { new ItemStack(chests[i]), new ItemStack(Blocks.tripwire_hook) }); } + // Dyes from TF plants + GameRegistry.addShapelessRecipe(new ItemStack(Items.dye, 2, 13), new Object[] { TFBlocks.hugeWaterLily }); + GameRegistry.addShapelessRecipe(new ItemStack(Items.dye, 2, 1), new Object[] { TFBlocks.thornRose }); + GameRegistry.addRecipe( new ItemStack(TFBlocks.nagastoneStairsLeft, 8, 0), new Object[] { "# ", "## ", "###", '#', new ItemStack(TFBlocks.nagastoneEtched, 1, 0) }); @@ -182,9 +210,10 @@ public static void registerRecipes() { 3, new Object[] { "###", "# #", "# #", '#', TFItems.nagaScale }); - GameRegistry.addShapelessRecipe( - new ItemStack(TFBlocks.fireflyJar, 1, 0), - new Object[] { TFBlocks.firefly, Items.glass_bottle }); + GameRegistry.addRecipe( + new ShapelessOreRecipe( + new ItemStack(TFBlocks.fireflyJar, 1, 0), + new Object[] { "firefly", Items.glass_bottle })); GameRegistry.addShapelessRecipe( new ItemStack(TFItems.scepterTwilight), @@ -310,12 +339,10 @@ public static void registerRecipes() { GameRegistry.addSmelting(TFItems.venisonRaw, new ItemStack(TFItems.venisonCooked), 0.3F); - GameRegistry.addShapelessRecipe( - new ItemStack(TFItems.fieryIngot), - new Object[] { TFItems.fieryBlood, Items.iron_ingot }); - GameRegistry.addShapelessRecipe( - new ItemStack(TFItems.fieryIngot), - new Object[] { TFItems.fieryTears, Items.iron_ingot }); + GameRegistry.addRecipe( + new ShapelessOreRecipe( + new ItemStack(TFItems.fieryIngot), + new Object[] { "fieryEssence", Items.iron_ingot })); GameRegistry .addRecipe(new ItemStack(TFItems.fieryHelm), new Object[] { "###", "# #", '#', TFItems.fieryIngot }); GameRegistry.addRecipe( @@ -326,6 +353,30 @@ public static void registerRecipes() { new Object[] { "###", "# #", "# #", '#', TFItems.fieryIngot }); GameRegistry .addRecipe(new ItemStack(TFItems.fieryBoots), new Object[] { "# #", "# #", '#', TFItems.fieryIngot }); + + // Direct Fiery armor crafting + GameRegistry.addRecipe( + new ShapelessOreRecipe( + new ItemStack(TFItems.fieryHelm), + new Object[] { new ItemStack(Items.iron_helmet, 1, 0), "fieryEssence", "fieryEssence", + "fieryEssence", "fieryEssence", "fieryEssence" })); + GameRegistry.addRecipe( + new ShapelessOreRecipe( + new ItemStack(TFItems.fieryPlate), + new Object[] { new ItemStack(Items.iron_chestplate, 1, 0), "fieryEssence", "fieryEssence", + "fieryEssence", "fieryEssence", "fieryEssence", "fieryEssence", "fieryEssence", + "fieryEssence" })); + GameRegistry.addRecipe( + new ShapelessOreRecipe( + new ItemStack(TFItems.fieryLegs), + new Object[] { new ItemStack(Items.iron_leggings, 1, 0), "fieryEssence", "fieryEssence", + "fieryEssence", "fieryEssence", "fieryEssence", "fieryEssence", "fieryEssence" })); + GameRegistry.addRecipe( + new ShapelessOreRecipe( + new ItemStack(TFItems.fieryBoots), + new Object[] { new ItemStack(Items.iron_boots, 1, 0), "fieryEssence", "fieryEssence", + "fieryEssence", "fieryEssence" })); + addEnchantedRecipe( TFItems.fierySword, Enchantment.fireAspect, diff --git a/src/main/java/twilightforest/structures/courtyard/ComponentTFNagaCourtyardTerraceDuct.java b/src/main/java/twilightforest/structures/courtyard/ComponentTFNagaCourtyardTerraceDuct.java index f33f90f134..2431dd7922 100644 --- a/src/main/java/twilightforest/structures/courtyard/ComponentTFNagaCourtyardTerraceDuct.java +++ b/src/main/java/twilightforest/structures/courtyard/ComponentTFNagaCourtyardTerraceDuct.java @@ -3,6 +3,8 @@ import java.util.List; import java.util.Random; +import net.minecraft.block.Block; +import net.minecraft.block.material.Material; import net.minecraft.init.Blocks; import net.minecraft.world.World; import net.minecraft.world.gen.structure.StructureBoundingBox; @@ -220,9 +222,44 @@ public boolean addComponentParts(World world, Random random, StructureBoundingBo TFBlocks.nagastonePillar, horizontalColumnsOrient4, true); - this.fillWithBlocks(world, structureBoundingBox, 7, 0, 7, 16, 0, 9, Blocks.water, Blocks.water, true); - this.fillWithBlocks(world, structureBoundingBox, 7, 0, 7, 9, 0, 16, Blocks.water, Blocks.water, true); - + this.fillWithBlocksAndUpdate(world, structureBoundingBox, 7, 0, 7, 16, 0, 9, Blocks.water, Blocks.water, false); + this.fillWithBlocksAndUpdate(world, structureBoundingBox, 7, 0, 7, 9, 0, 16, Blocks.water, Blocks.water, false); return true; } + + /** + * arguments: (World worldObj, StructureBoundingBox structBB, int minX, int minY, int minZ, int maxX, int maxY, int + * maxZ, int placeBlock, int replaceBlock, boolean alwaysreplace) + */ + protected void fillWithBlocksAndUpdate(World world, StructureBoundingBox sbb, int minX, int minY, int minZ, + int maxX, int maxY, int maxZ, Block placeBlock, Block replaceBlock, boolean alwaysReplace) { + for (int k1 = minY; k1 <= maxY; ++k1) { + for (int l1 = minX; l1 <= maxX; ++l1) { + for (int i2 = minZ; i2 <= maxZ; ++i2) { + if (!alwaysReplace + || this.getBlockAtCurrentPosition(world, l1, k1, i2, sbb).getMaterial() != Material.air) { + if (k1 != minY && k1 != maxY && l1 != minX && l1 != maxX && i2 != minZ && i2 != maxZ) { + this.placeBlockAtCurrentPositionWithUpdate(world, replaceBlock, 0, l1, k1, i2, sbb); + } else { + this.placeBlockAtCurrentPositionWithUpdate(world, placeBlock, 0, l1, k1, i2, sbb); + } + } + } + } + } + } + + /** + * current Position depends on currently set Coordinates mode, is computed here + */ + protected void placeBlockAtCurrentPositionWithUpdate(World world, Block block, int meta, int x, int y, int z, + StructureBoundingBox sbb) { + int i1 = this.getXWithOffset(x, z); + int j1 = this.getYWithOffset(y); + int k1 = this.getZWithOffset(x, z); + + if (sbb.isVecInside(i1, j1, k1)) { + world.setBlock(i1, j1, k1, block, meta, 1); + } + } } diff --git a/src/main/java/twilightforest/tileentity/TileEntityTFAlphaYetiSpawner.java b/src/main/java/twilightforest/tileentity/TileEntityTFAlphaYetiSpawner.java new file mode 100644 index 0000000000..9b0ecf4168 --- /dev/null +++ b/src/main/java/twilightforest/tileentity/TileEntityTFAlphaYetiSpawner.java @@ -0,0 +1,20 @@ +package twilightforest.tileentity; + +import net.minecraft.entity.player.EntityPlayer; + +import twilightforest.entity.TFCreatures; + +public class TileEntityTFAlphaYetiSpawner extends TileEntityTFBossSpawner { + + public TileEntityTFAlphaYetiSpawner() { + this.mobID = TFCreatures.getSpawnerNameFor("Yeti Boss"); + } + + @Override + public boolean anyPlayerInRange() { + EntityPlayer closestPlayer = worldObj.getClosestPlayer(xCoord + 0.5D, yCoord + 0.5D, zCoord + 0.5D, 30D); + + return closestPlayer != null && closestPlayer.posY > yCoord - 4; + } + +} diff --git a/src/main/java/twilightforest/tileentity/TileEntityTFChest.java b/src/main/java/twilightforest/tileentity/TileEntityTFChest.java new file mode 100644 index 0000000000..d41c526d9b --- /dev/null +++ b/src/main/java/twilightforest/tileentity/TileEntityTFChest.java @@ -0,0 +1,117 @@ +package twilightforest.tileentity; + +import net.minecraft.block.Block; +import net.minecraft.tileentity.TileEntityChest; + +import cpw.mods.fml.relauncher.Side; +import cpw.mods.fml.relauncher.SideOnly; +import twilightforest.block.BlockTFChest; +import twilightforest.block.BlockTFChest.WoodType; + +public class TileEntityTFChest extends TileEntityChest { + + public WoodType cachedMaterial = WoodType.NULL; + + public TileEntityTFChest() { + super(); + } + + @SideOnly(Side.CLIENT) + public TileEntityTFChest(WoodType material) { + super(); + this.cachedMaterial = material; + } + + /** + * Performs the check for adjacent chests to determine if this chest is double or not. + */ + @Override + public void checkForAdjacentChests() { + if (!this.adjacentChestChecked) { + this.adjacentChestChecked = true; + this.adjacentChestZNeg = null; + this.adjacentChestXPos = null; + this.adjacentChestXNeg = null; + this.adjacentChestZPos = null; + + if (this.func_145977_a(this.xCoord - 1, this.yCoord, this.zCoord)) { + this.adjacentChestXNeg = (TileEntityChest) this.worldObj + .getTileEntity(this.xCoord - 1, this.yCoord, this.zCoord); + } + + if (this.func_145977_a(this.xCoord + 1, this.yCoord, this.zCoord)) { + this.adjacentChestXPos = (TileEntityChest) this.worldObj + .getTileEntity(this.xCoord + 1, this.yCoord, this.zCoord); + } + + if (this.func_145977_a(this.xCoord, this.yCoord, this.zCoord - 1)) { + this.adjacentChestZNeg = (TileEntityChest) this.worldObj + .getTileEntity(this.xCoord, this.yCoord, this.zCoord - 1); + } + + if (this.func_145977_a(this.xCoord, this.yCoord, this.zCoord + 1)) { + this.adjacentChestZPos = (TileEntityChest) this.worldObj + .getTileEntity(this.xCoord, this.yCoord, this.zCoord + 1); + } + + if (this.adjacentChestZNeg instanceof TileEntityTFChest) { + ((TileEntityTFChest) this.adjacentChestZNeg).func_145978_a(this, 0); + } + + if (this.adjacentChestZPos instanceof TileEntityTFChest) { + ((TileEntityTFChest) this.adjacentChestZPos).func_145978_a(this, 2); + } + + if (this.adjacentChestXPos instanceof TileEntityTFChest) { + ((TileEntityTFChest) this.adjacentChestXPos).func_145978_a(this, 1); + } + + if (this.adjacentChestXNeg instanceof TileEntityTFChest) { + ((TileEntityTFChest) this.adjacentChestXNeg).func_145978_a(this, 3); + } + } + } + + private boolean func_145977_a(int p_145977_1_, int p_145977_2_, int p_145977_3_) { + if (this.worldObj == null) { + return false; + } else { + Block block = this.worldObj.getBlock(p_145977_1_, p_145977_2_, p_145977_3_); + Block thisBlock = this.worldObj.getBlock(this.xCoord, this.yCoord, this.zCoord); + return block instanceof BlockTFChest && thisBlock instanceof BlockTFChest + && ((BlockTFChest) block).getWoodType() == ((BlockTFChest) thisBlock).getWoodType(); + } + } + + private void func_145978_a(TileEntityChest p_145978_1_, int p_145978_2_) { + if (p_145978_1_.isInvalid()) { + this.adjacentChestChecked = false; + } else if (this.adjacentChestChecked) { + switch (p_145978_2_) { + case 0: + if (this.adjacentChestZPos != p_145978_1_) { + this.adjacentChestChecked = false; + } + + break; + case 1: + if (this.adjacentChestXNeg != p_145978_1_) { + this.adjacentChestChecked = false; + } + + break; + case 2: + if (this.adjacentChestZNeg != p_145978_1_) { + this.adjacentChestChecked = false; + } + + break; + case 3: + if (this.adjacentChestXPos != p_145978_1_) { + this.adjacentChestChecked = false; + } + } + } + } + +} diff --git a/src/main/java/twilightforest/tileentity/TileEntityTFCicada.java b/src/main/java/twilightforest/tileentity/TileEntityTFCicada.java index 1169933354..112c3b88e3 100644 --- a/src/main/java/twilightforest/tileentity/TileEntityTFCicada.java +++ b/src/main/java/twilightforest/tileentity/TileEntityTFCicada.java @@ -1,5 +1,11 @@ package twilightforest.tileentity; +import net.minecraft.client.Minecraft; +import net.minecraft.client.audio.ISound; +import net.minecraft.client.audio.PositionedSoundRecord; +import net.minecraft.util.ChunkCoordinates; +import net.minecraft.util.ResourceLocation; + import twilightforest.TwilightForestMod; public class TileEntityTFCicada extends TileEntityTFCritter { @@ -90,14 +96,22 @@ public void doSingAnimation() { } public void playSong() { - if (!TwilightForestMod.silentCicadas) { - worldObj.playSoundEffect( - xCoord, - yCoord, - zCoord, - TwilightForestMod.ID + ":mob.cicada", - 1.0f, - (worldObj.rand.nextFloat() - worldObj.rand.nextFloat()) * 0.2F + 1.0F); + if (!TwilightForestMod.silentCicadas && worldObj.isRemote) { + ResourceLocation resource = new ResourceLocation(TwilightForestMod.ID + ":mob.cicada"); + ChunkCoordinates chunkcoordinates = new ChunkCoordinates(xCoord, yCoord, zCoord); + Minecraft mc = Minecraft.getMinecraft(); + ISound isound = (ISound) mc.renderGlobal.mapSoundPositions.get(chunkcoordinates); + if (isound == null) { + PositionedSoundRecord positionedsoundrecord = new PositionedSoundRecord( + resource, + 1.0f, + (worldObj.rand.nextFloat() - worldObj.rand.nextFloat()) * 0.2F + 1.0F, + (float) xCoord, + (float) yCoord, + (float) zCoord); + mc.renderGlobal.mapSoundPositions.put(chunkcoordinates, positionedsoundrecord); + mc.getSoundHandler().playSound(positionedsoundrecord); + } } } } diff --git a/src/main/java/twilightforest/tileentity/TileEntityTFHydraSpawner.java b/src/main/java/twilightforest/tileentity/TileEntityTFHydraSpawner.java index 07d85c8a80..0d37071e5c 100644 --- a/src/main/java/twilightforest/tileentity/TileEntityTFHydraSpawner.java +++ b/src/main/java/twilightforest/tileentity/TileEntityTFHydraSpawner.java @@ -2,8 +2,10 @@ import net.minecraft.entity.Entity; import net.minecraft.entity.EntityList; +import net.minecraft.entity.EntityLiving; import twilightforest.entity.TFCreatures; +import twilightforest.entity.boss.EntityTFHydra; public class TileEntityTFHydraSpawner extends TileEntityTFBossSpawner { @@ -21,4 +23,14 @@ public Entity getDisplayEntity() { return this.displayCreature; } + + /** + * Any post-creation initialization goes here + */ + @Override + protected void initializeCreature(EntityLiving myCreature) { + if (myCreature instanceof EntityTFHydra) { + ((EntityTFHydra) myCreature).setHomeArea(xCoord, yCoord, zCoord, 46); + } + } } diff --git a/src/main/java/twilightforest/tileentity/TileEntityTFKnightPhantomsSpawner.java b/src/main/java/twilightforest/tileentity/TileEntityTFKnightPhantomsSpawner.java index ff6d36957c..915086e90a 100644 --- a/src/main/java/twilightforest/tileentity/TileEntityTFKnightPhantomsSpawner.java +++ b/src/main/java/twilightforest/tileentity/TileEntityTFKnightPhantomsSpawner.java @@ -8,6 +8,8 @@ public class TileEntityTFKnightPhantomsSpawner extends TileEntityTFBossSpawner { + public int knightsCount = 6; + public TileEntityTFKnightPhantomsSpawner() { this.mobID = TFCreatures.getSpawnerNameFor("Knight Phantom"); } @@ -24,7 +26,7 @@ public boolean anyPlayerInRange() { */ protected void spawnMyBoss() { - for (int i = 0; i < 6; i++) { + for (int i = 0; i < knightsCount; i++) { // spawn creature EntityLiving myCreature = makeMyCreature(); diff --git a/src/main/java/twilightforest/tileentity/TileEntityTFMinoshroomSpawner.java b/src/main/java/twilightforest/tileentity/TileEntityTFMinoshroomSpawner.java new file mode 100644 index 0000000000..d434b5bff9 --- /dev/null +++ b/src/main/java/twilightforest/tileentity/TileEntityTFMinoshroomSpawner.java @@ -0,0 +1,20 @@ +package twilightforest.tileentity; + +import net.minecraft.entity.player.EntityPlayer; + +import twilightforest.entity.TFCreatures; + +public class TileEntityTFMinoshroomSpawner extends TileEntityTFBossSpawner { + + public TileEntityTFMinoshroomSpawner() { + this.mobID = TFCreatures.getSpawnerNameFor("Minoshroom"); + } + + @Override + public boolean anyPlayerInRange() { + EntityPlayer closestPlayer = worldObj.getClosestPlayer(xCoord + 0.5D, yCoord + 0.5D, zCoord + 0.5D, 15D); + + return closestPlayer != null && closestPlayer.posY > yCoord - 4; + } + +} diff --git a/src/main/java/twilightforest/tileentity/TileEntityTFTowerBossSpawner.java b/src/main/java/twilightforest/tileentity/TileEntityTFTowerBossSpawner.java index f29fcc1db0..776d7a4542 100644 --- a/src/main/java/twilightforest/tileentity/TileEntityTFTowerBossSpawner.java +++ b/src/main/java/twilightforest/tileentity/TileEntityTFTowerBossSpawner.java @@ -4,6 +4,7 @@ import net.minecraft.entity.player.EntityPlayer; import twilightforest.entity.TFCreatures; +import twilightforest.entity.boss.EntityTFUrGhast; public class TileEntityTFTowerBossSpawner extends TileEntityTFBossSpawner { @@ -34,4 +35,14 @@ protected void spawnMyBoss() { worldObj.spawnEntityInWorld(myCreature); } + /** + * Any post-creation initialization goes here + */ + @Override + protected void initializeCreature(EntityLiving myCreature) { + if (myCreature instanceof EntityTFUrGhast) { + ((EntityTFUrGhast) myCreature).setHomeArea(xCoord, yCoord, zCoord, 46); + } + } + } diff --git a/src/main/resources/META-INF/twilightforest_at.cfg b/src/main/resources/META-INF/twilightforest_at.cfg index b69250e4d1..6529f5b709 100644 --- a/src/main/resources/META-INF/twilightforest_at.cfg +++ b/src/main/resources/META-INF/twilightforest_at.cfg @@ -2,5 +2,8 @@ public net.minecraft.entity.EntityLivingBase field_110153_bc #lastDamage public net.minecraft.util.EntityDamageSource field_76386_o #damageSourceEntity public net.minecraft.util.EntityDamageSourceIndirect field_76387_p #indirectEntity +public net.minecraft.entity.ai.EntityAINearestAttackableTarget field_75309_a #targetEntity +public net.minecraft.entity.Entity field_70146_Z #rand +public net.minecraft.client.renderer.RenderGlobal field_147593_P #mapSoundPositions public net.minecraft.block.BlockStairs field_150149_b public net.minecraft.block.BlockStairs field_150151_M diff --git a/src/main/resources/assets/twilightforest/lang/en_US.lang b/src/main/resources/assets/twilightforest/lang/en_US.lang index a938e48f5f..c6e1facd4f 100644 --- a/src/main/resources/assets/twilightforest/lang/en_US.lang +++ b/src/main/resources/assets/twilightforest/lang/en_US.lang @@ -43,6 +43,22 @@ tile.TFTrapDoorTime.0.name=Timewood Trapdoor tile.TFTrapDoorTrans.0.name=Transwood Trapdoor tile.TFTrapDoorMine.0.name=Minewood Trapdoor tile.TFTrapDoorSort.0.name=Sortingwood Trapdoor +tile.TFChestTwilight.0.name=Twilight Oak Chest +tile.TFChestCanopy.0.name=Canopy Tree Chest +tile.TFChestMangrove.0.name=Mangrove Chest +tile.TFChestDarkwood.0.name=Darkwood Chest +tile.TFChestTime.0.name=Timewood Chest +tile.TFChestTrans.0.name=Transwood Chest +tile.TFChestMine.0.name=Minewood Chest +tile.TFChestSort.0.name=Sortingwood Chest +tile.TFChestTrapTwilight.0.name=Trapped Twilight Oak Chest +tile.TFChestTrapCanopy.0.name=Trapped Canopy Tree Chest +tile.TFChestTrapMangrove.0.name=Trapped Mangrove Chest +tile.TFChestTrapDarkwood.0.name=Trapped Darkwood Chest +tile.TFChestTrapTime.0.name=Trapped Timewood Chest +tile.TFChestTrapTrans.0.name=Trapped Transwood Chest +tile.TFChestTrapMine.0.name=Trapped Minewood Chest +tile.TFChestTrapSort.0.name=Trapped Sortingwood Chest tile.TFLeaves.0.name=Twilight Oak Leaves tile.TFLeaves.1.name=Canopy Tree Leaves tile.TFLeaves.2.name=Mangrove Leaves @@ -67,9 +83,9 @@ tile.TFBossSpawner.1.name=Lich Spawner tile.TFBossSpawner.2.name=Hydra Spawner tile.TFBossSpawner.3.name=Ur-ghast Spawner tile.TFBossSpawner.4.name=Knight Phantoms Spawner -tile.twilightforest.BossSpawner.5.name=Snow Queen Spawner -tile.twilightforest.BossSpawner.6.name=Minoshroom Spawner -tile.twilightforest.BossSpawner.7.name=Alpha Yeti Spawner +tile.TFBossSpawner.5.name=Snow Queen Spawner +tile.TFBossSpawner.6.name=Minoshroom Spawner +tile.TFBossSpawner.7.name=Alpha Yeti Spawner tile.TFFireflyJar.name=Firefly Jar tile.TFPlant.3.name=Moss Patch tile.TFPlant.4.name=Mayapple @@ -376,6 +392,10 @@ item.trophy.naga.name=Naga Trophy item.trophy.lich.name=Lich Trophy item.trophy.ur-ghast.name=Ur-ghast Trophy item.trophy.snowQueen.name=Snow Queen Trophy +item.trophy.minoshroom.name=Minoshroom Trophy +item.trophy.knightPhantom.name=Knight Phantom Trophy +item.trophy.questingRam.name=Questing Ram Trophy +item.trophy.alphaYeti.name=Alpha Yeti Trophy item.adherentFragment.name=Cloth Of The Adherent item.harbingerFragment.name=Fragment Of The Harbinger item.experiment115.name=Experiment 115 @@ -442,11 +462,14 @@ item.yetiHelm.tooltip=Chills attackers item.yetiPlate.tooltip=Chills attackers item.yetiLegs.tooltip=Chills attackers item.yetiBoots.tooltip=Chills attackers +item.phantomHelm.tooltip=Even the death won't do you part +item.phantomPlate.tooltip=Even the death won't do you part item.wand.tooltip=%n charges left item.fieryBlood.tooltip=Can be poured into Tinkers Construct tanks item.fieryTears.tooltip=Can be poured into Tinkers Construct tanks item.charm.tooltip=Can be equipped into any Baubles slot -item.nagastone.outdatedTooltip=Outdated, place and break to update +item.outdated.tooltip=Outdated, place and break to update +itemBlock.compressed.tooltip=Usable for Beacon bases tooltip.tf.adherent=An Adherent, but to whom? tooltip.tf.harbinger=A Harbinger, but of what? @@ -583,6 +606,7 @@ achievement.twilightProgressCastle=So Castle Very Wow achievement.twilightProgressCastle.desc=What could even be in that castle?!? chat.tf.wrongportalitem=Hm, what do you expect to happen? Try to use %s. +chat.tf.pedestalunworthy=You are unworthy. progressionBook.author=A Forgotten Explorer progressionBook.default.title=Notes on the Unexplained diff --git a/src/main/resources/assets/twilightforest/lang/ru_RU.lang b/src/main/resources/assets/twilightforest/lang/ru_RU.lang index 3122f5eb2c..ac90302557 100644 --- a/src/main/resources/assets/twilightforest/lang/ru_RU.lang +++ b/src/main/resources/assets/twilightforest/lang/ru_RU.lang @@ -43,6 +43,22 @@ tile.TFTrapDoorTime.0.name=Люк из дерева времени tile.TFTrapDoorTrans.0.name=Люк из дерева трансформации tile.TFTrapDoorMine.0.name=Люк из дерева шахтёра tile.TFTrapDoorSort.0.name=Люк из дерева сортировки +tile.TFChestTwilight.0.name=Сундук из сумеречного дуба +tile.TFChestCanopy.0.name=Сундук из сумеречной сосны +tile.TFChestMangrove.0.name=Мангровый сундук +tile.TFChestDarkwood.0.name=Сундук из тёмного дерева +tile.TFChestTime.0.name=Сундук из дерева времени +tile.TFChestTrans.0.name=Сундук из дерева трансформации +tile.TFChestMine.0.name=Сундук из дерева шахтёра +tile.TFChestSort.0.name=Сундук из дерева сортировки +tile.TFChestTrapTwilight.0.name=Сундук-ловушка из сумеречного дуба +tile.TFChestTrapCanopy.0.name=Сундук-ловушка из сумеречной сосны +tile.TFChestTrapMangrove.0.name=Мангровый сундук-ловушка +tile.TFChestTrapDarkwood.0.name=Сундук-ловушка из тёмного дерева +tile.TFChestTrapTime.0.name=Сундук-ловушка из дерева времени +tile.TFChestTrapTrans.0.name=Сундук-ловушка из дерева трансформации +tile.TFChestTrapMine.0.name=Сундук-ловушка из дерева шахтёра +tile.TFChestTrapSort.0.name=Сундук-ловушка из дерева сортировки tile.TFLeaves.0.name=Листва сумеречного дуба tile.TFLeaves.1.name=Листва сумеречной сосны tile.TFLeaves.2.name=Мангровая листва @@ -62,14 +78,14 @@ tile.TFMazestone.8.name=Лабиринтовый потолок tile.TFHedge.0.name=Живая изгородь tile.TFHedge.1.name=Листва тёмного дерева tile.TFHedge.2.name=Живая изгородь -tile.TFBossSpawner.0.name=Спаунер Наги -tile.TFBossSpawner.1.name=Спаунер Лича -tile.TFBossSpawner.2.name=Спаунер Гидры -tile.TFBossSpawner.3.name=Спаунер Тёмного гаста -tile.TFBossSpawner.4.name=Спаунер рыцарей-фантомов -tile.twilightforest.BossSpawner.5.name=Спаунер Снежной королевы -tile.twilightforest.BossSpawner.6.name=Спаунер Грибного кентавра -tile.twilightforest.BossSpawner.7.name=Спаунер Альфа-йети +tile.TFBossSpawner.0.name=Призыватель Наги +tile.TFBossSpawner.1.name=Призыватель Лича +tile.TFBossSpawner.2.name=Призыватель Гидры +tile.TFBossSpawner.3.name=Призыватель Тёмного гаста +tile.TFBossSpawner.4.name=Призыватель рыцарей-фантомов +tile.TFBossSpawner.5.name=Призыватель Снежной королевы +tile.TFBossSpawner.6.name=Призыватель Грибного кентавра +tile.TFBossSpawner.7.name=Призыватель Альфа-йети tile.TFFireflyJar.name=Банка со светлячком tile.TFPlant.3.name=Мшистый покров tile.TFPlant.4.name=Дикая мандрагора @@ -321,6 +337,10 @@ item.trophy.naga.name=Трофей Наги item.trophy.lich.name=Трофей Сумеречного лича item.trophy.ur-ghast.name=Трофей Тёмного гаста item.trophy.snowQueen.name=Трофей Снежной королевы +item.trophy.minoshroom.name=Трофей Грибного кентавра +item.trophy.knightPhantom.name=Трофей Рыцаря-фантома +item.trophy.questingRam.name=Трофей Цветного барана +item.trophy.alphaYeti.name=Трофей Альфа-йети item.adherentFragment.name=Ткань Последователя item.harbingerFragment.name=Фрагмент Предвестинка item.experiment115.name=Эксперимент 115 @@ -386,11 +406,14 @@ item.yetiHelm.tooltip=Остужает атакующих item.yetiPlate.tooltip=Остужает атакующих item.yetiLegs.tooltip=Остужает атакующих item.yetiBoots.tooltip=Остужает атакующих +item.phantomHelm.tooltip=Даже смерть не разлучит вас +item.phantomPlate.tooltip=Даже смерть не разлучит вас item.wand.tooltip=Осталось %n зарядов item.fieryBlood.tooltip=Может быть налита в цистерны Tinkers Construct item.fieryTears.tooltip=Могут быть налиты в цистерны Tinkers Construct item.charm.tooltip=Можно надеть в слот для кольца, амулета или пояса -item.nagastone.outdatedTooltip=Устаревшая версия блока, установите и сломайте чтобы обновить +item.outdated.tooltip=Устаревшая версия блока, установите и сломайте чтобы обновить +itemBlock.compressed.tooltip=Подходит для основы маяка tooltip.tf.adherent=Последователь, но чей? tooltip.tf.harbinger=Предвестник, но чего? @@ -527,6 +550,7 @@ achievement.twilightProgressCastle=§1So castle §cVery wow achievement.twilightProgressCastle.desc=Что же может быть в этом замке?!? chat.tf.wrongportalitem=Хмм, чего это ты ожидал? Попробуй лучше %s. +chat.tf.pedestalunworthy=Ты недостоин. progressionBook.author=Забытый исследователь progressionBook.default.title=Заметки о необъяснимом diff --git a/src/main/resources/assets/twilightforest/sounds.json b/src/main/resources/assets/twilightforest/sounds.json index 99e3187038..ce54687581 100644 --- a/src/main/resources/assets/twilightforest/sounds.json +++ b/src/main/resources/assets/twilightforest/sounds.json @@ -219,6 +219,60 @@ "mob/ice/death0", "mob/ice/death1" ] + }, + "mob.yeti.hurt": { + "category": "hostile", + "sounds": [ + "mob/yeti/hurt1", + "mob/yeti/hurt2", + "mob/yeti/hurt3" + ] + }, + "mob.yeti.death": { + "category": "hostile", + "sounds": [ + "mob/yeti/death" + ] + }, + "mob.yeti.growl": { + "category": "hostile", + "sounds": [ + "mob/yeti/growl1", + "mob/yeti/growl2", + "mob/yeti/growl3" + ] + }, + "mob.yeti.roar": { + "category": "hostile", + "sounds": [ + "mob/yeti/roar" + ] + }, + "mob.yeti.alert": { + "category": "hostile", + "sounds": [ + "mob/yeti/alert" + ] + }, + "mob.yeti.grab": { + "category": "hostile", + "sounds": [ + "mob/yeti/grab" + ] + }, + "mob.yeti.throw": { + "category": "hostile", + "sounds": [ + "mob/yeti/throw" + ] + }, + "mob.yeti.pant": { + "category": "hostile", + "sounds": [ + "mob/yeti/pant1", + "mob/yeti/pant2", + "mob/yeti/pant" + ] }, "random.slider": { "category": "block", diff --git a/src/main/resources/assets/twilightforest/sounds/mob/yeti/alert.ogg b/src/main/resources/assets/twilightforest/sounds/mob/yeti/alert.ogg new file mode 100644 index 0000000000..73b0410cf2 Binary files /dev/null and b/src/main/resources/assets/twilightforest/sounds/mob/yeti/alert.ogg differ diff --git a/src/main/resources/assets/twilightforest/sounds/mob/yeti/death.ogg b/src/main/resources/assets/twilightforest/sounds/mob/yeti/death.ogg new file mode 100644 index 0000000000..31909af08c Binary files /dev/null and b/src/main/resources/assets/twilightforest/sounds/mob/yeti/death.ogg differ diff --git a/src/main/resources/assets/twilightforest/sounds/mob/yeti/grab.ogg b/src/main/resources/assets/twilightforest/sounds/mob/yeti/grab.ogg new file mode 100644 index 0000000000..9985479e40 Binary files /dev/null and b/src/main/resources/assets/twilightforest/sounds/mob/yeti/grab.ogg differ diff --git a/src/main/resources/assets/twilightforest/sounds/mob/yeti/growl1.ogg b/src/main/resources/assets/twilightforest/sounds/mob/yeti/growl1.ogg new file mode 100644 index 0000000000..20c5d4e6d8 Binary files /dev/null and b/src/main/resources/assets/twilightforest/sounds/mob/yeti/growl1.ogg differ diff --git a/src/main/resources/assets/twilightforest/sounds/mob/yeti/growl2.ogg b/src/main/resources/assets/twilightforest/sounds/mob/yeti/growl2.ogg new file mode 100644 index 0000000000..c1520c1aa9 Binary files /dev/null and b/src/main/resources/assets/twilightforest/sounds/mob/yeti/growl2.ogg differ diff --git a/src/main/resources/assets/twilightforest/sounds/mob/yeti/growl3.ogg b/src/main/resources/assets/twilightforest/sounds/mob/yeti/growl3.ogg new file mode 100644 index 0000000000..d8e7c2a8c0 Binary files /dev/null and b/src/main/resources/assets/twilightforest/sounds/mob/yeti/growl3.ogg differ diff --git a/src/main/resources/assets/twilightforest/sounds/mob/yeti/hurt1.ogg b/src/main/resources/assets/twilightforest/sounds/mob/yeti/hurt1.ogg new file mode 100644 index 0000000000..4e80d4d7ff Binary files /dev/null and b/src/main/resources/assets/twilightforest/sounds/mob/yeti/hurt1.ogg differ diff --git a/src/main/resources/assets/twilightforest/sounds/mob/yeti/hurt2.ogg b/src/main/resources/assets/twilightforest/sounds/mob/yeti/hurt2.ogg new file mode 100644 index 0000000000..98722421aa Binary files /dev/null and b/src/main/resources/assets/twilightforest/sounds/mob/yeti/hurt2.ogg differ diff --git a/src/main/resources/assets/twilightforest/sounds/mob/yeti/hurt3.ogg b/src/main/resources/assets/twilightforest/sounds/mob/yeti/hurt3.ogg new file mode 100644 index 0000000000..172daaa76e Binary files /dev/null and b/src/main/resources/assets/twilightforest/sounds/mob/yeti/hurt3.ogg differ diff --git a/src/main/resources/assets/twilightforest/sounds/mob/yeti/pant1.ogg b/src/main/resources/assets/twilightforest/sounds/mob/yeti/pant1.ogg new file mode 100644 index 0000000000..b237634c52 Binary files /dev/null and b/src/main/resources/assets/twilightforest/sounds/mob/yeti/pant1.ogg differ diff --git a/src/main/resources/assets/twilightforest/sounds/mob/yeti/pant2.ogg b/src/main/resources/assets/twilightforest/sounds/mob/yeti/pant2.ogg new file mode 100644 index 0000000000..35a33ef314 Binary files /dev/null and b/src/main/resources/assets/twilightforest/sounds/mob/yeti/pant2.ogg differ diff --git a/src/main/resources/assets/twilightforest/sounds/mob/yeti/pant3.ogg b/src/main/resources/assets/twilightforest/sounds/mob/yeti/pant3.ogg new file mode 100644 index 0000000000..a3724a0a4f Binary files /dev/null and b/src/main/resources/assets/twilightforest/sounds/mob/yeti/pant3.ogg differ diff --git a/src/main/resources/assets/twilightforest/sounds/mob/yeti/roar.ogg b/src/main/resources/assets/twilightforest/sounds/mob/yeti/roar.ogg new file mode 100644 index 0000000000..8dc94ffeaf Binary files /dev/null and b/src/main/resources/assets/twilightforest/sounds/mob/yeti/roar.ogg differ diff --git a/src/main/resources/assets/twilightforest/sounds/mob/yeti/throw.ogg b/src/main/resources/assets/twilightforest/sounds/mob/yeti/throw.ogg new file mode 100644 index 0000000000..50f6e96409 Binary files /dev/null and b/src/main/resources/assets/twilightforest/sounds/mob/yeti/throw.ogg differ diff --git a/src/main/resources/assets/twilightforest/textures/blocks/fiery_block_inner.png b/src/main/resources/assets/twilightforest/textures/blocks/fiery_block_inner.png new file mode 100644 index 0000000000..f4a333d34c Binary files /dev/null and b/src/main/resources/assets/twilightforest/textures/blocks/fiery_block_inner.png differ diff --git a/src/main/resources/assets/twilightforest/textures/blocks/fiery_block_inner_cross.png b/src/main/resources/assets/twilightforest/textures/blocks/fiery_block_inner_cross.png new file mode 100644 index 0000000000..a8bce7f9e9 Binary files /dev/null and b/src/main/resources/assets/twilightforest/textures/blocks/fiery_block_inner_cross.png differ diff --git a/src/main/resources/assets/twilightforest/textures/blocks/fiery_block_inner_full.png b/src/main/resources/assets/twilightforest/textures/blocks/fiery_block_inner_full.png new file mode 100644 index 0000000000..9bd58c3d4f Binary files /dev/null and b/src/main/resources/assets/twilightforest/textures/blocks/fiery_block_inner_full.png differ diff --git a/src/main/resources/assets/twilightforest/textures/blocks/fiery_block_inner_horizontal.png b/src/main/resources/assets/twilightforest/textures/blocks/fiery_block_inner_horizontal.png new file mode 100644 index 0000000000..20429195ba Binary files /dev/null and b/src/main/resources/assets/twilightforest/textures/blocks/fiery_block_inner_horizontal.png differ diff --git a/src/main/resources/assets/twilightforest/textures/blocks/fiery_block_inner_vertical.png b/src/main/resources/assets/twilightforest/textures/blocks/fiery_block_inner_vertical.png new file mode 100644 index 0000000000..9e005f98b1 Binary files /dev/null and b/src/main/resources/assets/twilightforest/textures/blocks/fiery_block_inner_vertical.png differ diff --git a/src/main/resources/assets/twilightforest/textures/blocks/fiery_pattern.png b/src/main/resources/assets/twilightforest/textures/blocks/fiery_pattern.png new file mode 100644 index 0000000000..78a8dcebd7 Binary files /dev/null and b/src/main/resources/assets/twilightforest/textures/blocks/fiery_pattern.png differ diff --git a/src/main/resources/assets/twilightforest/textures/gui/mapicons.png b/src/main/resources/assets/twilightforest/textures/gui/mapicons.png index 8cffc74e7f..bad28d60cd 100644 Binary files a/src/main/resources/assets/twilightforest/textures/gui/mapicons.png and b/src/main/resources/assets/twilightforest/textures/gui/mapicons.png differ diff --git a/src/main/resources/assets/twilightforest/textures/items/alphaYetiTrophy.png b/src/main/resources/assets/twilightforest/textures/items/alphaYetiTrophy.png new file mode 100644 index 0000000000..8c1d1d77ea Binary files /dev/null and b/src/main/resources/assets/twilightforest/textures/items/alphaYetiTrophy.png differ diff --git a/src/main/resources/assets/twilightforest/textures/items/chainBlockRing.png b/src/main/resources/assets/twilightforest/textures/items/chainBlockRing.png new file mode 100644 index 0000000000..33f09f7969 Binary files /dev/null and b/src/main/resources/assets/twilightforest/textures/items/chainBlockRing.png differ diff --git a/src/main/resources/assets/twilightforest/textures/items/knightPhantomTrophy.png b/src/main/resources/assets/twilightforest/textures/items/knightPhantomTrophy.png new file mode 100644 index 0000000000..a6203c28ed Binary files /dev/null and b/src/main/resources/assets/twilightforest/textures/items/knightPhantomTrophy.png differ diff --git a/src/main/resources/assets/twilightforest/textures/items/knightmetalRing.png b/src/main/resources/assets/twilightforest/textures/items/knightmetalRing.png index 33f09f7969..d6ad3fd3df 100644 Binary files a/src/main/resources/assets/twilightforest/textures/items/knightmetalRing.png and b/src/main/resources/assets/twilightforest/textures/items/knightmetalRing.png differ diff --git a/src/main/resources/assets/twilightforest/textures/items/minoshroomTrophy.png b/src/main/resources/assets/twilightforest/textures/items/minoshroomTrophy.png new file mode 100644 index 0000000000..29662700ce Binary files /dev/null and b/src/main/resources/assets/twilightforest/textures/items/minoshroomTrophy.png differ diff --git a/src/main/resources/assets/twilightforest/textures/items/questingRamTrophy.png b/src/main/resources/assets/twilightforest/textures/items/questingRamTrophy.png new file mode 100644 index 0000000000..1828ce902d Binary files /dev/null and b/src/main/resources/assets/twilightforest/textures/items/questingRamTrophy.png differ diff --git a/src/main/resources/assets/twilightforest/textures/items/trophyTemplate.xcf b/src/main/resources/assets/twilightforest/textures/items/trophyTemplate.xcf new file mode 100644 index 0000000000..11403156f6 Binary files /dev/null and b/src/main/resources/assets/twilightforest/textures/items/trophyTemplate.xcf differ diff --git a/src/main/resources/assets/twilightforest/textures/model/chest/canopy.png b/src/main/resources/assets/twilightforest/textures/model/chest/canopy.png new file mode 100644 index 0000000000..73870e9a2d Binary files /dev/null and b/src/main/resources/assets/twilightforest/textures/model/chest/canopy.png differ diff --git a/src/main/resources/assets/twilightforest/textures/model/chest/canopy_double.png b/src/main/resources/assets/twilightforest/textures/model/chest/canopy_double.png new file mode 100644 index 0000000000..5915d4ee34 Binary files /dev/null and b/src/main/resources/assets/twilightforest/textures/model/chest/canopy_double.png differ diff --git a/src/main/resources/assets/twilightforest/textures/model/chest/darkwood.png b/src/main/resources/assets/twilightforest/textures/model/chest/darkwood.png new file mode 100644 index 0000000000..0a9ab920ef Binary files /dev/null and b/src/main/resources/assets/twilightforest/textures/model/chest/darkwood.png differ diff --git a/src/main/resources/assets/twilightforest/textures/model/chest/darkwood_double.png b/src/main/resources/assets/twilightforest/textures/model/chest/darkwood_double.png new file mode 100644 index 0000000000..1807938c78 Binary files /dev/null and b/src/main/resources/assets/twilightforest/textures/model/chest/darkwood_double.png differ diff --git a/src/main/resources/assets/twilightforest/textures/model/chest/double.xcf b/src/main/resources/assets/twilightforest/textures/model/chest/double.xcf new file mode 100644 index 0000000000..a9e7f74450 Binary files /dev/null and b/src/main/resources/assets/twilightforest/textures/model/chest/double.xcf differ diff --git a/src/main/resources/assets/twilightforest/textures/model/chest/mangrove.png b/src/main/resources/assets/twilightforest/textures/model/chest/mangrove.png new file mode 100644 index 0000000000..161fcbfc3c Binary files /dev/null and b/src/main/resources/assets/twilightforest/textures/model/chest/mangrove.png differ diff --git a/src/main/resources/assets/twilightforest/textures/model/chest/mangrove_double.png b/src/main/resources/assets/twilightforest/textures/model/chest/mangrove_double.png new file mode 100644 index 0000000000..2ed58f2dc3 Binary files /dev/null and b/src/main/resources/assets/twilightforest/textures/model/chest/mangrove_double.png differ diff --git a/src/main/resources/assets/twilightforest/textures/model/chest/mining.png b/src/main/resources/assets/twilightforest/textures/model/chest/mining.png new file mode 100644 index 0000000000..9cbeed2b7a Binary files /dev/null and b/src/main/resources/assets/twilightforest/textures/model/chest/mining.png differ diff --git a/src/main/resources/assets/twilightforest/textures/model/chest/mining_double.png b/src/main/resources/assets/twilightforest/textures/model/chest/mining_double.png new file mode 100644 index 0000000000..ed069f279f Binary files /dev/null and b/src/main/resources/assets/twilightforest/textures/model/chest/mining_double.png differ diff --git a/src/main/resources/assets/twilightforest/textures/model/chest/normal.xcf b/src/main/resources/assets/twilightforest/textures/model/chest/normal.xcf new file mode 100644 index 0000000000..9085395559 Binary files /dev/null and b/src/main/resources/assets/twilightforest/textures/model/chest/normal.xcf differ diff --git a/src/main/resources/assets/twilightforest/textures/model/chest/sort.png b/src/main/resources/assets/twilightforest/textures/model/chest/sort.png new file mode 100644 index 0000000000..5c15d56ae6 Binary files /dev/null and b/src/main/resources/assets/twilightforest/textures/model/chest/sort.png differ diff --git a/src/main/resources/assets/twilightforest/textures/model/chest/sort_double.png b/src/main/resources/assets/twilightforest/textures/model/chest/sort_double.png new file mode 100644 index 0000000000..794afefde0 Binary files /dev/null and b/src/main/resources/assets/twilightforest/textures/model/chest/sort_double.png differ diff --git a/src/main/resources/assets/twilightforest/textures/model/chest/time.png b/src/main/resources/assets/twilightforest/textures/model/chest/time.png new file mode 100644 index 0000000000..7b5505fc4e Binary files /dev/null and b/src/main/resources/assets/twilightforest/textures/model/chest/time.png differ diff --git a/src/main/resources/assets/twilightforest/textures/model/chest/time_double.png b/src/main/resources/assets/twilightforest/textures/model/chest/time_double.png new file mode 100644 index 0000000000..76c4e3b51a Binary files /dev/null and b/src/main/resources/assets/twilightforest/textures/model/chest/time_double.png differ diff --git a/src/main/resources/assets/twilightforest/textures/model/chest/trans.png b/src/main/resources/assets/twilightforest/textures/model/chest/trans.png new file mode 100644 index 0000000000..88ac50d6c6 Binary files /dev/null and b/src/main/resources/assets/twilightforest/textures/model/chest/trans.png differ diff --git a/src/main/resources/assets/twilightforest/textures/model/chest/trans_double.png b/src/main/resources/assets/twilightforest/textures/model/chest/trans_double.png new file mode 100644 index 0000000000..12adbb8a53 Binary files /dev/null and b/src/main/resources/assets/twilightforest/textures/model/chest/trans_double.png differ diff --git a/src/main/resources/assets/twilightforest/textures/model/chest/twilight.png b/src/main/resources/assets/twilightforest/textures/model/chest/twilight.png new file mode 100644 index 0000000000..1448b161c0 Binary files /dev/null and b/src/main/resources/assets/twilightforest/textures/model/chest/twilight.png differ diff --git a/src/main/resources/assets/twilightforest/textures/model/chest/twilight_double.png b/src/main/resources/assets/twilightforest/textures/model/chest/twilight_double.png new file mode 100644 index 0000000000..11f201c76d Binary files /dev/null and b/src/main/resources/assets/twilightforest/textures/model/chest/twilight_double.png differ diff --git a/src/main/resources/assets/twilightforest/textures/model/phantomtrophy.png b/src/main/resources/assets/twilightforest/textures/model/phantomtrophy.png new file mode 100644 index 0000000000..8264bb495c Binary files /dev/null and b/src/main/resources/assets/twilightforest/textures/model/phantomtrophy.png differ