diff --git a/README.md b/README.md index 77e4714e3..7e1ce9b38 100644 --- a/README.md +++ b/README.md @@ -16,3 +16,5 @@ ## Key and Locks Hold the **Shift** key while using a key or a lock on a chest in order to use it. + +## Read the [documentation](https://github.com/gottsch/gottsch-minecraft-Treasure/wiki) diff --git a/build.gradle b/build.gradle index 18cdf59c1..45ad7f70a 100644 --- a/build.gradle +++ b/build.gradle @@ -21,10 +21,10 @@ apply plugin: 'net.minecraftforge.gradle.forge' ext { // Open the Git repository in the parent directory. - git = org.ajoberstar.grgit.Grgit.open(file('../')) +// git = org.ajoberstar.grgit.Grgit.open(file('../')) // Get commit id of HEAD. - revision = git.head().id +// revision = git.head().id // Alternative is using abbreviatedId of head() method. // revision = git.head().abbreviatedId } @@ -53,13 +53,14 @@ sourceSets.main{ srcDirs 'src' //, 'test' //set the source folder as the /src subfolder } resources{ - srcDirs 'src/resources'//set the resources folder as the /resources subfolder + srcDirs 'src/resources' //set the resources folder as the /resources subfolder } } -def gottschcore_path="../../gottsch-minecraft-GottschCore/GottschCore${mc_version}/build/libs/GottschCore-mc${mc_version}-f${forge_version}-v${gottschcore_version}.jar" +def gottschcore_path="../gottsch-minecraft-GottschCore/GottschCore${mc_version}/build/libs/GottschCore-mc${mc_version}-f${forge_version}-v${gottschcore_version}.jar" + dependencies { -compile files('../../ModCommonLibs/libs/commons-cli-1.4.jar') +compile files('../ModCommonLibs/libs/commons-cli-1.4.jar') //compile files(gottschcore_path) shadow files(gottschcore_path) compileOnly "vazkii.patchouli:Patchouli:${patchouli_version}" diff --git a/gradle.properties b/gradle.properties index 4516562cf..48fe4c0d7 100644 --- a/gradle.properties +++ b/gradle.properties @@ -7,13 +7,13 @@ package_group=someguyssoftware.treasure2 # user alpha, beta, or v (for version) mod_version_type=v -mod_version=1.12.0 +mod_version=1.13.0 #versions mc_version=1.12.2 forge_version=14.23.5.2768 mappings_version=snapshot_20171003 -gottschcore_version=1.13.0 +gottschcore_version=1.13.1 patchouli_version=1.0-20.108 # paths diff --git a/src/com/someguyssoftware/treasure2/Treasure.java b/src/com/someguyssoftware/treasure2/Treasure.java index 7d4e38186..fdf4f429f 100644 --- a/src/com/someguyssoftware/treasure2/Treasure.java +++ b/src/com/someguyssoftware/treasure2/Treasure.java @@ -23,7 +23,10 @@ import com.someguyssoftware.treasure2.block.TreasureBlocks; import com.someguyssoftware.treasure2.capability.CharmCapability; import com.someguyssoftware.treasure2.capability.CharmStorage; +import com.someguyssoftware.treasure2.capability.EffectiveMaxDamageCapability; +import com.someguyssoftware.treasure2.capability.EffectiveMaxDamageStorage; import com.someguyssoftware.treasure2.capability.ICharmCapability; +import com.someguyssoftware.treasure2.capability.IEffectiveMaxDamageCapability; import com.someguyssoftware.treasure2.capability.IKeyRingCapability; import com.someguyssoftware.treasure2.capability.KeyRingCapability; import com.someguyssoftware.treasure2.capability.KeyRingStorage; @@ -37,7 +40,8 @@ import com.someguyssoftware.treasure2.command.SpawnWellStructureCommand; import com.someguyssoftware.treasure2.command.SpawnWitherTreeCommand; import com.someguyssoftware.treasure2.config.TreasureConfig; -import com.someguyssoftware.treasure2.enums.WorldGenerators; +import com.someguyssoftware.treasure2.enums.WorldGeneratorType; +import com.someguyssoftware.treasure2.eventhandler.AnvilEventHandler; import com.someguyssoftware.treasure2.eventhandler.LogoutEventHandler; import com.someguyssoftware.treasure2.eventhandler.MimicEventHandler; import com.someguyssoftware.treasure2.eventhandler.PlayerEventHandler; @@ -94,18 +98,19 @@ "Credits to CuddleBeak for some Keys and Locks textures.", "Credits to mn_ti for Chinese and to DarkKnightComes for Polish translation.", "Credits to Mythical Sausage for tutorials on house/tower designs.", - "Credits to OdinsRagnarok for Spanish translation and DarvinSlav for Russian translation." }) + "Credits to OdinsRagnarok for Spanish translation and DarvinSlav for Russian translation.", + "Credits to sfs131010 for updated Chinese translation."}) public class Treasure extends AbstractMod { // constants public static final String MODID = "treasure2"; protected static final String NAME = "Treasure2"; - protected static final String VERSION = "1.12.0"; + protected static final String VERSION = "1.12.2"; - public static final String UPDATE_JSON_URL = "https://raw.githubusercontent.com/gottsch/gottsch-minecraft-Treasure/master/Treasure2-1.12.2/update.json"; + public static final String UPDATE_JSON_URL = "https://raw.githubusercontent.com/gottsch/gottsch-minecraft-Treasure/master/update.json"; private static final String VERSION_URL = ""; - private static final BuildVersion MINECRAFT_VERSION = new BuildVersion(1, 12, 2); + private static final BuildVersion MINECRAFT_VERSION = new BuildVersion(1, 13, 0); // latest version private static BuildVersion latestVersion; @@ -133,7 +138,7 @@ public ItemStack getTabIconItem() { }; // forge world generators - public final static Map WORLD_GENERATORS = new HashMap<>(); + public final static Map WORLD_GENERATORS = new HashMap<>(); // template manager public static TreasureTemplateManager TEMPLATE_MANAGER; @@ -162,13 +167,14 @@ public void preInt(FMLPreInitializationEvent event) { super.preInt(event); // initialize/reload the config - ((TreasureConfig) getConfig()).init(); + TreasureConfig.init(); // register additional events MinecraftForge.EVENT_BUS.register(new LogoutEventHandler(getInstance())); MinecraftForge.EVENT_BUS.register(new PlayerEventHandler(getInstance())); MinecraftForge.EVENT_BUS.register(new WorldEventHandler(getInstance())); - MinecraftForge.EVENT_BUS.register(new MimicEventHandler(getInstance())); + MinecraftForge.EVENT_BUS.register(new MimicEventHandler(getInstance())); + MinecraftForge.EVENT_BUS.register(new AnvilEventHandler(getInstance())); // configure logging // create a rolling file appender @@ -194,6 +200,7 @@ public void preInt(FMLPreInitializationEvent event) { // add capabilities CapabilityManager.INSTANCE.register(ICharmCapability.class, new CharmStorage(), CharmCapability::new); CapabilityManager.INSTANCE.register(IKeyRingCapability.class, new KeyRingStorage(), KeyRingCapability::new); + CapabilityManager.INSTANCE.register(IEffectiveMaxDamageCapability.class, new EffectiveMaxDamageStorage(), EffectiveMaxDamageCapability::new); // register custom loot functions LootFunctionManager.registerFunction(new CharmRandomly.Serializer()); @@ -238,15 +245,15 @@ public void init(FMLInitializationEvent event) { super.init(event); // register world generators - WORLD_GENERATORS.put(WorldGenerators.SURFACE_CHEST, new SurfaceChestWorldGenerator()); - WORLD_GENERATORS.put(WorldGenerators.SUBMERGED_CHEST, new SubmergedChestWorldGenerator()); - WORLD_GENERATORS.put(WorldGenerators.WELL, new WellWorldGenerator()); - WORLD_GENERATORS.put(WorldGenerators.WITHER_TREE, new WitherTreeWorldGenerator()); - WORLD_GENERATORS.put(WorldGenerators.GEM, new GemOreWorldGenerator()); - WORLD_GENERATORS.put(WorldGenerators.OASIS, new OasisWorldGenerator()); + WORLD_GENERATORS.put(WorldGeneratorType.SURFACE_CHEST, new SurfaceChestWorldGenerator()); + WORLD_GENERATORS.put(WorldGeneratorType.SUBMERGED_CHEST, new SubmergedChestWorldGenerator()); + WORLD_GENERATORS.put(WorldGeneratorType.WELL, new WellWorldGenerator()); + WORLD_GENERATORS.put(WorldGeneratorType.WITHER_TREE, new WitherTreeWorldGenerator()); + WORLD_GENERATORS.put(WorldGeneratorType.GEM, new GemOreWorldGenerator()); + WORLD_GENERATORS.put(WorldGeneratorType.OASIS, new OasisWorldGenerator()); int genWeight = 0; - for (Entry gen : WORLD_GENERATORS.entrySet()) { + for (Entry gen : WORLD_GENERATORS.entrySet()) { GameRegistry.registerWorldGenerator(gen.getValue(), genWeight++); } diff --git a/src/com/someguyssoftware/treasure2/block/AbstractChestBlock.java b/src/com/someguyssoftware/treasure2/block/AbstractChestBlock.java index 55984b489..adca73d0a 100644 --- a/src/com/someguyssoftware/treasure2/block/AbstractChestBlock.java +++ b/src/com/someguyssoftware/treasure2/block/AbstractChestBlock.java @@ -13,7 +13,7 @@ import com.someguyssoftware.treasure2.chest.TreasureChestType; import com.someguyssoftware.treasure2.enums.Rarity; import com.someguyssoftware.treasure2.lock.LockState; -import com.someguyssoftware.treasure2.tileentity.AbstractTreasureChestTileEntity; +import com.someguyssoftware.treasure2.tileentity.ITreasureChestTileEntity; import net.minecraft.block.material.Material; import net.minecraft.block.properties.IProperty; @@ -48,7 +48,7 @@ public abstract class AbstractChestBlock extends AbstractModContainerBlock imple /* * the concrete object of the tile entity */ - private AbstractTreasureChestTileEntity tileEntity; + private ITreasureChestTileEntity tileEntity; /* * the type of chest @@ -68,7 +68,7 @@ public abstract class AbstractChestBlock extends AbstractModContainerBlock imple /** * */ - public AbstractChestBlock(String modID, String name, Material material, Class te, TreasureChestType type, Rarity rarity) { + public AbstractChestBlock(String modID, String name, Material material, Class te, TreasureChestType type, Rarity rarity) { this(modID, name, material); setTileEntityClass(te); setChestType(type); @@ -85,10 +85,10 @@ public AbstractChestBlock(String modID, String name, Material material, Class lockStates = new LinkedList<>(); @@ -126,7 +126,7 @@ public TileEntity createNewTileEntity(World worldIn, int meta) { catch(Exception e) { e.printStackTrace(); } - return chestTileEntity; + return (TileEntity) chestTileEntity; } /** @@ -178,11 +178,11 @@ public boolean rotateLockStates(World world, BlockPos pos, Rotate rotate) { if (rotate != Rotate.NO_ROTATE) shouldRotate = true; // Treasure.logger.debug("Rotate to:" + rotate); - AbstractTreasureChestTileEntity tcte = null; + ITreasureChestTileEntity tcte = null; TileEntity te = world.getTileEntity(pos); - if (te != null && te instanceof AbstractTreasureChestTileEntity) { + if (te != null && te instanceof ITreasureChestTileEntity) { // get the backing tile entity - tcte = (AbstractTreasureChestTileEntity) te; + tcte = (ITreasureChestTileEntity) te; } else { return false; @@ -304,14 +304,14 @@ public void setTileEntityClass(Class tileEntityClass) { /** * @return the tileEntity */ - public AbstractTreasureChestTileEntity getTileEntity() { + public ITreasureChestTileEntity getTileEntity() { return tileEntity; } /** * @param tileEntity the tileEntity to set */ - public AbstractChestBlock setTileEntity(AbstractTreasureChestTileEntity tileEntity) { + public AbstractChestBlock setTileEntity(ITreasureChestTileEntity tileEntity) { this.tileEntity = tileEntity; return this; } diff --git a/src/com/someguyssoftware/treasure2/block/BlackstoneBlock.java b/src/com/someguyssoftware/treasure2/block/BlackstoneBlock.java new file mode 100644 index 000000000..01f711906 --- /dev/null +++ b/src/com/someguyssoftware/treasure2/block/BlackstoneBlock.java @@ -0,0 +1,52 @@ +/** + * + */ +package com.someguyssoftware.treasure2.block; + +import java.util.Random; + +import net.minecraft.block.Block; +import net.minecraft.block.SoundType; +import net.minecraft.block.material.Material; +import net.minecraft.block.state.IBlockState; +import net.minecraft.entity.item.EntityItem; +import net.minecraft.entity.player.EntityPlayer; +import net.minecraft.init.Blocks; +import net.minecraft.init.Items; +import net.minecraft.inventory.IInventory; +import net.minecraft.item.Item; +import net.minecraft.item.ItemStack; +import net.minecraft.util.EnumFacing; +import net.minecraft.util.math.AxisAlignedBB; +import net.minecraft.world.World; + +import org.apache.logging.log4j.LogManager; +import org.apache.logging.log4j.Logger; + +import com.someguyssoftware.gottschcore.block.ModBlock; +import com.someguyssoftware.treasure2.Treasure; + +/** + * + * @author Mark Gottschling on Sep 8, 2020 + * + */ +public class BlackstoneBlock extends ModBlock implements IWishingWellBlock { + public static Logger logger = LogManager.getLogger(BlackstoneBlock.class); + + /** + * + * @param material + */ + public BlackstoneBlock(String modID, String name) { + super(modID, name, Material.ROCK); + setSoundType(SoundType.STONE); + setCreativeTab(Treasure.TREASURE_TAB); + this.setHardness(3.0F); + } + + @Override + public Item getItemDropped(IBlockState state, Random rand, int fortune) { + return Item.getItemFromBlock(TreasureBlocks.BLACKSTONE); + } +} diff --git a/src/com/someguyssoftware/treasure2/block/TreasureBlocks.java b/src/com/someguyssoftware/treasure2/block/TreasureBlocks.java index 2a0f12148..f35fb37ec 100644 --- a/src/com/someguyssoftware/treasure2/block/TreasureBlocks.java +++ b/src/com/someguyssoftware/treasure2/block/TreasureBlocks.java @@ -13,6 +13,7 @@ import com.google.common.base.Preconditions; import com.google.common.collect.ArrayListMultimap; import com.google.common.collect.Multimap; +import com.someguyssoftware.gottschcore.block.ModBlock; import com.someguyssoftware.treasure2.Treasure; import com.someguyssoftware.treasure2.chest.TreasureChestTypes; import com.someguyssoftware.treasure2.client.gui.GuiHandler; @@ -165,6 +166,7 @@ public class TreasureBlocks { public static final Block FALLING_GRASS; public static final Block FALLING_SAND; public static final Block FALLING_RED_SAND; + public static final Block BLACKSTONE; // treasures: paintings public static final AbstractPaintingBlock PAINTING_BLOCKS_BRICKS; @@ -492,6 +494,7 @@ public class TreasureBlocks { FALLING_GRASS = new FallingGrassBlock(Treasure.MODID, TreasureConfig.FALLING_GRASS_ID); FALLING_SAND = new FallingSandBlock(Treasure.MODID, TreasureConfig.FALLING_SAND_ID); FALLING_RED_SAND = new FallingRedSandBlock(Treasure.MODID, TreasureConfig.FALLING_RED_SAND_ID); + BLACKSTONE = new BlackstoneBlock(Treasure.MODID, TreasureConfig.BLACKSTONE_ID); // treasures: paintings AxisAlignedBB[] pbs = new AxisAlignedBB[4]; @@ -563,7 +566,8 @@ public static void registerBlocks(final RegistryEvent.Register event) { PAINTING_BLOCKS_WOOD, SAPPHIRE_ORE, RUBY_ORE, FALLING_GRASS, FALLING_SAND, - FALLING_RED_SAND + FALLING_RED_SAND, + BLACKSTONE }; registry.registerAll(blocks); @@ -626,7 +630,8 @@ public static void registerItemBlocks(final RegistryEvent.Register event) new ItemBlock(PROXIMITY_SPAWNER), new ItemBlock(FALLING_GRASS), new ItemBlock(FALLING_SAND), - new ItemBlock(FALLING_RED_SAND) + new ItemBlock(FALLING_RED_SAND), + new ItemBlock(BLACKSTONE) }; for (final ItemBlock item : items) { diff --git a/src/com/someguyssoftware/treasure2/block/TreasureChestBlock.java b/src/com/someguyssoftware/treasure2/block/TreasureChestBlock.java index 988e899d4..8181bbdf2 100644 --- a/src/com/someguyssoftware/treasure2/block/TreasureChestBlock.java +++ b/src/com/someguyssoftware/treasure2/block/TreasureChestBlock.java @@ -22,6 +22,7 @@ import com.someguyssoftware.treasure2.enums.Rarity; import com.someguyssoftware.treasure2.printer.ChestNBTPrettyPrinter; import com.someguyssoftware.treasure2.tileentity.AbstractTreasureChestTileEntity; +import com.someguyssoftware.treasure2.tileentity.ITreasureChestTileEntity; import net.minecraft.block.material.Material; import net.minecraft.block.state.IBlockState; @@ -56,7 +57,7 @@ public class TreasureChestBlock extends AbstractChestBlock { * @param te * @param type */ - public TreasureChestBlock(String modID, String name, Class te, + public TreasureChestBlock(String modID, String name, Class te, TreasureChestType type, Rarity rarity) { this(modID, name, Material.WOOD, te, type, rarity); } @@ -70,7 +71,7 @@ public TreasureChestBlock(String modID, String name, Class te, TreasureChestType type, Rarity rarity) { + Class te, TreasureChestType type, Rarity rarity) { super(modID, name, material, te, type, rarity); } @@ -120,7 +121,7 @@ public void onBlockPlacedBy(World worldIn, BlockPos pos, IBlockState state, Enti oldPersistedChestDirection = Direction.fromFacing(EnumFacing.getFront(tcte.getFacing())); // dump stack NBT - if (Treasure.logger.isDebugEnabled()) { + if (Treasure.logger.isDebugEnabled() && WorldInfo.isServerSide(worldIn)) { dump(stack.getTagCompound(), new Coords(pos), "STACK ITEM -> CHEST NBT"); } } diff --git a/src/com/someguyssoftware/treasure2/capability/EffectiveMaxDamageCapability.java b/src/com/someguyssoftware/treasure2/capability/EffectiveMaxDamageCapability.java new file mode 100644 index 000000000..8accfa1b9 --- /dev/null +++ b/src/com/someguyssoftware/treasure2/capability/EffectiveMaxDamageCapability.java @@ -0,0 +1,34 @@ +/** + * + */ +package com.someguyssoftware.treasure2.capability; + +/** + * @author Mark Gottschling on Sep 6, 2020 + * + */ +public class EffectiveMaxDamageCapability implements IEffectiveMaxDamageCapability { + private int effectiveMaxDamage; + + /** + * + */ + public EffectiveMaxDamageCapability() { + + } + + @Override + public int getEffectiveMaxDamage() { + return effectiveMaxDamage; + } + + @Override + public void setEffectiveMaxDamage(int maxDamage) { + if (maxDamage > IEffectiveMaxDamageCapability.EFFECTIVE_MAX_DAMAGE_MAX) { + this.effectiveMaxDamage = IEffectiveMaxDamageCapability.EFFECTIVE_MAX_DAMAGE_MAX; + } + else { + this.effectiveMaxDamage = maxDamage; + } + } +} diff --git a/src/com/someguyssoftware/treasure2/capability/EffectiveMaxDamageCapabilityProvider.java b/src/com/someguyssoftware/treasure2/capability/EffectiveMaxDamageCapabilityProvider.java new file mode 100644 index 000000000..345d5b3ba --- /dev/null +++ b/src/com/someguyssoftware/treasure2/capability/EffectiveMaxDamageCapabilityProvider.java @@ -0,0 +1,59 @@ +/** + * + */ +package com.someguyssoftware.treasure2.capability; + +import net.minecraft.nbt.NBTTagCompound; +import net.minecraft.util.EnumFacing; +import net.minecraftforge.common.capabilities.Capability; +import net.minecraftforge.common.capabilities.CapabilityInject; +import net.minecraftforge.common.capabilities.ICapabilityProvider; +import net.minecraftforge.common.capabilities.ICapabilitySerializable; + +/** + * @author Mark Gottschling on Sep 6, 2020 + * + */ +public class EffectiveMaxDamageCapabilityProvider implements ICapabilityProvider, ICapabilitySerializable { + + /* + * NOTE Ensure to use interfaces in @CapabilityInject, the static capability and in the instance. + */ + @CapabilityInject(IEffectiveMaxDamageCapability.class) + public static Capability EFFECTIVE_MAX_DAMAGE_CAPABILITY = null; + private final EffectiveMaxDamageCapability instance = new EffectiveMaxDamageCapability(); + + /** + * + */ + @Override + public NBTTagCompound serializeNBT() { + NBTTagCompound tag = (NBTTagCompound)EFFECTIVE_MAX_DAMAGE_CAPABILITY.getStorage().writeNBT(EFFECTIVE_MAX_DAMAGE_CAPABILITY, instance, null); + return tag; + } + + /** + * + */ + @Override + public void deserializeNBT(NBTTagCompound nbt) { + EFFECTIVE_MAX_DAMAGE_CAPABILITY.getStorage().readNBT(EFFECTIVE_MAX_DAMAGE_CAPABILITY, this.instance, null, nbt); + } + + @Override + public boolean hasCapability(Capability capability, EnumFacing facing) { + if (capability == EFFECTIVE_MAX_DAMAGE_CAPABILITY) { + return true; + } + return false; + } + + @SuppressWarnings("unchecked") + @Override + public T getCapability(Capability capability, EnumFacing facing) { + if (capability == EFFECTIVE_MAX_DAMAGE_CAPABILITY) { + return EFFECTIVE_MAX_DAMAGE_CAPABILITY.cast(this.instance); + } + return null; + } +} diff --git a/src/com/someguyssoftware/treasure2/capability/EffectiveMaxDamageStorage.java b/src/com/someguyssoftware/treasure2/capability/EffectiveMaxDamageStorage.java new file mode 100644 index 000000000..6b5a891d2 --- /dev/null +++ b/src/com/someguyssoftware/treasure2/capability/EffectiveMaxDamageStorage.java @@ -0,0 +1,43 @@ +/** + * + */ +package com.someguyssoftware.treasure2.capability; + +import static com.someguyssoftware.treasure2.Treasure.logger; + +import com.someguyssoftware.treasure2.Treasure; + +import net.minecraft.nbt.NBTBase; +import net.minecraft.nbt.NBTTagCompound; +import net.minecraft.util.EnumFacing; +import net.minecraftforge.common.capabilities.Capability; + +/** + * @author Mark Gottschling on Sep 6, 2020 + * + */ +public class EffectiveMaxDamageStorage implements Capability.IStorage { + private static final String EFFECTIVE_MAX_DAMAGE_TAG = "effectiveMaxDamage"; + + @Override + public NBTBase writeNBT(Capability capability, IEffectiveMaxDamageCapability instance, EnumFacing side) { + NBTTagCompound mainTag = new NBTTagCompound(); + try { + mainTag.setInteger(EFFECTIVE_MAX_DAMAGE_TAG, instance.getEffectiveMaxDamage()); + } catch (Exception e) { + logger.error("Unable to write state to NBT:", e); + } + return mainTag; + } + + @Override + public void readNBT(Capability capability, IEffectiveMaxDamageCapability instance, EnumFacing side, + NBTBase nbt) { + if (nbt instanceof NBTTagCompound) { + NBTTagCompound tag = (NBTTagCompound) nbt; + if (tag.hasKey(EFFECTIVE_MAX_DAMAGE_TAG)) { + instance.setEffectiveMaxDamage(tag.getInteger(EFFECTIVE_MAX_DAMAGE_TAG)); + } + } + } +} diff --git a/src/com/someguyssoftware/treasure2/capability/IEffectiveMaxDamageCapability.java b/src/com/someguyssoftware/treasure2/capability/IEffectiveMaxDamageCapability.java new file mode 100644 index 000000000..382c595ac --- /dev/null +++ b/src/com/someguyssoftware/treasure2/capability/IEffectiveMaxDamageCapability.java @@ -0,0 +1,14 @@ +package com.someguyssoftware.treasure2.capability; + +/** + * + * @author Mark Gottschling on Sep 6, 2020 + * + */ +public interface IEffectiveMaxDamageCapability { + public static final int EFFECTIVE_MAX_DAMAGE_MAX = 1000; + + public int getEffectiveMaxDamage(); + + public void setEffectiveMaxDamage(int damage); +} \ No newline at end of file diff --git a/src/com/someguyssoftware/treasure2/capability/PouchCapabilityProvider.java b/src/com/someguyssoftware/treasure2/capability/PouchCapabilityProvider.java index f67af0bc8..b6979706e 100644 --- a/src/com/someguyssoftware/treasure2/capability/PouchCapabilityProvider.java +++ b/src/com/someguyssoftware/treasure2/capability/PouchCapabilityProvider.java @@ -3,7 +3,7 @@ */ package com.someguyssoftware.treasure2.capability; -import com.someguyssoftware.treasure2.inventory.KeyRingInventory; +import com.someguyssoftware.treasure2.inventory.PouchInventory; import net.minecraft.nbt.NBTTagCompound; import net.minecraft.util.EnumFacing; @@ -27,7 +27,7 @@ public class PouchCapabilityProvider implements ICapabilityProvider, ICapability */ @CapabilityInject(IItemHandler.class) public static Capability INVENTORY_CAPABILITY = null; - private final ItemStackHandler inventory_instance = new ItemStackHandler(KeyRingInventory.INVENTORY_SIZE); + private final ItemStackHandler inventory_instance = new ItemStackHandler(PouchInventory.INVENTORY_SIZE); /** * diff --git a/src/com/someguyssoftware/treasure2/client/gui/GuiHandler.java b/src/com/someguyssoftware/treasure2/client/gui/GuiHandler.java index 7577fa44e..1f502d69b 100644 --- a/src/com/someguyssoftware/treasure2/client/gui/GuiHandler.java +++ b/src/com/someguyssoftware/treasure2/client/gui/GuiHandler.java @@ -3,6 +3,13 @@ */ package com.someguyssoftware.treasure2.client.gui; +import static com.someguyssoftware.treasure2.Treasure.logger; + +import java.util.Random; +import java.util.function.Supplier; + +import com.someguyssoftware.gottschcore.loot.LootContext; +import com.someguyssoftware.gottschcore.loot.LootTable; import com.someguyssoftware.treasure2.Treasure; import com.someguyssoftware.treasure2.client.gui.inventory.CompressorChestGui; import com.someguyssoftware.treasure2.client.gui.inventory.KeyRingGui; @@ -12,6 +19,7 @@ import com.someguyssoftware.treasure2.client.gui.inventory.StandardChestGui; import com.someguyssoftware.treasure2.client.gui.inventory.StrongboxChestGui; import com.someguyssoftware.treasure2.client.gui.inventory.WitherChestGui; +import com.someguyssoftware.treasure2.generator.chest.IChestGenerator; import com.someguyssoftware.treasure2.inventory.CompressorChestContainer; import com.someguyssoftware.treasure2.inventory.KeyRingContainer; import com.someguyssoftware.treasure2.inventory.KeyRingInventory; @@ -25,27 +33,25 @@ import com.someguyssoftware.treasure2.item.IPouch; import com.someguyssoftware.treasure2.item.KeyRingItem; import com.someguyssoftware.treasure2.item.PouchItem; -import com.someguyssoftware.treasure2.item.TreasureItems; -import com.someguyssoftware.treasure2.tileentity.AbstractTreasureChestTileEntity; +import com.someguyssoftware.treasure2.tileentity.ITreasureChestTileEntity; +import net.minecraft.client.gui.inventory.GuiContainer; import net.minecraft.entity.player.EntityPlayer; +import net.minecraft.inventory.Container; import net.minecraft.inventory.IInventory; import net.minecraft.item.ItemStack; import net.minecraft.tileentity.TileEntity; import net.minecraft.util.math.BlockPos; import net.minecraft.world.World; +import net.minecraft.world.WorldServer; import net.minecraftforge.fml.common.network.IGuiHandler; -/** - - * - */ /** * @author Mark Gottschling on Jan 16, 2018 * - * This class is used to get the client and server gui elements when a - * player opens a gui. There can only be one registered IGuiHandler - * instance handler per mod. + * This class is used to get the client and server gui elements when a + * player opens a gui. There can only be one registered IGuiHandler + * instance handler per mod. */ public class GuiHandler implements IGuiHandler { public static final int STANDARD_CHEST_GUIID = 1; @@ -68,39 +74,57 @@ public class GuiHandler implements IGuiHandler { */ @Override public Object getServerGuiElement(int ID, EntityPlayer player, World world, int x, int y, int z) { - BlockPos pos = new BlockPos(x, y, z); - TileEntity tileEntity = world.getTileEntity(pos); + TileEntity tileEntity = world.getTileEntity(new BlockPos(x, y, z)); + + if (tileEntity instanceof ITreasureChestTileEntity) { + ITreasureChestTileEntity chestTileEntity = (ITreasureChestTileEntity) tileEntity; +// logger.debug("is chest sealed -> {}", chestTileEntity.isSealed()); + if (chestTileEntity.isSealed()) { + chestTileEntity.setSealed(false); +// logger.debug("chest gen type -> {}", chestTileEntity.getGenerationContext().getChestGeneratorType()); + // construct the chest generator used to create the tile entity + IChestGenerator chestGenerator = chestTileEntity.getGenerationContext().getChestGeneratorType().getChestGenerator(); +// logger.debug("chest gen -> {}", chestTileEntity.getGenerationContext().getChestGeneratorType().getChestGenerator().getClass().getSimpleName()); + + // select a loot table + LootTable lootTable = chestGenerator.selectLootTable(Random::new, chestTileEntity.getGenerationContext().getLootRarity()); + if (lootTable == null) { + logger.warn("Unable to select a lootTable."); + return null; + } + logger.debug("Generating loot from loot table for rarity {}", chestTileEntity.getGenerationContext().getLootRarity()); + LootContext lootContext = new LootContext.Builder((WorldServer) world, Treasure.LOOT_TABLES.getLootTableManager()) + .withLuck(player.getLuck()) + .withPlayer(player) + .build(); + if (lootContext == null) { + lootContext = Treasure.LOOT_TABLES.getContext(); + } + lootTable.fillInventory((IInventory) tileEntity, new Random(), lootContext); + + // TODO future IChestGenerator.addSpecialLoot(world, random, chestTileEntity); + } + } + Container container = null; switch (ID) { case STANDARD_CHEST_GUIID: - if (tileEntity instanceof AbstractTreasureChestTileEntity) { - return new StandardChestContainer(player.inventory, (IInventory) tileEntity); - } + container = new StandardChestContainer(player.inventory, (IInventory) tileEntity); break; case STRONGBOX_CHEST_GUIID: - if (tileEntity instanceof AbstractTreasureChestTileEntity) { - return new StrongboxChestContainer(player.inventory, (IInventory) tileEntity); - } + container = new StrongboxChestContainer(player.inventory, (IInventory) tileEntity); break; case COMPRESSOR_CHEST_GUIID: - if (tileEntity instanceof AbstractTreasureChestTileEntity) { - return new CompressorChestContainer(player.inventory, (IInventory) tileEntity); - } + container = new CompressorChestContainer(player.inventory, (IInventory) tileEntity); break; case SKULL_CHEST_GUIID: - if (tileEntity instanceof AbstractTreasureChestTileEntity) { - return new SkullChestContainer(player.inventory, (IInventory) tileEntity); - } + container = new SkullChestContainer(player.inventory, (IInventory) tileEntity); break; case WITHER_CHEST_GUIID: - if (tileEntity instanceof AbstractTreasureChestTileEntity) { - return new WitherChestContainer(player.inventory, (IInventory) tileEntity); - } + container = new WitherChestContainer(player.inventory, (IInventory) tileEntity); break; case MOLLUSCS_CHEST_GUIID: - if (tileEntity instanceof AbstractTreasureChestTileEntity) { - return new MolluscChestContainer(player.inventory, (IInventory) tileEntity); - } + container = new MolluscChestContainer(player.inventory, (IInventory) tileEntity); break; case KEY_RING_GUIID: // get the held item @@ -114,8 +138,8 @@ public Object getServerGuiElement(int ID, EntityPlayer player, World world, int // create inventory from item IInventory inventory = new KeyRingInventory(keyRingItem); // open the container - return new KeyRingContainer(player.inventory, inventory); - + container = new KeyRingContainer(player.inventory, inventory); + break; case POUCH_GUIID: // get the held item ItemStack pouchStack = player.getHeldItemMainhand(); @@ -128,12 +152,12 @@ public Object getServerGuiElement(int ID, EntityPlayer player, World world, int // create inventory from item IInventory pouchInventory = new PouchInventory(pouchStack); // open the container - return new PouchContainer(player.inventory, pouchInventory, pouchStack); - + container = new PouchContainer(player.inventory, pouchInventory, pouchStack); + break; default: - return null; + } - return null; + return container; } /* @@ -146,52 +170,29 @@ public Object getServerGuiElement(int ID, EntityPlayer player, World world, int */ @Override public Object getClientGuiElement(int ID, EntityPlayer player, World world, int x, int y, int z) { - BlockPos xyz = new BlockPos(x, y, z); - TileEntity tileEntity = world.getTileEntity(xyz); + TileEntity tileEntity = world.getTileEntity(new BlockPos(x, y, z)); + ITreasureChestTileEntity chestTileEntity = null; + switch (ID) { case STANDARD_CHEST_GUIID: - if (tileEntity instanceof AbstractTreasureChestTileEntity) { - // NOTE could pass in the different bg textures here - return new StandardChestGui(player.inventory, (AbstractTreasureChestTileEntity) tileEntity); - } else { - Treasure.logger.warn("Umm, GUI handler error - wrong tile entity."); - } - break; + // NOTE could pass in the different bg textures here + if ((chestTileEntity = getChestTileEntity(tileEntity)) == null) return null; + return new StandardChestGui(player.inventory, chestTileEntity); case STRONGBOX_CHEST_GUIID: - if (tileEntity instanceof AbstractTreasureChestTileEntity) { - return new StrongboxChestGui(player.inventory, (AbstractTreasureChestTileEntity) tileEntity); - } else { - Treasure.logger.warn("Umm, GUI handler error - wrong tile entity."); - } - break; + if ((chestTileEntity = getChestTileEntity(tileEntity)) == null) return null; + return new StrongboxChestGui(player.inventory, chestTileEntity); case COMPRESSOR_CHEST_GUIID: - if (tileEntity instanceof AbstractTreasureChestTileEntity) { - return new CompressorChestGui(player.inventory, (AbstractTreasureChestTileEntity) tileEntity); - } else { - Treasure.logger.warn("Umm, GUI handler error - wrong tile entity."); - } - break; + if ((chestTileEntity = getChestTileEntity(tileEntity)) == null) return null; + return new CompressorChestGui(player.inventory, chestTileEntity); case SKULL_CHEST_GUIID: - if (tileEntity instanceof AbstractTreasureChestTileEntity) { - return new SkullChestGui(player.inventory, (AbstractTreasureChestTileEntity) tileEntity); - } else { - Treasure.logger.warn("Umm, GUI handler error - wrong tile entity."); - } - break; + if ((chestTileEntity = getChestTileEntity(tileEntity)) == null) return null; + return new SkullChestGui(player.inventory, chestTileEntity); case WITHER_CHEST_GUIID: - if (tileEntity instanceof AbstractTreasureChestTileEntity) { - return new WitherChestGui(player.inventory, (AbstractTreasureChestTileEntity) tileEntity); - } else { - Treasure.logger.warn("Umm, GUI handler error - wrong tile entity."); - } - break; + if ((chestTileEntity = getChestTileEntity(tileEntity)) == null) return null; + return new WitherChestGui(player.inventory, chestTileEntity); case MOLLUSCS_CHEST_GUIID: - if (tileEntity instanceof AbstractTreasureChestTileEntity) { - return new MolluscChestGui(player.inventory, (AbstractTreasureChestTileEntity) tileEntity); - } else { - Treasure.logger.warn("Umm, GUI handler error - wrong tile entity."); - } - break; + if ((chestTileEntity = getChestTileEntity(tileEntity)) == null) return null; + return new MolluscChestGui(player.inventory, chestTileEntity); case KEY_RING_GUIID: // get the held item ItemStack keyRingItem = player.getHeldItemMainhand(); @@ -205,7 +206,7 @@ public Object getClientGuiElement(int ID, EntityPlayer player, World world, int IInventory inventory = new KeyRingInventory(keyRingItem); // open the container return new KeyRingGui(player.inventory, inventory, keyRingItem); - + case POUCH_GUIID: // get the held item ItemStack pouchStack = player.getHeldItemMainhand(); @@ -214,16 +215,24 @@ public Object getClientGuiElement(int ID, EntityPlayer player, World world, int if (pouchStack == null || !(pouchStack.getItem() instanceof PouchItem)) return null; } - + // create inventory from item IInventory pouchInventory = new PouchInventory(pouchStack); // open the container return new PouchGui(player.inventory, pouchInventory, pouchStack); - + default: return null; } - return null; } -} + + private ITreasureChestTileEntity getChestTileEntity(TileEntity tileEntity) { + ITreasureChestTileEntity chestTileEntity = (tileEntity instanceof ITreasureChestTileEntity) ? (ITreasureChestTileEntity) tileEntity : null; + if (chestTileEntity == null) { + logger.warn("Umm, GUI handler error - wrong tile entity."); + return null; + } + return chestTileEntity; + } +} \ No newline at end of file diff --git a/src/com/someguyssoftware/treasure2/client/gui/inventory/CompressorChestGui.java b/src/com/someguyssoftware/treasure2/client/gui/inventory/CompressorChestGui.java index 8b70e3749..c2c48c63d 100644 --- a/src/com/someguyssoftware/treasure2/client/gui/inventory/CompressorChestGui.java +++ b/src/com/someguyssoftware/treasure2/client/gui/inventory/CompressorChestGui.java @@ -7,7 +7,7 @@ import com.someguyssoftware.treasure2.Treasure; import com.someguyssoftware.treasure2.inventory.CompressorChestContainer; -import com.someguyssoftware.treasure2.tileentity.AbstractTreasureChestTileEntity; +import com.someguyssoftware.treasure2.tileentity.ITreasureChestTileEntity; import net.minecraft.client.Minecraft; import net.minecraft.client.gui.inventory.GuiContainer; @@ -25,7 +25,7 @@ public class CompressorChestGui extends GuiContainer { // This is the resource location for the background image for the GUI private static final ResourceLocation texture = new ResourceLocation(Treasure.MODID, "textures/gui/container/compressor_chest.png"); - private AbstractTreasureChestTileEntity tileEntity; + private ITreasureChestTileEntity tileEntity; /** * NOTE can pass anything into the ChestGui (GuiContainer) as long as the @@ -35,7 +35,7 @@ public class CompressorChestGui extends GuiContainer { * @param invPlayer * @param tileEntity */ - public CompressorChestGui(InventoryPlayer invPlayer, AbstractTreasureChestTileEntity tileEntity) { + public CompressorChestGui(InventoryPlayer invPlayer, ITreasureChestTileEntity tileEntity) { super(new CompressorChestContainer(invPlayer, (IInventory) tileEntity)); this.tileEntity = tileEntity; diff --git a/src/com/someguyssoftware/treasure2/client/gui/inventory/MolluscChestGui.java b/src/com/someguyssoftware/treasure2/client/gui/inventory/MolluscChestGui.java index 2553ad2f4..910d88851 100644 --- a/src/com/someguyssoftware/treasure2/client/gui/inventory/MolluscChestGui.java +++ b/src/com/someguyssoftware/treasure2/client/gui/inventory/MolluscChestGui.java @@ -7,7 +7,7 @@ import com.someguyssoftware.treasure2.Treasure; import com.someguyssoftware.treasure2.inventory.MolluscChestContainer; -import com.someguyssoftware.treasure2.tileentity.AbstractTreasureChestTileEntity; +import com.someguyssoftware.treasure2.tileentity.ITreasureChestTileEntity; import net.minecraft.client.Minecraft; import net.minecraft.client.gui.inventory.GuiContainer; @@ -25,7 +25,7 @@ public class MolluscChestGui extends GuiContainer { // This is the resource location for the background image for the GUI private static final ResourceLocation texture = new ResourceLocation(Treasure.MODID, "textures/gui/container/mollusc_chest.png"); - private AbstractTreasureChestTileEntity tileEntity; + private ITreasureChestTileEntity tileEntity; /** * NOTE can pass anything into the ChestGui (GuiContainer) as long as the @@ -35,7 +35,7 @@ public class MolluscChestGui extends GuiContainer { * @param invPlayer * @param tileEntity */ - public MolluscChestGui(InventoryPlayer invPlayer, AbstractTreasureChestTileEntity tileEntity) { + public MolluscChestGui(InventoryPlayer invPlayer, ITreasureChestTileEntity tileEntity) { super(new MolluscChestContainer(invPlayer, (IInventory) tileEntity)); this.tileEntity = tileEntity; diff --git a/src/com/someguyssoftware/treasure2/client/gui/inventory/SkullChestGui.java b/src/com/someguyssoftware/treasure2/client/gui/inventory/SkullChestGui.java index 3e575c842..3aaa02560 100644 --- a/src/com/someguyssoftware/treasure2/client/gui/inventory/SkullChestGui.java +++ b/src/com/someguyssoftware/treasure2/client/gui/inventory/SkullChestGui.java @@ -7,7 +7,7 @@ import com.someguyssoftware.treasure2.Treasure; import com.someguyssoftware.treasure2.inventory.SkullChestContainer; -import com.someguyssoftware.treasure2.tileentity.AbstractTreasureChestTileEntity; +import com.someguyssoftware.treasure2.tileentity.ITreasureChestTileEntity; import net.minecraft.client.Minecraft; import net.minecraft.client.gui.inventory.GuiContainer; @@ -25,7 +25,7 @@ public class SkullChestGui extends GuiContainer { // This is the resource location for the background image for the GUI private static final ResourceLocation texture = new ResourceLocation(Treasure.MODID, "textures/gui/container/skull_chest.png"); - private AbstractTreasureChestTileEntity tileEntity; + private ITreasureChestTileEntity tileEntity; /** * NOTE can pass anything into the ChestGui (GuiContainer) as long as the @@ -35,7 +35,7 @@ public class SkullChestGui extends GuiContainer { * @param invPlayer * @param tileEntity */ - public SkullChestGui(InventoryPlayer invPlayer, AbstractTreasureChestTileEntity tileEntity) { + public SkullChestGui(InventoryPlayer invPlayer, ITreasureChestTileEntity tileEntity) { super(new SkullChestContainer(invPlayer, (IInventory) tileEntity)); this.tileEntity = tileEntity; diff --git a/src/com/someguyssoftware/treasure2/client/gui/inventory/StandardChestGui.java b/src/com/someguyssoftware/treasure2/client/gui/inventory/StandardChestGui.java index be4e2d0e5..0addce127 100644 --- a/src/com/someguyssoftware/treasure2/client/gui/inventory/StandardChestGui.java +++ b/src/com/someguyssoftware/treasure2/client/gui/inventory/StandardChestGui.java @@ -8,6 +8,7 @@ import com.someguyssoftware.treasure2.Treasure; import com.someguyssoftware.treasure2.inventory.StandardChestContainer; import com.someguyssoftware.treasure2.tileentity.AbstractTreasureChestTileEntity; +import com.someguyssoftware.treasure2.tileentity.ITreasureChestTileEntity; import net.minecraft.client.Minecraft; import net.minecraft.client.gui.inventory.GuiContainer; @@ -25,7 +26,7 @@ public class StandardChestGui extends GuiContainer { // This is the resource location for the background image for the GUI private static final ResourceLocation texture = new ResourceLocation(Treasure.MODID, "textures/gui/container/treasure_chest.png"); - private AbstractTreasureChestTileEntity tileEntity; + private ITreasureChestTileEntity tileEntity; /** * NOTE can pass anything into the ChestGui (GuiContainer) as long as the @@ -35,7 +36,7 @@ public class StandardChestGui extends GuiContainer { * @param invPlayer * @param tileEntity */ - public StandardChestGui(InventoryPlayer invPlayer, AbstractTreasureChestTileEntity tileEntity) { + public StandardChestGui(InventoryPlayer invPlayer, ITreasureChestTileEntity tileEntity) { super(new StandardChestContainer(invPlayer, (IInventory) tileEntity)); this.tileEntity = tileEntity; diff --git a/src/com/someguyssoftware/treasure2/client/gui/inventory/StrongboxChestGui.java b/src/com/someguyssoftware/treasure2/client/gui/inventory/StrongboxChestGui.java index 0622155b9..557d0c455 100644 --- a/src/com/someguyssoftware/treasure2/client/gui/inventory/StrongboxChestGui.java +++ b/src/com/someguyssoftware/treasure2/client/gui/inventory/StrongboxChestGui.java @@ -7,7 +7,7 @@ import com.someguyssoftware.treasure2.Treasure; import com.someguyssoftware.treasure2.inventory.StrongboxChestContainer; -import com.someguyssoftware.treasure2.tileentity.AbstractTreasureChestTileEntity; +import com.someguyssoftware.treasure2.tileentity.ITreasureChestTileEntity; import net.minecraft.client.Minecraft; import net.minecraft.client.gui.inventory.GuiContainer; @@ -25,7 +25,7 @@ public class StrongboxChestGui extends GuiContainer { // This is the resource location for the background image for the GUI private static final ResourceLocation texture = new ResourceLocation(Treasure.MODID, "textures/gui/container/strongbox.png"); - private AbstractTreasureChestTileEntity tileEntity; + private ITreasureChestTileEntity tileEntity; /** * NOTE can pass anything into the ChestGui (GuiContainer) as long as the @@ -35,7 +35,7 @@ public class StrongboxChestGui extends GuiContainer { * @param invPlayer * @param tileEntity */ - public StrongboxChestGui(InventoryPlayer invPlayer, AbstractTreasureChestTileEntity tileEntity) { + public StrongboxChestGui(InventoryPlayer invPlayer, ITreasureChestTileEntity tileEntity) { super(new StrongboxChestContainer(invPlayer, (IInventory) tileEntity)); this.tileEntity = tileEntity; diff --git a/src/com/someguyssoftware/treasure2/client/gui/inventory/WitherChestGui.java b/src/com/someguyssoftware/treasure2/client/gui/inventory/WitherChestGui.java index 530099542..b25c5ca89 100644 --- a/src/com/someguyssoftware/treasure2/client/gui/inventory/WitherChestGui.java +++ b/src/com/someguyssoftware/treasure2/client/gui/inventory/WitherChestGui.java @@ -7,7 +7,7 @@ import com.someguyssoftware.treasure2.Treasure; import com.someguyssoftware.treasure2.inventory.WitherChestContainer; -import com.someguyssoftware.treasure2.tileentity.AbstractTreasureChestTileEntity; +import com.someguyssoftware.treasure2.tileentity.ITreasureChestTileEntity; import net.minecraft.client.Minecraft; import net.minecraft.client.gui.inventory.GuiContainer; @@ -26,7 +26,7 @@ public class WitherChestGui extends GuiContainer { // This is the resource location for the background image for the GUI private static final ResourceLocation texture = new ResourceLocation(Treasure.MODID, "textures/gui/container/wither_chest.png"); - private AbstractTreasureChestTileEntity tileEntity; + private ITreasureChestTileEntity tileEntity; /** * NOTE can pass anything into the ChestGui (GuiContainer) as long as the @@ -36,7 +36,7 @@ public class WitherChestGui extends GuiContainer { * @param invPlayer * @param tileEntity */ - public WitherChestGui(InventoryPlayer invPlayer, AbstractTreasureChestTileEntity tileEntity) { + public WitherChestGui(InventoryPlayer invPlayer, ITreasureChestTileEntity tileEntity) { super(new WitherChestContainer(invPlayer, (IInventory) tileEntity)); this.tileEntity = tileEntity; diff --git a/src/com/someguyssoftware/treasure2/client/model/BandedChestModel.java b/src/com/someguyssoftware/treasure2/client/model/BandedChestModel.java index 32f604ad8..e3bf7c1d5 100644 --- a/src/com/someguyssoftware/treasure2/client/model/BandedChestModel.java +++ b/src/com/someguyssoftware/treasure2/client/model/BandedChestModel.java @@ -1,6 +1,6 @@ package com.someguyssoftware.treasure2.client.model; -import com.someguyssoftware.treasure2.tileentity.AbstractTreasureChestTileEntity; +import com.someguyssoftware.treasure2.tileentity.ITreasureChestTileEntity; import net.minecraft.client.model.ModelBase; import net.minecraft.client.model.ModelRenderer; @@ -173,7 +173,7 @@ public void setRotationAngles(float f, float f1, float f2, float f3, float f4, f * */ @Override - public void renderAll(AbstractTreasureChestTileEntity te) { + public void renderAll(ITreasureChestTileEntity te) { // set the angles of the latch to same as the lib RightTopBand.rotateAngleX = lid.rotateAngleX; LeftTopBand.rotateAngleX = lid.rotateAngleX; diff --git a/src/com/someguyssoftware/treasure2/client/model/CauldronChestModel.java b/src/com/someguyssoftware/treasure2/client/model/CauldronChestModel.java index e3e8dea31..a3273873f 100644 --- a/src/com/someguyssoftware/treasure2/client/model/CauldronChestModel.java +++ b/src/com/someguyssoftware/treasure2/client/model/CauldronChestModel.java @@ -1,6 +1,6 @@ package com.someguyssoftware.treasure2.client.model; -import com.someguyssoftware.treasure2.tileentity.AbstractTreasureChestTileEntity; +import com.someguyssoftware.treasure2.tileentity.ITreasureChestTileEntity; import net.minecraft.client.model.ModelBase; import net.minecraft.client.model.ModelRenderer; @@ -157,7 +157,7 @@ public void setRotationAngles(float f, float f1, float f2, float f3, float f4, f * */ @Override - public void renderAll(AbstractTreasureChestTileEntity te) { + public void renderAll(ITreasureChestTileEntity te) { // set the angles of the latch to same as the lib lidRight.rotateAngleZ = -lidLeft.rotateAngleZ; diff --git a/src/com/someguyssoftware/treasure2/client/model/ClamChestModel.java b/src/com/someguyssoftware/treasure2/client/model/ClamChestModel.java index 0971fcb2f..44997ba66 100644 --- a/src/com/someguyssoftware/treasure2/client/model/ClamChestModel.java +++ b/src/com/someguyssoftware/treasure2/client/model/ClamChestModel.java @@ -2,7 +2,7 @@ //Made with Blockbench //Paste this code into your mod. -import com.someguyssoftware.treasure2.tileentity.AbstractTreasureChestTileEntity; +import com.someguyssoftware.treasure2.tileentity.ITreasureChestTileEntity; import net.minecraft.client.model.ModelBase; import net.minecraft.client.model.ModelBox; @@ -45,7 +45,7 @@ public void render(Entity entity, float f, float f1, float f2, float f3, float f } @Override - public void renderAll(AbstractTreasureChestTileEntity te) { + public void renderAll(ITreasureChestTileEntity te) { bottom.render(0.0625F); lid.render(0.0625F); hinge.render(0.0625F); diff --git a/src/com/someguyssoftware/treasure2/client/model/CompressorChestModel.java b/src/com/someguyssoftware/treasure2/client/model/CompressorChestModel.java index a593ff832..8280adcf1 100644 --- a/src/com/someguyssoftware/treasure2/client/model/CompressorChestModel.java +++ b/src/com/someguyssoftware/treasure2/client/model/CompressorChestModel.java @@ -1,7 +1,7 @@ package com.someguyssoftware.treasure2.client.model; import com.someguyssoftware.treasure2.lock.LockState; -import com.someguyssoftware.treasure2.tileentity.AbstractTreasureChestTileEntity; +import com.someguyssoftware.treasure2.tileentity.ITreasureChestTileEntity; import net.minecraft.client.model.ModelBase; import net.minecraft.client.model.ModelRenderer; @@ -153,7 +153,7 @@ public void setRotationAngles(float f, float f1, float f2, float f3, float f4, f * */ @Override - public void renderAll(AbstractTreasureChestTileEntity te) { + public void renderAll(ITreasureChestTileEntity te) { float originalAngle = lid1.rotateAngleX; float f5 = 0.0625F; diff --git a/src/com/someguyssoftware/treasure2/client/model/CrateChestModel.java b/src/com/someguyssoftware/treasure2/client/model/CrateChestModel.java index fcdbb164e..82243035e 100644 --- a/src/com/someguyssoftware/treasure2/client/model/CrateChestModel.java +++ b/src/com/someguyssoftware/treasure2/client/model/CrateChestModel.java @@ -1,6 +1,6 @@ package com.someguyssoftware.treasure2.client.model; -import com.someguyssoftware.treasure2.tileentity.AbstractTreasureChestTileEntity; +import com.someguyssoftware.treasure2.tileentity.ITreasureChestTileEntity; import net.minecraft.client.model.ModelBase; import net.minecraft.client.model.ModelRenderer; @@ -172,7 +172,7 @@ public void setRotationAngles(float f, float f1, float f2, float f3, float f4, f * */ @Override - public void renderAll(AbstractTreasureChestTileEntity te) { + public void renderAll(ITreasureChestTileEntity te) { float f5 = 0.0625F; // set the angles diff --git a/src/com/someguyssoftware/treasure2/client/model/DreadPirateChestModel.java b/src/com/someguyssoftware/treasure2/client/model/DreadPirateChestModel.java index 7dd7e061b..38911b2e4 100644 --- a/src/com/someguyssoftware/treasure2/client/model/DreadPirateChestModel.java +++ b/src/com/someguyssoftware/treasure2/client/model/DreadPirateChestModel.java @@ -1,6 +1,6 @@ package com.someguyssoftware.treasure2.client.model; -import com.someguyssoftware.treasure2.tileentity.AbstractTreasureChestTileEntity; +import com.someguyssoftware.treasure2.tileentity.ITreasureChestTileEntity; import net.minecraft.client.model.ModelBase; import net.minecraft.client.model.ModelRenderer; @@ -162,7 +162,7 @@ public void setRotationAngles(float f, float f1, float f2, float f3, float f4, f * */ @Override - public void renderAll(AbstractTreasureChestTileEntity te) { + public void renderAll(ITreasureChestTileEntity te) { float f5 = 0.0625F; // set the angles diff --git a/src/com/someguyssoftware/treasure2/client/model/ITreasureChestModel.java b/src/com/someguyssoftware/treasure2/client/model/ITreasureChestModel.java index 39b0cd7fa..a263a0a50 100644 --- a/src/com/someguyssoftware/treasure2/client/model/ITreasureChestModel.java +++ b/src/com/someguyssoftware/treasure2/client/model/ITreasureChestModel.java @@ -3,7 +3,7 @@ */ package com.someguyssoftware.treasure2.client.model; -import com.someguyssoftware.treasure2.tileentity.AbstractTreasureChestTileEntity; +import com.someguyssoftware.treasure2.tileentity.ITreasureChestTileEntity; import net.minecraft.client.model.ModelRenderer; @@ -13,7 +13,7 @@ */ public interface ITreasureChestModel { - public void renderAll(AbstractTreasureChestTileEntity te); + public void renderAll(ITreasureChestTileEntity te); public ModelRenderer getLid(); } diff --git a/src/com/someguyssoftware/treasure2/client/model/OysterChestModel.java b/src/com/someguyssoftware/treasure2/client/model/OysterChestModel.java index b08459101..5f98fd084 100644 --- a/src/com/someguyssoftware/treasure2/client/model/OysterChestModel.java +++ b/src/com/someguyssoftware/treasure2/client/model/OysterChestModel.java @@ -2,7 +2,7 @@ //Made with Blockbench //Paste this code into your mod. -import com.someguyssoftware.treasure2.tileentity.AbstractTreasureChestTileEntity; +import com.someguyssoftware.treasure2.tileentity.ITreasureChestTileEntity; import net.minecraft.client.model.ModelBase; import net.minecraft.client.model.ModelBox; @@ -57,7 +57,7 @@ public void render(Entity entity, float f, float f1, float f2, float f3, float f } @Override - public void renderAll(AbstractTreasureChestTileEntity te) { + public void renderAll(ITreasureChestTileEntity te) { bottom.render(0.0625F); lid.render(0.0625F); hinge.render(0.0625F); diff --git a/src/com/someguyssoftware/treasure2/client/model/SafeModel.java b/src/com/someguyssoftware/treasure2/client/model/SafeModel.java index ced073e1e..836b51814 100644 --- a/src/com/someguyssoftware/treasure2/client/model/SafeModel.java +++ b/src/com/someguyssoftware/treasure2/client/model/SafeModel.java @@ -3,7 +3,7 @@ */ package com.someguyssoftware.treasure2.client.model; -import com.someguyssoftware.treasure2.tileentity.AbstractTreasureChestTileEntity; +import com.someguyssoftware.treasure2.tileentity.ITreasureChestTileEntity; import com.someguyssoftware.treasure2.tileentity.SafeTileEntity; import net.minecraft.client.model.ModelBase; @@ -145,7 +145,7 @@ public SafeModel() { * .someguyssoftware.treasure2.tileentity.AbstractTreasureChestTileEntity) */ @Override - public void renderAll(AbstractTreasureChestTileEntity te) { + public void renderAll(ITreasureChestTileEntity te) { SafeTileEntity ste = (SafeTileEntity) te; float scale = 0.0625F; diff --git a/src/com/someguyssoftware/treasure2/client/model/SkullChestModel.java b/src/com/someguyssoftware/treasure2/client/model/SkullChestModel.java index 6170fa93c..5c3401a3e 100644 --- a/src/com/someguyssoftware/treasure2/client/model/SkullChestModel.java +++ b/src/com/someguyssoftware/treasure2/client/model/SkullChestModel.java @@ -1,6 +1,6 @@ package com.someguyssoftware.treasure2.client.model; -import com.someguyssoftware.treasure2.tileentity.AbstractTreasureChestTileEntity; +import com.someguyssoftware.treasure2.tileentity.ITreasureChestTileEntity; import net.minecraft.client.model.ModelBase; import net.minecraft.client.model.ModelRenderer; @@ -77,7 +77,7 @@ public void setRotationAngles(float f, float f1, float f2, float f3, float f4, f * */ @Override - public void renderAll(AbstractTreasureChestTileEntity te) { + public void renderAll(ITreasureChestTileEntity te) { head.rotateAngleX = top.rotateAngleX; jaw.rotateAngleX = top.rotateAngleX; diff --git a/src/com/someguyssoftware/treasure2/client/model/SpiderChestModel.java b/src/com/someguyssoftware/treasure2/client/model/SpiderChestModel.java index 9c1fe2892..17941f59d 100644 --- a/src/com/someguyssoftware/treasure2/client/model/SpiderChestModel.java +++ b/src/com/someguyssoftware/treasure2/client/model/SpiderChestModel.java @@ -1,6 +1,6 @@ package com.someguyssoftware.treasure2.client.model; -import com.someguyssoftware.treasure2.tileentity.AbstractTreasureChestTileEntity; +import com.someguyssoftware.treasure2.tileentity.ITreasureChestTileEntity; import net.minecraft.client.model.ModelBase; import net.minecraft.client.model.ModelBox; @@ -62,7 +62,7 @@ public void render(Entity entity, float f, float f1, float f2, float f3, float f } @Override - public void renderAll(AbstractTreasureChestTileEntity te) { + public void renderAll(ITreasureChestTileEntity te) { headBone.rotateAngleX = lid.rotateAngleX; chest.render(0.0625F); bone.render(0.0625F); diff --git a/src/com/someguyssoftware/treasure2/client/model/StandardChestModel.java b/src/com/someguyssoftware/treasure2/client/model/StandardChestModel.java index c93d66319..10e347ea5 100644 --- a/src/com/someguyssoftware/treasure2/client/model/StandardChestModel.java +++ b/src/com/someguyssoftware/treasure2/client/model/StandardChestModel.java @@ -1,7 +1,7 @@ package com.someguyssoftware.treasure2.client.model; import com.someguyssoftware.treasure2.lock.LockState; -import com.someguyssoftware.treasure2.tileentity.AbstractTreasureChestTileEntity; +import com.someguyssoftware.treasure2.tileentity.ITreasureChestTileEntity; import net.minecraft.client.model.ModelBase; import net.minecraft.client.model.ModelRenderer; @@ -124,7 +124,7 @@ public void setRotationAngles(float f, float f1, float f2, float f3, float f4, f * */ @Override - public void renderAll(AbstractTreasureChestTileEntity te) { + public void renderAll(ITreasureChestTileEntity te) { // set the angles of the latch to same as the lib Latch1.rotateAngleX = lid.rotateAngleX; Latch2.rotateAngleX = lid.rotateAngleX; diff --git a/src/com/someguyssoftware/treasure2/client/model/StrongboxModel.java b/src/com/someguyssoftware/treasure2/client/model/StrongboxModel.java index abe35b3d5..db5cab971 100644 --- a/src/com/someguyssoftware/treasure2/client/model/StrongboxModel.java +++ b/src/com/someguyssoftware/treasure2/client/model/StrongboxModel.java @@ -1,6 +1,6 @@ package com.someguyssoftware.treasure2.client.model; -import com.someguyssoftware.treasure2.tileentity.AbstractTreasureChestTileEntity; +import com.someguyssoftware.treasure2.tileentity.ITreasureChestTileEntity; import net.minecraft.client.model.ModelBase; import net.minecraft.client.model.ModelRenderer; @@ -92,7 +92,7 @@ public void setRotationAngles(float f, float f1, float f2, float f3, float f4, f * */ @Override - public void renderAll(AbstractTreasureChestTileEntity te) { + public void renderAll(ITreasureChestTileEntity te) { latch.rotateAngleX = lid.rotateAngleX; pad.rotateAngleX = lid.rotateAngleX; diff --git a/src/com/someguyssoftware/treasure2/client/model/VikingChestModel.java b/src/com/someguyssoftware/treasure2/client/model/VikingChestModel.java index 799898908..f0c756e20 100644 --- a/src/com/someguyssoftware/treasure2/client/model/VikingChestModel.java +++ b/src/com/someguyssoftware/treasure2/client/model/VikingChestModel.java @@ -3,7 +3,7 @@ */ package com.someguyssoftware.treasure2.client.model; -import com.someguyssoftware.treasure2.tileentity.AbstractTreasureChestTileEntity; +import com.someguyssoftware.treasure2.tileentity.ITreasureChestTileEntity; import net.minecraft.client.model.ModelBase; import net.minecraft.client.model.ModelBox; @@ -91,7 +91,7 @@ public void setRotationAngle(ModelRenderer modelRenderer, float x, float y, floa } @Override - public void renderAll(AbstractTreasureChestTileEntity te) { + public void renderAll(ITreasureChestTileEntity te) { mainBox.render(0.0625F); lid.render(0.0625F); side1.render(0.0625F); diff --git a/src/com/someguyssoftware/treasure2/client/model/WitherChestModel.java b/src/com/someguyssoftware/treasure2/client/model/WitherChestModel.java index 6c104cc5e..da26b4a41 100644 --- a/src/com/someguyssoftware/treasure2/client/model/WitherChestModel.java +++ b/src/com/someguyssoftware/treasure2/client/model/WitherChestModel.java @@ -1,6 +1,6 @@ package com.someguyssoftware.treasure2.client.model; -import com.someguyssoftware.treasure2.tileentity.AbstractTreasureChestTileEntity; +import com.someguyssoftware.treasure2.tileentity.ITreasureChestTileEntity; import net.minecraft.client.model.ModelBase; import net.minecraft.client.model.ModelRenderer; @@ -137,7 +137,7 @@ public void setRotationAngles(float f, float f1, float f2, float f3, float f4, f /** * */ - public void renderAll(AbstractTreasureChestTileEntity te) { + public void renderAll(ITreasureChestTileEntity te) { rside.rotateAngleY = rfront.rotateAngleY; lfront.rotateAngleY = -(rfront.rotateAngleY); lside.rotateAngleY = lfront.rotateAngleY; diff --git a/src/com/someguyssoftware/treasure2/command/SpawnChestCommand.java b/src/com/someguyssoftware/treasure2/command/SpawnChestCommand.java index 529842ccb..279bfbb4a 100644 --- a/src/com/someguyssoftware/treasure2/command/SpawnChestCommand.java +++ b/src/com/someguyssoftware/treasure2/command/SpawnChestCommand.java @@ -19,7 +19,7 @@ import com.someguyssoftware.treasure2.Treasure; import com.someguyssoftware.treasure2.block.AbstractChestBlock; import com.someguyssoftware.treasure2.enums.Rarity; -import com.someguyssoftware.treasure2.enums.WorldGenerators; +import com.someguyssoftware.treasure2.enums.WorldGeneratorType; import com.someguyssoftware.treasure2.generator.chest.IChestGenerator; import com.someguyssoftware.treasure2.tileentity.AbstractTreasureChestTileEntity; import com.someguyssoftware.treasure2.worldgen.SurfaceChestWorldGenerator; @@ -144,7 +144,7 @@ public void execute(MinecraftServer server, ICommandSender commandSender, String // get the chest world generator SurfaceChestWorldGenerator chestGens = (SurfaceChestWorldGenerator) Treasure.WORLD_GENERATORS - .get(WorldGenerators.SURFACE_CHEST); + .get(WorldGeneratorType.SURFACE_CHEST); // get the rarity chest generator IChestGenerator gen = chestGens.getChestGenMap().get(rarity).next(); BlockPos pos = new BlockPos(x, y, z); @@ -157,7 +157,7 @@ public void execute(MinecraftServer server, ICommandSender commandSender, String if (tileEntity != null) { // get the loot table - LootTable lootTable = gen.selectLootTable(new Random(), rarity); + LootTable lootTable = gen.selectLootTable(Random::new, rarity); if (lootTable == null) { Treasure.logger.warn("Unable to select a lootTable for rarity -> {}", rarity); diff --git a/src/com/someguyssoftware/treasure2/command/SpawnOasisCommand.java b/src/com/someguyssoftware/treasure2/command/SpawnOasisCommand.java index 3db49ee39..c2e35e21c 100644 --- a/src/com/someguyssoftware/treasure2/command/SpawnOasisCommand.java +++ b/src/com/someguyssoftware/treasure2/command/SpawnOasisCommand.java @@ -20,7 +20,7 @@ import com.someguyssoftware.treasure2.Treasure; import com.someguyssoftware.treasure2.config.TreasureConfig; import com.someguyssoftware.treasure2.enums.Rarity; -import com.someguyssoftware.treasure2.enums.WorldGenerators; +import com.someguyssoftware.treasure2.enums.WorldGeneratorType; import com.someguyssoftware.treasure2.generator.ChestGeneratorData; import com.someguyssoftware.treasure2.generator.GeneratorData; import com.someguyssoftware.treasure2.generator.GeneratorResult; diff --git a/src/com/someguyssoftware/treasure2/command/SpawnPitCommand.java b/src/com/someguyssoftware/treasure2/command/SpawnPitCommand.java index 15f10d431..8f23db5aa 100644 --- a/src/com/someguyssoftware/treasure2/command/SpawnPitCommand.java +++ b/src/com/someguyssoftware/treasure2/command/SpawnPitCommand.java @@ -20,7 +20,7 @@ import com.someguyssoftware.treasure2.Treasure; import com.someguyssoftware.treasure2.config.TreasureConfig; import com.someguyssoftware.treasure2.enums.Rarity; -import com.someguyssoftware.treasure2.enums.WorldGenerators; +import com.someguyssoftware.treasure2.enums.WorldGeneratorType; import com.someguyssoftware.treasure2.generator.ChestGeneratorData; import com.someguyssoftware.treasure2.generator.GeneratorResult; import com.someguyssoftware.treasure2.generator.chest.IChestGenerator; @@ -84,7 +84,7 @@ public void execute(MinecraftServer server, ICommandSender commandSender, String Random random = new Random(); GeneratorResult result = SurfaceChestWorldGenerator.generatePit(world, random, rarity, new Coords(x, y, z), TreasureConfig.CHESTS.surfaceChests.configMap.get(rarity)); if (result.isSuccess()) { - SurfaceChestWorldGenerator chestGens = (SurfaceChestWorldGenerator) Treasure.WORLD_GENERATORS.get(WorldGenerators.SURFACE_CHEST); + SurfaceChestWorldGenerator chestGens = (SurfaceChestWorldGenerator) Treasure.WORLD_GENERATORS.get(WorldGeneratorType.SURFACE_CHEST); IChestGenerator gen = chestGens.getChestGenMap().get(rarity).next(); ICoords chestCoords = result.getData().getChestContext().getCoords(); if (chestCoords != null) { diff --git a/src/com/someguyssoftware/treasure2/command/SpawnRuinsCommand.java b/src/com/someguyssoftware/treasure2/command/SpawnRuinsCommand.java index 28d4bdaeb..26c6e1c6d 100644 --- a/src/com/someguyssoftware/treasure2/command/SpawnRuinsCommand.java +++ b/src/com/someguyssoftware/treasure2/command/SpawnRuinsCommand.java @@ -21,7 +21,7 @@ import com.someguyssoftware.gottschcore.world.gen.structure.IDecayRuleSet; import com.someguyssoftware.treasure2.Treasure; import com.someguyssoftware.treasure2.enums.Rarity; -import com.someguyssoftware.treasure2.enums.WorldGenerators; +import com.someguyssoftware.treasure2.enums.WorldGeneratorType; import com.someguyssoftware.treasure2.generator.ChestGeneratorData; import com.someguyssoftware.treasure2.generator.GeneratorResult; import com.someguyssoftware.treasure2.generator.chest.IChestGenerator; @@ -131,7 +131,7 @@ public void execute(MinecraftServer server, ICommandSender commandSender, String // get the structure generator SurfaceChestWorldGenerator worldGen = - (SurfaceChestWorldGenerator) Treasure.WORLD_GENERATORS.get(WorldGenerators.SURFACE_CHEST); + (SurfaceChestWorldGenerator) Treasure.WORLD_GENERATORS.get(WorldGeneratorType.SURFACE_CHEST); // build the template key ResourceLocation templateKey = new ResourceLocation(Treasure.MODID + ":" + Treasure.TEMPLATE_MANAGER.getBaseResourceFolder() diff --git a/src/com/someguyssoftware/treasure2/config/TreasureConfig.java b/src/com/someguyssoftware/treasure2/config/TreasureConfig.java index ce33a5d8c..dfc805a04 100644 --- a/src/com/someguyssoftware/treasure2/config/TreasureConfig.java +++ b/src/com/someguyssoftware/treasure2/config/TreasureConfig.java @@ -79,7 +79,9 @@ public class TreasureConfig implements IConfig, ILoggerConfig { // locks @Ignore public static final String WOOD_LOCK_ID = "wood_lock"; - @Ignore public static final String STONE_LOCK_ID = "stone_lock"; + @Ignore public static final String STONE_LOCK_ID = "stone_lock"; + @Ignore public static final String EMBER_LOCK_ID = "ember_lock"; + @Ignore public static final String LEAF_LOCK_ID = "leaf_lock"; @Ignore public static final String IRON_LOCK_ID = "iron_lock"; @Ignore public static final String GOLD_LOCK_ID = "gold_lock"; @Ignore public static final String DIAMOND_LOCK_ID = "diamond_lock"; @@ -91,11 +93,14 @@ public class TreasureConfig implements IConfig, ILoggerConfig { // keys @Ignore public static final String WOOD_KEY_ID = "wood_key"; - @Ignore public static final String IRON_KEY_ID = "iron_key"; - @Ignore public static final String GOLD_KEY_ID = "gold_key"; - @Ignore public static final String DIAMOND_KEY_ID = "diamond_key"; - @Ignore public static final String STONE_KEY_ID = "stone_key"; + @Ignore public static final String EMBER_KEY_ID = "ember_key"; + @Ignore public static final String LEAF_KEY_ID = "leaf_key"; + @Ignore public static final String LIGHTNING_KEY_ID = "lightning_key"; + + @Ignore public static final String GOLD_KEY_ID = "gold_key"; + @Ignore public static final String IRON_KEY_ID = "iron_key"; + @Ignore public static final String DIAMOND_KEY_ID = "diamond_key"; @Ignore public static final String EMERALD_KEY_ID = "emerald_key"; @Ignore public static final String RUBY_KEY_ID = "ruby_key"; @Ignore public static final String SAPPHIRE_KEY_ID = "sapphire_key"; @@ -164,6 +169,7 @@ public class TreasureConfig implements IConfig, ILoggerConfig { @Ignore public static final String WISHING_WELL_BLOCK_ID = "wishing_well_block"; @Ignore public static final String DESERT_WISHING_WELL_BLOCK_ID = "desert_wishing_well_block"; + @Ignore public static final String BLACKSTONE_ID = "blackstone"; @Ignore public static final String FOG_BLOCK_ID = "fog"; @Ignore public static final String HIGH_FOG_BLOCK_ID = "high_fog"; @Ignore public static final String MED_FOG_BLOCK_ID = "med_fog"; @@ -835,8 +841,8 @@ public static class KeysAndLocks { @Name("06. Stone key max uses:") @RangeInt(min = 1, max = 32000) @RequiresMcRestart - public int stoneKeyMaxUses = 10; - + public int stoneKeyMaxUses = 10; + @Comment({ "The maximum uses for a given iron key." }) @Name("07. Iron key max. uses:") @RangeInt(min = 1, max = 32000) @@ -901,7 +907,25 @@ public static class KeysAndLocks { @Name("17. Wither key max. uses:") @RangeInt(min = 1, max = 32000) @RequiresMcRestart - public int witherKeyMaxUses = 5; + public int witherKeyMaxUses = 5; + + @Comment({ "The maximum uses for a given ember key." }) + @Name("18. Ember key max uses:") + @RangeInt(min = 1, max = 32000) + @RequiresMcRestart + public int emberKeyMaxUses = 15; + + @Comment({ "The maximum uses for a given leaf key." }) + @Name("19. Leaf key max uses:") + @RangeInt(min = 1, max = 32000) + @RequiresMcRestart + public int leafKeyMaxUses = 15; + + @Comment({ "The maximum uses for a given lightning key." }) + @Name("20. Lightning key max uses:") + @RangeInt(min = 1, max = 32000) + @RequiresMcRestart + public int lightningKeyMaxUses = 10; } /* diff --git a/src/com/someguyssoftware/treasure2/enums/Category.java b/src/com/someguyssoftware/treasure2/enums/Category.java index 7e9b43c5b..0714ffa6a 100644 --- a/src/com/someguyssoftware/treasure2/enums/Category.java +++ b/src/com/someguyssoftware/treasure2/enums/Category.java @@ -8,7 +8,7 @@ * */ public enum Category { - BASIC, + ELEMENTAL, METALS, GEMS, MAGIC, diff --git a/src/com/someguyssoftware/treasure2/enums/ChestGeneratorType.java b/src/com/someguyssoftware/treasure2/enums/ChestGeneratorType.java new file mode 100644 index 000000000..9b9ef81b5 --- /dev/null +++ b/src/com/someguyssoftware/treasure2/enums/ChestGeneratorType.java @@ -0,0 +1,49 @@ +/** + * + */ +package com.someguyssoftware.treasure2.enums; + +import java.util.function.Supplier; + +import com.someguyssoftware.treasure2.generator.chest.CauldronChestGenerator; +import com.someguyssoftware.treasure2.generator.chest.CommonChestGenerator; +import com.someguyssoftware.treasure2.generator.chest.EpicChestGenerator; +import com.someguyssoftware.treasure2.generator.chest.GoldSkullChestGenerator; +import com.someguyssoftware.treasure2.generator.chest.IChestGenerator; +import com.someguyssoftware.treasure2.generator.chest.RareChestGenerator; +import com.someguyssoftware.treasure2.generator.chest.ScarceChestGenerator; +import com.someguyssoftware.treasure2.generator.chest.SkullChestGenerator; +import com.someguyssoftware.treasure2.generator.chest.UncommonChestGenerator; +import com.someguyssoftware.treasure2.generator.chest.WitherChestGenerator; + +/** + * @author Mark Gottschling on Sep 4, 2020 + * + */ +public enum ChestGeneratorType { + COMMON(CommonChestGenerator::new), + UNCOMMON(UncommonChestGenerator::new), + SCARCE(ScarceChestGenerator::new), + RARE(RareChestGenerator::new), + EPIC(EpicChestGenerator::new), + WITHER(WitherChestGenerator::new), + SKULL(SkullChestGenerator::new), + GOLD_SKULL(GoldSkullChestGenerator::new), + CAULDRON(CauldronChestGenerator::new); + + private Supplier factory; + + /** + * + */ + ChestGeneratorType(Supplier factory) { + this.factory = factory; + } + + /** + * + */ + public IChestGenerator getChestGenerator() { + return factory.get(); + } +} diff --git a/src/com/someguyssoftware/treasure2/enums/Pits.java b/src/com/someguyssoftware/treasure2/enums/Pits.java index f500382d6..397526ce2 100644 --- a/src/com/someguyssoftware/treasure2/enums/Pits.java +++ b/src/com/someguyssoftware/treasure2/enums/Pits.java @@ -22,10 +22,8 @@ public enum Pits implements IEnum { MOB_TRAP_PIT(4, "Mob Trapped Pit"), LAVA_SIDE_TRAP_PIT(5, "Lava Side Trapped Pit"), BIG_BOTTOM_MOB_TRAP_PIT(6, "Big Bottom Mob Trapped Pit"), - COLLAPSING_TRAP_PIT(7, "Collapsing Trapped Pit"); - -// -// STRUCTURE_PIT(7, "Structure Pit"); + COLLAPSING_TRAP_PIT(7, "Collapsing Trapped Pit"), + VOLCANO_PIT(8, "Volcano Pit"); private static final Map codes = new HashMap(); private static final Map values = new HashMap(); diff --git a/src/com/someguyssoftware/treasure2/enums/WorldGenerators.java b/src/com/someguyssoftware/treasure2/enums/WorldGeneratorType.java similarity index 83% rename from src/com/someguyssoftware/treasure2/enums/WorldGenerators.java rename to src/com/someguyssoftware/treasure2/enums/WorldGeneratorType.java index c82542076..92520198b 100644 --- a/src/com/someguyssoftware/treasure2/enums/WorldGenerators.java +++ b/src/com/someguyssoftware/treasure2/enums/WorldGeneratorType.java @@ -8,7 +8,7 @@ * @author Mark Gottschling on Jan 30, 2019 * */ -public enum WorldGenerators { +public enum WorldGeneratorType { CHEST("chest"), WELL("well"), GEM("gem"), @@ -23,7 +23,7 @@ public enum WorldGenerators { * * @param value */ - WorldGenerators(String value) { + WorldGeneratorType(String value) { this.value = value; } diff --git a/src/com/someguyssoftware/treasure2/eventhandler/AnvilEventHandler.java b/src/com/someguyssoftware/treasure2/eventhandler/AnvilEventHandler.java new file mode 100644 index 000000000..cd2d9c05b --- /dev/null +++ b/src/com/someguyssoftware/treasure2/eventhandler/AnvilEventHandler.java @@ -0,0 +1,92 @@ +/** + * + */ +package com.someguyssoftware.treasure2.eventhandler; + +import com.someguyssoftware.gottschcore.mod.IMod; +import com.someguyssoftware.gottschcore.world.WorldInfo; +import static com.someguyssoftware.treasure2.Treasure.logger; +import com.someguyssoftware.treasure2.capability.EffectiveMaxDamageCapability; +import com.someguyssoftware.treasure2.capability.EffectiveMaxDamageCapabilityProvider; +import com.someguyssoftware.treasure2.item.KeyItem; +import com.someguyssoftware.treasure2.item.TreasureItems; + +import net.minecraft.item.ItemStack; +import net.minecraftforge.event.AnvilUpdateEvent; +import net.minecraftforge.event.entity.living.LivingEvent.LivingUpdateEvent; +import net.minecraftforge.fml.common.event.FMLServerStoppingEvent; +import net.minecraftforge.fml.common.eventhandler.SubscribeEvent; + +/** + * @author Mark Gottschling on Sep 6, 2020 + * + */ +public class AnvilEventHandler { + // reference to the mod. + private IMod mod; + + /** + * + */ + public AnvilEventHandler(IMod mod) { + setMod(mod); + } + + @SubscribeEvent + public void onAnvilUpdate(AnvilUpdateEvent event) { + ItemStack leftItemStack = event.getLeft(); + ItemStack rightItemStack = event.getRight(); + + // add all uses/damage remaining in the right item to the left item. + if (leftItemStack.getItem() == rightItemStack.getItem() && (leftItemStack.getItem() instanceof KeyItem)) { + if (leftItemStack.hasCapability(EffectiveMaxDamageCapabilityProvider.EFFECTIVE_MAX_DAMAGE_CAPABILITY, null) + && rightItemStack.hasCapability(EffectiveMaxDamageCapabilityProvider.EFFECTIVE_MAX_DAMAGE_CAPABILITY, null)) { + + event.setCost(1); + EffectiveMaxDamageCapability leftItemCap = (EffectiveMaxDamageCapability) leftItemStack.getCapability(EffectiveMaxDamageCapabilityProvider.EFFECTIVE_MAX_DAMAGE_CAPABILITY, null); + EffectiveMaxDamageCapability rightItemCap = (EffectiveMaxDamageCapability) rightItemStack.getCapability(EffectiveMaxDamageCapabilityProvider.EFFECTIVE_MAX_DAMAGE_CAPABILITY, null); + + if (leftItemCap != null && rightItemCap != null) { + int leftRemainingUses = leftItemCap.getEffectiveMaxDamage() - leftItemStack.getItemDamage(); + int rightRemainingUses = rightItemCap.getEffectiveMaxDamage() - rightItemStack.getItemDamage(); + ItemStack outputItem = new ItemStack(leftItemStack.getItem()); + + EffectiveMaxDamageCapability outputItemCap = (EffectiveMaxDamageCapability) outputItem.getCapability(EffectiveMaxDamageCapabilityProvider.EFFECTIVE_MAX_DAMAGE_CAPABILITY, null); + + int remainingUses = leftRemainingUses + rightRemainingUses; + if (remainingUses > Math.max(leftItemCap.getEffectiveMaxDamage(), rightItemCap.getEffectiveMaxDamage())) { +// if (logger.isDebugEnabled()) { +// logger.debug("output has greater uses -> {} than emd -> {} - update emd", remainingUses, Math.max(leftItemCap.getEffectiveMaxDamage(), rightItemCap.getEffectiveMaxDamage())); +// } + outputItemCap.setEffectiveMaxDamage(Math.max(leftItemCap.getEffectiveMaxDamage(), rightItemCap.getEffectiveMaxDamage()) + leftItemStack.getMaxDamage()); + outputItem.setItemDamage(leftItemStack.getItemDamage() + rightItemStack.getItemDamage()); + } + else { + if (remainingUses < Math.min(leftItemCap.getEffectiveMaxDamage(), rightItemCap.getEffectiveMaxDamage())) { + outputItemCap.setEffectiveMaxDamage(Math.min(leftItemCap.getEffectiveMaxDamage(), rightItemCap.getEffectiveMaxDamage())); + } + else { + outputItemCap.setEffectiveMaxDamage(Math.max(leftItemCap.getEffectiveMaxDamage(), rightItemCap.getEffectiveMaxDamage())); + } + outputItem.setItemDamage(outputItemCap.getEffectiveMaxDamage() - remainingUses); + } + event.setOutput(outputItem); + } + } + } + } + + /** + * @return the mod + */ + public IMod getMod() { + return mod; + } + + /** + * @param mod the mod to set + */ + public void setMod(IMod mod) { + this.mod = mod; + } +} diff --git a/src/com/someguyssoftware/treasure2/eventhandler/WorldEventHandler.java b/src/com/someguyssoftware/treasure2/eventhandler/WorldEventHandler.java index d5e411e95..0f17b2e6e 100644 --- a/src/com/someguyssoftware/treasure2/eventhandler/WorldEventHandler.java +++ b/src/com/someguyssoftware/treasure2/eventhandler/WorldEventHandler.java @@ -9,7 +9,7 @@ import com.someguyssoftware.gottschcore.world.WorldInfo; import com.someguyssoftware.treasure2.Treasure; import com.someguyssoftware.treasure2.config.TreasureConfig; -import com.someguyssoftware.treasure2.enums.WorldGenerators; +import com.someguyssoftware.treasure2.enums.WorldGeneratorType; import com.someguyssoftware.treasure2.persistence.GenDataPersistence; import com.someguyssoftware.treasure2.registry.ChestRegistry; import com.someguyssoftware.treasure2.worldgen.GemOreWorldGenerator; @@ -69,7 +69,7 @@ public void onWorldLoad(WorldEvent.Load event) { /* * clear the current World Gens values and reload */ - for (Entry worldGenEntry : Treasure.WORLD_GENERATORS.entrySet()) { + for (Entry worldGenEntry : Treasure.WORLD_GENERATORS.entrySet()) { worldGenEntry.getValue().init(); } diff --git a/src/com/someguyssoftware/treasure2/generator/chest/CauldronChestGenerator.java b/src/com/someguyssoftware/treasure2/generator/chest/CauldronChestGenerator.java index f02b6b108..671f41762 100644 --- a/src/com/someguyssoftware/treasure2/generator/chest/CauldronChestGenerator.java +++ b/src/com/someguyssoftware/treasure2/generator/chest/CauldronChestGenerator.java @@ -4,13 +4,16 @@ package com.someguyssoftware.treasure2.generator.chest; import java.util.Random; +import java.util.function.Supplier; import com.someguyssoftware.gottschcore.loot.LootTable; import com.someguyssoftware.treasure2.Treasure; import com.someguyssoftware.treasure2.block.TreasureBlocks; import com.someguyssoftware.treasure2.block.TreasureChestBlock; +import com.someguyssoftware.treasure2.enums.ChestGeneratorType; import com.someguyssoftware.treasure2.enums.Rarity; import com.someguyssoftware.treasure2.loot.TreasureLootTableMaster.SpecialLootTables; +import com.someguyssoftware.treasure2.tileentity.AbstractTreasureChestTileEntity; /** * @@ -18,12 +21,21 @@ * */ public class CauldronChestGenerator extends EpicChestGenerator { - + /** * */ public CauldronChestGenerator() {} - + + /** + * + */ + @Override + public void addGenerationContext(AbstractTreasureChestTileEntity tileEntity, Rarity rarity) { + AbstractTreasureChestTileEntity.GenerationContext generationContext = tileEntity.new GenerationContext(rarity, ChestGeneratorType.CAULDRON); + tileEntity.setGenerationContext(generationContext); + } + /* * @param random * @param chestRarity @@ -33,7 +45,12 @@ public CauldronChestGenerator() {} public LootTable selectLootTable(Random random, final Rarity chestRarity) { return Treasure.LOOT_TABLES.getSpecialLootTable(SpecialLootTables.CAULDRON_CHEST); } - + + @Override + public LootTable selectLootTable(Supplier factory, final Rarity rarity) { + return Treasure.LOOT_TABLES.getSpecialLootTable(SpecialLootTables.CAULDRON_CHEST); + } + /** * Always select a cauldron chest. */ diff --git a/src/com/someguyssoftware/treasure2/generator/chest/CommonChestGenerator.java b/src/com/someguyssoftware/treasure2/generator/chest/CommonChestGenerator.java index ca8a6a1f4..49eefc500 100644 --- a/src/com/someguyssoftware/treasure2/generator/chest/CommonChestGenerator.java +++ b/src/com/someguyssoftware/treasure2/generator/chest/CommonChestGenerator.java @@ -10,6 +10,7 @@ import com.someguyssoftware.gottschcore.loot.LootTable; import com.someguyssoftware.treasure2.Treasure; import com.someguyssoftware.treasure2.block.AbstractChestBlock; +import com.someguyssoftware.treasure2.enums.ChestGeneratorType; import com.someguyssoftware.treasure2.enums.Rarity; import com.someguyssoftware.treasure2.item.LockItem; import com.someguyssoftware.treasure2.item.TreasureItems; @@ -27,6 +28,15 @@ public class CommonChestGenerator implements IChestGenerator { */ public CommonChestGenerator() {} + /** + * + */ + @Override + public void addGenerationContext(AbstractTreasureChestTileEntity tileEntity, Rarity rarity) { + AbstractTreasureChestTileEntity.GenerationContext generationContext = tileEntity.new GenerationContext(rarity, ChestGeneratorType.COMMON); + tileEntity.setGenerationContext(generationContext); + } + /** * * @param random @@ -47,13 +57,13 @@ public List buildLootTableList(final Rarity chestRarity) { * @param chest */ @Override - public void addLocks(Random random, AbstractChestBlock chest, AbstractTreasureChestTileEntity te, Rarity rarity) { + public void addLocks(Random random, AbstractChestBlock chest, AbstractTreasureChestTileEntity chestTileEntity, Rarity rarity) { // select a rarity locks List locks = new ArrayList<>(); locks.addAll((List) TreasureItems.locks.get(Rarity.COMMON)); locks.addAll(TreasureItems.locks.get(Rarity.UNCOMMON)); - addLocks(random, chest, te, locks); + addLocks(random, chest, chestTileEntity, locks); locks.clear(); } } diff --git a/src/com/someguyssoftware/treasure2/generator/chest/EpicChestGenerator.java b/src/com/someguyssoftware/treasure2/generator/chest/EpicChestGenerator.java index d5af17ae1..7d5c7b704 100644 --- a/src/com/someguyssoftware/treasure2/generator/chest/EpicChestGenerator.java +++ b/src/com/someguyssoftware/treasure2/generator/chest/EpicChestGenerator.java @@ -8,6 +8,10 @@ import com.someguyssoftware.gottschcore.random.RandomHelper; import com.someguyssoftware.treasure2.Treasure; import com.someguyssoftware.treasure2.chest.TreasureChestType; +import com.someguyssoftware.treasure2.enums.ChestGeneratorType; +import com.someguyssoftware.treasure2.enums.Rarity; +import com.someguyssoftware.treasure2.tileentity.AbstractTreasureChestTileEntity; +import com.someguyssoftware.treasure2.tileentity.AbstractTreasureChestTileEntity.GenerationContext; /** * @@ -21,6 +25,15 @@ public class EpicChestGenerator implements IChestGenerator { */ public EpicChestGenerator() {} + /** + * + */ + @Override + public void addGenerationContext(AbstractTreasureChestTileEntity tileEntity, Rarity rarity) { + AbstractTreasureChestTileEntity.GenerationContext generationContext = tileEntity.new GenerationContext(rarity, ChestGeneratorType.EPIC); + tileEntity.setGenerationContext(generationContext); + } + /** * Epic will have at least one lock. */ diff --git a/src/com/someguyssoftware/treasure2/generator/chest/GoldSkullChestGenerator.java b/src/com/someguyssoftware/treasure2/generator/chest/GoldSkullChestGenerator.java index bf2603e31..1f7d004cc 100644 --- a/src/com/someguyssoftware/treasure2/generator/chest/GoldSkullChestGenerator.java +++ b/src/com/someguyssoftware/treasure2/generator/chest/GoldSkullChestGenerator.java @@ -6,6 +6,7 @@ import java.util.ArrayList; import java.util.List; import java.util.Random; +import java.util.function.Supplier; import com.someguyssoftware.gottschcore.loot.LootTable; import com.someguyssoftware.gottschcore.random.RandomHelper; @@ -14,11 +15,13 @@ import com.someguyssoftware.treasure2.block.TreasureBlocks; import com.someguyssoftware.treasure2.block.TreasureChestBlock; import com.someguyssoftware.treasure2.chest.TreasureChestType; +import com.someguyssoftware.treasure2.enums.ChestGeneratorType; import com.someguyssoftware.treasure2.enums.Rarity; import com.someguyssoftware.treasure2.item.LockItem; import com.someguyssoftware.treasure2.item.TreasureItems; import com.someguyssoftware.treasure2.loot.TreasureLootTableMaster.SpecialLootTables; import com.someguyssoftware.treasure2.tileentity.AbstractTreasureChestTileEntity; +import com.someguyssoftware.treasure2.tileentity.AbstractTreasureChestTileEntity.GenerationContext; /** * @@ -26,12 +29,21 @@ * */ public class GoldSkullChestGenerator implements IChestGenerator { - + /** * */ public GoldSkullChestGenerator() {} - + + /** + * + */ + @Override + public void addGenerationContext(AbstractTreasureChestTileEntity tileEntity, Rarity rarity) { + AbstractTreasureChestTileEntity.GenerationContext generationContext = tileEntity.new GenerationContext(rarity, ChestGeneratorType.GOLD_SKULL); + tileEntity.setGenerationContext(generationContext); + } + /* * @param random * @param chestRarity @@ -41,7 +53,12 @@ public GoldSkullChestGenerator() {} public LootTable selectLootTable(Random random, final Rarity chestRarity) { return Treasure.LOOT_TABLES.getSpecialLootTable(SpecialLootTables.GOLD_SKULL_CHEST); } - + + @Override + public LootTable selectLootTable(Supplier factory, final Rarity rarity) { + return Treasure.LOOT_TABLES.getSpecialLootTable(SpecialLootTables.GOLD_SKULL_CHEST); + } + /** * Always select a wither chest. */ @@ -50,7 +67,7 @@ public TreasureChestBlock selectChest(final Random random, final Rarity rarity) TreasureChestBlock chest = (TreasureChestBlock) TreasureBlocks.GOLD_SKULL_CHEST; return chest; } - + /** * Skull chest will have at least one lock. */ @@ -58,10 +75,10 @@ public int randomizedNumberOfLocksByChestType(Random random, TreasureChestType t // determine the number of locks to add int numLocks = RandomHelper.randomInt(random, 1, type.getMaxLocks()); Treasure.logger.debug("# of locks to use: {})", numLocks); - + return numLocks; } - + /** * Select Locks from Uncommon and Scare rarities. * @param chest diff --git a/src/com/someguyssoftware/treasure2/generator/chest/IChestGenerator.java b/src/com/someguyssoftware/treasure2/generator/chest/IChestGenerator.java index 20c5c1bce..1eae8a679 100644 --- a/src/com/someguyssoftware/treasure2/generator/chest/IChestGenerator.java +++ b/src/com/someguyssoftware/treasure2/generator/chest/IChestGenerator.java @@ -6,11 +6,15 @@ import java.util.ArrayList; import java.util.List; import java.util.Random; +import java.util.function.Supplier; import com.someguyssoftware.gottschcore.loot.LootTable; import com.someguyssoftware.gottschcore.positional.ICoords; import com.someguyssoftware.gottschcore.random.RandomHelper; import com.someguyssoftware.gottschcore.world.gen.structure.BlockContext; + +import static com.someguyssoftware.treasure2.Treasure.logger; + import com.someguyssoftware.treasure2.Treasure; import com.someguyssoftware.treasure2.block.AbstractChestBlock; import com.someguyssoftware.treasure2.block.IMimicBlock; @@ -45,42 +49,47 @@ default public GeneratorResult generate(final World world, f final Rarity rarity, IBlockState state) { GeneratorResult result = new GeneratorResult<>(ChestGeneratorData.class); result.getData().setSpawnCoords(coords); - // select a loot table - LootTable lootTable = selectLootTable(random, rarity); - if (lootTable == null) { - Treasure.logger.warn("Unable to select a lootTable."); - return result.fail(); - } + // LootTable lootTable = selectLootTable(random, rarity); + // if (lootTable == null) { + // logger.warn("Unable to select a lootTable."); + // return result.fail(); + // } // select a chest from the rarity AbstractChestBlock chest = selectChest(random, rarity); if (chest == null) { - Treasure.logger.warn("Unable to select a chest for rarity {}.", rarity); + logger.warn("Unable to select a chest for rarity {}.", rarity); return result.fail(); } // place the chest in the world - TileEntity te = null; + TileEntity tileEntity = null; if (state != null) { - te = placeInWorld(world, random, coords, chest, state); + tileEntity = placeInWorld(world, random, coords, chest, state); } else { - te = placeInWorld(world, random, chest, coords); + tileEntity = placeInWorld(world, random, chest, coords); } - if (te == null) { - Treasure.logger.debug("Unable to locate tile entity for chest -> {}", coords); + if (tileEntity == null) { + logger.debug("Unable to locate tile entity for chest -> {}", coords); return result.fail(); } - if (!(chest instanceof IMimicBlock)) { - Treasure.logger.debug("Generating loot from loot table for rarity {}", rarity); - lootTable.fillInventory((IInventory) te, random, Treasure.LOOT_TABLES.getContext()); - } + // seal the chest + addSeal((AbstractTreasureChestTileEntity) tileEntity); + + // update the backing tile entity's generation contxt + addGenerationContext((AbstractTreasureChestTileEntity) tileEntity, rarity); + + // if (!(chest instanceof IMimicBlock)) { + // logger.debug("Generating loot from loot table for rarity {}", rarity); + // lootTable.fillInventory((IInventory) te, random, Treasure.LOOT_TABLES.getContext()); + // } // add locks - addLocks(random, chest, (AbstractTreasureChestTileEntity) te, rarity); - + addLocks(random, chest, (AbstractTreasureChestTileEntity) tileEntity, rarity); + // update result result.getData().setChestContext(new BlockContext(coords, state)); @@ -112,12 +121,12 @@ default public AbstractChestBlock selectChest(final Random random, final Rarity if (chest == TreasureBlocks.WOOD_CHEST) { if (RandomHelper.checkProbability(random, config.getMimicProbability())) { chest = (AbstractChestBlock) TreasureBlocks.WOOD_MIMIC; - Treasure.logger.debug("Selecting a WOOD MIMIC chest!"); + logger.debug("Selecting a WOOD MIMIC chest!"); } } else if (chest == TreasureBlocks.PIRATE_CHEST) { if (RandomHelper.checkProbability(random, config.getMimicProbability())) { chest = (AbstractChestBlock) TreasureBlocks.PIRATE_MIMIC; - Treasure.logger.debug("Selecting a PIRATE MIMIC chest!"); + logger.debug("Selecting a PIRATE MIMIC chest!"); } } return chest; @@ -129,6 +138,7 @@ default public AbstractChestBlock selectChest(final Random random, final Rarity * @param rarity * @return */ + @Deprecated default public LootTable selectLootTable(Random random, final Rarity rarity) { LootTable table = null; @@ -138,30 +148,68 @@ default public LootTable selectLootTable(Random random, final Rarity rarity) { // select a random table from the list if (tables != null && !tables.isEmpty()) { int index = 0; - /* - * get a random container - */ if (tables.size() == 1) { table = tables.get(0); } else { index = RandomHelper.randomInt(random, 0, tables.size() - 1); table = tables.get(index); } - Treasure.logger.debug("Selected loot table index --> {}", index); + logger.debug("Selected loot table index --> {}", index); + } + return table; + } + + /** + * + * @param tileEntity + * @param rarity + */ + public void addGenerationContext(AbstractTreasureChestTileEntity tileEntity, Rarity rarity); + + /** + * + * @param factory + * @param rarity + * @return + */ + default public LootTable selectLootTable(Supplier factory, final Rarity rarity) { + LootTable table = null; + + // select the loot table by rarity + List tables = buildLootTableList(rarity); + + // select a random table from the list + if (tables != null && !tables.isEmpty()) { + int index = 0; + if (tables.size() == 1) { + table = tables.get(0); + } else { + index = RandomHelper.randomInt(factory.get(), 0, tables.size() - 1); + table = tables.get(index); + } + logger.debug("Selected loot table index --> {}", index); } return table; } + /** + * + * @param tileEntity + */ + default public void addSeal(AbstractTreasureChestTileEntity tileEntity) { + tileEntity.setSealed(true); + } + /** * Default implementation. Select locks only from with the same Rarity. * * @param chest */ - default public void addLocks(Random random, AbstractChestBlock chest, AbstractTreasureChestTileEntity te, + default public void addLocks(Random random, AbstractChestBlock chest, AbstractTreasureChestTileEntity chestTileEntity, Rarity rarity) { List locks = new ArrayList<>(); locks.addAll(TreasureItems.locks.get(rarity)); - addLocks(random, chest, te, locks); + addLocks(random, chest, chestTileEntity, locks); locks.clear(); } @@ -172,16 +220,16 @@ default public void addLocks(Random random, AbstractChestBlock chest, AbstractTr * @param te * @param locks */ - default public void addLocks(Random random, AbstractChestBlock chest, AbstractTreasureChestTileEntity te, + default public void addLocks(Random random, AbstractChestBlock chest, AbstractTreasureChestTileEntity chestTileEntity, List locks) { int numLocks = randomizedNumberOfLocksByChestType(random, chest.getChestType()); // get the lock states - List lockStates = te.getLockStates(); + List lockStates = chestTileEntity.getLockStates(); for (int i = 0; i < numLocks; i++) { LockItem lock = locks.get(RandomHelper.randomInt(random, 0, locks.size() - 1)); - Treasure.logger.debug("adding lock: {}", lock); + logger.debug("adding lock: {}", lock); // add the lock to the chest lockStates.get(i).setLock(lock); } @@ -196,7 +244,7 @@ default public void addLocks(Random random, AbstractChestBlock chest, AbstractTr default public int randomizedNumberOfLocksByChestType(Random random, TreasureChestType type) { // determine the number of locks to add int numLocks = RandomHelper.randomInt(random, 0, type.getMaxLocks()); - Treasure.logger.debug("# of locks to use: {})", numLocks); + logger.debug("# of locks to use: {})", numLocks); return numLocks; } @@ -218,7 +266,7 @@ default public void addMarkers(World world, Random random, ICoords coords, final // GenUtil.placeMarkers(world, random, coords); if (!isSurfaceChest && TreasureConfig.WORLD_GEN.getMarkerProperties().isMarkerStructuresAllowed && RandomHelper .checkProbability(random, TreasureConfig.WORLD_GEN.getMarkerProperties().markerStructureProbability)) { - Treasure.logger.debug("generating a random structure marker -> {}", coords.toShortString()); + logger.debug("generating a random structure marker -> {}", coords.toShortString()); new StructureMarkerGenerator().generate(world, random, coords); } else { new GravestoneMarkerGenerator().generate(world, random, coords); @@ -238,27 +286,27 @@ default public TileEntity placeInWorld(World world, Random random, AbstractChest boolean isPlaced = GenUtil.replaceBlockWithChest(world, random, chest, chestCoords); // get the backing tile entity of the chest - TileEntity te = (TileEntity) world.getTileEntity(chestCoords.toPos()); + TileEntity tileEntity = (TileEntity) world.getTileEntity(chestCoords.toPos()); // check to ensure the chest has been generated if (!isPlaced || !(world.getBlockState(chestCoords.toPos()).getBlock() instanceof AbstractChestBlock)) { - Treasure.logger.debug("Unable to place chest @ {}", chestCoords.toShortString()); + logger.debug("Unable to place chest @ {}", chestCoords.toShortString()); // remove the title entity (if exists) - if (te != null && (te instanceof AbstractTreasureChestTileEntity)) { + if (tileEntity != null && (tileEntity instanceof AbstractTreasureChestTileEntity)) { world.removeTileEntity(chestCoords.toPos()); } return null; } // if tile entity failed to create, remove the chest - if (te == null || !(te instanceof AbstractTreasureChestTileEntity)) { + if (tileEntity == null || !(tileEntity instanceof AbstractTreasureChestTileEntity)) { // remove chest world.setBlockToAir(chestCoords.toPos()); - Treasure.logger.debug("Unable to create TileEntityChest, removing BlockChest"); + logger.debug("Unable to create TileEntityChest, removing BlockChest"); return null; } - return te; + return tileEntity; } /** @@ -274,28 +322,28 @@ default public TileEntity placeInWorld(World world, Random random, ICoords chest IBlockState state) { // replace block @ coords boolean isPlaced = GenUtil.replaceBlockWithChest(world, random, chestCoords, chest, state); - Treasure.logger.debug("isPlaced -> {}", isPlaced); + logger.debug("isPlaced -> {}", isPlaced); // get the backing tile entity of the chest - TileEntity te = (TileEntity) world.getTileEntity(chestCoords.toPos()); + TileEntity tileEntity = (TileEntity) world.getTileEntity(chestCoords.toPos()); // check to ensure the chest has been generated if (!isPlaced || !(world.getBlockState(chestCoords.toPos()).getBlock() instanceof AbstractChestBlock)) { - Treasure.logger.debug("Unable to place chest @ {}", chestCoords.toShortString()); + logger.debug("Unable to place chest @ {}", chestCoords.toShortString()); // remove the title entity (if exists) - if (te != null && (te instanceof AbstractTreasureChestTileEntity)) { + if (tileEntity != null && (tileEntity instanceof AbstractTreasureChestTileEntity)) { world.removeTileEntity(chestCoords.toPos()); } return null; } // if tile entity failed to create, remove the chest - if (te == null || !(te instanceof AbstractTreasureChestTileEntity)) { + if (tileEntity == null || !(tileEntity instanceof AbstractTreasureChestTileEntity)) { // remove chest world.setBlockToAir(chestCoords.toPos()); - Treasure.logger.debug("Unable to create TileEntityChest, removing BlockChest"); + logger.debug("Unable to create TileEntityChest, removing BlockChest"); return null; } - return te; + return tileEntity; } } diff --git a/src/com/someguyssoftware/treasure2/generator/chest/RareChestGenerator.java b/src/com/someguyssoftware/treasure2/generator/chest/RareChestGenerator.java index f83026a3b..865a66c6f 100644 --- a/src/com/someguyssoftware/treasure2/generator/chest/RareChestGenerator.java +++ b/src/com/someguyssoftware/treasure2/generator/chest/RareChestGenerator.java @@ -14,10 +14,12 @@ import com.someguyssoftware.treasure2.Treasure; import com.someguyssoftware.treasure2.block.AbstractChestBlock; import com.someguyssoftware.treasure2.chest.TreasureChestType; +import com.someguyssoftware.treasure2.enums.ChestGeneratorType; import com.someguyssoftware.treasure2.enums.Rarity; import com.someguyssoftware.treasure2.item.LockItem; import com.someguyssoftware.treasure2.item.TreasureItems; import com.someguyssoftware.treasure2.tileentity.AbstractTreasureChestTileEntity; +import com.someguyssoftware.treasure2.tileentity.AbstractTreasureChestTileEntity.GenerationContext; /** @@ -26,12 +28,21 @@ * */ public class RareChestGenerator implements IChestGenerator { - + /** * */ public RareChestGenerator() {} + /** + * + */ + @Override + public void addGenerationContext(AbstractTreasureChestTileEntity tileEntity, Rarity rarity) { + AbstractTreasureChestTileEntity.GenerationContext generationContext = tileEntity.new GenerationContext(rarity, ChestGeneratorType.RARE); + tileEntity.setGenerationContext(generationContext); + } + @Override public List buildLootTableList(final Rarity chestRarity) { List tables = new ArrayList<>(); diff --git a/src/com/someguyssoftware/treasure2/generator/chest/ScarceChestGenerator.java b/src/com/someguyssoftware/treasure2/generator/chest/ScarceChestGenerator.java index ac3e55a1b..09fdaf51f 100644 --- a/src/com/someguyssoftware/treasure2/generator/chest/ScarceChestGenerator.java +++ b/src/com/someguyssoftware/treasure2/generator/chest/ScarceChestGenerator.java @@ -14,10 +14,12 @@ import com.someguyssoftware.treasure2.Treasure; import com.someguyssoftware.treasure2.block.AbstractChestBlock; import com.someguyssoftware.treasure2.chest.TreasureChestType; +import com.someguyssoftware.treasure2.enums.ChestGeneratorType; import com.someguyssoftware.treasure2.enums.Rarity; import com.someguyssoftware.treasure2.item.LockItem; import com.someguyssoftware.treasure2.item.TreasureItems; import com.someguyssoftware.treasure2.tileentity.AbstractTreasureChestTileEntity; +import com.someguyssoftware.treasure2.tileentity.AbstractTreasureChestTileEntity.GenerationContext; /** @@ -32,6 +34,15 @@ public class ScarceChestGenerator implements IChestGenerator { */ public ScarceChestGenerator() {} + /** + * + */ + @Override + public void addGenerationContext(AbstractTreasureChestTileEntity tileEntity, Rarity rarity) { + AbstractTreasureChestTileEntity.GenerationContext generationContext = tileEntity.new GenerationContext(rarity, ChestGeneratorType.SCARCE); + tileEntity.setGenerationContext(generationContext); + } + /** * */ diff --git a/src/com/someguyssoftware/treasure2/generator/chest/SkullChestGenerator.java b/src/com/someguyssoftware/treasure2/generator/chest/SkullChestGenerator.java index ee72cdcdb..122059d69 100644 --- a/src/com/someguyssoftware/treasure2/generator/chest/SkullChestGenerator.java +++ b/src/com/someguyssoftware/treasure2/generator/chest/SkullChestGenerator.java @@ -6,6 +6,7 @@ import java.util.ArrayList; import java.util.List; import java.util.Random; +import java.util.function.Supplier; import com.someguyssoftware.gottschcore.loot.LootTable; import com.someguyssoftware.gottschcore.random.RandomHelper; @@ -14,11 +15,13 @@ import com.someguyssoftware.treasure2.block.TreasureBlocks; import com.someguyssoftware.treasure2.block.TreasureChestBlock; import com.someguyssoftware.treasure2.chest.TreasureChestType; +import com.someguyssoftware.treasure2.enums.ChestGeneratorType; import com.someguyssoftware.treasure2.enums.Rarity; import com.someguyssoftware.treasure2.item.LockItem; import com.someguyssoftware.treasure2.item.TreasureItems; import com.someguyssoftware.treasure2.loot.TreasureLootTableMaster.SpecialLootTables; import com.someguyssoftware.treasure2.tileentity.AbstractTreasureChestTileEntity; +import com.someguyssoftware.treasure2.tileentity.AbstractTreasureChestTileEntity.GenerationContext; /** * @@ -26,12 +29,21 @@ * */ public class SkullChestGenerator implements IChestGenerator { - + /** * */ public SkullChestGenerator() {} - + + /** + * + */ + @Override + public void addGenerationContext(AbstractTreasureChestTileEntity tileEntity, Rarity rarity) { + AbstractTreasureChestTileEntity.GenerationContext generationContext = tileEntity.new GenerationContext(rarity, ChestGeneratorType.SKULL); + tileEntity.setGenerationContext(generationContext); + } + /* * @param random * @param chestRarity @@ -41,7 +53,12 @@ public SkullChestGenerator() {} public LootTable selectLootTable(Random random, final Rarity chestRarity) { return Treasure.LOOT_TABLES.getSpecialLootTable(SpecialLootTables.SKULL_CHEST); } - + + @Override + public LootTable selectLootTable(Supplier factory, final Rarity rarity) { + return Treasure.LOOT_TABLES.getSpecialLootTable(SpecialLootTables.SKULL_CHEST); + } + /** * Always select a skull chest. */ @@ -50,7 +67,7 @@ public TreasureChestBlock selectChest(final Random random, final Rarity rarity) TreasureChestBlock chest = (TreasureChestBlock) TreasureBlocks.SKULL_CHEST; return chest; } - + /** * Skull chest will have at least one lock. */ @@ -58,10 +75,10 @@ public int randomizedNumberOfLocksByChestType(Random random, TreasureChestType t // determine the number of locks to add int numLocks = RandomHelper.randomInt(random, 1, type.getMaxLocks()); Treasure.logger.debug("# of locks to use: {})", numLocks); - + return numLocks; } - + /** * Select Locks from Uncommon and Scare rarities. * @param chest diff --git a/src/com/someguyssoftware/treasure2/generator/chest/UncommonChestGenerator.java b/src/com/someguyssoftware/treasure2/generator/chest/UncommonChestGenerator.java index 878e161ea..6ea24c3e7 100644 --- a/src/com/someguyssoftware/treasure2/generator/chest/UncommonChestGenerator.java +++ b/src/com/someguyssoftware/treasure2/generator/chest/UncommonChestGenerator.java @@ -12,10 +12,12 @@ import com.someguyssoftware.gottschcore.loot.LootTable; import com.someguyssoftware.treasure2.Treasure; import com.someguyssoftware.treasure2.block.AbstractChestBlock; +import com.someguyssoftware.treasure2.enums.ChestGeneratorType; import com.someguyssoftware.treasure2.enums.Rarity; import com.someguyssoftware.treasure2.item.LockItem; import com.someguyssoftware.treasure2.item.TreasureItems; import com.someguyssoftware.treasure2.tileentity.AbstractTreasureChestTileEntity; +import com.someguyssoftware.treasure2.tileentity.AbstractTreasureChestTileEntity.GenerationContext; /** * @@ -29,6 +31,15 @@ public class UncommonChestGenerator implements IChestGenerator { */ public UncommonChestGenerator() {} + /** + * + */ + @Override + public void addGenerationContext(AbstractTreasureChestTileEntity tileEntity, Rarity rarity) { + AbstractTreasureChestTileEntity.GenerationContext generationContext = tileEntity.new GenerationContext(rarity, ChestGeneratorType.UNCOMMON); + tileEntity.setGenerationContext(generationContext); + } + /** * */ diff --git a/src/com/someguyssoftware/treasure2/generator/chest/WitherChestGenerator.java b/src/com/someguyssoftware/treasure2/generator/chest/WitherChestGenerator.java index 357ce2802..134b67b23 100644 --- a/src/com/someguyssoftware/treasure2/generator/chest/WitherChestGenerator.java +++ b/src/com/someguyssoftware/treasure2/generator/chest/WitherChestGenerator.java @@ -5,6 +5,7 @@ import java.util.List; import java.util.Random; +import java.util.function.Supplier; import com.someguyssoftware.gottschcore.loot.LootTable; import com.someguyssoftware.gottschcore.positional.ICoords; @@ -14,6 +15,7 @@ import com.someguyssoftware.treasure2.block.TreasureBlocks; import com.someguyssoftware.treasure2.block.TreasureChestBlock; import com.someguyssoftware.treasure2.chest.TreasureChestType; +import com.someguyssoftware.treasure2.enums.ChestGeneratorType; import com.someguyssoftware.treasure2.enums.Rarity; import com.someguyssoftware.treasure2.generator.GenUtil; import com.someguyssoftware.treasure2.item.LockItem; @@ -21,6 +23,7 @@ import com.someguyssoftware.treasure2.lock.LockState; import com.someguyssoftware.treasure2.loot.TreasureLootTableMaster.SpecialLootTables; import com.someguyssoftware.treasure2.tileentity.AbstractTreasureChestTileEntity; +import com.someguyssoftware.treasure2.tileentity.AbstractTreasureChestTileEntity.GenerationContext; import net.minecraft.block.state.IBlockState; import net.minecraft.tileentity.TileEntity; @@ -38,6 +41,15 @@ public class WitherChestGenerator implements IChestGenerator { */ public WitherChestGenerator() {} + /** + * + */ + @Override + public void addGenerationContext(AbstractTreasureChestTileEntity tileEntity, Rarity rarity) { + AbstractTreasureChestTileEntity.GenerationContext generationContext = tileEntity.new GenerationContext(rarity, ChestGeneratorType.WITHER); + tileEntity.setGenerationContext(generationContext); + } + /* * @param random * @param chestRarity @@ -47,6 +59,11 @@ public WitherChestGenerator() {} public LootTable selectLootTable(Random random, final Rarity chestRarity) { return Treasure.LOOT_TABLES.getSpecialLootTable(SpecialLootTables.WITHER_CHEST); } + + @Override + public LootTable selectLootTable(Supplier factory, final Rarity rarity) { + return Treasure.LOOT_TABLES.getSpecialLootTable(SpecialLootTables.WITHER_CHEST); + } /** * Always select a wither chest. diff --git a/src/com/someguyssoftware/treasure2/generator/marker/GravestoneMarkerGenerator.java b/src/com/someguyssoftware/treasure2/generator/marker/GravestoneMarkerGenerator.java index 20ffe56ad..aebbe8d64 100644 --- a/src/com/someguyssoftware/treasure2/generator/marker/GravestoneMarkerGenerator.java +++ b/src/com/someguyssoftware/treasure2/generator/marker/GravestoneMarkerGenerator.java @@ -130,7 +130,7 @@ public GeneratorResult generate(World world, Random random, ICoor // determine if gravestone spawns an entity if (TreasureConfig.WORLD_GEN.markerProperties.isGravestoneSpawnMobAllowed && RandomHelper .checkProbability(random, TreasureConfig.WORLD_GEN.markerProperties.gravestoneMobProbability)) { - + Treasure.logger.debug("Created Gravestone with mob entity @ -> {}", spawnCoords.toShortString()); // update the tile entity GravestoneProximitySpawnerTileEntity tileEntity = (GravestoneProximitySpawnerTileEntity) world .getTileEntity(spawnCoords.toPos()); diff --git a/src/com/someguyssoftware/treasure2/generator/marker/StructureMarkerGenerator.java b/src/com/someguyssoftware/treasure2/generator/marker/StructureMarkerGenerator.java index dc83984d1..9958d430c 100644 --- a/src/com/someguyssoftware/treasure2/generator/marker/StructureMarkerGenerator.java +++ b/src/com/someguyssoftware/treasure2/generator/marker/StructureMarkerGenerator.java @@ -130,6 +130,7 @@ public GeneratorResult generate(World world, Random random, ICoor te.setMobName(r); te.setMobNum(new Quantity(1, 2)); te.setProximity(10D); +// Treasure.logger.debug("Creating proximity spawner @ {} -> [mobName={}, spawnRange={}", c.getCoords().toShortString(), r, te.getProximity()); } result.setData(genResult.getData()); diff --git a/src/com/someguyssoftware/treasure2/generator/oasis/DesertOasisGenerator.java b/src/com/someguyssoftware/treasure2/generator/oasis/DesertOasisGenerator.java index 0a418beda..7fef0dd80 100644 --- a/src/com/someguyssoftware/treasure2/generator/oasis/DesertOasisGenerator.java +++ b/src/com/someguyssoftware/treasure2/generator/oasis/DesertOasisGenerator.java @@ -16,7 +16,7 @@ import com.someguyssoftware.treasure2.config.IOasisConfig; import com.someguyssoftware.treasure2.config.TreasureConfig; import com.someguyssoftware.treasure2.enums.Rarity; -import com.someguyssoftware.treasure2.enums.WorldGenerators; +import com.someguyssoftware.treasure2.enums.WorldGeneratorType; import com.someguyssoftware.treasure2.generator.ChestGeneratorData; import com.someguyssoftware.treasure2.generator.GeneratorData; import com.someguyssoftware.treasure2.generator.GeneratorResult; @@ -139,7 +139,7 @@ private GeneratorResult generateChest(World world, Random ra Rarity rarity = Rarity.values()[random.nextInt(Rarity.values().length)]; // select a random facing IBlockState chestState = Blocks.CHEST.getDefaultState().withProperty(BlockChest.FACING, EnumFacing.HORIZONTALS[random.nextInt(EnumFacing.HORIZONTALS.length)]); - SurfaceChestWorldGenerator chestWorldGen = (SurfaceChestWorldGenerator) Treasure.WORLD_GENERATORS.get(WorldGenerators.SURFACE_CHEST); + SurfaceChestWorldGenerator chestWorldGen = (SurfaceChestWorldGenerator) Treasure.WORLD_GENERATORS.get(WorldGeneratorType.SURFACE_CHEST); IChestGenerator chestGen = chestWorldGen.getChestGenMap().get(rarity).next(); Optional> result = Optional.ofNullable(chestGen.generate(world, random, chestCoords, rarity, chestState)); if (result.isPresent() && result.get().isSuccess()) { diff --git a/src/com/someguyssoftware/treasure2/generator/pit/AbstractPitGenerator.java b/src/com/someguyssoftware/treasure2/generator/pit/AbstractPitGenerator.java index ae989da48..c513eaf0d 100644 --- a/src/com/someguyssoftware/treasure2/generator/pit/AbstractPitGenerator.java +++ b/src/com/someguyssoftware/treasure2/generator/pit/AbstractPitGenerator.java @@ -121,7 +121,7 @@ public GeneratorResult generate(World world, Random random, int yDist = (surfaceCoords.getY() - spawnCoords.getY()) - 2; Treasure.logger.debug("Distance to ySurface =" + yDist); - if (yDist > 6) { + if (yDist > getMinSurfaceToSpawnDistance()) { Treasure.logger.debug("Generating shaft @ " + spawnCoords.toShortString()); generateBase(world, random, surfaceCoords, spawnCoords); @@ -140,6 +140,15 @@ else if (yDist >= 2) { return result.success(); } + /** + * + * @return + */ + @Override + public int getMinSurfaceToSpawnDistance() { + return 6; + } + /** * * @param world diff --git a/src/com/someguyssoftware/treasure2/generator/pit/IPitGenerator.java b/src/com/someguyssoftware/treasure2/generator/pit/IPitGenerator.java index 08d9b0409..2a37feb75 100644 --- a/src/com/someguyssoftware/treasure2/generator/pit/IPitGenerator.java +++ b/src/com/someguyssoftware/treasure2/generator/pit/IPitGenerator.java @@ -29,4 +29,6 @@ public interface IPitGenerator> { public int getOffsetY(); public void setOffsetY(int i); + + int getMinSurfaceToSpawnDistance(); } \ No newline at end of file diff --git a/src/com/someguyssoftware/treasure2/generator/pit/VolcanoPitGenerator.java b/src/com/someguyssoftware/treasure2/generator/pit/VolcanoPitGenerator.java new file mode 100644 index 000000000..ecd3b77f3 --- /dev/null +++ b/src/com/someguyssoftware/treasure2/generator/pit/VolcanoPitGenerator.java @@ -0,0 +1,217 @@ +package com.someguyssoftware.treasure2.generator.pit; + +import java.util.Random; + +import static com.someguyssoftware.treasure2.Treasure.logger; +import com.someguyssoftware.gottschcore.cube.Cube; +import com.someguyssoftware.gottschcore.positional.Coords; +import com.someguyssoftware.gottschcore.positional.ICoords; +import com.someguyssoftware.gottschcore.random.RandomHelper; +import com.someguyssoftware.gottschcore.random.RandomWeightedCollection; +import com.someguyssoftware.treasure2.block.TreasureBlocks; +import com.someguyssoftware.treasure2.generator.ChestGeneratorData; +import com.someguyssoftware.treasure2.generator.GenUtil; +import com.someguyssoftware.treasure2.generator.GeneratorResult; +import com.sun.media.jfxmedia.logging.Logger; + +import net.minecraft.block.Block; +import net.minecraft.init.Blocks; +import net.minecraft.util.math.AxisAlignedBB; +import net.minecraft.world.World; + + +/** + * A Volcano Pit requires at least 15 blocks under the surface to construct. + * @author Mark Gottschling on Sep 5, 2020 + * + */ +public class VolcanoPitGenerator extends AbstractPitGenerator { + private static final int MIN_VOLCANO_RADIUS = 4; + private static final int MAX_VOLCANO_RADIUS = 8; + private static final int MIN_VERTICAL_DISTANCE = 15; + + /** + * + */ + public VolcanoPitGenerator() { + getBlockLayers().add(50, Blocks.AIR); + getBlockLayers().add(25, Blocks.SAND); + getBlockLayers().add(15, Blocks.COBBLESTONE); + getBlockLayers().add(15, Blocks.GRAVEL); + getBlockLayers().add(10, Blocks.LOG); + } + + /** + * + * @param world + * @param random + * @param surfaceCoords + * @param spawnCoords + * @return + */ + @Override + public GeneratorResult generate(World world, Random random, ICoords surfaceCoords, ICoords spawnCoords) { + GeneratorResult result = super.generate(world, random, surfaceCoords, spawnCoords); + if (result.isSuccess()) { + logger.debug("Generated Volcano Pit at " + spawnCoords.toShortString()); + } + return result; + } + + /** + * + * @param world + * @param random + * @param spawnCoords + * @param surfaceCoords + * @return + */ + @Override + public ICoords buildPit(World world, Random random, ICoords coords, ICoords surfaceCoords, RandomWeightedCollection col) { + ICoords nextCoords = null; + ICoords expectedCoords = null; + + // determine size of volcano + int radius = RandomHelper.randomInt(random, MIN_VOLCANO_RADIUS, MAX_VOLCANO_RADIUS); // min of 4, so diameter = 9 (4*2 + 1 (center)), area = 9x9 + + // select 2/3 point of pit length - topmost coords of volcano chamber / bottom of pit shaft + int shaftStartY = coords.getY() + ((surfaceCoords.getY() - coords.getY()) / 3 * 2); + + // build lava around base + buildLavaBaseLayer(world, coords.down(1), radius); + + nextCoords = coords; + while (nextCoords.getY() < (shaftStartY - 4)) { + nextCoords = buildLayer(world, nextCoords, radius, Blocks.AIR, true); + } + + // taper in until 2/3 point is reached + while (nextCoords.getY() < shaftStartY && radius > 1) { + nextCoords = buildLayer(world, nextCoords, radius--, Blocks.AIR, false); + } + + // build one layer of logs + nextCoords = buildLogLayer(world, random, nextCoords, Blocks.LOG); + + // build shaft + for (int yIndex = nextCoords.getY() + 1; yIndex <= surfaceCoords.getY() - SURFACE_OFFSET_Y; yIndex++) { + // if the block to be replaced is air block then skip to the next pos + Cube cube = new Cube(world, new Coords(coords.getX(), yIndex, coords.getZ())); + if (cube.isAir()) { + continue; + } + + // get the next type of block layer to build + Block block = col.next(); + if (block == Blocks.LOG) { + // special log build layer + nextCoords = buildLogLayer(world, random, cube.getCoords(), block); // could have difference classes and implement buildLayer differently + } + else { + nextCoords = buildLayer(world, cube.getCoords(), block); + } + + // get the expected coords + expectedCoords = cube.getCoords().add(0, 1, 0); + + // check if the return coords is different than the anticipated coords and resolve + yIndex = autoCorrectIndex(yIndex, nextCoords, expectedCoords); + } + return nextCoords; + } + + /** + * + */ + @Override + public void buildAboveChestLayers(World world, Random random, ICoords spawnCoords) { + + } + + /** + * + */ + private ICoords buildLayer(World world, ICoords coords, int radius, Block block, boolean addDecorations) { + int radiusSquared = radius * radius; + Integer[] distancesMet = new Integer[radius + 1]; + ICoords spawnCoords = null; + for (int xOffset = -(radius); xOffset <= radius; xOffset++) { + for (int zOffset = -(radius); zOffset <= radius; zOffset++) { + boolean isDistanceMet = false; + spawnCoords = coords.add(xOffset, 0, zOffset); + if (distancesMet[Math.abs(xOffset)] != null) { + if (Math.abs(zOffset) <= distancesMet[Math.abs(xOffset)]) { + isDistanceMet = true; + } + } + else { + if (coords.getDistanceSq(spawnCoords) < radiusSquared) { + distancesMet[Math.abs(xOffset)] = Math.abs(zOffset); + isDistanceMet = true; + } + } + + if (isDistanceMet) { + Random random = new Random(); + GenUtil.replaceWithBlock(world, spawnCoords, block); + + if (addDecorations) { + if (xOffset < 0) { + ICoords replaceCoords = spawnCoords.west(1); + addDecorations(world, random, replaceCoords); + } + else if (xOffset > 0) { + ICoords replaceCoords = spawnCoords.east(1); + addDecorations(world, random, replaceCoords); + } + + if (zOffset < 0) { + ICoords replaceCoords = spawnCoords.north(1); + addDecorations(world, random, replaceCoords); + } + else if (zOffset > 0) { + ICoords replaceCoords = spawnCoords.south(1); + addDecorations(world, random, replaceCoords); + } + } + } + } + } + + return coords.up(1); + } + + /** + * + */ + private void addDecorations(World world, Random random, ICoords coords) { + if (world.getBlockState(coords.toPos()).getBlock() != Blocks.AIR) { + if (RandomHelper.checkProbability(random, 30)) { + world.setBlockState(coords.toPos(), TreasureBlocks.BLACKSTONE.getDefaultState()); + } + else if (RandomHelper.checkProbability(random, 10)) { + world.setBlockState(coords.toPos(), Blocks.LAVA.getDefaultState()); + } + } + } + + /** + * + * @param world + * @param coords + */ + private void buildLavaBaseLayer(World world, ICoords coords, int radius) { + logger.debug("Building lava baselayer from @ {} ", coords.toShortString()); + + // for circular chamber + buildLayer(world, coords, radius, Blocks.LAVA, false); + + // add the chest + GenUtil.replaceWithBlock(world, coords, Blocks.STONE); + } + + @Override + public int getMinSurfaceToSpawnDistance() { + return MIN_VERTICAL_DISTANCE; + } +} \ No newline at end of file diff --git a/src/com/someguyssoftware/treasure2/inventory/KeyRingInventory.java b/src/com/someguyssoftware/treasure2/inventory/KeyRingInventory.java index f1743a993..70a64604e 100644 --- a/src/com/someguyssoftware/treasure2/inventory/KeyRingInventory.java +++ b/src/com/someguyssoftware/treasure2/inventory/KeyRingInventory.java @@ -29,7 +29,6 @@ public class KeyRingInventory implements IInventory { private ItemStack itemStack; /** IInventory properties */ -// private int numberOfSlots = INVENTORY_SIZE; // default size private NonNullList items = NonNullList.withSize(INVENTORY_SIZE, ItemStack.EMPTY); /** @@ -41,8 +40,8 @@ public KeyRingInventory(ItemStack stack) { this.itemStack = stack; if (stack.hasCapability(KeyRingCapabilityProvider.KEY_RING_INVENTORY_CAPABILITY, null)) { - IItemHandler cap = stack.getCapability(KeyRingCapabilityProvider.KEY_RING_INVENTORY_CAPABILITY, null); - readInventoryFromNBT(cap); + IItemHandler itemHandler = stack.getCapability(KeyRingCapabilityProvider.KEY_RING_INVENTORY_CAPABILITY, null); + readInventoryFromHandler(itemHandler); } } @@ -50,7 +49,7 @@ public KeyRingInventory(ItemStack stack) { * * @param handler */ - public void readInventoryFromNBT(IItemHandler handler) { + public void readInventoryFromHandler(IItemHandler handler) { try { // read the inventory for (int i = 0; i < INVENTORY_SIZE; i++) { @@ -66,7 +65,7 @@ public void readInventoryFromNBT(IItemHandler handler) { * * @param handler */ - public void writeInventoryToNBT(IItemHandler handler) { + public void writeInventoryToHandler(IItemHandler handler) { try { for (int i = 0; i < items.size(); i++) { handler.insertItem(i, items.get(i), false); @@ -216,8 +215,8 @@ public void closeInventory(EntityPlayer player) { * write the locked state to the nbt */ if (getItemStack().hasCapability(KeyRingCapabilityProvider.KEY_RING_INVENTORY_CAPABILITY, null)) { - IItemHandler cap = getItemStack().getCapability(KeyRingCapabilityProvider.KEY_RING_INVENTORY_CAPABILITY, null); - writeInventoryToNBT(cap); + IItemHandler itemHandler = getItemStack().getCapability(KeyRingCapabilityProvider.KEY_RING_INVENTORY_CAPABILITY, null); + writeInventoryToHandler(itemHandler); } if (getItemStack().hasCapability(KeyRingCapabilityProvider.KEY_RING_CAPABILITY, null)) { IKeyRingCapability cap = getItemStack().getCapability(KeyRingCapabilityProvider.KEY_RING_CAPABILITY, null); diff --git a/src/com/someguyssoftware/treasure2/inventory/PouchContainer.java b/src/com/someguyssoftware/treasure2/inventory/PouchContainer.java index 784e7feda..886c41ab0 100644 --- a/src/com/someguyssoftware/treasure2/inventory/PouchContainer.java +++ b/src/com/someguyssoftware/treasure2/inventory/PouchContainer.java @@ -1,6 +1,5 @@ package com.someguyssoftware.treasure2.inventory; -import com.someguyssoftware.treasure2.Treasure; import com.someguyssoftware.treasure2.item.PouchItem; import com.someguyssoftware.treasure2.item.TreasureItems; @@ -19,11 +18,11 @@ public class PouchContainer extends AbstractChestContainer { private ItemStack stack; /** * - * @param invPlayer + * @param playerInventory * @param inventory */ - public PouchContainer(InventoryPlayer invPlayer, IInventory inventory, ItemStack stack) { - super(invPlayer, inventory); + public PouchContainer(InventoryPlayer playerInventory, IInventory inventory, ItemStack stack) { + super(playerInventory, inventory); this.stack = stack; @@ -38,7 +37,7 @@ public PouchContainer(InventoryPlayer invPlayer, IInventory inventory, ItemStack setContainerInventoryColumnCount(3); // build the container - buildContainer(invPlayer, inventory); + buildContainer(playerInventory, inventory); } @Override diff --git a/src/com/someguyssoftware/treasure2/inventory/PouchInventory.java b/src/com/someguyssoftware/treasure2/inventory/PouchInventory.java index 98290f570..90c2ac181 100644 --- a/src/com/someguyssoftware/treasure2/inventory/PouchInventory.java +++ b/src/com/someguyssoftware/treasure2/inventory/PouchInventory.java @@ -16,8 +16,7 @@ import net.minecraft.util.text.ITextComponent; import net.minecraft.util.text.TextComponentTranslation; import net.minecraftforge.items.IItemHandler; - -// TODO make an abstract as different pouches will have different sizes +import net.minecraftforge.items.ItemStackHandler; /** * @author Mark Gottschling on Mar 9, 2018 @@ -44,7 +43,7 @@ public PouchInventory(ItemStack stack) { if (stack.hasCapability(PouchCapabilityProvider.INVENTORY_CAPABILITY, null)) { IItemHandler cap = stack.getCapability(PouchCapabilityProvider.INVENTORY_CAPABILITY, null); - readInventoryFromNBT(cap); + readInventory(cap); } } @@ -52,7 +51,7 @@ public PouchInventory(ItemStack stack) { * * @param handler */ - public void readInventoryFromNBT(IItemHandler handler) { + public void readInventory(IItemHandler handler) { try { // read the inventory for (int i = 0; i < INVENTORY_SIZE; i++) { @@ -68,8 +67,17 @@ public void readInventoryFromNBT(IItemHandler handler) { * * @param handler */ - public void writeInventoryToNBT(IItemHandler handler) { + public void writeInventory(IItemHandler handler) { try { + /* + * NOTE must clear the ItemStackHandler first because it retains it's inventory, the + * when insertItem is called, it actually appends, not replaces, items into it's inventory + * causing doubling of items. + */ + // clear the item handler capability + ((ItemStackHandler)handler).setSize(PouchInventory.INVENTORY_SIZE); + + // add all items from inventory into item handler for (int i = 0; i < items.size(); i++) { handler.insertItem(i, items.get(i), false); } @@ -217,8 +225,9 @@ public void closeInventory(EntityPlayer player) { * write the locked state to the nbt */ if (getItemStack().hasCapability(PouchCapabilityProvider.INVENTORY_CAPABILITY, null)) { - IItemHandler cap = getItemStack().getCapability(PouchCapabilityProvider.INVENTORY_CAPABILITY, null); - writeInventoryToNBT(cap); + IItemHandler itemHandler = getItemStack().getCapability(PouchCapabilityProvider.INVENTORY_CAPABILITY, null); + // persist + writeInventory(itemHandler); } // if (getItemStack().hasCapability(PouchCapabilityProvider.KEY_RING_CAPABILITY, null)) { // IKeyRingCapability cap = getItemStack().getCapability(PuchCapabilityProvider.KEY_RING_CAPABILITY, null); diff --git a/src/com/someguyssoftware/treasure2/item/EmberKey.java b/src/com/someguyssoftware/treasure2/item/EmberKey.java new file mode 100644 index 000000000..fd5b020b3 --- /dev/null +++ b/src/com/someguyssoftware/treasure2/item/EmberKey.java @@ -0,0 +1,64 @@ +/** + * + */ +package com.someguyssoftware.treasure2.item; + +import java.util.List; + +import net.minecraft.client.util.ITooltipFlag; +import net.minecraft.item.ItemStack; +import net.minecraft.util.text.TextFormatting; +import net.minecraft.util.text.translation.I18n; +import net.minecraft.world.World; + +/** + * + * @author Mark Gottschling on Sep 5, 2018 + * + */ +public class EmberKey extends KeyItem { + + /** + * + * @param modID + * @param name + */ + public EmberKey(String modID, String name) { + super(modID, name); + } + + /** + * Format: (Additions) + * + * Specials: [text] [color=gold] + */ + @SuppressWarnings("deprecation") + @Override + public void addInformation(ItemStack stack, World worldIn, List tooltip, ITooltipFlag flagIn) { + super.addInformation(stack, worldIn, tooltip, flagIn); + + tooltip.add( + I18n.translateToLocalFormatted("tooltip.label.specials", + TextFormatting.GOLD) + I18n.translateToLocal("tooltip.ember_key.specials") + ); + } + + /** + * This key can fits ember locks and wood locks. + */ + @Override + public boolean fitsLock(LockItem lockItem) { + if (lockItem == TreasureItems.EMBER_LOCK || lockItem == TreasureItems.WOOD_LOCK) { + return true; + } + return false; + } + + @Override + public boolean breaksLock(LockItem lockItem) { + if (lockItem == TreasureItems.WOOD_LOCK) { + return true; + } + return false; + } +} diff --git a/src/com/someguyssoftware/treasure2/item/EmberLock.java b/src/com/someguyssoftware/treasure2/item/EmberLock.java new file mode 100644 index 000000000..4bc843b37 --- /dev/null +++ b/src/com/someguyssoftware/treasure2/item/EmberLock.java @@ -0,0 +1,51 @@ +package com.someguyssoftware.treasure2.item; + +import java.util.List; + +import net.minecraft.client.util.ITooltipFlag; +import net.minecraft.item.ItemStack; +import net.minecraft.util.text.TextFormatting; +import net.minecraft.util.text.translation.I18n; +import net.minecraft.world.World; + +/** + * + * @author Mark Gottschling on Sep 5, 2018 + * + */ +public class EmberLock extends LockItem { + + /** + * + * @param modID + * @param name + * @param keys + */ + public EmberLock(String modID, String name, KeyItem[] keys) { + super(modID, name, keys); + } + + /** + * Format: (Additions) + * + * Specials: [text] [color=gold] + */ + @SuppressWarnings("deprecation") + @Override + public void addInformation(ItemStack stack, World worldIn, List tooltip, ITooltipFlag flagIn) { + super.addInformation(stack, worldIn, tooltip, flagIn); + + tooltip.add( + I18n.translateToLocalFormatted("tooltip.label.specials", + TextFormatting.GOLD) + I18n.translateToLocal("tooltip.ember_lock.specials") + ); + } + + @Override + public boolean breaksKey(KeyItem key) { + if (key != TreasureItems.EMBER_KEY && key != TreasureItems.LIGHTNING_KEY) { + return true; + } + return false; + } +} \ No newline at end of file diff --git a/src/com/someguyssoftware/treasure2/item/KeyItem.java b/src/com/someguyssoftware/treasure2/item/KeyItem.java index 97e0819e6..bdc0ab8b1 100644 --- a/src/com/someguyssoftware/treasure2/item/KeyItem.java +++ b/src/com/someguyssoftware/treasure2/item/KeyItem.java @@ -6,12 +6,16 @@ import java.util.List; import java.util.Random; +import static com.someguyssoftware.treasure2.Treasure.logger; import com.someguyssoftware.gottschcore.item.ModItem; import com.someguyssoftware.gottschcore.random.RandomHelper; import com.someguyssoftware.gottschcore.world.WorldInfo; import com.someguyssoftware.treasure2.Treasure; import com.someguyssoftware.treasure2.block.AbstractChestBlock; import com.someguyssoftware.treasure2.block.ITreasureChestProxy; +import com.someguyssoftware.treasure2.capability.EffectiveMaxDamageCapability; +import com.someguyssoftware.treasure2.capability.EffectiveMaxDamageCapabilityProvider; +import com.someguyssoftware.treasure2.capability.IEffectiveMaxDamageCapability; import com.someguyssoftware.treasure2.config.TreasureConfig; import com.someguyssoftware.treasure2.enums.Category; import com.someguyssoftware.treasure2.enums.Rarity; @@ -24,6 +28,7 @@ import net.minecraft.init.SoundEvents; import net.minecraft.inventory.InventoryHelper; import net.minecraft.item.ItemStack; +import net.minecraft.nbt.NBTTagCompound; import net.minecraft.tileentity.TileEntity; import net.minecraft.util.EnumActionResult; import net.minecraft.util.EnumFacing; @@ -34,6 +39,7 @@ import net.minecraft.util.text.TextFormatting; import net.minecraft.util.text.translation.I18n; import net.minecraft.world.World; +import net.minecraftforge.common.capabilities.ICapabilityProvider; /** * @@ -81,16 +87,24 @@ public class KeyItem extends ModItem { public KeyItem(String modID, String name) { setItemName(modID, name); setCreativeTab(Treasure.TREASURE_TAB); - setCategory(Category.BASIC); + setCategory(Category.ELEMENTAL); setRarity(Rarity.COMMON); setBreakable(true); setDamageable(true); setCraftable(false); setMaxDamage(DEFAULT_MAX_USES); - setSuccessProbability(90D); + setSuccessProbability(95); setMaxStackSize(1); // 12/3/2018: set to max 1 because keys are damaged and don't stack well. } + @Override + public ICapabilityProvider initCapabilities(ItemStack stack, NBTTagCompound nbt) { + EffectiveMaxDamageCapabilityProvider provider = new EffectiveMaxDamageCapabilityProvider(); + IEffectiveMaxDamageCapability cap = provider.getCapability(EffectiveMaxDamageCapabilityProvider.EFFECTIVE_MAX_DAMAGE_CAPABILITY, null); + cap.setEffectiveMaxDamage(getMaxDamage()); + return provider; + } + /** * Format: * Item Name (vanilla minecraft) @@ -107,9 +121,17 @@ public void addInformation(ItemStack stack, World worldIn, List tooltip, super.addInformation(stack, worldIn, tooltip, flagIn); tooltip.add(I18n.translateToLocalFormatted("tooltip.label.rarity", TextFormatting.DARK_BLUE + getRarity().toString())); - tooltip.add(I18n.translateToLocalFormatted("tooltip.label.category", getCategory())); - tooltip.add(I18n.translateToLocalFormatted("tooltip.label.max_uses", getMaxDamage())); + tooltip.add(I18n.translateToLocalFormatted("tooltip.label.category", getCategory())); + + if (stack.hasCapability(EffectiveMaxDamageCapabilityProvider.EFFECTIVE_MAX_DAMAGE_CAPABILITY, null)) { + EffectiveMaxDamageCapability cap = (EffectiveMaxDamageCapability) stack.getCapability(EffectiveMaxDamageCapabilityProvider.EFFECTIVE_MAX_DAMAGE_CAPABILITY, null); + tooltip.add(I18n.translateToLocalFormatted("tooltip.label.uses", cap.getEffectiveMaxDamage() - stack.getItemDamage(), cap.getEffectiveMaxDamage())); +// tooltip.add(I18n.translateToLocalFormatted("tooltip.label.effective_max_uses", cap.getEffectiveMaxDamage())); +// tooltip.add(I18n.translateToLocalFormatted("tooltip.label.remaining_uses", cap.getEffectiveMaxDamage() - stack.getItemDamage())); + } + tooltip.add(I18n.translateToLocalFormatted("tooltip.label.max_uses", getMaxDamage())); + // is breakable tooltip String breakable = ""; if (isBreakable()) { @@ -140,7 +162,35 @@ public void addInformation(ItemStack stack, World worldIn, List tooltip, tooltip.add( I18n.translateToLocalFormatted("tooltip.label.damageable", damageable)); } - + + /** + * Queries the percentage of the 'Durability' bar that should be drawn. + * + * @param stack The current ItemStack + * @return 0.0 for 100% (no damage / full bar), 1.0 for 0% (fully damaged / empty bar) + */ + @Override + public double getDurabilityForDisplay(ItemStack stack) { + if (stack.hasCapability(EffectiveMaxDamageCapabilityProvider.EFFECTIVE_MAX_DAMAGE_CAPABILITY, null)) { + EffectiveMaxDamageCapability cap = (EffectiveMaxDamageCapability) stack.getCapability(EffectiveMaxDamageCapabilityProvider.EFFECTIVE_MAX_DAMAGE_CAPABILITY, null); + return (double)stack.getItemDamage() / (double) cap.getEffectiveMaxDamage(); + } + else { + return (double)stack.getItemDamage() / (double)stack.getMaxDamage(); + } + } + + /** + * Return whether this item is repairable in an anvil. + */ + @Override + public boolean getIsRepairable(ItemStack itemToRepair, ItemStack resourceItem) { + if (itemToRepair.isItemDamaged() && itemToRepair.getItem() == this && resourceItem.getItem() == this) { + return true; + } + return false; + } + /** * */ @@ -158,12 +208,12 @@ public EnumActionResult onItemUse(EntityPlayer player, World worldIn, BlockPos p if (block instanceof AbstractChestBlock) { // get the tile entity - TileEntity te = worldIn.getTileEntity(chestPos); - if (te == null || !(te instanceof AbstractTreasureChestTileEntity)) { - Treasure.logger.warn("Null or incorrect TileEntity"); + TileEntity tileEntity = worldIn.getTileEntity(chestPos); + if (tileEntity == null || !(tileEntity instanceof AbstractTreasureChestTileEntity)) { + logger.warn("Null or incorrect TileEntity"); return EnumActionResult.FAIL; } - AbstractTreasureChestTileEntity tcte = (AbstractTreasureChestTileEntity)te; + AbstractTreasureChestTileEntity chestTileEntity = (AbstractTreasureChestTileEntity)tileEntity; // exit if on the client if (WorldInfo.isClientSide(worldIn)) { @@ -171,18 +221,18 @@ public EnumActionResult onItemUse(EntityPlayer player, World worldIn, BlockPos p } // determine if chest is locked - if (!tcte.hasLocks()) { + if (!chestTileEntity.hasLocks()) { return EnumActionResult.SUCCESS; } try { - ItemStack heldItem = player.getHeldItem(hand); + ItemStack heldItemStack = player.getHeldItem(hand); boolean breakKey = true; boolean fitsLock = false; LockState lockState = null; boolean isKeyBroken = false; // check if this key is one that opens a lock (only first lock that key fits is unlocked). - lockState = fitsFirstLock(tcte.getLockStates()); + lockState = fitsFirstLock(chestTileEntity.getLockStates()); if (lockState != null) { fitsLock = true; } @@ -195,29 +245,34 @@ public EnumActionResult onItemUse(EntityPlayer player, World worldIn, BlockPos p // play noise worldIn.playSound(player, chestPos, SoundEvents.BLOCK_LEVER_CLICK, SoundCategory.BLOCKS, 0.3F, 0.6F); // update the client - tcte.sendUpdates(); - // spawn the lock - if (TreasureConfig.KEYS_LOCKS.enableLockDrops) { - InventoryHelper.spawnItemStack(worldIn, (double)chestPos.getX(), (double)chestPos.getY(), (double)chestPos.getZ(), new ItemStack(lock)); - } - // don't break the key - breakKey = false; + chestTileEntity.sendUpdates(); + if(!breaksLock(lock)) { + // spawn the lock + if (TreasureConfig.KEYS_LOCKS.enableLockDrops) { + InventoryHelper.spawnItemStack(worldIn, (double)chestPos.getX(), (double)chestPos.getY(), (double)chestPos.getZ(), new ItemStack(lock)); + } + } + // don't break the key + breakKey = false; } } - + + // get capability + IEffectiveMaxDamageCapability cap = heldItemStack.getCapability(EffectiveMaxDamageCapabilityProvider.EFFECTIVE_MAX_DAMAGE_CAPABILITY, null); + // check key's breakability - if (breakKey) { - if (isBreakable() && TreasureConfig.KEYS_LOCKS.enableKeyBreaks) { - // break key; - heldItem.shrink(1); - player.sendMessage(new TextComponentString("Key broke.")); - worldIn.playSound(player, chestPos, SoundEvents.BLOCK_METAL_BREAK, SoundCategory.BLOCKS, 0.3F, 0.6F); - // flag the key as broken - isKeyBroken = true; - // if the keyStack > 0, then reset the damage - don't break a brand new key and leave the used one - if (heldItem.getCount() > 0) { - heldItem.setItemDamage(0); - } + if (breakKey) { + if ((isBreakable() || anyLockBreaksKey(chestTileEntity.getLockStates(), this)) && TreasureConfig.KEYS_LOCKS.enableKeyBreaks) { + int damage = heldItemStack.getItemDamage() + (getMaxDamage() - (heldItemStack.getItemDamage() % getMaxDamage())); + heldItemStack.setItemDamage(damage); + if (heldItemStack.getItemDamage() >= cap.getEffectiveMaxDamage()) { + // break key; + heldItemStack.shrink(1); + } + player.sendMessage(new TextComponentString("Key broke.")); + worldIn.playSound(player, chestPos, SoundEvents.BLOCK_METAL_BREAK, SoundCategory.BLOCKS, 0.3F, 0.6F); + // flag the key as broken + isKeyBroken = true; } else { player.sendMessage(new TextComponentString("Failed to unlock.")); @@ -226,20 +281,22 @@ public EnumActionResult onItemUse(EntityPlayer player, World worldIn, BlockPos p // user attempted to use key - increment the damage if (isDamageable() && !isKeyBroken) { - heldItem.damageItem(1, player); - if (heldItem.getItemDamage() == heldItem.getMaxDamage()) { - heldItem.shrink(1); - } +// logger.debug("before damage -> {}", heldItemStack.getItemDamage()); + heldItemStack.setItemDamage(heldItemStack.getItemDamage() + 1); +// logger.debug("after damage -> {}", heldItemStack.getItemDamage()); + if (heldItemStack.getItemDamage() >= cap.getEffectiveMaxDamage()) { + heldItemStack.shrink(1); + } } } catch (Exception e) { - Treasure.logger.error("error: ", e); + logger.error("error: ", e); } } return super.onItemUse(player, worldIn, chestPos, hand, facing, hitX, hitY, hitZ); } - + /** * This method is a secondary check against a lock item. * Override this method to overrule LockItem.acceptsKey() if this is a key with special abilities. @@ -255,7 +312,7 @@ public boolean fitsLock(LockItem lockItem) { * @param lockStates * @return */ - public LockState fitsFirstLock(List lockStates) { + public LockState fitsFirstLock(List lockStates) { LockState lockState = null; // check if this key is one that opens a lock (only first lock that key fits is unlocked). for (LockState ls : lockStates) { @@ -269,6 +326,23 @@ public LockState fitsFirstLock(List lockStates) { return null; // <-- TODO should return EMPTY_LOCKSTATE } + /** + * + * @param lockStates + * @param key + * @return + */ + private boolean anyLockBreaksKey(List lockStates, KeyItem key) { + for (LockState ls : lockStates) { + if (ls.getLock() != null) { + if (ls.getLock().breaksKey(key)) { + return true; + } + } + } + return false; + } + /** * * @param lockItem @@ -276,15 +350,19 @@ public LockState fitsFirstLock(List lockStates) { */ public boolean unlock(LockItem lockItem) { if (lockItem.acceptsKey(this) || fitsLock(lockItem)) { - Treasure.logger.debug("Lock -> {} accepts key -> {}", lockItem.getRegistryName(), this.getRegistryName()); + logger.debug("Lock -> {} accepts key -> {}", lockItem.getRegistryName(), this.getRegistryName()); if (RandomHelper.checkProbability(new Random(), this.getSuccessProbability())) { - Treasure.logger.debug("Unlock attempt met probability"); + logger.debug("Unlock attempt met probability"); return true; } } return false; - } - + } + + public boolean breaksLock(LockItem lockItem) { + return false; + } + /** * @return the rarity */ diff --git a/src/com/someguyssoftware/treasure2/item/KeyRingItem.java b/src/com/someguyssoftware/treasure2/item/KeyRingItem.java index e63daef71..f35a62787 100644 --- a/src/com/someguyssoftware/treasure2/item/KeyRingItem.java +++ b/src/com/someguyssoftware/treasure2/item/KeyRingItem.java @@ -9,15 +9,13 @@ import com.someguyssoftware.gottschcore.world.WorldInfo; import com.someguyssoftware.treasure2.Treasure; import com.someguyssoftware.treasure2.block.TreasureChestBlock; -import com.someguyssoftware.treasure2.capability.CharmCapabilityProvider; import com.someguyssoftware.treasure2.capability.IKeyRingCapability; -import com.someguyssoftware.treasure2.capability.KeyRingCapability; import com.someguyssoftware.treasure2.capability.KeyRingCapabilityProvider; import com.someguyssoftware.treasure2.client.gui.GuiHandler; import com.someguyssoftware.treasure2.config.TreasureConfig; import com.someguyssoftware.treasure2.inventory.KeyRingInventory; import com.someguyssoftware.treasure2.lock.LockState; -import com.someguyssoftware.treasure2.tileentity.AbstractTreasureChestTileEntity; +import com.someguyssoftware.treasure2.tileentity.ITreasureChestTileEntity; import net.minecraft.block.Block; import net.minecraft.client.util.ITooltipFlag; @@ -25,7 +23,6 @@ import net.minecraft.init.Items; import net.minecraft.init.SoundEvents; import net.minecraft.inventory.InventoryHelper; -import net.minecraft.inventory.ItemStackHelper; import net.minecraft.item.ItemStack; import net.minecraft.nbt.NBTTagCompound; import net.minecraft.tileentity.TileEntity; @@ -101,11 +98,11 @@ public EnumActionResult onItemUse(EntityPlayer player, World worldIn, BlockPos p if (block instanceof TreasureChestBlock) { // get the tile entity TileEntity te = worldIn.getTileEntity(pos); - if (te == null || !(te instanceof AbstractTreasureChestTileEntity)) { + if (te == null || !(te instanceof ITreasureChestTileEntity)) { Treasure.logger.warn("Null or incorrect TileEntity"); return EnumActionResult.FAIL; } - AbstractTreasureChestTileEntity tcte = (AbstractTreasureChestTileEntity)te; + ITreasureChestTileEntity tcte = (ITreasureChestTileEntity)te; ItemStack heldItem = player.getHeldItem(hand); diff --git a/src/com/someguyssoftware/treasure2/item/LightningKey.java b/src/com/someguyssoftware/treasure2/item/LightningKey.java new file mode 100644 index 000000000..293cb0a30 --- /dev/null +++ b/src/com/someguyssoftware/treasure2/item/LightningKey.java @@ -0,0 +1,58 @@ +/** + * + */ +package com.someguyssoftware.treasure2.item; + +import java.util.List; + +import com.someguyssoftware.treasure2.enums.Category; + +import net.minecraft.client.util.ITooltipFlag; +import net.minecraft.item.ItemStack; +import net.minecraft.util.text.TextFormatting; +import net.minecraft.util.text.translation.I18n; +import net.minecraft.world.World; + +/** + * + * @author Mark Gottschling on Sep 11, 2020 + * + */ +public class LightningKey extends KeyItem { + + /** + * + * @param modID + * @param name + */ + public LightningKey(String modID, String name) { + super(modID, name); + } + + /** + * Format: (Additions) + * + * Specials: [text] [color=gold] + */ + @SuppressWarnings("deprecation") + @Override + public void addInformation(ItemStack stack, World worldIn, List tooltip, ITooltipFlag flagIn) { + super.addInformation(stack, worldIn, tooltip, flagIn); + + tooltip.add( + I18n.translateToLocalFormatted("tooltip.label.specials", + TextFormatting.GOLD) + I18n.translateToLocal("tooltip.lightning_key.specials") + ); + + } + + /** + * This key can fits any lock from the with a Category of [ELEMENTAL]. + */ + @Override + public boolean fitsLock(LockItem lockItem) { + Category category = lockItem.getCategory(); + if (category == Category.ELEMENTAL) return true; + return false; + } +} diff --git a/src/com/someguyssoftware/treasure2/item/LockItem.java b/src/com/someguyssoftware/treasure2/item/LockItem.java index 7c879db0b..eb04df903 100644 --- a/src/com/someguyssoftware/treasure2/item/LockItem.java +++ b/src/com/someguyssoftware/treasure2/item/LockItem.java @@ -72,7 +72,7 @@ public LockItem(String modID, String name, KeyItem[] keys) { */ public LockItem(String modID, String name) { setItemName(modID, name); - setCategory(Category.BASIC); + setCategory(Category.ELEMENTAL); setRarity(Rarity.COMMON); setCraftable(false); setCreativeTab(Treasure.TREASURE_TAB); @@ -123,7 +123,7 @@ public EnumActionResult onItemUse(EntityPlayer player, World worldIn, BlockPos p if (block instanceof AbstractChestBlock) { // get the tile entity - AbstractTreasureChestTileEntity te = (AbstractTreasureChestTileEntity) worldIn.getTileEntity(chestPos); + AbstractTreasureChestTileEntity tileEntity = (AbstractTreasureChestTileEntity) worldIn.getTileEntity(chestPos); // exit if on the client if (WorldInfo.isClientSide(worldIn)) { @@ -136,7 +136,7 @@ public EnumActionResult onItemUse(EntityPlayer player, World worldIn, BlockPos p // NOTE don't use the return boolean as the locked flag here, as the chest is // already locked and if the method was // unsuccessful it could state the chest is unlocked. - handleHeldLock(te, player, heldItem); + handleHeldLock(tileEntity, player, heldItem); } catch (Exception e) { Treasure.logger.error("error: ", e); } @@ -151,20 +151,16 @@ public EnumActionResult onItemUse(EntityPlayer player, World worldIn, BlockPos p * @param heldItem * @return flag indicating if a lock was added */ - private boolean handleHeldLock(AbstractTreasureChestTileEntity te, EntityPlayer player, ItemStack heldItem) { + private boolean handleHeldLock(AbstractTreasureChestTileEntity tileEntity, EntityPlayer player, ItemStack heldItem) { boolean lockedAdded = false; LockItem lock = (LockItem) heldItem.getItem(); // add the lock to the first lockstate that has an available slot - for (LockState lockState : te.getLockStates()) { + for (LockState lockState : tileEntity.getLockStates()) { if (lockState != null && lockState.getLock() == null) { lockState.setLock(lock); - te.sendUpdates(); + tileEntity.sendUpdates(); // decrement item in hand heldItem.shrink(1); -// if (heldItem.getCount() <=0 && !player.capabilities.isCreativeMode) { -// IInventory inventory = player.inventory; -// inventory.setInventorySlotContents(player.inventory.currentItem, null); -// } lockedAdded = true; break; } @@ -185,6 +181,10 @@ public boolean acceptsKey(KeyItem keyItem) { return false; } + public boolean breaksKey(KeyItem keyItem) { + return false; + } + /** * @return the rarity */ diff --git a/src/com/someguyssoftware/treasure2/item/MimicChestItemBlock.java b/src/com/someguyssoftware/treasure2/item/MimicChestItemBlock.java index 0a719afe3..4868013df 100644 --- a/src/com/someguyssoftware/treasure2/item/MimicChestItemBlock.java +++ b/src/com/someguyssoftware/treasure2/item/MimicChestItemBlock.java @@ -5,26 +5,13 @@ import java.util.List; -import com.someguyssoftware.treasure2.Treasure; import com.someguyssoftware.treasure2.block.MimicChestBlock; -import com.someguyssoftware.treasure2.block.TreasureChestBlock; -import com.someguyssoftware.treasure2.tileentity.AbstractTreasureChestTileEntity; +import com.someguyssoftware.treasure2.tileentity.ITreasureChestTileEntity; import net.minecraft.block.Block; import net.minecraft.client.util.ITooltipFlag; -import net.minecraft.entity.item.EntityItem; -import net.minecraft.entity.player.EntityPlayer; -import net.minecraft.inventory.ItemStackHelper; import net.minecraft.item.ItemBlock; import net.minecraft.item.ItemStack; -import net.minecraft.nbt.NBTTagCompound; -import net.minecraft.nbt.NBTTagList; -import net.minecraft.util.ActionResult; -import net.minecraft.util.EnumActionResult; -import net.minecraft.util.EnumFacing; -import net.minecraft.util.EnumHand; -import net.minecraft.util.NonNullList; -import net.minecraft.util.math.BlockPos; import net.minecraft.util.text.TextFormatting; import net.minecraft.util.text.translation.I18n; import net.minecraft.world.World; @@ -52,7 +39,7 @@ public void addInformation(ItemStack stack, World worldIn, List tooltip, super.addInformation(stack, worldIn, tooltip, flagIn); // get the block MimicChestBlock tb = (MimicChestBlock)getBlock(); - AbstractTreasureChestTileEntity te = tb.getTileEntity(); + ITreasureChestTileEntity te = tb.getTileEntity(); // chest info tooltip.add(I18n.translateToLocalFormatted("tooltip.label.rarity", TextFormatting.DARK_BLUE + tb.getRarity().toString())); diff --git a/src/com/someguyssoftware/treasure2/item/PouchItem.java b/src/com/someguyssoftware/treasure2/item/PouchItem.java index 200966cec..fa7208f5b 100644 --- a/src/com/someguyssoftware/treasure2/item/PouchItem.java +++ b/src/com/someguyssoftware/treasure2/item/PouchItem.java @@ -79,7 +79,8 @@ public void addInformation(ItemStack stack, World worldIn, List tooltip, public ActionResult onItemRightClick(World worldIn, EntityPlayer playerIn, EnumHand handIn) { // exit if on the client if (WorldInfo.isClientSide(worldIn)) { - return new ActionResult(EnumActionResult.FAIL, playerIn.getHeldItem(handIn)); +// return new ActionResult(EnumActionResult.FAIL, playerIn.getHeldItem(handIn)); + return new ActionResult(EnumActionResult.PASS, playerIn.getHeldItem(handIn)); // 9/2/20 } BlockPos pos = playerIn.getPosition(); diff --git a/src/com/someguyssoftware/treasure2/item/TreasureChestItemBlock.java b/src/com/someguyssoftware/treasure2/item/TreasureChestItemBlock.java index eeb90cb7d..67c72fd64 100644 --- a/src/com/someguyssoftware/treasure2/item/TreasureChestItemBlock.java +++ b/src/com/someguyssoftware/treasure2/item/TreasureChestItemBlock.java @@ -5,25 +5,13 @@ import java.util.List; -import com.someguyssoftware.treasure2.Treasure; import com.someguyssoftware.treasure2.block.TreasureChestBlock; -import com.someguyssoftware.treasure2.tileentity.AbstractTreasureChestTileEntity; +import com.someguyssoftware.treasure2.tileentity.ITreasureChestTileEntity; import net.minecraft.block.Block; import net.minecraft.client.util.ITooltipFlag; -import net.minecraft.entity.item.EntityItem; -import net.minecraft.entity.player.EntityPlayer; -import net.minecraft.inventory.ItemStackHelper; import net.minecraft.item.ItemBlock; import net.minecraft.item.ItemStack; -import net.minecraft.nbt.NBTTagCompound; -import net.minecraft.nbt.NBTTagList; -import net.minecraft.util.ActionResult; -import net.minecraft.util.EnumActionResult; -import net.minecraft.util.EnumFacing; -import net.minecraft.util.EnumHand; -import net.minecraft.util.NonNullList; -import net.minecraft.util.math.BlockPos; import net.minecraft.util.text.TextFormatting; import net.minecraft.util.text.translation.I18n; import net.minecraft.world.World; @@ -50,7 +38,7 @@ public void addInformation(ItemStack stack, World worldIn, List tooltip, super.addInformation(stack, worldIn, tooltip, flagIn); // get the block TreasureChestBlock tb = (TreasureChestBlock)getBlock(); - AbstractTreasureChestTileEntity te = tb.getTileEntity(); + ITreasureChestTileEntity te = tb.getTileEntity(); // chest info tooltip.add(I18n.translateToLocalFormatted("tooltip.label.rarity", TextFormatting.DARK_BLUE + tb.getRarity().toString())); diff --git a/src/com/someguyssoftware/treasure2/item/TreasureItems.java b/src/com/someguyssoftware/treasure2/item/TreasureItems.java index 429b04024..c8130904f 100644 --- a/src/com/someguyssoftware/treasure2/item/TreasureItems.java +++ b/src/com/someguyssoftware/treasure2/item/TreasureItems.java @@ -74,7 +74,9 @@ public class TreasureItems { // locks public static LockItem WOOD_LOCK; - public static LockItem STONE_LOCK; + public static LockItem STONE_LOCK; + public static LockItem EMBER_LOCK; + public static LockItem LEAF_LOCK; public static LockItem IRON_LOCK; public static LockItem GOLD_LOCK; public static LockItem DIAMOND_LOCK; @@ -86,7 +88,10 @@ public class TreasureItems { // keys public static KeyItem WOOD_KEY; - public static KeyItem STONE_KEY; + public static KeyItem STONE_KEY; + public static KeyItem EMBER_KEY; + public static KeyItem LEAF_KEY; + public static KeyItem LIGHTNING_KEY; public static KeyItem IRON_KEY; public static KeyItem GOLD_KEY; public static KeyItem METALLURGISTS_KEY; @@ -260,23 +265,42 @@ public ICapabilityProvider initCapabilities(ItemStack stack, NBTTagCompound nbt) // KEYS WOOD_KEY = new KeyItem(Treasure.MODID, TreasureConfig.WOOD_KEY_ID) - .setCategory(Category.BASIC) + .setCategory(Category.ELEMENTAL) .setRarity(Rarity.COMMON) .setCraftable(false) .setMaxDamage(TreasureConfig.KEYS_LOCKS.woodKeyMaxUses); STONE_KEY = new KeyItem(Treasure.MODID, TreasureConfig.STONE_KEY_ID) - .setCategory(Category.BASIC) + .setCategory(Category.ELEMENTAL) .setRarity(Rarity.COMMON) .setCraftable(false) .setMaxDamage(TreasureConfig.KEYS_LOCKS.stoneKeyMaxUses); + EMBER_KEY = new EmberKey(Treasure.MODID, TreasureConfig.EMBER_KEY_ID) + .setCategory(Category.ELEMENTAL) + .setRarity(Rarity.SCARCE) + .setCraftable(false) + .setMaxDamage(TreasureConfig.KEYS_LOCKS.emberKeyMaxUses); + + LEAF_KEY = new KeyItem(Treasure.MODID, TreasureConfig.LEAF_KEY_ID) + .setCategory(Category.ELEMENTAL) + .setRarity(Rarity.UNCOMMON) + .setCraftable(false) + .setMaxDamage(TreasureConfig.KEYS_LOCKS.leafKeyMaxUses); + + LIGHTNING_KEY = new LightningKey(Treasure.MODID, TreasureConfig.LIGHTNING_KEY_ID) + .setCategory(Category.ELEMENTAL) + .setRarity(Rarity.SCARCE) + .setBreakable(false) + .setCraftable(false) + .setMaxDamage(TreasureConfig.KEYS_LOCKS.lightningKeyMaxUses); + IRON_KEY = new KeyItem(Treasure.MODID, TreasureConfig.IRON_KEY_ID) .setCategory(Category.METALS) .setRarity(Rarity.UNCOMMON) .setCraftable(false) - .setMaxDamage(TreasureConfig.KEYS_LOCKS.ironKeyMaxUses); - + .setMaxDamage(TreasureConfig.KEYS_LOCKS.ironKeyMaxUses); + GOLD_KEY = new KeyItem(Treasure.MODID, TreasureConfig.GOLD_KEY_ID) .setCategory(Category.METALS) .setRarity(Rarity.SCARCE) @@ -326,7 +350,7 @@ public ICapabilityProvider initCapabilities(ItemStack stack, NBTTagCompound nbt) .setMaxDamage(TreasureConfig.KEYS_LOCKS.metallurgistsKeyMaxUses); SKELETON_KEY = new SkeletonKey(Treasure.MODID, TreasureConfig.SKELETON_KEY_ID) - .setCategory(Category.BASIC) + .setCategory(Category.ELEMENTAL) .setRarity(Rarity.RARE) .setBreakable(false) .setCraftable(false) @@ -347,20 +371,20 @@ public ICapabilityProvider initCapabilities(ItemStack stack, NBTTagCompound nbt) .setMaxDamage(TreasureConfig.KEYS_LOCKS.witherKeyMaxUses); PILFERERS_LOCK_PICK = new PilferersLockPick(Treasure.MODID, TreasureConfig.PILFERERS_LOCK_PICK_ID) - .setCategory(Category.BASIC) + .setCategory(Category.ELEMENTAL) .setRarity(Rarity.COMMON) .setBreakable(true) .setCraftable(true) .setMaxDamage(TreasureConfig.KEYS_LOCKS.pilferersLockPickMaxUses) - .setSuccessProbability(24); + .setSuccessProbability(32); THIEFS_LOCK_PICK = new ThiefsLockPick(Treasure.MODID, TreasureConfig.THIEFS_LOCK_PICK_ID) - .setCategory(Category.BASIC) + .setCategory(Category.ELEMENTAL) .setRarity(Rarity.UNCOMMON) .setBreakable(true) .setCraftable(true) .setMaxDamage(TreasureConfig.KEYS_LOCKS.thiefsLockPickMaxUses) - .setSuccessProbability(32); + .setSuccessProbability(48); // KEY RING KEY_RING = new KeyRingItem(Treasure.MODID, TreasureConfig.KEY_RING_ID); @@ -373,14 +397,20 @@ public ICapabilityProvider initCapabilities(ItemStack stack, NBTTagCompound nbt) // LOCKS WOOD_LOCK = new LockItem(Treasure.MODID, TreasureConfig.WOOD_LOCK_ID, new KeyItem[] {WOOD_KEY}) - .setCategory(Category.BASIC) + .setCategory(Category.ELEMENTAL) .setRarity(Rarity.COMMON); STONE_LOCK = new LockItem(Treasure.MODID, TreasureConfig.STONE_LOCK_ID, new KeyItem[] {STONE_KEY}) - .setCategory(Category.BASIC) - .setRarity(Rarity.COMMON); + .setCategory(Category.ELEMENTAL) + .setRarity(Rarity.COMMON); + EMBER_LOCK = new EmberLock(Treasure.MODID, TreasureConfig.EMBER_LOCK_ID, new KeyItem[] {EMBER_KEY}) + .setCategory(Category.ELEMENTAL) + .setRarity(Rarity.SCARCE); + LEAF_LOCK = new LockItem(Treasure.MODID, TreasureConfig.LEAF_LOCK_ID, new KeyItem[] {LEAF_KEY}) + .setCategory(Category.ELEMENTAL) + .setRarity(Rarity.UNCOMMON); IRON_LOCK = new LockItem(Treasure.MODID, TreasureConfig.IRON_LOCK_ID, new KeyItem[] {IRON_KEY}) .setCategory(Category.METALS) - .setRarity(Rarity.UNCOMMON); + .setRarity(Rarity.UNCOMMON); GOLD_LOCK = new LockItem(Treasure.MODID, TreasureConfig.GOLD_LOCK_ID, new KeyItem[] {GOLD_KEY}) .setCategory(Category.METALS) .setRarity(Rarity.SCARCE); @@ -406,7 +436,9 @@ public ICapabilityProvider initCapabilities(ItemStack stack, NBTTagCompound nbt) locks = ArrayListMultimap.create(); locks.put(WOOD_LOCK.getRarity(), WOOD_LOCK); - locks.put(STONE_LOCK.getRarity(), STONE_LOCK); + locks.put(STONE_LOCK.getRarity(), STONE_LOCK); + locks.put(EMBER_LOCK.getRarity(), EMBER_LOCK); + locks.put(LEAF_LOCK.getRarity(), LEAF_LOCK); locks.put(IRON_LOCK.getRarity(), IRON_LOCK); locks.put(GOLD_LOCK.getRarity(), GOLD_LOCK); locks.put(DIAMOND_LOCK.getRarity(), DIAMOND_LOCK); @@ -536,7 +568,9 @@ public static void registerItems(final RegistryEvent.Register event) { WHITE_PEARL, BLACK_PEARL, WOOD_LOCK, - STONE_LOCK, + STONE_LOCK, + EMBER_LOCK, + LEAF_LOCK, IRON_LOCK, GOLD_LOCK, DIAMOND_LOCK, @@ -546,8 +580,11 @@ public static void registerItems(final RegistryEvent.Register event) { SPIDER_LOCK, WITHER_LOCK, WOOD_KEY, - STONE_KEY, - IRON_KEY, + STONE_KEY, + EMBER_KEY, + LEAF_KEY, + LIGHTNING_KEY, + IRON_KEY, GOLD_KEY, DIAMOND_KEY, EMERALD_KEY, diff --git a/src/com/someguyssoftware/treasure2/loot/function/CharmRandomly.java b/src/com/someguyssoftware/treasure2/loot/function/CharmRandomly.java index b9bfa55f8..63da6d5f9 100644 --- a/src/com/someguyssoftware/treasure2/loot/function/CharmRandomly.java +++ b/src/com/someguyssoftware/treasure2/loot/function/CharmRandomly.java @@ -74,7 +74,6 @@ public ItemStack apply(ItemStack stack, Random rand, LootContext context) { if (!tempCharms.isEmpty()) { // select a charm randomly charm = tempCharms.get(rand.nextInt(tempCharms.size())); - } } else { diff --git a/src/com/someguyssoftware/treasure2/loot/function/SetCharms.java b/src/com/someguyssoftware/treasure2/loot/function/SetCharms.java index bf8ed0a31..9236c6ac6 100644 --- a/src/com/someguyssoftware/treasure2/loot/function/SetCharms.java +++ b/src/com/someguyssoftware/treasure2/loot/function/SetCharms.java @@ -3,6 +3,7 @@ */ package com.someguyssoftware.treasure2.loot.function; +import java.util.ArrayList; import java.util.Collections; import java.util.HashMap; import java.util.List; @@ -24,6 +25,7 @@ import com.someguyssoftware.treasure2.Treasure; import com.someguyssoftware.treasure2.capability.CharmCapabilityProvider; import com.someguyssoftware.treasure2.capability.ICharmCapability; +import com.someguyssoftware.treasure2.item.charm.CharmLevel; import com.someguyssoftware.treasure2.item.charm.CharmState; import com.someguyssoftware.treasure2.item.charm.CharmStateFactory; import com.someguyssoftware.treasure2.item.charm.CharmType; @@ -79,6 +81,22 @@ public ItemStack apply(ItemStack stack, Random rand, LootContext context) { } } } + else { + // randomly add a charm (in case loot table is misconfigured) + List tempCharms = new ArrayList<>(); + // if charms list is empty, create a default list of minor charms + for (ICharm c : TreasureCharms.REGISTRY.values()) { + if (c.getCharmLevel() == CharmLevel.LEVEL1 || c.getCharmLevel() == CharmLevel.LEVEL2) { + tempCharms.add(c); + } + } + if (!tempCharms.isEmpty()) { + // select a charm randomly + ICharm charm = tempCharms.get(rand.nextInt(tempCharms.size())); + Treasure.logger.debug("giving item a random charm -> {}", charm.getName()); + charmStates.add(CharmStateFactory.createCharmState(charm)); + } + } } return stack; } diff --git a/src/com/someguyssoftware/treasure2/model/TreasureModels.java b/src/com/someguyssoftware/treasure2/model/TreasureModels.java index 45aedd77b..ab5227f3f 100644 --- a/src/com/someguyssoftware/treasure2/model/TreasureModels.java +++ b/src/com/someguyssoftware/treasure2/model/TreasureModels.java @@ -111,6 +111,7 @@ public static void registerModels(ModelRegistryEvent event) { registerItemModel(Item.getItemFromBlock(TreasureBlocks.FALLING_GRASS)); registerItemModel(Item.getItemFromBlock(TreasureBlocks.FALLING_SAND)); registerItemModel(Item.getItemFromBlock(TreasureBlocks.FALLING_RED_SAND)); + registerItemModel(Item.getItemFromBlock(TreasureBlocks.BLACKSTONE)); // COINS registerItemModel(TreasureItems.GOLD_COIN); @@ -139,6 +140,8 @@ public static void registerModels(ModelRegistryEvent event) { // LOCKS registerItemModel(TreasureItems.WOOD_LOCK); registerItemModel(TreasureItems.STONE_LOCK); + registerItemModel(TreasureItems.EMBER_LOCK); + registerItemModel(TreasureItems.LEAF_LOCK); registerItemModel(TreasureItems.IRON_LOCK); registerItemModel(TreasureItems.GOLD_LOCK); registerItemModel(TreasureItems.DIAMOND_LOCK); @@ -151,6 +154,9 @@ public static void registerModels(ModelRegistryEvent event) { // KEYS registerItemModel(TreasureItems.WOOD_KEY); registerItemModel(TreasureItems.STONE_KEY); + registerItemModel(TreasureItems.EMBER_KEY); + registerItemModel(TreasureItems.LEAF_KEY); + registerItemModel(TreasureItems.LIGHTNING_KEY); registerItemModel(TreasureItems.IRON_KEY); registerItemModel(TreasureItems.GOLD_KEY); registerItemModel(TreasureItems.DIAMOND_KEY); diff --git a/src/com/someguyssoftware/treasure2/persistence/GenDataPersistence.java b/src/com/someguyssoftware/treasure2/persistence/GenDataPersistence.java index b4fce26a5..cb016815a 100644 --- a/src/com/someguyssoftware/treasure2/persistence/GenDataPersistence.java +++ b/src/com/someguyssoftware/treasure2/persistence/GenDataPersistence.java @@ -12,7 +12,7 @@ import com.someguyssoftware.treasure2.Treasure; import com.someguyssoftware.treasure2.chest.ChestInfo; import com.someguyssoftware.treasure2.enums.Rarity; -import com.someguyssoftware.treasure2.enums.WorldGenerators; +import com.someguyssoftware.treasure2.enums.WorldGeneratorType; import com.someguyssoftware.treasure2.generator.oasis.OasisInfo; import com.someguyssoftware.treasure2.registry.ChestRegistry; import com.someguyssoftware.treasure2.registry.OasisRegistry; @@ -82,12 +82,12 @@ public void readFromNBT(NBTTagCompound tag) { Treasure.logger.debug("Loading Treasure! saved gen data..."); // get the world generators - SurfaceChestWorldGenerator surfaceChestGen = (SurfaceChestWorldGenerator) Treasure.WORLD_GENERATORS.get(WorldGenerators.SURFACE_CHEST); - SubmergedChestWorldGenerator submergedChestGen = (SubmergedChestWorldGenerator) Treasure.WORLD_GENERATORS.get(WorldGenerators.SUBMERGED_CHEST); - WellWorldGenerator wellGen = (WellWorldGenerator) Treasure.WORLD_GENERATORS.get(WorldGenerators.WELL); - WitherTreeWorldGenerator witherGen = (WitherTreeWorldGenerator) Treasure.WORLD_GENERATORS.get(WorldGenerators.WITHER_TREE); - GemOreWorldGenerator gemGen = (GemOreWorldGenerator) Treasure.WORLD_GENERATORS.get(WorldGenerators.GEM); - OasisWorldGenerator oasisGen = (OasisWorldGenerator) Treasure.WORLD_GENERATORS.get(WorldGenerators.OASIS); + SurfaceChestWorldGenerator surfaceChestGen = (SurfaceChestWorldGenerator) Treasure.WORLD_GENERATORS.get(WorldGeneratorType.SURFACE_CHEST); + SubmergedChestWorldGenerator submergedChestGen = (SubmergedChestWorldGenerator) Treasure.WORLD_GENERATORS.get(WorldGeneratorType.SUBMERGED_CHEST); + WellWorldGenerator wellGen = (WellWorldGenerator) Treasure.WORLD_GENERATORS.get(WorldGeneratorType.WELL); + WitherTreeWorldGenerator witherGen = (WitherTreeWorldGenerator) Treasure.WORLD_GENERATORS.get(WorldGeneratorType.WITHER_TREE); + GemOreWorldGenerator gemGen = (GemOreWorldGenerator) Treasure.WORLD_GENERATORS.get(WorldGeneratorType.GEM); + OasisWorldGenerator oasisGen = (OasisWorldGenerator) Treasure.WORLD_GENERATORS.get(WorldGeneratorType.OASIS); // treasure NBTTagCompound treasureGen = tag.getCompoundTag(TREASURE_GEN_TAG_NAME); @@ -207,8 +207,8 @@ public NBTTagCompound writeToNBT(NBTTagCompound tag) { ///// Chests ////// // get the chest world generators - SurfaceChestWorldGenerator surfaceChestGen = (SurfaceChestWorldGenerator) Treasure.WORLD_GENERATORS.get(WorldGenerators.SURFACE_CHEST); - SubmergedChestWorldGenerator submergedChestGen = (SubmergedChestWorldGenerator) Treasure.WORLD_GENERATORS.get(WorldGenerators.SUBMERGED_CHEST); + SurfaceChestWorldGenerator surfaceChestGen = (SurfaceChestWorldGenerator) Treasure.WORLD_GENERATORS.get(WorldGeneratorType.SURFACE_CHEST); + SubmergedChestWorldGenerator submergedChestGen = (SubmergedChestWorldGenerator) Treasure.WORLD_GENERATORS.get(WorldGeneratorType.SUBMERGED_CHEST); // create a new compounds NBTTagCompound surfaceTag = new NBTTagCompound(); @@ -252,7 +252,7 @@ public NBTTagCompound writeToNBT(NBTTagCompound tag) { ///// Oasis //// // get the oasis world generators - OasisWorldGenerator oasisGen = (OasisWorldGenerator) Treasure.WORLD_GENERATORS.get(WorldGenerators.OASIS); + OasisWorldGenerator oasisGen = (OasisWorldGenerator) Treasure.WORLD_GENERATORS.get(WorldGeneratorType.OASIS); // create a new compound NBTTagCompound oasisTag = new NBTTagCompound(); @@ -283,19 +283,19 @@ public NBTTagCompound writeToNBT(NBTTagCompound tag) { ///// Well //// // get the well world generator - WellWorldGenerator wellGen = (WellWorldGenerator) Treasure.WORLD_GENERATORS.get(WorldGenerators.WELL); + WellWorldGenerator wellGen = (WellWorldGenerator) Treasure.WORLD_GENERATORS.get(WorldGeneratorType.WELL); // add the chest gen last count to the treasure compound treasureGen.setInteger("chunksSinceLastWell", wellGen.getChunksSinceLastWell()); //// Wither Tree ///// - WitherTreeWorldGenerator witherGen = (WitherTreeWorldGenerator) Treasure.WORLD_GENERATORS.get(WorldGenerators.WITHER_TREE); + WitherTreeWorldGenerator witherGen = (WitherTreeWorldGenerator) Treasure.WORLD_GENERATORS.get(WorldGeneratorType.WITHER_TREE); // add the chest gen last count to the treasure compound treasureGen.setInteger("chunksSinceLastTree", witherGen.getChunksSinceLastTree()); //// Gem Ore //// - GemOreWorldGenerator gemGen = (GemOreWorldGenerator) Treasure.WORLD_GENERATORS.get(WorldGenerators.GEM); + GemOreWorldGenerator gemGen = (GemOreWorldGenerator) Treasure.WORLD_GENERATORS.get(WorldGeneratorType.GEM); treasureGen.setInteger("chunksSinceLastOre", gemGen.getChunksSinceLastOre()); ///// ChestConfig Registry ///// diff --git a/src/com/someguyssoftware/treasure2/printer/ChestNBTPrettyPrinter.java b/src/com/someguyssoftware/treasure2/printer/ChestNBTPrettyPrinter.java index e0db63ff2..dca7d6943 100644 --- a/src/com/someguyssoftware/treasure2/printer/ChestNBTPrettyPrinter.java +++ b/src/com/someguyssoftware/treasure2/printer/ChestNBTPrettyPrinter.java @@ -7,6 +7,7 @@ import java.util.Arrays; import com.someguyssoftware.treasure2.Treasure; +import com.someguyssoftware.treasure2.enums.ChestGeneratorType; import com.someguyssoftware.treasure2.lock.LockState; import net.minecraft.nbt.NBTTagCompound; @@ -107,7 +108,21 @@ public String print(NBTTagCompound tag, String title) { if (tag.hasKey("facing")) { sb.append(String.format(format, "Facing", EnumFacing.getFront(tag.getInteger("facing")))); } + + if (tag.hasKey("sealed")) { + sb.append(String.format(format, "Sealed", tag.getBoolean("sealed"))); + } + if (tag.hasKey("genContext")) { + NBTTagCompound contextTag = tag.getCompoundTag("genContext"); + if (contextTag.hasKey("lootRarity")) { + sb.append(String.format(format, "Loot Rarity", contextTag.getString("lootRarity"))); + } + if (contextTag.hasKey("chestGenType")) { + sb.append(String.format(format, "Chest Generation Type", ChestGeneratorType.valueOf(contextTag.getString("chestGenType")).name())); + } + } + // print each lock state if (lockStates != null) { for (int i = 0; i < lockStates.tagCount(); i++) { diff --git a/src/com/someguyssoftware/treasure2/tileentity/AbstractProximityTileEntity.java b/src/com/someguyssoftware/treasure2/tileentity/AbstractProximityTileEntity.java index 85e912609..e872e82df 100644 --- a/src/com/someguyssoftware/treasure2/tileentity/AbstractProximityTileEntity.java +++ b/src/com/someguyssoftware/treasure2/tileentity/AbstractProximityTileEntity.java @@ -84,7 +84,8 @@ public void update() { player = (EntityPlayer)getWorld().playerEntities.get(playerIndex); // get the distance double distanceSq = player.getDistanceSq(this.getPos().add(0.5D, 0.5D, 0.5D)); - +// GottschCore.logger.debug("PTE @ -> {}, proximity -> {}, distance -> {}, triggered -> {}, dead -> {}, result -> {}", +// this.pos, proximitySq, distanceSq, isTriggered, this.isDead, (!isTriggered && !this.isDead && (distanceSq < proximitySq)) ? "met" : "not met"); if (!isTriggered && !this.isDead && (distanceSq < proximitySq)) { GottschCore.logger.debug("PTE proximity was met."); isTriggered = true; diff --git a/src/com/someguyssoftware/treasure2/tileentity/AbstractTreasureChestTileEntity.java b/src/com/someguyssoftware/treasure2/tileentity/AbstractTreasureChestTileEntity.java index 782b41137..391f0326b 100644 --- a/src/com/someguyssoftware/treasure2/tileentity/AbstractTreasureChestTileEntity.java +++ b/src/com/someguyssoftware/treasure2/tileentity/AbstractTreasureChestTileEntity.java @@ -3,6 +3,8 @@ */ package com.someguyssoftware.treasure2.tileentity; +import static com.someguyssoftware.treasure2.Treasure.logger; + import java.util.LinkedList; import java.util.List; @@ -10,8 +12,9 @@ import com.someguyssoftware.gottschcore.tileentity.AbstractModTileEntity; import com.someguyssoftware.gottschcore.world.WorldInfo; -import com.someguyssoftware.treasure2.Treasure; import com.someguyssoftware.treasure2.block.TreasureChestBlock; +import com.someguyssoftware.treasure2.enums.ChestGeneratorType; +import com.someguyssoftware.treasure2.enums.Rarity; import com.someguyssoftware.treasure2.lock.LockState; import net.minecraft.block.state.IBlockState; @@ -42,7 +45,32 @@ * @author Mark Gottschling onDec 22, 2017 * */ -public abstract class AbstractTreasureChestTileEntity extends AbstractModTileEntity implements IInventory, ITickable { +public abstract class AbstractTreasureChestTileEntity extends AbstractModTileEntity implements ITreasureChestTileEntity, ITickable { + public class GenerationContext { + /* + * The rarity level of the loot that the chest will contain + */ + private Rarity lootRarity; + /* + * + */ + private ChestGeneratorType chestGeneratorType; + + public GenerationContext(Rarity rarity, ChestGeneratorType chestGeneratorType) { + this.lootRarity = rarity; + this.chestGeneratorType = chestGeneratorType; + } + + public Rarity getLootRarity() { + return lootRarity; + } + + public ChestGeneratorType getChestGeneratorType() { + return chestGeneratorType; + } + + } + /* * A list of lockStates the chest has. The list should be the size of the max * allowed for the chestType. @@ -54,6 +82,18 @@ public abstract class AbstractTreasureChestTileEntity extends AbstractModTileEnt */ private int facing; + /* + * A flag to indicate if the chest has been opened for the first time + */ + private boolean sealed; + + /* + * Properties detailing how the tile entity was generated + */ + private GenerationContext generationContext; + + private int numberOfSlots = 27; // default size + /* * Vanilla properties for controlling the lid */ @@ -67,7 +107,6 @@ public abstract class AbstractTreasureChestTileEntity extends AbstractModTileEnt public int ticksSinceSync; /** IInventory properties */ - private int numberOfSlots = 27; // default size private NonNullList items = NonNullList.withSize(getNumberOfSlots(), ItemStack.EMPTY); private String customName; @@ -76,11 +115,13 @@ public abstract class AbstractTreasureChestTileEntity extends AbstractModTileEnt */ public AbstractTreasureChestTileEntity() { setFacing(EnumFacing.NORTH.getIndex()); + setSealed(false); } /** * Like the old updateEntity(), except more generic. */ + @Override public void update() { int i = this.pos.getX(); int j = this.pos.getY(); @@ -162,7 +203,7 @@ public NBTTagCompound writeToNBT(NBTTagCompound parentNBT) { // write custom name writePropertiesToNBT(parentNBT); } catch (Exception e) { - Treasure.logger.error("Error writing to NBT:", e); + logger.error("Error writing to NBT:", e); } return parentNBT; } @@ -179,7 +220,7 @@ public NBTTagCompound writeLockStatesToNBT(NBTTagCompound parentNBT) { NBTTagList list = new NBTTagList(); // write custom tile entity properties for (LockState state : getLockStates()) { -// Treasure.logger.debug("Writing lock state:" + state); + // logger.debug("Writing lock state:" + state); NBTTagCompound stateNBT = new NBTTagCompound(); state.writeToNBT(stateNBT); list.appendTag(stateNBT); @@ -187,7 +228,7 @@ public NBTTagCompound writeLockStatesToNBT(NBTTagCompound parentNBT) { parentNBT.setTag("lockStates", list); } } catch (Exception e) { - Treasure.logger.error("Error writing LockStates to NBT:", e); + logger.error("Error writing LockStates to NBT:", e); } return parentNBT; } @@ -195,22 +236,29 @@ public NBTTagCompound writeLockStatesToNBT(NBTTagCompound parentNBT) { /** * Write custom properties to NBT * - * @param parentNBT + * @param sourceTag * @return */ - public NBTTagCompound writePropertiesToNBT(NBTTagCompound parentNBT) { + public NBTTagCompound writePropertiesToNBT(NBTTagCompound sourceTag) { try { // write custom name if (this.hasCustomName()) { - parentNBT.setString("CustomName", this.customName); + sourceTag.setString("CustomName", this.customName); } // write facing -// Treasure.logger.debug("Writing FACING to NBT ->{}", getFacing()); - parentNBT.setInteger("facing", getFacing()); + // logger.debug("Writing FACING to NBT ->{}", getFacing()); + sourceTag.setInteger("facing", getFacing()); + sourceTag.setBoolean("sealed", isSealed()); + if (getGenerationContext() != null) { + NBTTagCompound contextTag = new NBTTagCompound(); + contextTag.setString("lootRarity", getGenerationContext().getLootRarity().getValue()); + contextTag.setString("chestGenType", getGenerationContext().getChestGeneratorType().name()); + sourceTag.setTag("genContext", contextTag); + } } catch (Exception e) { - Treasure.logger.error("Error writing Properties to NBT:", e); + logger.error("Error writing Properties to NBT:", e); } - return parentNBT; + return sourceTag; } /** @@ -224,7 +272,7 @@ public NBTTagCompound writeInventoryToNBT(NBTTagCompound parentNBT) { // write inventory ItemStackHelper.saveAllItems(parentNBT, this.getItems()); } catch (Exception e) { - Treasure.logger.error("Error writing Inventory to NBT:", e); + logger.error("Error writing Inventory to NBT:", e); } return parentNBT; } @@ -238,7 +286,7 @@ public void readInventoryFromNBT(NBTTagCompound parentNBT) { // read the inventory ItemStackHelper.loadAllItems(parentNBT, this.getItems()); } catch (Exception e) { - Treasure.logger.error("Error reading Properties from NBT:", e); + logger.error("Error reading Properties from NBT:", e); } } @@ -250,12 +298,12 @@ public void readLockStatesFromNBT(NBTTagCompound parentNBT) { try { // read the lockstates if (parentNBT.hasKey("lockStates")) { -// Treasure.logger.debug("Has lockStates"); + // logger.debug("Has lockStates"); if (this.getLockStates() != null) { -// Treasure.logger.debug("size of internal lockstates:" + this.getLockStates().size()); + // logger.debug("size of internal lockstates:" + this.getLockStates().size()); } else { this.setLockStates(new LinkedList()); -// Treasure.logger.debug("created lockstates:" + this.getLockStates().size()); + // logger.debug("created lockstates:" + this.getLockStates().size()); } List states = new LinkedList(); @@ -264,33 +312,48 @@ public void readLockStatesFromNBT(NBTTagCompound parentNBT) { NBTTagCompound c = list.getCompoundTagAt(i); LockState lockState = LockState.readFromNBT(c); states.add(lockState.getSlot().getIndex(), lockState); -// Treasure.logger.debug("Read NBT lockstate:" + lockState); } // update the tile entity setLockStates(states); } } catch (Exception e) { - Treasure.logger.error("Error reading Lock States from NBT:", e); + logger.error("Error reading Lock States from NBT:", e); } } /** * - * @param parentNBT + * @param sourceTag */ - public void readPropertiesFromNBT(NBTTagCompound parentNBT) { + public void readPropertiesFromNBT(NBTTagCompound sourceTag) { try { // read the custom name - if (parentNBT.hasKey("CustomName", 8)) { - this.customName = parentNBT.getString("CustomName"); + if (sourceTag.hasKey("CustomName", 8)) { + this.customName = sourceTag.getString("CustomName"); } // read the facing - if (parentNBT.hasKey("facing")) { -// Treasure.logger.debug("Has 'facing' key -> {}", parentNBT.getInteger("facing")); - this.setFacing(parentNBT.getInteger("facing")); + if (sourceTag.hasKey("facing")) { + // logger.debug("Has 'facing' key -> {}", parentNBT.getInteger("facing")); + this.setFacing(sourceTag.getInteger("facing")); + } + if (sourceTag.hasKey("sealed")) { + this.setSealed(sourceTag.getBoolean("sealed")); + } + if (sourceTag.hasKey("genContext")) { + NBTTagCompound contextTag = sourceTag.getCompoundTag("genContext"); + Rarity rarity = null; + ChestGeneratorType genType = null; + if (contextTag.hasKey("lootRarity")) { + rarity = Rarity.getByValue(contextTag.getString("lootRarity")); + } + if (contextTag.hasKey("chestGenType")) { + genType = ChestGeneratorType.valueOf(contextTag.getString("chestGenType")); + } + AbstractTreasureChestTileEntity.GenerationContext genContext = this.new GenerationContext(rarity, genType); + this.setGenerationContext(genContext); } } catch (Exception e) { - Treasure.logger.error("Error reading Properties from NBT:", e); + logger.error("Error reading Properties from NBT:", e); } } @@ -306,7 +369,7 @@ public void readFromNBT(NBTTagCompound parentNBT) { readInventoryFromNBT(parentNBT); readPropertiesFromNBT(parentNBT); } catch (Exception e) { - Treasure.logger.error("Error reading to NBT:", e); + logger.error("Error reading to NBT:", e); } } @@ -319,7 +382,7 @@ public void readFromItemStackNBT(NBTTagCompound nbt) { readInventoryFromNBT(nbt); readPropertiesFromNBT(nbt); } catch (Exception e) { - Treasure.logger.error("Error reading to NBT:", e); + logger.error("Error reading to NBT:", e); } } @@ -347,14 +410,14 @@ public void onDataPacket(NetworkManager net, SPacketUpdateTileEntity pkt) { */ @Override public boolean shouldRefresh(World world, BlockPos pos, IBlockState oldState, IBlockState newState) { -// Treasure.logger.debug("ShouldRefresh:" + (oldState.getBlock() != newState.getBlock())); + // logger.debug("ShouldRefresh:" + (oldState.getBlock() != newState.getBlock())); return oldState.getBlock() != newState.getBlock(); - } /** * Sync client and server states */ + @Override public void sendUpdates() { world.markBlockRangeForRenderUpdate(pos, pos); world.notifyBlockUpdate(pos, getState(), getState(), 3); @@ -373,6 +436,7 @@ private IBlockState getState() { /** * @return the lockStates */ + @Override public List getLockStates() { return lockStates; } @@ -380,6 +444,7 @@ public List getLockStates() { /** * @param lockStates the lockStates to set */ + @Override public void setLockStates(List lockStates) { this.lockStates = lockStates; } @@ -388,6 +453,7 @@ public void setLockStates(List lockStates) { * * @return */ + @Override public boolean hasLocks() { // TODO TEMP do this for now. should have another property numActiveLocks so // that the renderer doesn't keep calling this @@ -400,6 +466,16 @@ public boolean hasLocks() { return false; } + @Override + public int getFacing() { + return facing; + } + + @Override + public void setFacing(int facing) { + this.facing = facing; + } + /** * Get the formatted ChatComponent that will be used for the sender's username * in chat @@ -536,7 +612,7 @@ public void openInventory(EntityPlayer player) { this.numPlayersUsing = 0; } ++this.numPlayersUsing; - Treasure.logger.debug("Incremented numPlayersUsing to:" + numPlayersUsing); +// logger.debug("Incremented numPlayersUsing to:" + numPlayersUsing); this.world.addBlockEvent(this.pos, this.getBlockType(), 1, this.numPlayersUsing); this.world.notifyNeighborsOfStateChange(this.pos, this.getBlockType(), false); } @@ -601,6 +677,7 @@ public void setCustomName(String customName) { /** * @return the numberOfSlots */ + @Override public int getNumberOfSlots() { return numberOfSlots; } @@ -608,6 +685,7 @@ public int getNumberOfSlots() { /** * @param numberOfSlots the numberOfSlots to set */ + @Override public void setNumberOfSlots(int numberOfSlots) { this.numberOfSlots = numberOfSlots; } @@ -626,12 +704,23 @@ public void setItems(NonNullList chestContents) { this.items = chestContents; } - public int getFacing() { - return facing; + @Override + public boolean isSealed() { + return sealed; } - public void setFacing(int facing) { - this.facing = facing; + @Override + public void setSealed(boolean sealed) { + this.sealed = sealed; } + @Override + public GenerationContext getGenerationContext() { + return generationContext; + } + + @Override + public void setGenerationContext(GenerationContext context) { + generationContext = context; + } } diff --git a/src/com/someguyssoftware/treasure2/tileentity/GravestoneProximitySpawnerTileEntity.java b/src/com/someguyssoftware/treasure2/tileentity/GravestoneProximitySpawnerTileEntity.java index 214b4b13a..5d3b11cd2 100644 --- a/src/com/someguyssoftware/treasure2/tileentity/GravestoneProximitySpawnerTileEntity.java +++ b/src/com/someguyssoftware/treasure2/tileentity/GravestoneProximitySpawnerTileEntity.java @@ -39,8 +39,7 @@ public GravestoneProximitySpawnerTileEntity() { setMobNum(new Quantity(1, 1)); setSpawnRange(3D); setHasEntity(false); - // TEMP/DEBUG -// setHasEntity(true); +// Treasure.logger.debug("Created Gravestone tile entity @ -> {}", this.pos); } /** @@ -48,12 +47,8 @@ public GravestoneProximitySpawnerTileEntity() { */ @Override public void update() { - // TODO somehow the update is getting called right away and setting the - // hasEntity to fall before - // player is in range. boolean hasEntity = hasEntity(); if (hasEntity && TreasureConfig.WORLD_GEN.getMarkerProperties().isGravestoneSpawnMobAllowed) { -// super.update(); // this is copied fromt he abstract if (WorldInfo.isClientSide()) { @@ -74,7 +69,7 @@ public void update() { // get the distance double distanceSq = player.getDistanceSq(this.getPos().add(0.5D, 0.5D, 0.5D)); if (!isTriggered && !this.isDead() && (distanceSq < proximitySq)) { - Treasure.logger.debug("PTE proximity was met."); +// Treasure.logger.debug("PTE proximity @ -> {} was met.", new Coords(this.pos).toShortString()); isTriggered = true; // exectute action execute(this.getWorld(), new Random(), new Coords(this.getPos()), new Coords(player.getPosition())); @@ -154,8 +149,9 @@ public void readFromNBT(NBTTagCompound parentNBT) { // read the custom name if (parentNBT.hasKey("hasEntity", 8)) { this.hasEntity = parentNBT.getBoolean("hasEntity"); - Treasure.logger.debug("value of nbt entity -> {}", parentNBT.getBoolean("hasEntity")); +// Treasure.logger.debug("value of nbt entity -> {}", parentNBT.getBoolean("hasEntity")); } +// Treasure.logger.debug("reading proximity spawner @ {} -> [hasEntity={}, mobName={}, mobName={}", this.pos, parentNBT.getBoolean("hasEntity"), parentNBT.getString("mobName"), this.getMobName()); } catch (Exception e) { Treasure.logger.error("Error reading AbstractProximity properties from NBT:", e); } @@ -168,6 +164,8 @@ public void readFromNBT(NBTTagCompound parentNBT) { public NBTTagCompound writeToNBT(NBTTagCompound tag) { super.writeToNBT(tag); tag.setBoolean("hasEntity", hasEntity()); +// Treasure.logger.debug("writing proximity spawner @ {} -> [hasEntity={}, mobName={}, spawnRange={}", this.pos, tag.getBoolean("hasEntity"), tag.getString("mobName"), tag.getDouble("spawnRange")); + return tag; } diff --git a/src/com/someguyssoftware/treasure2/tileentity/ITreasureChestTileEntity.java b/src/com/someguyssoftware/treasure2/tileentity/ITreasureChestTileEntity.java new file mode 100644 index 000000000..5867eac41 --- /dev/null +++ b/src/com/someguyssoftware/treasure2/tileentity/ITreasureChestTileEntity.java @@ -0,0 +1,32 @@ +package com.someguyssoftware.treasure2.tileentity; + +import java.util.List; + +import com.someguyssoftware.treasure2.lock.LockState; +import com.someguyssoftware.treasure2.tileentity.AbstractTreasureChestTileEntity.GenerationContext; + +import net.minecraft.inventory.IInventory; + +/** + * @author Mark Gottschling on 9/4/2020 + */ +public interface ITreasureChestTileEntity extends IInventory { + + public List getLockStates(); + public void setLockStates(List lockStates); + boolean hasLocks(); + + public int getFacing(); + public void setFacing(int facing); + + public boolean isSealed(); + public void setSealed(boolean sealed); + + public GenerationContext getGenerationContext(); + public void setGenerationContext(GenerationContext context); + + int getNumberOfSlots(); + void setNumberOfSlots(int numberOfSlots); + void sendUpdates(); + +} \ No newline at end of file diff --git a/src/com/someguyssoftware/treasure2/tileentity/ProximitySpawnerTileEntity.java b/src/com/someguyssoftware/treasure2/tileentity/ProximitySpawnerTileEntity.java index 9032de202..0914d8f12 100644 --- a/src/com/someguyssoftware/treasure2/tileentity/ProximitySpawnerTileEntity.java +++ b/src/com/someguyssoftware/treasure2/tileentity/ProximitySpawnerTileEntity.java @@ -5,17 +5,21 @@ import java.util.Random; +import com.someguyssoftware.gottschcore.GottschCore; import com.someguyssoftware.gottschcore.measurement.Quantity; import com.someguyssoftware.gottschcore.positional.Coords; import com.someguyssoftware.gottschcore.random.RandomHelper; +import com.someguyssoftware.gottschcore.world.WorldInfo; import com.someguyssoftware.treasure2.Treasure; import net.minecraft.entity.Entity; import net.minecraft.entity.EntityList; import net.minecraft.entity.EntityLiving; import net.minecraft.entity.IEntityLivingData; +import net.minecraft.entity.player.EntityPlayer; import net.minecraft.nbt.NBTTagCompound; import net.minecraft.util.ResourceLocation; +import net.minecraft.util.StringUtils; import net.minecraft.util.math.BlockPos; import net.minecraft.util.math.MathHelper; import net.minecraft.world.World; @@ -28,7 +32,7 @@ public class ProximitySpawnerTileEntity extends AbstractProximityTileEntity { private ResourceLocation mobName; private Quantity mobNum; - private Double spawnRange = 1D; + private Double spawnRange = 5D; /** * @@ -47,30 +51,34 @@ public ProximitySpawnerTileEntity(double proximity) { * */ @Override - public void readFromNBT(NBTTagCompound parentNBT) { - super.readFromNBT(parentNBT); + public void readFromNBT(NBTTagCompound sourceTag) { + super.readFromNBT(sourceTag); try { // read the custom name - if (parentNBT.hasKey("mobName", 8)) { - this.mobName = new ResourceLocation(parentNBT.getString("mobName")); + if (sourceTag.hasKey("mobName", 8)) { + this.mobName = new ResourceLocation(sourceTag.getString("mobName")); } else { - // select a random mob + // select a random mob this.mobName = DungeonHooks.getRandomDungeonMob(new Random()); } + if (getMobName() == null || StringUtils.isNullOrEmpty(getMobName().toString())) { + defaultMobSpawnerSettings(); + return; + } int min = 1; int max = 1; - if (parentNBT.hasKey("mobNumMin")) { - min = parentNBT.getInteger("mobNumMin"); + if (sourceTag.hasKey("mobNumMin")) { + min = sourceTag.getInteger("mobNumMin"); } - if (parentNBT.hasKey("mobNumMax")) { - min = parentNBT.getInteger("mobNumMax"); + if (sourceTag.hasKey("mobNumMax")) { + min = sourceTag.getInteger("mobNumMax"); } this.mobNum = new Quantity(min, max); - if (parentNBT.hasKey("spawnRange")) { - Double spawnRange = parentNBT.getDouble("spawnRange"); + if (sourceTag.hasKey("spawnRange")) { + Double spawnRange = sourceTag.getDouble("spawnRange"); setSpawnRange(spawnRange); } @@ -84,15 +92,65 @@ public void readFromNBT(NBTTagCompound parentNBT) { * */ @Override - public NBTTagCompound writeToNBT(NBTTagCompound tag) { - super.writeToNBT(tag); - tag.setString("mobName", getMobName().toString()); - tag.setInteger("mobNumMin", getMobNum().getMinInt()); - tag.setInteger("mobNumMax", getMobNum().getMaxInt()); - tag.setDouble("spawnRange", getSpawnRange()); - return tag; + public NBTTagCompound writeToNBT(NBTTagCompound sourceTag) { + super.writeToNBT(sourceTag); + if (getMobName() == null || StringUtils.isNullOrEmpty(getMobName().toString())) { + defaultMobSpawnerSettings(); + } + sourceTag.setString("mobName", getMobName().toString()); + sourceTag.setInteger("mobNumMin", getMobNum().getMinInt()); + sourceTag.setInteger("mobNumMax", getMobNum().getMaxInt()); + sourceTag.setDouble("spawnRange", getSpawnRange()); + + return sourceTag; } - + + /** + * + */ + private void defaultMobSpawnerSettings() { + setMobName(new ResourceLocation("minecraft", "zombie")); + setMobNum(new Quantity(1, 1)); + setSpawnRange(5.0D); + } + + ///// TEMP + @Override + public void update() { + if (WorldInfo.isClientSide()) { + return; + } + + // get all players within range + EntityPlayer player = null; + + boolean isTriggered = false; + double proximitySq = getProximity() * getProximity(); + if (proximitySq < 1) proximitySq = 1; + + // for each player + for (int playerIndex = 0; playerIndex < getWorld().playerEntities.size(); ++playerIndex) { + player = (EntityPlayer)getWorld().playerEntities.get(playerIndex); + // get the distance + double distanceSq = player.getDistanceSq(this.getPos().add(0.5D, 0.5D, 0.5D)); + if (this.getMobName().getResourcePath().equals("bound_soul")) { + Treasure.logger.debug("PTE for mob -> {} @ -> {}, proximity -> {}, distance -> {}, triggered -> {}, dead -> {}, result -> {}", this.getMobName(), + this.pos, proximitySq, distanceSq, isTriggered, this.isDead(), (!isTriggered && !this.isDead() && (distanceSq < proximitySq)) ? "met" : "not met"); + } + if (!isTriggered && !this.isDead() && (distanceSq < proximitySq)) { + Treasure.logger.debug("PTE proximity was met."); + isTriggered = true; + // exectute action + execute(this.getWorld(), new Random(), new Coords(this.getPos()), new Coords(player.getPosition())); + + // NOTE: does not self-destruct that is up to the execute action to perform + } + + if (this.isDead()) break; + } + } + /////// + /** * */ @@ -114,6 +172,7 @@ public void execute(World world, Random random, Coords blockCoords, Coords playe double z = (double)blockCoords.getZ() + (world.rand.nextDouble() - world.rand.nextDouble()) * getSpawnRange() + 0.5D; entity.setLocationAndAngles(x, y, z, MathHelper.wrapDegrees(world.rand.nextFloat() * 360.0F), 0.0F); + Treasure.logger.debug("entity instanceof EntityLiving -> {}", (entity instanceof EntityLiving)); if (entity instanceof EntityLiving) { EntityLiving entityLiving = (EntityLiving)entity; if (entityLiving.getCanSpawnHere() && entityLiving.isNotColliding()) { diff --git a/src/com/someguyssoftware/treasure2/worldgen/SurfaceChestWorldGenerator.java b/src/com/someguyssoftware/treasure2/worldgen/SurfaceChestWorldGenerator.java index 55de80302..96b9ed374 100644 --- a/src/com/someguyssoftware/treasure2/worldgen/SurfaceChestWorldGenerator.java +++ b/src/com/someguyssoftware/treasure2/worldgen/SurfaceChestWorldGenerator.java @@ -56,6 +56,7 @@ import com.someguyssoftware.treasure2.generator.pit.SimplePitGenerator; import com.someguyssoftware.treasure2.generator.pit.StructurePitGenerator; import com.someguyssoftware.treasure2.generator.pit.TntTrapPitGenerator; +import com.someguyssoftware.treasure2.generator.pit.VolcanoPitGenerator; import com.someguyssoftware.treasure2.generator.ruins.SurfaceRuinGenerator; import com.someguyssoftware.treasure2.persistence.GenDataPersistence; import com.someguyssoftware.treasure2.registry.ChestRegistry; @@ -163,7 +164,10 @@ public void init() { // NONE for STRUCTURE pitGens.put(PitTypes.STANDARD, Pits.COLLAPSING_TRAP_PIT, new CollapsingTrapPitGenerator()); - pitGens.put(PitTypes.STRUCTURE, Pits.COLLAPSING_TRAP_PIT, new StructurePitGenerator(new CollapsingTrapPitGenerator())); + pitGens.put(PitTypes.STRUCTURE, Pits.COLLAPSING_TRAP_PIT, new StructurePitGenerator(new CollapsingTrapPitGenerator())); + + pitGens.put(PitTypes.STANDARD, Pits.VOLCANO_PIT, new VolcanoPitGenerator()); + // NONE for STRUCTURE } /** @@ -174,14 +178,6 @@ public void generate(Random random, int chunkX, int chunkZ, World world, IChunkG if (TreasureConfig.WORLD_GEN.getGeneralProperties().getDimensionsWhiteList().contains(Integer.valueOf(world.provider.getDimension()))) { generate(world, random, chunkX, chunkZ); } - -// switch(world.provider.getDimension()){ -// case 0: -// generateInOverworld(world, random, chunkX, chunkZ); -// break; -// default: -// break; -// } } /** @@ -372,7 +368,9 @@ else if (config.isSubterraneanAllowed()) { if (!chestResult.isSuccess()) { return result.fail(); } - + + // TODO can update tile entity GenerationContext with WorldGenerationType here + Treasure.logger.info("CHEATER! {} chest at coords: {}", chestRarity, markerCoords.toShortString()); result.setData(chestResult.getData()); return result.success(); diff --git a/src/resources/assets/treasure2/blockstates/blackstone.json b/src/resources/assets/treasure2/blockstates/blackstone.json new file mode 100644 index 000000000..670af67f4 --- /dev/null +++ b/src/resources/assets/treasure2/blockstates/blackstone.json @@ -0,0 +1,7 @@ +{ + "variants": { + "normal": { + "model": "treasure2:blackstone" + } + } +} \ No newline at end of file diff --git a/src/resources/assets/treasure2/lang/en_US.lang b/src/resources/assets/treasure2/lang/en_US.lang index 9060a5b0a..04f1c55d6 100644 --- a/src/resources/assets/treasure2/lang/en_US.lang +++ b/src/resources/assets/treasure2/lang/en_US.lang @@ -84,6 +84,7 @@ tile.treasure2:spanish_moss.name=Spanish Moss tile.treasure2:falling_grass.name=Grass Block tile.treasure2:falling_sand.name=Sand Block tile.treasure2:falling_red_sand.name=Red Sand Block +tile.treasure2:blackstone.name=Blackstone #items item.treasure2:gold_coin.name=Gold Coin @@ -109,6 +110,9 @@ item.treasure2:masters_pouch.name=Master's Pouch item.treasure2:key_ring.name=Key Ring item.treasure2:wood_key.name=Wood Key item.treasure2:stone_key.name=Stone Key +item.treasure2:ember_key.name=Ember Key +item.treasure2:leaf_key.name=Leaf Key +item.treasure2:lightning_key.name=Lightning Key item.treasure2:iron_key.name=Iron Key item.treasure2:gold_key.name=Gold Key item.treasure2:diamond_key.name=Diamond Key @@ -124,6 +128,9 @@ item.treasure2:shucking_knife.name=Shucking Knife item.treasure2:wood_lock.name=Wood Lock item.treasure2:stone_lock.name=Stone Lock +item.treasure2:ember_lock.name=Ember Lock +item.treasure2:leaf_lock.name=Leaf Lock +item.treasure2:lightning_lock.name=Ligtning Lock item.treasure2:iron_lock.name=Iron Lock item.treasure2:gold_lock.name=Gold Lock item.treasure2:diamond_lock.name=Diamond Lock @@ -161,7 +168,6 @@ item.treasure2:clam_stew.name=Clam Stew item.treasure2:treasure_tool.name=Treasure Tool #entities -#TODO rename standard to wood entity.wood_mimic.name=Wood Mimic entity.pirate_mimic.name=Pirate Mimic entity.bound_soul.name=Bound Soul @@ -174,7 +180,10 @@ tooltip.yes=Yes tooltip.no=No tooltip.label.rarity=Rarity: %s tooltip.label.category=Category: %s -tooltip.label.max_uses=Max Uses: %s +tooltip.label.uses=Uses Remaining: [%s/%s] +tooltip.label.max_uses=Base Max Uses: %s +tooltip.label.effective_max_uses=Eff Max Uses: %s +tooltip.label.remaining_uses=Remaining Uses: %s tooltip.label.breakable=Breakable: %s tooltip.label.craftable=Craftable: %s tooltip.label.damageable=Damageable: %s @@ -190,8 +199,11 @@ tooltip.label.charms=Charms: tooltip.label.max_locks=Max Locks: %s tooltip.label.container_size=Inventory Size: %s +tooltip.ember_key.specials=Destroys Wood Locks +tooltip.ember_lock.specials=Destroys All Keys regardless of breakability (excluding Ember) tooltip.metallurgists_key.specials=Opens any lock in METALS category tooltip.skeleton_key.specials=Opens COMMON, UNCOMMON, SCARCE and RARE locks (excluding Wither) +tooltip.lightning_key.specials=Opens any lock in ELEMENTAL category tooltip.pilferers_lock_pick.specials=Opens COMMON (%s%%) and UNCOMMON (%s%%) locks tooltip.thiefs_lock_pick.specials=Opens COMMON (%s%%), UNCOMMON (%s%%) and SCARCE (%s%%) locks tooltip.jewelled_key.specials=Opens any lock in GEMS category diff --git a/src/resources/assets/treasure2/lang/zh_CN.lang b/src/resources/assets/treasure2/lang/zh_CN.lang index c25c75cab..91f6aee1d 100644 --- a/src/resources/assets/treasure2/lang/zh_CN.lang +++ b/src/resources/assets/treasure2/lang/zh_CN.lang @@ -1,185 +1,266 @@ #chests -tile.treasure2:wood_chest.name=木箱å­� -tile.treasure2:crate_chest.name=æ�¿æ�¡ç®± -tile.treasure2:crate_chest_moldy.name=å�‘霉æ�¿æ�¡ç®± -tile.treasure2:ironbound_chest.name=é“�钉箱å­� -tile.treasure2:iron_strongbox.name=é“�匣å­� -tile.treasure2:gold_strongbox.name=金匣å­� -tile.treasure2:pirate_chest.name=æµ·ç›—ç®±å­� -tile.treasure2:safe.name=ä¿�险箱 -tile.treasure2:dread_pirate_chest.name=æ��怖海盗箱å­� -tile.treasure2:compressor_chest.name=压缩箱å­� -tile.treasure2:wither_chest.name=凋零箱å­� -tile.treasure2:skull_chest.name=骷髅箱å­� -tile.treasure2:gold_skull_chest.name=黄金骷髅箱å­� -tile.treasure2:cauldron_chest.name=å�©åŸšç®±å­� - -tile.treasure2:wood_mimic.name=木制模仿者 +tile.treasure2:wood_chest.name=木宝箱 +tile.treasure2:crate_chest.name=板条箱 +tile.treasure2:crate_chest_moldy.name=老旧的板条箱 +tile.treasure2:ironbound_chest.name=铁板加固的箱子 +tile.treasure2:iron_strongbox.name=铁质保险箱 +tile.treasure2:gold_strongbox.name=金质保险箱 +tile.treasure2:pirate_chest.name=海盗宝箱 +tile.treasure2:safe.name=保险箱 +tile.treasure2:dread_pirate_chest.name=可怕的海盗宝箱 +tile.treasure2:compressor_chest.name=压缩箱子 +tile.treasure2:wither_chest.name=凋零箱子 +tile.treasure2:skull_chest.name=头颅箱子 +tile.treasure2:gold_skull_chest.name=金头颅箱子 +tile.treasure2:cauldron_chest.name=坩埚箱子 +tile.treasure2:spider_chest.name=蜘蛛箱子 +tile.treasure2:viking_chest.name=维京箱子 + +tile.treasure2:wood_mimic.name=木宝箱怪 +tile.treasure2:wood_mimic.name=海盗宝箱怪 #wells -tile.treasure2:wishing_well_block.name=许愿井石 -tile.treasure2:desert_wishing_well_block.name=Desert Wishing Well Stone +tile.treasure2:wishing_well_block.name=许愿井石 +tile.treasure2:desert_wishing_well_block.name=沙漠许愿井石 #gravestones -tile.treasure2:gravestone1_stone.name=石头墓碑 -tile.treasure2:gravestone1_cobblestone.name=圆石墓碑 -tile.treasure2:gravestone1_mossy_cobblestone.name=苔石墓碑 -tile.treasure2:gravestone1_polished_granite.name=花岗岩墓碑 -tile.treasure2:gravestone1_polished_andesite.name=安山岩墓碑 -tile.treasure2:gravestone1_polished_diorite.name=闪长岩墓碑 -tile.treasure2:gravestone1_obsidian.name=黑曜石墓碑 - -tile.treasure2:gravestone2_stone.name=石头墓碑 -tile.treasure2:gravestone2_cobblestone.name=圆石墓碑 -tile.treasure2:gravestone2_mossy_cobblestone.name=苔石墓碑 -tile.treasure2:gravestone2_polished_granite.name=花岗岩墓碑 -tile.treasure2:gravestone2_polished_andesite.name=安山岩墓碑 -tile.treasure2:gravestone2_polished_diorite.name=闪长岩墓碑 -tile.treasure2:gravestone2_obsidian.name=黑曜石墓碑 - -tile.treasure2:gravestone3_stone.name=石头墓碑 -tile.treasure2:gravestone3_cobblestone.name=圆石墓碑 -tile.treasure2:gravestone3_mossy_cobblestone.name=苔石墓碑 -tile.treasure2:gravestone3_polished_granite.name=花岗岩墓碑 -tile.treasure2:gravestone3_polished_andesite.name=安山岩墓碑 -tile.treasure2:gravestone3_polished_diorite.name=闪长岩墓碑 -tile.treasure2:gravestone3_obsidian.name=黑曜石墓碑 - -tile.treasure2:skull_and_crossbones.name=头骨 -tile.treasure2:skeleton.name骨架 +tile.treasure2:gravestone1_stone.name=石头墓碑 +tile.treasure2:gravestone1_cobblestone.name=圆石墓碑 +tile.treasure2:gravestone1_mossy_cobblestone.name=苔石墓碑 +tile.treasure2:gravestone1_polished_granite.name=花岗岩墓碑 +tile.treasure2:gravestone1_polished_andesite.name=安山岩墓碑 +tile.treasure2:gravestone1_polished_diorite.name=闪长岩墓碑 +tile.treasure2:gravestone1_obsidian.name=黑曜石墓碑 + +tile.treasure2:gravestone2_stone.name=石头墓碑 +tile.treasure2:gravestone2_cobblestone.name=圆石墓碑 +tile.treasure2:gravestone2_mossy_cobblestone.name=苔石墓碑 +tile.treasure2:gravestone2_polished_granite.name=花岗岩墓碑 +tile.treasure2:gravestone2_polished_andesite.name=安山岩墓碑 +tile.treasure2:gravestone2_polished_diorite.name=闪长岩墓碑 +tile.treasure2:gravestone2_obsidian.name=黑曜石墓碑 + +tile.treasure2:gravestone3_stone.name=石头墓碑 +tile.treasure2:gravestone3_cobblestone.name=圆石墓碑 +tile.treasure2:gravestone3_mossy_cobblestone.name=苔石墓碑 +tile.treasure2:gravestone3_polished_granite.name=花岗岩墓碑 +tile.treasure2:gravestone3_polished_andesite.name=安山岩墓碑 +tile.treasure2:gravestone3_polished_diorite.name=闪长岩墓碑 +tile.treasure2:gravestone3_obsidian.name=黑曜石墓碑 + +tile.treasure2:skull_and_crossbones.name=头颅与骨头 +tile.treasure2:skeleton.name=骷髅 #wither tree -tile.treasure2:wither_log.name=凋零原木 -tile.treasure2:wither_broken_log.name=凋零断木 -tile.treasure2:wither_log_soul.name=凋零ç�µé­‚原木 -tile.treasure2:wither_branch.name=凋零木æž� -tile.treasure2:wither_root.name=凋零木根 -tile.treasure2:wither_planks.name=凋零木æ�¿ +tile.treasure2:wither_log.name=凋零原木 +tile.treasure2:wither_broken_log.name=破损的凋零原木 +tile.treasure2:wither_log_soul.name=凋零灵魂原木 +tile.treasure2:wither_branch.name=凋零树枝 +tile.treasure2:wither_root.name=凋零树根 +tile.treasure2:wither_planks.name=凋零木板 #fogs -tile.treasure2:fog.name=雾 -tile.treasure2:high_fog.name=高雾 -tile.treasure2:med_fog.name=中雾 -tile.treasure2:low_fog.name=低雾 +tile.treasure2:fog.name=雾 +tile.treasure2:high_fog.name=浓雾 +tile.treasure2:med_fog.name=雾 +tile.treasure2:low_fog.name=轻雾 -tile.treasure2:wither_fog.name=凋零雾 -tile.treasure2:high_wither_fog.name=高凋零雾 -tile.treasure2:med_wither_fog.name=中凋零雾 -tile.treasure2:low_wither_fog.name=低凋零雾 +tile.treasure2:wither_fog.name=凋零雾 +tile.treasure2:high_wither_fog.name=浓凋零雾 +tile.treasure2:med_wither_fog.name=凋零雾 +tile.treasure2:low_wither_fog.name=轻凋零雾 -tile.treasure2:poison_fog.name=毒雾 -tile.treasure2:high_poison_fog.name=高毒雾 -tile.treasure2:med_poison_fog.name=中毒雾 -tile.treasure2:low_poison_fog.name=低毒雾 +tile.treasure2:poison_fog.name=毒雾 +tile.treasure2:high_poison_fog.name=浓毒雾 +tile.treasure2:med_poison_fog.name=毒雾 +tile.treasure2:low_poison_fog.name=轻毒雾 #ores -tile.treasure2:sapphire_ore.name=è“�å®�石矿 -tile.treasure2:ruby_ore.name=红å®�石矿 +tile.treasure2:sapphire_ore.name=蓝宝石矿石 +tile.treasure2:ruby_ore.name=红宝石矿石 #other -tile.treasure2:spanish_moss.name=寄生藤 +tile.treasure2:spanish_moss.name=寄生藤 +tile.treasure2:falling_grass.name=草方块 +tile.treasure2:falling_sand.name=沙子 +tile.treasure2:falling_red_sand.name=红沙 #items -item.treasure2:gold_coin.name=金å¸� -item.treasure2:silver_coin.name=银å¸� - -item.treasure2:key_ring.name=钥匙串 -item.treasure2:wood_key.name=木钥匙 -item.treasure2:stone_key.name=石钥匙 -item.treasure2:iron_key.name=é“�钥匙 -item.treasure2:gold_key.name=金钥匙 -item.treasure2:diamond_key.name=钻石钥匙 -item.treasure2:emerald_key.name=绿å®�石钥匙 -item.treasure2:ruby_key.name=红å®�石钥匙 -item.treasure2:sapphire_key.name=è“�å®�石钥匙 -item.treasure2:jewelled_key.name=å®�石钥匙 -item.treasure2:metallurgists_key.name=冶金师的钥匙 -item.treasure2:skeleton_key.name=骷髅钥匙 -item.treasure2:spider_key.name=蜘蛛钥匙 -item.treasure2:wither_key.name=凋零钥匙 - -item.treasure2:wood_lock.name=木é”� -item.treasure2:stone_lock.name=石é”� -item.treasure2:iron_lock.name=é“�é”� -item.treasure2:gold_lock.name=金é”� -item.treasure2:diamond_lock.name=钻石é”� -item.treasure2:emerald_lock.name=绿å®�石é”� -item.treasure2:ruby_lock.name=红å®�石é”� -item.treasure2:sapphire_lock.name=è“�å®�石é”� -item.treasure2:spider_lock.name=蜘蛛é”� -item.treasure2:wither_lock.name=凋零é”� - -item.treasure2:wither_stick_item.name=凋零木æž� -item.treasure2:wither_root_item.name=凋零木根 -item.treasure2:pilferers_lock_pick.name=å�·ç›—者的开é”�工具 -item.treasure2:thiefs_lock_pick.name=å°�å�·çš„å¼€é”�工具 - -item.treasure2:painting_blocks_bricks.name=o2xygeno画的砖å�— -item.treasure2:painting_blocks_cobblestone.name=o2xygeno画的圆石 -item.treasure2:painting_blocks_dirt.name=o2xygeno画的泥土 -item.treasure2:painting_blocks_lava.name=o2xygeno画的岩浆 -item.treasure2:painting_blocks_sand.name=o2xygeno画的沙å­� -item.treasure2:painting_blocks_water.name=o2xygeno画的水 -item.treasure2:painting_blocks_wood.name=o2xygeno画的木æ�¿ - -item.treasure2:eye_patch.name=眼罩 -item.treasure2:skull_sword.name=颅骨剑 -item.treasure2:spanish_moss.name=寄生藤 -item.treasure2:sapphire.name=è“�å®�石 -item.treasure2:ruby.name=红å®�石 -item.treasure2:skeleton_item.name=骨架 -item.treasure2:treasure_tool.name=å®�è—�工具 +item.treasure2:gold_coin.name=金币 +item.treasure2:silver_coin.name=银币 +item.treasure2:charmed_silver_coin.name=幸运银币 +item.treasure2:charmed_gold_coin.name=幸运金币 +item.treasure2:charmed_ruby.name=幸运红宝石 +item.treasure2:charmed_sapphire.name=幸运蓝宝石 + +item.treasure2:angel_blessed.name=天使祝福钱币 +item.treasure2:fools_coin.name=愚人钱币 +item.treasure2:miners_friend.name=矿工之友 +item.treasure2:medics_token.name=医生的象征 +item.treasure2:salandaars_ward.name=Sal'andaar的保护 +item.treasure2:dwarven_talisman.name=矮人护身符 +item.treasure2:adephagias_bounty.name=Adephagia的赏金 +item.treasure2:mirthas_torch.name=Mirtha的火炬 +item.treasure2:pouch.name=钱袋子 +item.treasure2:lucky_pouch.name=幸运袋子 +item.treasure2:apprentices_pouch.name=学徒袋子 +item.treasure2:masters_pouch.name=大师袋子 + +item.treasure2:key_ring.name=钥匙环 +item.treasure2:wood_key.name=木钥匙 +item.treasure2:stone_key.name=石钥匙 +item.treasure2:iron_key.name=铁钥匙 +item.treasure2:gold_key.name=金钥匙 +item.treasure2:diamond_key.name=钻石钥匙 +item.treasure2:emerald_key.name=绿宝石钥匙 +item.treasure2:ruby_key.name=红宝石钥匙 +item.treasure2:sapphire_key.name=蓝宝石钥匙 +item.treasure2:jewelled_key.name=镶宝石钥匙 +item.treasure2:metallurgists_key.name=冶金学家的钥匙 +item.treasure2:skeleton_key.name=骷髅钥匙 +item.treasure2:spider_key.name=蜘蛛钥匙 +item.treasure2:wither_key.name=凋零钥匙 +item.treasure2:shucking_knife.name=剥皮刀 + +item.treasure2:wood_lock.name=木锁 +item.treasure2:stone_lock.name=石锁 +item.treasure2:iron_lock.name=铁锁 +item.treasure2:gold_lock.name=金锁 +item.treasure2:diamond_lock.name=钻石锁 +item.treasure2:emerald_lock.name=绿宝石锁 +item.treasure2:ruby_lock.name=红宝石锁 +item.treasure2:sapphire_lock.name=蓝宝石锁 +item.treasure2:spider_lock.name=蜘蛛锁 +item.treasure2:wither_lock.name=凋零锁 + +item.treasure2:wither_stick_item.name=凋零树枝 +item.treasure2:wither_root_item.name=凋零树根 +item.treasure2:pilferers_lock_pick.name=盗贼撬锁工具 +item.treasure2:thiefs_lock_pick.name=小偷撬锁工具 + +item.treasure2:painting_blocks_bricks.name=o2xygeno的砖块 +item.treasure2:painting_blocks_cobblestone.name=o2xygeno的圆石 +item.treasure2:painting_blocks_dirt.name=o2xygeno的泥土 +item.treasure2:painting_blocks_lava.name=o2xygeno的熔岩 +item.treasure2:painting_blocks_sand.name=o2xygeno的沙子 +item.treasure2:painting_blocks_water.name=o2xygeno的水 +item.treasure2:painting_blocks_wood.name=o2xygeno的木板 + +item.treasure2:eye_patch.name=眼罩 +item.treasure2:skull_sword.name=镶饰头颅剑 +item.treasure2:spanish_moss.name=寄生藤 +item.treasure2:sapphire.name=蓝宝石 +item.treasure2:ruby.name=红宝石 +item.treasure2:skeleton_item.name=骷髅 +item.treasure2:white_pearl.name=白珍珠 +item.treasure2:black_pearl.name=黑珍珠 +item.treasure2:oyster_meat.name=牡蛎肉 +item.treasure2:oyster_stew.name=炖牡蛎 +item.treasure2:clam_meat.name=蛤蜊肉 +item.treasure2:clam_stew.name=炖蛤蜊 +item.treasure2:treasure_tool.name=考古学家工具 #entities #TODO rename standard to wood -entity.wood_mimic.name=木模仿者 +entity.wood_mimic.name=木宝箱怪 +entity.pirate_mimic.name=海盗宝箱怪 +entity.bound_soul.name=地缚灵 #groups -itemGroup.treasure2:treasure_tab=å®�è—�II! +itemGroup.treasure2:treasure_tab=Treasure2! # string resources -tooltip.yes=是 -tooltip.no=å�¦ -tooltip.label.rarity=稀有度: %s -tooltip.label.category=类别: %s -tooltip.label.max_uses=最大使用次数: %s -tooltip.label.breakable=是å�¦å�¯æ–­å¼€: %s -tooltip.label.craftable=是å�¦å�¯åˆ¶ä½œ: %s -tooltip.label.damageable=是å�¦å�¯ç ´æ�Ÿ: %s -tooltip.label.specials=特殊说明: %s -tooltip.label.accepts_keys=认å�¯é’¥åŒ™: %s -tooltip.label.coin=投入许愿井里 -tooltip.label.key_ring=钥匙容器 -tooltip.label.treasure_tool=钥匙/å¼€é”�工具 å�ˆæˆ�所需. - -tooltip.label.max_locks=最大上é”�é‡�: %s -tooltip.label.container_size=储存大å°�: %s - - -tooltip.metallurgists_key.specials=打开金属类别的任何é”� -tooltip.skeleton_key.specials=打开普通,罕è§�,稀有,ç��贵的é”�(ä¸�包å�«å‡‹é›¶) -tooltip.pilferers_lock_pick.specials=打开普通 (%s%%)和罕è§� (%s%%)çš„é”� -tooltip.thiefs_lock_pick.specials=打开普通 (%s%%),罕è§� (%s%%)和稀有 (%s%%)çš„é”� -tooltip.jewelled_key.specials=打开å®�石类型的任何é”� +tooltip.yes=是 +tooltip.no=否 +tooltip.label.rarity=稀有度:%s +tooltip.label.category=类别:%s +tooltip.label.max_uses=最大耐久:%s +tooltip.label.breakable=可损坏:%s +tooltip.label.craftable=可合成:%s +tooltip.label.damageable=可损失耐久:%s +tooltip.label.specials=特殊:%s +tooltip.label.accepts_keys=可接受钥匙:%s +tooltip.label.coin=投入许愿井 +tooltip.label.key_ring=保存钥匙 +tooltip.label.coin_pouch=保存钱币、宝石、珍珠和饰品 +tooltip.label.treasure_tool=合成钥匙/撬锁工具 +tooltip.label.charmed=用手拿着或放进钱袋子里获得增益 +tooltip.label.charms=饰品: + +tooltip.label.max_locks=最大锁数:%s +tooltip.label.container_size=物品栏大小:%s + +tooltip.metallurgists_key.specials=打开任何金属类别的锁 +tooltip.skeleton_key.specials=打开普遍、常见、稀有、罕见的锁(凋零例外) +tooltip.pilferers_lock_pick.specials=打开普遍(%s%%)和常见(%s%%)的锁 +tooltip.thiefs_lock_pick.specials=打开普遍(%s%%)、常见(%s%%)和稀有(%s%%)的锁 +tooltip.jewelled_key.specials=打开任何宝石类别的锁 + +tooltip.charm.healing_rate=- 回复0.5颗心/秒 +tooltip.charm.lesser_healing=少量回复[%s/%s] +tooltip.charm.healing=回复[%s/%s] +tooltip.charm.greater_healing=大量回复[%s/%s] +tooltip.charm.grand_healing=极大量回复[%s/%s] +tooltip.charm.salandaars_convalescence=Salandaar的恢复饰品[%s/%s] + +tooltip.charm.shield_rate=- 吸收%s%%伤害 +tooltip.charm.durable_shielding=持久保护[%s/%s] +tooltip.charm.stout_shielding=厚实保护[%s/%s] +tooltip.charm.hardened_shielding=硬化保护[%s/%s] +tooltip.charm.powerful_shielding=强大保护[%s/%s] +tooltip.charm.armadillo_shielding=犰狳的保护[%s/%s] + +tooltip.charm.fullness_rate=- 恢复0.5饱食度/秒 +tooltip.charm.fullness=饱腹[%s/%s] +tooltip.charm.sated_fullness=厌腻饱腹[%s/%s] +tooltip.charm.overfed_fullness=过度饱腹[%s/%s] +tooltip.charm.gorged_fullness=狼吞虎咽[%s/%s] +tooltip.charm.bursting_fullness=爆裂饱腹[%s/%s] + +tooltip.charm.harvest_rate=- 收获%sX掉落物 +tooltip.charm.minor_harvesting=少量收获[%s/%s] +tooltip.charm.harvesting=收获[%s/%s] +tooltip.charm.major_harvesting=大量收获[%s/%s] +tooltip.charm.grand_harvesting=极大量收获[%s/%s] +tooltip.charm.glorious_harvesting=壮丽收获[%s/%s] + +tooltip.charm.illumination_rate=- 每5秒照明 +tooltip.charm.lesser_illumination=少量照明[%s/%s] +tooltip.charm.illumination=照明[%s/%s] +tooltip.charm.greater_illumination=大量照明[%s/%s] +tooltip.charm.grand_illumination=极大量照明[%s/%s] +tooltip.charm.glorious_illumination=壮丽照明[%s/%s] + +# curses +tooltip.charm.decay_rate=- 减少1颗心/5秒 +tooltip.charm.lesser_decay=少量减少[%s/%s] +tooltip.charm.decay=减少[%s/%s] +tooltip.charm.greater_decay=大量减少[%s/%s] +tooltip.charm.perishing_decay=极大量减少[%s/%s] tooltip.painting.name=%s -tooltip.painting.collection=收è—�å“�: %s -tooltip.painting.issue=期å�·: %s/%s -tooltip.painting.artist=作者 %s +tooltip.painting.collection=专辑:%s +tooltip.painting.issue=编号:%s/%s +tooltip.painting.artist=画家:%s #gui -display.wood_chest.name=木箱å­� -display.crate_chest.name=æ�¿æ�¡ç®± -display.crate_chest_moldy.name=å�‘霉的æ�¿æ�¡ç®±å­� -display.ironbound_chest.name=é“�钉箱å­� -display.pirate_chest.name=æµ·ç›—ç®±å­� -display.iron_strongbox.name=é“�匣å­� -display.gold_strongbox.name=金匣å­� -display.safe.name=ä¿�险箱 -display.dread_pirate_chest.name=æ��怖海盗箱å­� -display.compressor_chest.name=压缩箱å­� -display.wither_chest.name=凋零箱å­� -display.skull_chest.name=骷髅箱å­� -display.gold_skull_chest.name=黄金骷髅箱å­� -display.cauldron_chest.name=å�©åŸšç®±å­� +display.wood_chest.name=木宝箱 +display.crate_chest.name=板条箱 +display.crate_chest_moldy.name=老旧的板条箱 +display.ironbound_chest.name=铁板加固的箱子 +display.pirate_chest.name=铁质保险箱 +display.iron_strongbox.name=金质保险箱 +display.gold_strongbox.name=海盗宝箱 +display.safe.name=保险箱 +display.dread_pirate_chest.name=可怕的海盗宝箱 +display.compressor_chest.name=压缩箱子 +display.wither_chest.name=凋零箱子 +display.skull_chest.name=头颅箱子 +display.gold_skull_chest.name=金头颅箱子 +display.cauldron_chest.name=坩埚箱子 +#display.whale_bone_pirate_chest.name=鲸鱼骨海盗宝箱 +#display.clam_chest.name=蛤蜊箱 +#display.oyster_chest.name=杜砺箱 +display.spider_chest.name=蜘蛛箱子 +display.viking_chest.name=维京箱子 diff --git a/src/resources/assets/treasure2/models/block/blackstone.json b/src/resources/assets/treasure2/models/block/blackstone.json new file mode 100644 index 000000000..bfa2d1d85 --- /dev/null +++ b/src/resources/assets/treasure2/models/block/blackstone.json @@ -0,0 +1,7 @@ +{ + "parent": "minecraft:block/cube_column", + "textures": { + "end": "treasure2:blocks/blackstone_top", + "side": "treasure2:blocks/blackstone" + } +} \ No newline at end of file diff --git a/src/resources/assets/treasure2/models/item/blackstone.json b/src/resources/assets/treasure2/models/item/blackstone.json new file mode 100644 index 000000000..bf49abb8c --- /dev/null +++ b/src/resources/assets/treasure2/models/item/blackstone.json @@ -0,0 +1,3 @@ +{ + "parent": "treasure2:block/blackstone" +} \ No newline at end of file diff --git a/src/resources/assets/treasure2/models/item/ember_key.json b/src/resources/assets/treasure2/models/item/ember_key.json new file mode 100644 index 000000000..e147f3cab --- /dev/null +++ b/src/resources/assets/treasure2/models/item/ember_key.json @@ -0,0 +1,6 @@ +{ + "parent": "item/generated", + "textures": { + "layer0": "treasure2:items/keys/ember_key" + } +} \ No newline at end of file diff --git a/src/resources/assets/treasure2/models/item/ember_lock.json b/src/resources/assets/treasure2/models/item/ember_lock.json new file mode 100644 index 000000000..48344a57f --- /dev/null +++ b/src/resources/assets/treasure2/models/item/ember_lock.json @@ -0,0 +1,6 @@ +{ + "parent": "item/generated", + "textures": { + "layer0": "treasure2:items/locks/ember_lock" + } +} \ No newline at end of file diff --git a/src/resources/assets/treasure2/models/item/leaf_key.json b/src/resources/assets/treasure2/models/item/leaf_key.json new file mode 100644 index 000000000..9a1bb69d7 --- /dev/null +++ b/src/resources/assets/treasure2/models/item/leaf_key.json @@ -0,0 +1,6 @@ +{ + "parent": "item/generated", + "textures": { + "layer0": "treasure2:items/keys/leaf_key" + } +} \ No newline at end of file diff --git a/src/resources/assets/treasure2/models/item/leaf_lock.json b/src/resources/assets/treasure2/models/item/leaf_lock.json new file mode 100644 index 000000000..31f8d3b0d --- /dev/null +++ b/src/resources/assets/treasure2/models/item/leaf_lock.json @@ -0,0 +1,6 @@ +{ + "parent": "item/generated", + "textures": { + "layer0": "treasure2:items/locks/leaf_lock" + } +} \ No newline at end of file diff --git a/src/resources/assets/treasure2/models/item/lightning_key.json b/src/resources/assets/treasure2/models/item/lightning_key.json new file mode 100644 index 000000000..c88e23253 --- /dev/null +++ b/src/resources/assets/treasure2/models/item/lightning_key.json @@ -0,0 +1,6 @@ +{ + "parent": "item/generated", + "textures": { + "layer0": "treasure2:items/keys/lightning_key" + } +} \ No newline at end of file diff --git a/src/resources/assets/treasure2/textures/blocks/blackstone.png b/src/resources/assets/treasure2/textures/blocks/blackstone.png new file mode 100644 index 000000000..265aa349a Binary files /dev/null and b/src/resources/assets/treasure2/textures/blocks/blackstone.png differ diff --git a/src/resources/assets/treasure2/textures/blocks/blackstone_top.png b/src/resources/assets/treasure2/textures/blocks/blackstone_top.png new file mode 100644 index 000000000..45a4a4348 Binary files /dev/null and b/src/resources/assets/treasure2/textures/blocks/blackstone_top.png differ diff --git a/src/resources/assets/treasure2/textures/items/keys/ember_key.png b/src/resources/assets/treasure2/textures/items/keys/ember_key.png new file mode 100644 index 000000000..32bd68c21 Binary files /dev/null and b/src/resources/assets/treasure2/textures/items/keys/ember_key.png differ diff --git a/src/resources/assets/treasure2/textures/items/keys/leaf_key.png b/src/resources/assets/treasure2/textures/items/keys/leaf_key.png new file mode 100644 index 000000000..efd7e5780 Binary files /dev/null and b/src/resources/assets/treasure2/textures/items/keys/leaf_key.png differ diff --git a/src/resources/assets/treasure2/textures/items/keys/lightning_key.png b/src/resources/assets/treasure2/textures/items/keys/lightning_key.png new file mode 100644 index 000000000..dca61cee0 Binary files /dev/null and b/src/resources/assets/treasure2/textures/items/keys/lightning_key.png differ diff --git a/src/resources/assets/treasure2/textures/items/locks/ember_lock.png b/src/resources/assets/treasure2/textures/items/locks/ember_lock.png new file mode 100644 index 000000000..56ceb3d10 Binary files /dev/null and b/src/resources/assets/treasure2/textures/items/locks/ember_lock.png differ diff --git a/src/resources/assets/treasure2/textures/items/locks/leaf_lock.png b/src/resources/assets/treasure2/textures/items/locks/leaf_lock.png new file mode 100644 index 000000000..e47088581 Binary files /dev/null and b/src/resources/assets/treasure2/textures/items/locks/leaf_lock.png differ diff --git a/src/resources/loot_tables/treasure2/treasure/rare.json b/src/resources/loot_tables/treasure2/treasure/rare.json index fed13d015..907850337 100644 --- a/src/resources/loot_tables/treasure2/treasure/rare.json +++ b/src/resources/loot_tables/treasure2/treasure/rare.json @@ -1,10 +1,16 @@ { - "version": "1.0", + "version": "1.1", "pools": [ { "name": "rare_keys", "rolls": 1, "entries": [ + { + "entryName": "lightning_key", + "type": "item", + "name": "treasure2:lightning_key", + "weight": 10 + }, { "entryName": "metallurgists_key", "type": "item", diff --git a/src/resources/loot_tables/treasure2/treasure/scarce.json b/src/resources/loot_tables/treasure2/treasure/scarce.json index 94377aa65..a1bbe53a8 100644 --- a/src/resources/loot_tables/treasure2/treasure/scarce.json +++ b/src/resources/loot_tables/treasure2/treasure/scarce.json @@ -1,5 +1,5 @@ { - "version": "1.0", + "version": "1.1", "pools": [ { "name": "scarce_keys", @@ -35,6 +35,42 @@ } ] }, + { + "entryName": "leaf_key", + "type": "item", + "name": "treasure2:leaf_key", + "weight": 20, + "functions": [ + { + "function": "set_count", + "count": { + "min": 1, + "max": 2 + } + } + ] + }, + { + "entryName": "ember_key", + "type": "item", + "name": "treasure2:ember_key", + "weight": 25, + "functions": [ + { + "function": "set_count", + "count": { + "min": 1, + "max": 2 + } + } + ] + }, + { + "entryName": "lightning_key", + "type": "item", + "name": "treasure2:lightning_key", + "weight": 7 + }, { "entryName": "gold_key", "type": "item", diff --git a/src/resources/loot_tables/treasure2/treasure/uncommon.json b/src/resources/loot_tables/treasure2/treasure/uncommon.json index 6e2bfa877..f195c8087 100644 --- a/src/resources/loot_tables/treasure2/treasure/uncommon.json +++ b/src/resources/loot_tables/treasure2/treasure/uncommon.json @@ -1,5 +1,5 @@ { - "version": "1.0", + "version": "1.1", "pools": [ { "name": "uncommon_keys", @@ -80,6 +80,18 @@ } ] }, + { + "entryName": "ember_key", + "type": "item", + "name": "treasure2:ember_key", + "weight": 10 + }, + { + "entryName": "leaf_key", + "type": "item", + "name": "treasure2:leaf_key", + "weight": 15 + }, { "entryName": "gold_key", "type": "item", diff --git a/src/resources/mcmod.info b/src/resources/mcmod.info index ccf01a35d..c6d249d72 100644 --- a/src/resources/mcmod.info +++ b/src/resources/mcmod.info @@ -3,8 +3,8 @@ "modid": "treasure2", "name": "Treasure2!", "description": "", - "version": "1.12.0", - "mcversion": "1.12.2", + "version": "1.12.2", + "mcversion": "1.13.0", "url": "", "updateUrl": "", "authorList":["gottsch"], diff --git a/update.json b/update.json index 88e2bac61..58f45bbb8 100644 --- a/update.json +++ b/update.json @@ -1,8 +1,8 @@ { "homepage": "https://minecraft.curseforge.com/projects/treasure2", "promos": { - "1.12.2-latest": "1.12.0", - "1.12.2-recommended": "1.12.0" + "1.12.2-latest": "1.13.0", + "1.12.2-recommended": "1.13.0" }, "1.12.2": { "0.5.0": "alpha release", @@ -38,6 +38,8 @@ "1.10.0": "Replaced fog blocks with mist particles around gravestone and wither trees.\nAdded Bound Soul mob.\nAdded Collapsing Trap Pit.\nAdded 2 submerged structures.\nAdded beached shipwrecks.\nAdded skeleton, zombie and creeper heads to epic loot table.\nAdded config option to turn off gem ores gen.\nAdded config option to toggle default decay ruleset file enforcement.\nAdded config option to turn off starting book.\nUpdated spanish lang file.\nUsing GottschCore 1.12.1", "1.11.0": "Added Viking Chest.\nAdded some environmentals to Wither Tree grove.\nAdded Oasis framework and added Desert Oasis.\nAdded 2 surface structures.\nFixed Collpasing Trap Pit in deserts.\nRegistered Ruby and Sapphire with OreDict as gemRuby, gemSappphire.\nFixed loot table error.\nFixed Wither Chest bug.\nResized pearls textures to look more like pearls and less like snowballs.", "1.11.1": "Fixed server error on Wither tree gen. Fixed server crash when breaking gravestones.", - "1.12.0": "Added Charms system.\nAdded Pouches (Coin Pouch, Lucky Pouch, Apprentice's Pouch, Master's Pouch).\nAdded versions to all loot table files - if new versions made, old version will be backed up as .bak files.\nAdded Charms to loot tables.\nAdded relative positioning for t2-chest command.\nConvert KeyRing to use Capabilities.BACKUP your world, you will lose KeyRing items on update!\nUsing GottschCore v1.13.0.\n" + "1.12.0": "Added Charms system.\nAdded Pouches (Coin Pouch, Lucky Pouch, Apprentice's Pouch, Master's Pouch).\nAdded versions to all loot table files - if new versions made, old version will be backed up as .bak files.\nAdded Charms to loot tables.\nAdded relative positioning for t2-chest command.\nConvert KeyRing to use Capabilities.BACKUP your world, you will lose KeyRing items on update!\nUsing GottschCore v1.13.0.\n", + "1.12.1": "Fixed doubling of coins in Pouches bug (https://github.com/gottsch/gottsch-minecraft-Treasure/issues/142).\nAdded default values for MobProximitySpawners to prevent crashes (https://github.com/gottsch/gottsch-minecraft-Treasure/issues/152).\nAdded default charm assignments if loot table incorreclty configured (https://github.com/gottsch/gottsch-minecraft-Treasure/issues/146).", + "1.13.0": "Added Ember Lock and Key.\nAdded Leaf Lock and Key.\nAdded Lightning Key.\nAdded ability to merge Keys on anvil.\nAdded Volcano Pit.\nAdded Blackstone Block (from mc1.16).\nIncreased Key success rate to 95%.\nIncreased Pilferer's Lock Pick success rate to 32%.\nIncreased Thief's Lock Pick success rate to 48%.\nUpdated loot tables to include Ember, Leaf and Lightning Keys.\nUpdated Chinese lang file.\n" } } \ No newline at end of file