Compare commits
No commits in common. "0831ad4b2fe056de436cd96edf6b208899689101" and "b1c80d7bdee993185513581682f36ca71110cb31" have entirely different histories.
0831ad4b2f
...
b1c80d7bde
|
@ -1,14 +1,12 @@
|
||||||
package lostcave.deathchests;
|
package lostcave.deathchests;
|
||||||
|
|
||||||
import lostcave.deathchests.block.BlockDeathChest;
|
import lostcave.deathchests.block.BlockDeathChest;
|
||||||
import lostcave.deathchests.block.BlockDeathChest.TileDeathChest;
|
|
||||||
import lostcave.deathchests.item.ItemObituary;
|
import lostcave.deathchests.item.ItemObituary;
|
||||||
import lostcave.deathchests.util.Config;
|
import lostcave.deathchests.util.Config;
|
||||||
import lostcave.deathchests.util.DeathChestStorage;
|
import lostcave.deathchests.util.DeathChestStorage;
|
||||||
import lostcave.deathchests.util.Debug;
|
import lostcave.deathchests.util.Debug;
|
||||||
import net.minecraft.client.Minecraft;
|
import net.minecraft.client.Minecraft;
|
||||||
import net.minecraft.init.Blocks;
|
import net.minecraft.init.Blocks;
|
||||||
import net.minecraft.tileentity.TileEntity;
|
|
||||||
import net.minecraftforge.common.DimensionManager;
|
import net.minecraftforge.common.DimensionManager;
|
||||||
import net.minecraftforge.common.MinecraftForge;
|
import net.minecraftforge.common.MinecraftForge;
|
||||||
|
|
||||||
|
@ -58,9 +56,7 @@ public class DeathChests {
|
||||||
Debug.out("Received FMLInitializationEvent");
|
Debug.out("Received FMLInitializationEvent");
|
||||||
|
|
||||||
GameRegistry.registerBlock(BlockDeathChest.getInstance(), "death_chest");
|
GameRegistry.registerBlock(BlockDeathChest.getInstance(), "death_chest");
|
||||||
if (Config.giveObituary) {
|
GameRegistry.registerItem(ItemObituary.getInstance(), "obituary");
|
||||||
GameRegistry.registerItem(ItemObituary.getInstance(), "obituary");
|
|
||||||
}
|
|
||||||
Debug.out("Registered block and item.");
|
Debug.out("Registered block and item.");
|
||||||
|
|
||||||
MinecraftForge.EVENT_BUS.register(new EventHook());
|
MinecraftForge.EVENT_BUS.register(new EventHook());
|
||||||
|
@ -71,12 +67,12 @@ public class DeathChests {
|
||||||
@EventHandler
|
@EventHandler
|
||||||
public void init(FMLPostInitializationEvent event) {
|
public void init(FMLPostInitializationEvent event) {
|
||||||
Debug.out("Received FMLPostInitializationEvent");
|
Debug.out("Received FMLPostInitializationEvent");
|
||||||
TileEntity.addMapping(TileDeathChest.class, "death_chest");
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@EventHandler
|
@EventHandler
|
||||||
public void init(FMLServerAboutToStartEvent event) {
|
public void init(FMLServerAboutToStartEvent event) {
|
||||||
Debug.out("Received FMLServerAboutToStartEvent");
|
Debug.out("Received FMLServerAboutToStartEvent");
|
||||||
|
//TODO: get world save location
|
||||||
worldSaveLocation = DimensionManager.getCurrentSaveRootDirectory();
|
worldSaveLocation = DimensionManager.getCurrentSaveRootDirectory();
|
||||||
DeathChestStorage.load(worldSaveLocation);
|
DeathChestStorage.load(worldSaveLocation);
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,20 +1,15 @@
|
||||||
package lostcave.deathchests;
|
package lostcave.deathchests;
|
||||||
|
|
||||||
import java.util.ArrayList;
|
|
||||||
|
|
||||||
import cpw.mods.fml.common.eventhandler.SubscribeEvent;
|
import cpw.mods.fml.common.eventhandler.SubscribeEvent;
|
||||||
import cpw.mods.fml.common.gameevent.PlayerEvent;
|
import cpw.mods.fml.common.gameevent.PlayerEvent;
|
||||||
import lostcave.deathchests.block.BlockDeathChest;
|
import lostcave.deathchests.block.BlockDeathChest;
|
||||||
import lostcave.deathchests.block.BlockDeathChest.TileDeathChest;
|
|
||||||
import lostcave.deathchests.item.ItemObituary;
|
import lostcave.deathchests.item.ItemObituary;
|
||||||
import lostcave.deathchests.util.Config;
|
import lostcave.deathchests.util.Config;
|
||||||
import lostcave.deathchests.util.DeathChestStorage;
|
import lostcave.deathchests.util.DeathChestStorage;
|
||||||
import lostcave.deathchests.util.Debug;
|
import lostcave.deathchests.util.Debug;
|
||||||
import net.minecraft.block.BlockAir;
|
import net.minecraft.block.BlockAir;
|
||||||
import net.minecraft.entity.item.EntityItem;
|
|
||||||
import net.minecraft.entity.player.EntityPlayer;
|
import net.minecraft.entity.player.EntityPlayer;
|
||||||
import net.minecraft.item.ItemStack;
|
import net.minecraft.item.ItemStack;
|
||||||
import net.minecraft.nbt.NBTTagCompound;
|
|
||||||
import net.minecraft.world.World;
|
import net.minecraft.world.World;
|
||||||
import net.minecraftforge.event.entity.EntityEvent.EntityConstructing;
|
import net.minecraftforge.event.entity.EntityEvent.EntityConstructing;
|
||||||
import net.minecraftforge.event.entity.player.PlayerDropsEvent;
|
import net.minecraftforge.event.entity.player.PlayerDropsEvent;
|
||||||
|
@ -35,8 +30,6 @@ public class EventHook {
|
||||||
Debug.out("X: " + Long.toString(x));
|
Debug.out("X: " + Long.toString(x));
|
||||||
Debug.out("Y: " + Long.toString(y));
|
Debug.out("Y: " + Long.toString(y));
|
||||||
Debug.out("Z: " + Long.toString(z));
|
Debug.out("Z: " + Long.toString(z));
|
||||||
|
|
||||||
//TODO: Don’t place a death chest for an empty inventory
|
|
||||||
|
|
||||||
// Don’t place the chest outside the world
|
// Don’t place the chest outside the world
|
||||||
if (y < 0) y = 0;
|
if (y < 0) y = 0;
|
||||||
|
@ -169,20 +162,12 @@ public class EventHook {
|
||||||
suitableBlock[3] = event.entityPlayer.dimension;
|
suitableBlock[3] = event.entityPlayer.dimension;
|
||||||
|
|
||||||
world.setBlock(suitableBlock[0], suitableBlock[1], suitableBlock[2], BlockDeathChest.getInstance());
|
world.setBlock(suitableBlock[0], suitableBlock[1], suitableBlock[2], BlockDeathChest.getInstance());
|
||||||
|
//TODO: Get the player's items and put them in the death chest
|
||||||
TileDeathChest tile = (TileDeathChest) world.getTileEntity(suitableBlock[0], suitableBlock[1], suitableBlock[2]);
|
|
||||||
tile.owner = event.entityPlayer.getGameProfile().getId();
|
|
||||||
ArrayList<EntityItem> drops = event.drops;
|
|
||||||
for (EntityItem drop : drops) {
|
|
||||||
Debug.out(drop.getEntityItem().getDisplayName());
|
|
||||||
tile.addItemStack(drop.getEntityItem());
|
|
||||||
}
|
|
||||||
|
|
||||||
String uuid = event.entityPlayer.getGameProfile().getId().toString();
|
String uuid = event.entityPlayer.getGameProfile().getId().toString();
|
||||||
Debug.out(uuid);
|
Debug.out(uuid);
|
||||||
DeathChestStorage.addNewDeathChestLocation(uuid, suitableBlock);
|
DeathChestStorage.addNewDeathChestLocation(uuid, suitableBlock);
|
||||||
|
|
||||||
//TODO: prevent the items in question from spawning instead of canceling the event
|
|
||||||
event.setCanceled(true);
|
event.setCanceled(true);
|
||||||
Debug.out("Canceled PlayerDropEvent");
|
Debug.out("Canceled PlayerDropEvent");
|
||||||
} else {
|
} else {
|
||||||
|
@ -198,6 +183,7 @@ public class EventHook {
|
||||||
String uuid = event.player.getGameProfile().getId().toString();
|
String uuid = event.player.getGameProfile().getId().toString();
|
||||||
Debug.out("UUID: " + uuid);
|
Debug.out("UUID: " + uuid);
|
||||||
|
|
||||||
|
//TODO: check for stored chest location
|
||||||
if (DeathChestStorage.hasNewDeathChestLocation(uuid)) {
|
if (DeathChestStorage.hasNewDeathChestLocation(uuid)) {
|
||||||
int[] chestLocation = DeathChestStorage.popNewDeathChestLocation(uuid);
|
int[] chestLocation = DeathChestStorage.popNewDeathChestLocation(uuid);
|
||||||
Debug.out("Chest location X: " + Integer.toString(chestLocation[0]));
|
Debug.out("Chest location X: " + Integer.toString(chestLocation[0]));
|
||||||
|
@ -205,24 +191,11 @@ public class EventHook {
|
||||||
Debug.out("Chest location Z: " + Integer.toString(chestLocation[2]));
|
Debug.out("Chest location Z: " + Integer.toString(chestLocation[2]));
|
||||||
Debug.out("Chest location dimension: " + Integer.toString(chestLocation[3]));
|
Debug.out("Chest location dimension: " + Integer.toString(chestLocation[3]));
|
||||||
|
|
||||||
if (Config.giveObituary) {
|
//TODO: NBT data
|
||||||
ItemStack stack = new ItemStack(ItemObituary.getInstance());
|
event.player.inventory.addItemStackToInventory(new ItemStack(ItemObituary.getInstance()));
|
||||||
NBTTagCompound compound = new NBTTagCompound();
|
|
||||||
String location = Integer.toString(chestLocation[0]) + " " + Integer.toString(chestLocation[1]) + " " + Integer.toString(chestLocation[2]);
|
|
||||||
//TODO: Find the name of the dimension instead
|
|
||||||
String dimension = Integer.toString(chestLocation[3]);
|
|
||||||
String message = String.format(Config.locationMessage, location, dimension);
|
|
||||||
compound.setString("message", message);
|
|
||||||
stack.setTagCompound(compound);
|
|
||||||
event.player.inventory.addItemStackToInventory(stack);
|
|
||||||
}
|
|
||||||
} else {
|
} else {
|
||||||
Debug.out("No death chest location was stored.");
|
Debug.out("No death chest location was stored.");
|
||||||
ItemStack stack = new ItemStack(ItemObituary.getInstance());
|
//TODO: tell player that a death chest couldn’t be placed and that the items have been dropped
|
||||||
NBTTagCompound compound = new NBTTagCompound();
|
|
||||||
compound.setString("message", Config.dropMessage);
|
|
||||||
stack.setTagCompound(compound);
|
|
||||||
event.player.inventory.addItemStackToInventory(stack);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -1,71 +1,36 @@
|
||||||
package lostcave.deathchests.block;
|
package lostcave.deathchests.block;
|
||||||
|
|
||||||
import java.util.ArrayList;
|
|
||||||
import java.util.Random;
|
import java.util.Random;
|
||||||
import java.util.UUID;
|
|
||||||
|
|
||||||
import cpw.mods.fml.common.FMLCommonHandler;
|
import cpw.mods.fml.relauncher.Side;
|
||||||
import lostcave.deathchests.util.Config;
|
import cpw.mods.fml.relauncher.SideOnly;
|
||||||
import lostcave.deathchests.util.Debug;
|
import net.minecraft.block.Block;
|
||||||
import net.minecraft.block.BlockContainer;
|
import net.minecraft.block.BlockEnderChest;
|
||||||
import net.minecraft.block.material.Material;
|
|
||||||
import net.minecraft.client.renderer.texture.IIconRegister;
|
import net.minecraft.client.renderer.texture.IIconRegister;
|
||||||
import net.minecraft.entity.item.EntityItem;
|
|
||||||
import net.minecraft.entity.player.EntityPlayer;
|
import net.minecraft.entity.player.EntityPlayer;
|
||||||
|
import net.minecraft.init.Blocks;
|
||||||
|
import net.minecraft.inventory.InventoryEnderChest;
|
||||||
import net.minecraft.item.Item;
|
import net.minecraft.item.Item;
|
||||||
import net.minecraft.item.ItemStack;
|
|
||||||
import net.minecraft.nbt.NBTTagCompound;
|
|
||||||
import net.minecraft.nbt.NBTTagList;
|
|
||||||
import net.minecraft.tileentity.TileEntity;
|
import net.minecraft.tileentity.TileEntity;
|
||||||
import net.minecraft.util.ChatComponentText;
|
import net.minecraft.tileentity.TileEntityEnderChest;
|
||||||
import net.minecraft.util.IIcon;
|
|
||||||
import net.minecraft.world.Explosion;
|
import net.minecraft.world.Explosion;
|
||||||
import net.minecraft.world.World;
|
import net.minecraft.world.World;
|
||||||
|
|
||||||
public class BlockDeathChest extends BlockContainer {
|
public class BlockDeathChest extends BlockEnderChest {
|
||||||
|
|
||||||
private static final BlockDeathChest instance = new BlockDeathChest();
|
private static final BlockDeathChest instance = new BlockDeathChest();
|
||||||
|
|
||||||
public static BlockDeathChest getInstance() {
|
public static BlockDeathChest getInstance() {
|
||||||
return instance;
|
return instance;
|
||||||
}
|
}
|
||||||
|
|
||||||
private IIcon[] icons = new IIcon[6];
|
|
||||||
|
|
||||||
private BlockDeathChest() {
|
private BlockDeathChest() {
|
||||||
super(Material.rock);
|
super();
|
||||||
this.setBlockName("death_chest");
|
this.setBlockName("death_chest");
|
||||||
this.disableStats();
|
this.disableStats();
|
||||||
this.setBlockUnbreakable();
|
this.setBlockUnbreakable();
|
||||||
// same value as bedrock
|
// same value as bedrock
|
||||||
this.setResistance(6000000.0F);
|
this.setResistance(6000000.0F);
|
||||||
this.setBlockBounds(0.0625F, 0.0F, 0.0625F, 0.9375F, 0.875F, 0.9375F);
|
|
||||||
this.setBlockTextureName("deathchests:deathchest_top");
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void registerBlockIcons(IIconRegister register) {
|
|
||||||
icons[0] = register.registerIcon("deathchests:deathchest_top");
|
|
||||||
icons[1] = register.registerIcon("deathchests:deathchest_top");
|
|
||||||
icons[2] = register.registerIcon("deathchests:deathchest_side");
|
|
||||||
icons[3] = register.registerIcon("deathchests:deathchest_side");
|
|
||||||
icons[4] = register.registerIcon("deathchests:deathchest_side");
|
|
||||||
icons[5] = register.registerIcon("deathchests:deathchest_side");
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public IIcon getIcon(int side, int meta) {
|
|
||||||
return icons[side];
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public boolean isOpaqueCube() {
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public boolean renderAsNormalBlock() {
|
|
||||||
return true;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -90,24 +55,21 @@ public class BlockDeathChest extends BlockContainer {
|
||||||
public boolean onBlockActivated(World world, int x, int y, int z, EntityPlayer player, int p_149727_6_, float p_149727_7_, float p_149727_8_, float p_149727_9_) {
|
public boolean onBlockActivated(World world, int x, int y, int z, EntityPlayer player, int p_149727_6_, float p_149727_7_, float p_149727_8_, float p_149727_9_) {
|
||||||
if (world.isRemote) return true;
|
if (world.isRemote) return true;
|
||||||
|
|
||||||
TileDeathChest tileDeathChest = (TileDeathChest) world.getTileEntity(x, y, z);
|
TileDeathChest tiledeathchest = (TileDeathChest) world.getTileEntity(x, y, z);
|
||||||
if (tileDeathChest != null) {
|
if (tiledeathchest != null) {
|
||||||
tileDeathChest.requestItems(player);
|
//TODO: check if appropriate player
|
||||||
|
//TODO: drop items
|
||||||
return true;
|
return true;
|
||||||
} else return true;
|
} else return true;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Called when a player hits the block. Args: world, x, y, z, player
|
* Called when a player hits the block. Args: world, x, y, z, player
|
||||||
*/
|
*/
|
||||||
@Override
|
@Override
|
||||||
public void onBlockClicked(World world, int x, int y, int z, EntityPlayer player) {
|
public void onBlockClicked(World p_149699_1_, int p_149699_2_, int p_149699_3_, int p_149699_4_, EntityPlayer p_149699_5_) {
|
||||||
if (world.isRemote) return;
|
//TODO
|
||||||
|
|
||||||
TileDeathChest tileDeathChest = (TileDeathChest) world.getTileEntity(x, y, z);
|
|
||||||
if (tileDeathChest != null) {
|
|
||||||
tileDeathChest.requestItems(player);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -119,57 +81,35 @@ public class BlockDeathChest extends BlockContainer {
|
||||||
return new TileDeathChest();
|
return new TileDeathChest();
|
||||||
}
|
}
|
||||||
|
|
||||||
public static class TileDeathChest extends TileEntity {
|
/**
|
||||||
|
* A randomly called display update to be able to add particles or other items
|
||||||
private ArrayList<ItemStack> containedItems = new ArrayList<>();
|
* for display
|
||||||
public UUID owner = null;
|
* <br />
|
||||||
|
* <br/>
|
||||||
public void requestItems(EntityPlayer player) {
|
* This is here to disable the particles that would otherwise be emitted
|
||||||
if (player.getGameProfile().getId() == owner || Config.allowOtherPlayers) {
|
*/
|
||||||
this.worldObj.setBlockToAir(this.xCoord, this.yCoord, this.zCoord);
|
@Override
|
||||||
for (int i = 0; i < containedItems.size(); i++) {
|
@SideOnly(Side.CLIENT)
|
||||||
this.worldObj.spawnEntityInWorld(new EntityItem(this.worldObj, xCoord, yCoord, zCoord, containedItems.get(i)));
|
public void randomDisplayTick(World p_149734_1_, int p_149734_2_, int p_149734_3_, int p_149734_4_, Random p_149734_5_) {
|
||||||
}
|
|
||||||
} else {
|
|
||||||
player.addChatMessage(new ChatComponentText(Config.notAllowedMessage));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
public void addItemStack(ItemStack itemStack) {
|
|
||||||
containedItems.add(itemStack);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void readFromNBT(NBTTagCompound compound) {
|
|
||||||
Debug.out("Loading death chest from disk");
|
|
||||||
super.readFromNBT(compound);
|
|
||||||
containedItems = new ArrayList<>();
|
|
||||||
|
|
||||||
NBTTagList stacks = (NBTTagList) compound.getTag("stored_items");
|
|
||||||
for (int i = 0; i < stacks.tagCount(); i++) {
|
|
||||||
ItemStack stack = ItemStack.loadItemStackFromNBT(stacks.getCompoundTagAt(i));
|
|
||||||
Debug.out(stack.getDisplayName());
|
|
||||||
containedItems.add(stack);
|
|
||||||
}
|
|
||||||
|
|
||||||
Debug.out("--");
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void writeToNBT(NBTTagCompound compound) {
|
|
||||||
Debug.out("Writing death chest to disk");
|
|
||||||
super.writeToNBT(compound);
|
|
||||||
|
|
||||||
NBTTagList stacks = new NBTTagList();
|
|
||||||
|
|
||||||
for (int i = 0; i < containedItems.size(); i++) {
|
|
||||||
NBTTagCompound itemStackCompound = new NBTTagCompound();
|
|
||||||
containedItems.get(i).writeToNBT(itemStackCompound);
|
|
||||||
stacks.appendTag(itemStackCompound);
|
|
||||||
}
|
|
||||||
|
|
||||||
compound.setTag("stored_items", stacks);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
@SideOnly(Side.CLIENT)
|
||||||
|
public void registerBlockIcons(IIconRegister p_149651_1_) {
|
||||||
|
this.blockIcon = p_149651_1_.registerIcon("cobblestone");
|
||||||
|
}
|
||||||
|
|
||||||
|
public static class TileDeathChest extends TileEntity {
|
||||||
|
//TODO
|
||||||
|
}
|
||||||
|
|
||||||
|
//TODO: Custom texture? (optional)
|
||||||
|
//TODO: add chest inventory
|
||||||
|
//TODO: drop chest contents
|
||||||
|
//TODO: Remove chest when empty
|
||||||
|
//TODO: make unable to break by explosion (configurable?)
|
||||||
|
|
||||||
|
//TODO: Make it so items can only be taken out of the chest?
|
||||||
|
// Custom GUI? Maybe remove GUI altogether and have it drop the items when broken?
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,14 +1,6 @@
|
||||||
package lostcave.deathchests.item;
|
package lostcave.deathchests.item;
|
||||||
|
|
||||||
import java.util.List;
|
|
||||||
|
|
||||||
import lostcave.deathchests.util.Config;
|
|
||||||
import net.minecraft.entity.player.EntityPlayer;
|
|
||||||
import net.minecraft.item.Item;
|
import net.minecraft.item.Item;
|
||||||
import net.minecraft.item.ItemStack;
|
|
||||||
import net.minecraft.nbt.NBTTagCompound;
|
|
||||||
import net.minecraft.util.ChatComponentText;
|
|
||||||
import net.minecraft.world.World;
|
|
||||||
|
|
||||||
public class ItemObituary extends Item {
|
public class ItemObituary extends Item {
|
||||||
|
|
||||||
|
@ -21,28 +13,9 @@ public class ItemObituary extends Item {
|
||||||
private ItemObituary() {
|
private ItemObituary() {
|
||||||
this.setUnlocalizedName("obituary");
|
this.setUnlocalizedName("obituary");
|
||||||
this.setTextureName("paper");
|
this.setTextureName("paper");
|
||||||
this.setMaxStackSize(1);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public ItemStack onItemRightClick(ItemStack stack, World world, EntityPlayer player) {
|
|
||||||
if (world.isRemote) return stack;
|
|
||||||
|
|
||||||
String chatMessage = "§4Error: Missing data";
|
|
||||||
if (stack.hasTagCompound()) {
|
|
||||||
NBTTagCompound compound = stack.getTagCompound();
|
|
||||||
if (compound.hasKey("message")) {
|
|
||||||
chatMessage = compound.getString("message");
|
|
||||||
}
|
|
||||||
}
|
|
||||||
player.addChatMessage(new ChatComponentText(chatMessage));
|
|
||||||
|
|
||||||
return stack;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
//TODO: NBT data
|
||||||
|
//TODO: right click action
|
||||||
//TODO: item description
|
//TODO: item description
|
||||||
@Override
|
|
||||||
public void addInformation(ItemStack stack, EntityPlayer player, List lores, boolean bool) {
|
|
||||||
lores.add("Right-click me!");
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -15,13 +15,8 @@ public class Config {
|
||||||
public static boolean debug = true;
|
public static boolean debug = true;
|
||||||
public static boolean fixLog4J = true;
|
public static boolean fixLog4J = true;
|
||||||
public static int maxDistance = 50;
|
public static int maxDistance = 50;
|
||||||
public static boolean allowOtherPlayers = true;
|
|
||||||
public static String notAllowedMessage = "§4Cannot get items from another player's death chest.";
|
|
||||||
public static boolean giveObituary = true;
|
|
||||||
public static String dropMessage = "§4A death chest could not be placed for this death. Your items have been dropped.";
|
|
||||||
public static String locationMessage = "§eThe death chest for this death is at %s in dimension %s.";
|
|
||||||
|
|
||||||
private static final String config_header = "# The format of this file is strictly `option=value` (no spaces).\n# Lines starting with # and empty lines are ignored.";
|
private static final String config_header = "# The format of this file is strictly `option=value` (no spaces).\n# Lines starting with # and empty lines are ignored.\n";
|
||||||
|
|
||||||
public static void writeConfig() {
|
public static void writeConfig() {
|
||||||
String configOut = config_header;
|
String configOut = config_header;
|
||||||
|
@ -34,21 +29,6 @@ public class Config {
|
||||||
configOut += "\n\n# The maximum search radius for finding a suitable location for placing the death chest\n";
|
configOut += "\n\n# The maximum search radius for finding a suitable location for placing the death chest\n";
|
||||||
configOut += "maxDistance=";
|
configOut += "maxDistance=";
|
||||||
configOut += Integer.toString(maxDistance);
|
configOut += Integer.toString(maxDistance);
|
||||||
configOut += "\n\n# Allow players other than the owner to get the items?\n";
|
|
||||||
configOut += "allowOtherPlayers=";
|
|
||||||
configOut += allowOtherPlayers ? "true" : "false";
|
|
||||||
configOut += "\n\n# The message to display when trying to get items from another player's death chest and allowOtherPlayers=false";
|
|
||||||
configOut += "notAllowedMessage=";
|
|
||||||
configOut += notAllowedMessage;
|
|
||||||
configOut += "\n\n# Whether to give respawning players an obituary item\n";
|
|
||||||
configOut += "giveObituary=";
|
|
||||||
configOut += giveObituary ? "true" : "false";
|
|
||||||
configOut += "\n\n# The message to display when no suitable location for a death chest could be found and the items have been dropped";
|
|
||||||
configOut += "dropMessage=";
|
|
||||||
configOut += dropMessage;
|
|
||||||
configOut += "\n\n# The message to display when no suitable location for a death chest could be found and the items have been dropped";
|
|
||||||
configOut += "locationMessage=";
|
|
||||||
configOut += locationMessage;
|
|
||||||
|
|
||||||
File configFile = new File(configDir, config_file_name);
|
File configFile = new File(configDir, config_file_name);
|
||||||
try {
|
try {
|
||||||
|
@ -82,26 +62,6 @@ public class Config {
|
||||||
maxDistance = Integer.parseInt(configData.get(i).substring(equalsSign + 1));
|
maxDistance = Integer.parseInt(configData.get(i).substring(equalsSign + 1));
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
case ("allowOtherPlayers"): {
|
|
||||||
allowOtherPlayers = configData.get(i).substring(equalsSign + 1).equals("true") ? true : false;
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
case ("notAllowedMessage"): {
|
|
||||||
notAllowedMessage = configData.get(i).substring(equalsSign+1);
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
case ("giveObituary"): {
|
|
||||||
giveObituary = configData.get(i).substring(equalsSign + 1).equals("true") ? true : false;
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
case ("dropMessage"): {
|
|
||||||
dropMessage = configData.get(i).substring(equalsSign+1);
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
case ("locationMessage"): {
|
|
||||||
locationMessage = configData.get(i).substring(equalsSign+1);
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
default: {
|
default: {
|
||||||
System.err.println("Failed parsing config entry: " + configData.get(i));
|
System.err.println("Failed parsing config entry: " + configData.get(i));
|
||||||
FMLCommonHandler.instance().exitJava(1, false);
|
FMLCommonHandler.instance().exitJava(1, false);
|
||||||
|
|
Binary file not shown.
Before Width: | Height: | Size: 757 B |
Binary file not shown.
Before Width: | Height: | Size: 753 B |
Loading…
Reference in New Issue