Skip to content

Commit

Permalink
Merge remote-tracking branch 'Gordon-Frohman/master' into dev
Browse files Browse the repository at this point in the history
  • Loading branch information
Dream-Master committed May 26, 2024
2 parents 7be0500 + 3408c01 commit 383dcf3
Show file tree
Hide file tree
Showing 148 changed files with 3,602 additions and 395 deletions.
86 changes: 0 additions & 86 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -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
16 changes: 16 additions & 0 deletions src/main/java/twilightforest/TFCommonProxy.java
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,10 @@ public int getCakeBlockRenderID() {
return 0;
}

public int getChestBlockRenderID() {
return 0;
}

public int getComplexBlockRenderID() {
return 0;
}
Expand Down Expand Up @@ -75,6 +79,10 @@ public int getKnightmetalBlockRenderID() {
return 0;
}

public int getFieryMetalBlockRenderID() {
return 0;
}

public int getHugeLilyPadBlockRenderID() {
return 0;
}
Expand Down Expand Up @@ -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) {}

}
119 changes: 80 additions & 39 deletions src/main/java/twilightforest/TFEventListener.java
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
package twilightforest;

import java.io.File;
import java.io.IOException;
import java.util.ArrayList;
import java.util.HashMap;

Expand Down Expand Up @@ -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;
Expand All @@ -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;
Expand All @@ -71,6 +75,9 @@
*/
public class TFEventListener {

public static String fileName = "tf";
public static String fileNameBackup = "tfback";

protected HashMap<String, InventoryPlayer> playerKeepsMap = new HashMap<>();
protected HashMap<String, ItemStack[]> playerBaublesMap = new HashMap<>();
private boolean isBreakingWithGiantPick = false;
Expand Down Expand Up @@ -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) {
Expand Down Expand Up @@ -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);

}
}
Expand Down Expand Up @@ -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) {
Expand Down Expand Up @@ -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!
*/
Expand Down Expand Up @@ -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());
Expand All @@ -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());
}
}

/**
Expand Down
Loading

0 comments on commit 383dcf3

Please sign in to comment.