Skip to content

Commit

Permalink
Merge pull request #13 from gottsch/1.1.0
Browse files Browse the repository at this point in the history
1.1.0
  • Loading branch information
gottsch authored Nov 9, 2018
2 parents ffd515c + d44c6d4 commit bb5084a
Show file tree
Hide file tree
Showing 91 changed files with 6,196 additions and 1,016 deletions.
6 changes: 3 additions & 3 deletions Treasure2-1.12.2/gradle.properties
Original file line number Diff line number Diff line change
Expand Up @@ -6,10 +6,10 @@ mod_name=Treasure2
package_group=someguyssoftware.treasure2
# user alpha, beta, or v (for version)
mod_version_type=v
mod_version=1.0.1
mod_version=1.1.0

mc_version=1.12.2
forge_version=14.23.4.2705
forge_version=14.23.5.2768
mappings_version=snapshot_20171003

gottschcore_version=1.5.0
gottschcore_version=1.5.1
Original file line number Diff line number Diff line change
Expand Up @@ -63,13 +63,18 @@
acceptedMinecraftVersions = "[1.12.2]",
updateJSON = Treasure.UPDATE_JSON_URL
)
@Credits(values={"Treasure was first developed by Mark Gottschling on Aug 27, 2014.","Credits to Mason for ideas and debugging."})
@Credits(values={
"Treasure was first developed by Mark Gottschling on Aug 27, 2014.",
"Treasure2 was first developed by Mark Gottschling on Jan 2018.",
"Credits to Mason Gottschling for ideas and debugging.",
"Credits to CuddleBeak for some Keys and Locks textures."
})
public class Treasure extends AbstractMod {

// constants
public static final String MODID = "treasure2";
protected static final String NAME = "Treasure2";
protected static final String VERSION = "1.0.1";
protected static final String VERSION = "1.1.0";
public static final String UPDATE_JSON_URL = "https://raw.githubusercontent.com/gottsch/gottsch-minecraft-Treasure/master/Treasure2-1.12.2/update.json";

private static final String VERSION_URL = "";
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@

import net.minecraft.block.Block;
import net.minecraft.block.BlockTorch;
import net.minecraft.block.SoundType;
import net.minecraft.block.material.Material;
import net.minecraft.block.properties.IProperty;
import net.minecraft.block.properties.PropertyBool;
Expand Down Expand Up @@ -69,6 +70,7 @@ public FogBlock(String modID, String name, Material material, Map<FogHeight, Fog
.withProperty(CHECK_DECAY, Boolean.valueOf(true)) // was false
.withProperty(ACTIVATED, Boolean.valueOf(false)));
setNormalCube(false);
setSoundType(SoundType.SNOW);
setCreativeTab(Treasure.TREASURE_TAB);
setFogType(FogType.NORMAL);
setFogHeight(FogHeight.FULL_FOG);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -58,13 +58,11 @@ public Object getServerGuiElement(int ID, EntityPlayer player, World world, int
break;
case STRONGBOX_CHEST_GUIID:
if (tileEntity instanceof AbstractTreasureChestTileEntity) {
Treasure.logger.debug("Tile entity is of type TreasureChestTileEntity");
return new StrongboxChestContainer(player.inventory, ((AbstractTreasureChestTileEntity)tileEntity).getInventoryProxy());
}
break;
case COMPRESSOR_CHEST_GUIID:
if (tileEntity instanceof AbstractTreasureChestTileEntity) {
Treasure.logger.debug("Tile entity is of type TreasureChestTileEntity");
return new CompressorChestContainer(player.inventory, ((AbstractTreasureChestTileEntity)tileEntity).getInventoryProxy());
}
break;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
import com.someguyssoftware.treasure2.block.TreasureBlocks;
import com.someguyssoftware.treasure2.enums.Rarity;
import com.someguyssoftware.treasure2.generator.chest.CommonChestGenerator;
import com.someguyssoftware.treasure2.loot.TreasureLootTable;
import com.someguyssoftware.treasure2.loot.TreasureLootTables;
import com.someguyssoftware.treasure2.tileentity.AbstractTreasureChestTileEntity;

Expand Down Expand Up @@ -88,15 +89,15 @@ public void execute(MinecraftServer server, ICommandSender commandSender, String
// pop.populate(chest.getInventoryProxy(), c);
// }
CommonChestGenerator gen = new CommonChestGenerator();
LootTable lootTable = gen.selectLootTable(new Random(), rarity);
TreasureLootTable lootTable = gen.selectLootTable(new Random(), rarity);

if (lootTable == null) {
Treasure.logger.warn("Unable to select a lootTable.");
player.sendMessage(new TextComponentString("Unable to select a lootTable."));
}

Treasure.logger.debug("Generating loot from loot table for rarity {}", rarity);
List<ItemStack> stacks = lootTable.generateLootForPools(new Random(), TreasureLootTables.CONTEXT);
List<ItemStack> stacks = lootTable.generateLootFromPools(new Random(), TreasureLootTables.CONTEXT);
Treasure.logger.debug("Generated loot:");
for (ItemStack stack : stacks) {
Treasure.logger.debug(stack.getDisplayName());
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -155,13 +155,19 @@ public class TreasureConfig extends AbstractConfig {
/*
* mod settings
*/
public static final String MODS_FOLDER = "mods";
public static String treasureFolder;
public static boolean enableKeyBreaks = true;
public static boolean enableFog = true;
public static boolean enableWitherFog = true;
public static boolean enablePoisonFog = true;
public static boolean enableLockDrops = true;

/*
* other mod enablements for loot tables
*/
// public static boolean enableMoCreatures = true;

/*
* world gen
*/
Expand All @@ -188,9 +194,10 @@ public class TreasureConfig extends AbstractConfig {
// biome type white/black lists
public static String[] generalChestBiomeWhiteList;
public static String[] generalChestBiomeBlackList;



// foreign mod enablements
public static String[] enableForeignModIDs;
public static String[] availableForeignModLootTables;

/**
* @param mod
Expand Down Expand Up @@ -218,7 +225,9 @@ public Configuration load(File file) {
enableWitherFog = config.getBoolean("enableWitherFog", "03-mod", true, "Enables/Disable whether a wither fog is generated (ex. around wither trees)");
enablePoisonFog = config.getBoolean("enablePoisonFog", "03-mod", true, "Enables/Disable whether a poison fog is generated (ex. around wither trees)");
enableLockDrops = config.getBoolean("enableLockDrops", "03-mod", true, "Enables/Disable whether a Lock item is dropped when unlocked by Key item.");
// enableMoCreatures = config.getBoolean("enableMoCreatures", "03-mod", false, "Enables/Disable whether MoCreatures mod is installed and it's items can be used in loot tables.");


// white/black lists
config.setCategoryComment("04-gen", "World generation properties.");
generalChestBiomeWhiteList = config.getStringList("generalChestBiomeWhiteList", "04-gen", new String[]{}, "Allowable Biome Types for general Chest generation. Must match the Type identifer(s).");
Expand All @@ -240,6 +249,10 @@ public Configuration load(File file) {
witherRootItemGenProbability = config.getFloat("witherRootGenProbability", "04-gen", 50.0F, 0.0F, 100.0F, "");
witherBranchItemGenProbability = config.getFloat("witherBranchGenProbability", "04-gen", 50.0F, 0.0F, 100.0F, "");

// foreign mod enablements
enableForeignModIDs = config.getStringList("enableForeignModIDs", "04-gen", new String[]{"mocreatures"}, "Add mod's MODID to this list to enable custom loot tables for a mod.");
availableForeignModLootTables = config.getStringList("availableForeignModLootTables", "04-gen", new String[]{"mocreatures"}, "A list of mods that have prebuilt loot tables available. Note: used for informational purposes only.");

// the the default values
if(config.hasChanged()) {
config.save();
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
/**
*
*/
package com.someguyssoftware.treasure2.enums;

/**
* @author Mark Gottschling on Oct 27, 2018
*
*/
@Deprecated
public enum ForeignMods {
MO_CREATURES("mocreatures");

String modID;

ForeignMods(String modID) {
this.modID = modID;
}

public String getModID() {
return modID;
}

public void setModID(String modID) {
this.modID = modID;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,7 @@

import java.util.ArrayList;
import java.util.List;
import java.util.Map;
import java.util.Random;
import java.util.Map.Entry;

import com.someguyssoftware.gottschcore.positional.Coords;
import com.someguyssoftware.gottschcore.positional.ICoords;
Expand All @@ -22,7 +20,6 @@
import com.someguyssoftware.treasure2.chest.TreasureChestType;
import com.someguyssoftware.treasure2.config.Configs;
import com.someguyssoftware.treasure2.config.IChestConfig;
import com.someguyssoftware.treasure2.config.TreasureConfig;
import com.someguyssoftware.treasure2.enums.Category;
import com.someguyssoftware.treasure2.enums.Pits;
import com.someguyssoftware.treasure2.enums.Rarity;
Expand All @@ -31,17 +28,15 @@
import com.someguyssoftware.treasure2.item.LockItem;
import com.someguyssoftware.treasure2.item.TreasureItems;
import com.someguyssoftware.treasure2.lock.LockState;
import com.someguyssoftware.treasure2.loot.TreasureLootTable;
import com.someguyssoftware.treasure2.loot.TreasureLootTables;
import com.someguyssoftware.treasure2.tileentity.AbstractTreasureChestTileEntity;
import com.someguyssoftware.treasure2.tileentity.WoodChestTileEntity;
import com.someguyssoftware.treasure2.worldgen.ChestWorldGenerator;

import net.minecraft.block.Block;
import net.minecraft.item.ItemStack;
import net.minecraft.tileentity.TileEntity;
import net.minecraft.util.ResourceLocation;
import net.minecraft.world.World;
import net.minecraft.world.storage.loot.LootTable;

/**
* @author Mark Gottschling on Feb 1, 2018
Expand All @@ -55,7 +50,6 @@ public abstract class AbstractChestGenerator implements IChestGenerator {
*/
@Override
public boolean generate(World world, Random random, ICoords coords, Rarity chestRarity, IChestConfig config) {

ICoords chestCoords = null;
ICoords markerCoords = null;
ICoords spawnCoords = null;
Expand Down Expand Up @@ -113,7 +107,7 @@ else if (config.isBelowGroundAllowed()) {
// if successfully gen the pit
if (isGenerated) {
// Treasure.logger.debug("isGenerated = TRUE");
LootTable lootTable = selectLootTable(random, chestRarity);
TreasureLootTable lootTable = selectLootTable(random, chestRarity);

if (lootTable == null) {
Treasure.logger.warn("Unable to select a lootTable.");
Expand Down Expand Up @@ -154,10 +148,10 @@ else if (chest instanceof IMimicBlock) {
// InventoryPopulator pop = new InventoryPopulator();
// pop.populate(((AbstractTreasureChestTileEntity)te).getInventoryProxy(), container);
Treasure.logger.debug("Generating loot from loot table for rarity {}", chestRarity);
// List<ItemStack> stacks = lootTable.generateLootForPools(random, TreasureLootTables.CONTEXT);
List<ItemStack> stacks = lootTable.generateLootFromPools(random, TreasureLootTables.CONTEXT);
// Treasure.logger.debug("Generated loot:");
// for (ItemStack stack : stacks) {
// Treasure.logger.debug(stack.getDisplayName());
// Treasure.logger.debug("item -> {}, size -> {}", stack.getDisplayName(), stack.getCount());
// }
lootTable.fillInventory(((AbstractTreasureChestTileEntity)te).getInventoryProxy(),
random,
Expand Down Expand Up @@ -245,10 +239,21 @@ public TreasureChestBlock selectChest(final Random random, final Category categ
*/
public TileEntity placeInWorld(World world, Random random, AbstractChestBlock chest, ICoords chestCoords) {
// replace block @ coords
GenUtil.replaceBlockWithChest(world, random, chest, chestCoords);

boolean isPlaced = GenUtil.replaceBlockWithChest(world, random, chest, chestCoords);
// get the backing tile entity of the chest
TileEntity te = (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());
// remove the title entity (if exists)

if (te != null && (te instanceof AbstractTreasureChestTileEntity)) {
world.removeTileEntity(chestCoords.toPos());
}
return null;
}

// if tile entity failed to create, remove the chest
if (te == null || !(te instanceof AbstractTreasureChestTileEntity)) {
Expand Down Expand Up @@ -290,11 +295,11 @@ public TileEntity placeInWorld(World world, Random random, AbstractChestBlock ch
* @param chestRarity
* @return
*/
public LootTable selectLootTable(Random random, final Rarity chestRarity) {
LootTable table = null;
public TreasureLootTable selectLootTable(Random random, final Rarity chestRarity) {
TreasureLootTable table = null;

// select the loot table by rarity
List<LootTable> tables = buildLootTableList(chestRarity);
List<TreasureLootTable> tables = buildLootTableList(chestRarity);

// select a random table from the list
if (tables != null && !tables.isEmpty()) {
Expand All @@ -309,7 +314,7 @@ public LootTable selectLootTable(Random random, final Rarity chestRarity) {
index = RandomHelper.randomInt(random, 0, tables.size()-1);
table = tables.get(index);
}
// Treasure.logger.debug("Selected loot table index --> {}", index);
Treasure.logger.debug("Selected loot table index --> {}", index);
}
return table;
}
Expand All @@ -320,14 +325,14 @@ public LootTable selectLootTable(Random random, final Rarity chestRarity) {
* @return
*/
@Override
public List<LootTable> buildLootTableList(Rarity rarity) {
// List<LootTable> tables = TreasureLootTables.CHEST_LOOT_TABLE_MAP.get(rarity);
public List<TreasureLootTable> buildLootTableList(Rarity rarity) {
// List<TreasureLootTable> tables = TreasureLootTables.CHEST_LOOT_TABLE_MAP.get(rarity);

// get all loot tables by column key
// List<LootTable> tables = new ArrayList<>();
// Map<String, List<LootTable>> mapOfLootTables = TreasureLootTables.CHEST_LOOT_TABLES_TABLE.column(rarity);
// List<TreasureLootTable> tables = new ArrayList<>();
// Map<String, List<TreasureLootTable>> mapOfLootTables = TreasureLootTables.CHEST_LOOT_TABLES_TABLE.column(rarity);
// // convert to a single list
// for(Entry<String, List<LootTable>> n : mapOfLootTables.entrySet()) {
// for(Entry<String, List<TreasureLootTable>> n : mapOfLootTables.entrySet()) {
// tables.addAll(n.getValue());
// }

Expand All @@ -351,8 +356,10 @@ public void addMarkers(World world, Random random, ICoords coords) {
* @param chest
*/
public void addLocks(Random random, AbstractChestBlock chest, AbstractTreasureChestTileEntity te, Rarity rarity) {
List<LockItem> locks = (List<LockItem>) TreasureItems.locks.get(rarity);
List<LockItem> locks = new ArrayList<>();
locks.addAll(TreasureItems.locks.get(rarity));
addLocks(random, chest, te, locks);
locks.clear();
}

/**
Expand All @@ -362,15 +369,15 @@ public void addLocks(Random random, AbstractChestBlock chest, AbstractTreasureCh
* @param te
* @param locks
*/
public void addLocks(Random random, AbstractChestBlock chest, AbstractTreasureChestTileEntity te,List<LockItem> locks) {
public void addLocks(Random random, AbstractChestBlock chest, AbstractTreasureChestTileEntity te, List<LockItem> locks) {
int numLocks = randomizedNumberOfLocksByChestType(random, chest.getChestType());

// get the lock states
List<LockState> lockStates = te.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);
Treasure.logger.debug("adding lock: {}", lock);
// add the lock to the chest
lockStates.get(i).setLock(lock);
}
Expand All @@ -385,7 +392,7 @@ public void addLocks(Random random, AbstractChestBlock chest, AbstractTreasureCh
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);
Treasure.logger.debug("# of locks to use: {})", numLocks);

return numLocks;
}
Expand Down
Loading

0 comments on commit bb5084a

Please sign in to comment.