Skip to content

Commit

Permalink
Merge branch '1.6.0' into 1.5.1
Browse files Browse the repository at this point in the history
  • Loading branch information
gottsch authored Aug 20, 2019
2 parents 7dc7765 + d694e90 commit 9823faa
Show file tree
Hide file tree
Showing 11 changed files with 319 additions and 15 deletions.
2 changes: 1 addition & 1 deletion Treasure2-1.12.2/gradle.properties
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ mod_name=Treasure2
package_group=someguyssoftware.treasure2
# user alpha, beta, or v (for version)
mod_version_type=v
mod_version=1.5.1
mod_version=1.6.0

#versions
mc_version=1.12.2
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,7 @@ public class Treasure extends AbstractMod {
// constants
public static final String MODID = "treasure2";
protected static final String NAME = "Treasure2";
protected static final String VERSION = "1.5.1";
protected static final String VERSION = "1.6.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 @@ -78,6 +78,9 @@ public class TreasureConfig extends AbstractConfig {

public static final String GOLD_COIN_ID = "gold_coin";
public static final String SILVER_COIN_ID = "silver_coin";

public static final String WHITE_PEARL_ID = "white_pearl";
public static final String BLACK_PEARL_ID = "black_pearl";

// weapons / armor
public static final String SKULL_SWORD_ID = "skull_sword";
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,92 @@
/**
*
*/
package com.someguyssoftware.treasure2.enums;

import java.util.EnumSet;
import java.util.HashMap;
import java.util.Map;

/**
*
* @author Mark Gottschling on Aug 18, 2019
*
*/
public enum Pearls implements IEnum {
WHITE(0, "White PearlItem"),
BLACK(1, "Black PearlItem");

private static final Map<Integer, IEnum> codes = new HashMap<Integer, IEnum>();
private static final Map<String, IEnum> values = new HashMap<String, IEnum>();
private Integer code;
private String value;

// setup reverse lookup
static {
for (Pearls p : EnumSet.allOf(Pearls.class)) {
codes.put(p.getCode(), p);
values.put(p.getValue(), p);
}
}

/**
* Full constructor
* @param code
* @param value
*/
Pearls(Integer code, String value) {
this.code = code;
this.value = value;
}

@Override
public String getName() {
return name();
}

@Override
public Integer getCode() {
return code;
}

@Override
public void setCode(Integer code) {
this.code = code;
}

@Override
public String getValue() {
return value;
}

@Override
public void setValue(String value) {
this.value = value;
}

/**
*
* @param code
* @return
*/
public static Pearls getByCode(Integer code) {
return (Pearls) codes.get(code);
}
/**
*
* @param value
* @return
*/
public static Pearls getByValue(String value) {
return (Pearls) values.get(value);
}

@Override
public Map<Integer, IEnum> getCodes() {
return codes;
}
@Override
public Map<String, IEnum> getValues() {
return values;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,6 @@ public boolean onEntityItemUpdate(EntityItem entityItem) {
// get the position
ICoords coords = new Coords(entityItem.getPosition());
Cube cube = new Cube(world, coords);
// Block block = world.getBlockState(coords).getBlock();
Block block = cube.toBlock();
int numWishingWellBlocks = 0;
// check if in water
Expand All @@ -111,16 +110,10 @@ public boolean onEntityItemUpdate(EntityItem entityItem) {
// List<Rarity> rarityList = null;
// determine coin type
if (getCoin() == Coins.SILVER) {
// rarityList = Arrays.asList(new Rarity[] {Rarity.UNCOMMON, Rarity.SCARCE});
// lootTables.addAll(TreasureLootTables.CHEST_LOOT_TABLE_MAP.get(Rarity.UNCOMMON));
// lootTables.addAll(TreasureLootTables.CHEST_LOOT_TABLE_MAP.get(Rarity.SCARCE));
lootTables.addAll(Treasure.LOOT_TABLES.getLootTableByRarity(Rarity.UNCOMMON));
lootTables.addAll(Treasure.LOOT_TABLES.getLootTableByRarity(Rarity.SCARCE));
}
else if (getCoin() == Coins.GOLD) {
// rarityList = Arrays.asList(new Rarity[] {Rarity.SCARCE, Rarity.RARE});
// lootTables.addAll(TreasureLootTables.CHEST_LOOT_TABLE_MAP.get(Rarity.SCARCE));
// lootTables.addAll(TreasureLootTables.CHEST_LOOT_TABLE_MAP.get(Rarity.RARE));
lootTables.addAll(Treasure.LOOT_TABLES.getLootTableByRarity(Rarity.SCARCE));
lootTables.addAll(Treasure.LOOT_TABLES.getLootTableByRarity(Rarity.RARE));
}
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,162 @@
/**
*
*/
package com.someguyssoftware.treasure2.item;

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.cube.Cube;
import com.someguyssoftware.gottschcore.item.ModItem;
import com.someguyssoftware.gottschcore.loot.LootTable;
import com.someguyssoftware.gottschcore.positional.Coords;
import com.someguyssoftware.gottschcore.positional.ICoords;
import com.someguyssoftware.gottschcore.random.RandomHelper;
import com.someguyssoftware.gottschcore.world.WorldInfo;
import com.someguyssoftware.treasure2.Treasure;
import com.someguyssoftware.treasure2.block.TreasureBlocks;
import com.someguyssoftware.treasure2.enums.Coins;
import com.someguyssoftware.treasure2.enums.Pearls;
import com.someguyssoftware.treasure2.enums.Rarity;

import net.minecraft.block.Block;
import net.minecraft.client.util.ITooltipFlag;
import net.minecraft.entity.item.EntityItem;
import net.minecraft.init.Blocks;
import net.minecraft.init.Items;
import net.minecraft.inventory.InventoryHelper;
import net.minecraft.item.ItemStack;
import net.minecraft.util.text.TextFormatting;
import net.minecraft.util.text.translation.I18n;
import net.minecraft.world.World;

/**
* TODO implement Lombok and remove getter/setters
* @author Mark Gottschling on Aug 18, 2019
*
*/
public class PearlItem extends ModItem {

public static final int MAX_STACK_SIZE = 8;
private Pearls pearl;

/**
*
*/
public PearlItem (String modID, String name) {
super();
this.setItemName(modID, name);
this.setMaxStackSize(MAX_STACK_SIZE);
this.setCreativeTab(Treasure.TREASURE_TAB);
this.pearl = Pearls.WHITE;
}

/**
*
* @param pearl
*/
public PearlItem(String modID, String name, Pearls pearl) {
this(modID, name);
this.setPearl(pearl);
}

/**
*
*/
@SuppressWarnings("deprecation")
@Override
public void addInformation(ItemStack stack, World worldIn, List<String> tooltip, ITooltipFlag flagIn) {
super.addInformation(stack, worldIn, tooltip, flagIn);
tooltip.add(TextFormatting.GOLD + I18n.translateToLocal("tooltip.label.coin"));
}

/**
*
*/
@Override
public boolean onEntityItemUpdate(EntityItem entityItem) {
World world = entityItem.getEntityWorld();
if (WorldInfo.isClientSide(world)) {
return super.onEntityItemUpdate(entityItem);
}

// get the position
ICoords coords = new Coords(entityItem.getPosition());
Cube cube = new Cube(world, coords);
Block block = cube.toBlock();
int numWishingWellBlocks = 0;
// check if in water
if (cube.equalsBlock(Blocks.WATER)) {
// check if the water block is adjacent to 2 wishing well blocks
ICoords checkCoords = coords.add(-1, 0, -1);
for (int z = 0; z < 3; z++) {
for (int x = 0; x < 3; x++) {
Cube checkCube = new Cube(world, checkCoords);
if (checkCube.equalsBlock(TreasureBlocks.WISHING_WELL_BLOCK)) {
numWishingWellBlocks++;
}
if (numWishingWellBlocks >= 2) {
break;
}
}
}

List<LootTable> lootTables = new ArrayList<>();
if (numWishingWellBlocks >=2) {
Random random = new Random();

// determine pearl type
if (getPearl() == Pearls.WHITE) {
lootTables.addAll(Treasure.LOOT_TABLES.getLootTableByRarity(Rarity.RARE));
}
else if (getPearl() == Pearls.BLACK) {
lootTables.addAll(Treasure.LOOT_TABLES.getLootTableByRarity(Rarity.EPIC));
}

ItemStack stack = null;
// handle if loot tables is null or size = 0. return an item (apple) to ensure continuing functionality
if (lootTables == null || lootTables.size() == 0) {
stack = new ItemStack(Items.DIAMOND);
}
else {
// select a table
LootTable table = lootTables.get(RandomHelper.randomInt(random, 0, lootTables.size()-1));

// generate a list of itemStacks from the table pools
List<ItemStack> list =table.generateLootFromPools(random, Treasure.LOOT_TABLES.getContext());

// select one item randomly
stack = list.get(list.size()-1);
}

// spawn the item
if (stack != null) {
InventoryHelper.spawnItemStack(world, (double)coords.getX(), (double)coords.getY()+1, (double)coords.getZ(), stack);
}

// remove the item entity
entityItem.setDead();
return true;
}
}

return super.onEntityItemUpdate(entityItem);
}

/**
* @return the pearl
*/
public Pearls getPearl() {
return pearl;
}
/**
* @param pearl the pearl to set
*/
public PearlItem setPearl(Pearls pearl) {
this.pearl = pearl;
return this;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
import com.someguyssoftware.treasure2.config.TreasureConfig;
import com.someguyssoftware.treasure2.enums.Category;
import com.someguyssoftware.treasure2.enums.Coins;
import com.someguyssoftware.treasure2.enums.Pearls;
import com.someguyssoftware.treasure2.enums.Rarity;

import net.minecraft.block.material.MapColor;
Expand Down Expand Up @@ -41,6 +42,12 @@ public class TreasureItems {
// coins
public static Item GOLD_COIN;
public static Item SILVER_COIN;
// pearls
public static Item WHITE_PEARL;
public static Item BLACK_PEARL;
// gems
public static Item SAPPHIRE;
public static Item RUBY;
// locks
public static LockItem WOOD_LOCK;
public static LockItem STONE_LOCK;
Expand Down Expand Up @@ -108,8 +115,6 @@ public class TreasureItems {
// other
public static Item SPANISH_MOSS;
public static Item TREASURE_TOOL;
public static Item SAPPHIRE;
public static Item RUBY;
public static Item SKELETON;

/*
Expand All @@ -131,6 +136,10 @@ public class TreasureItems {
GOLD_COIN = new CoinItem(Treasure.MODID, TreasureConfig.GOLD_COIN_ID);
SILVER_COIN = new CoinItem(Treasure.MODID, TreasureConfig.SILVER_COIN_ID, Coins.SILVER);

// PEARLS
WHITE_PEARL = new PearlItem(Treasure.MODID, TreasureConfig.WHITE_PEARL_ID, Pearls.WHITE);
BLACK_PEARL = new PearlItem(Treasure.MODID, TreasureConfig.BLACK_PEARL_ID, Pearls.BLACK);

// KEYS
WOOD_KEY = new KeyItem(Treasure.MODID, TreasureConfig.WOOD_KEY_ID)
.setCategory(Category.BASIC)
Expand Down Expand Up @@ -394,6 +403,8 @@ public static void registerItems(final RegistryEvent.Register<Item> event) {
TREASURE_TAB,
SILVER_COIN,
GOLD_COIN,
WHITE_PEARL,
BLACK_PEARL,
WOOD_LOCK,
STONE_LOCK,
IRON_LOCK,
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
{
"parent": "builtin/generated",
"textures": {
"layer0": "treasure2:items/pearls/black_pearl"
},
"display": {
"thirdperson_righthand": {
"translation": [ 0, 1, 0],
"scale":[ 0.25, 0.25, 0.25]
},
"firstperson_righthand": {
"translation": [ 0, 2, 0],
"scale": [ 0.5, 0.5, 0.5 ]
},
"ground": {
"rotation": [ 0, 0, 0 ],
"translation": [ 0, 1, 0],
"scale":[ 0.25, 0.25, 0.25]
}
}
}
Loading

0 comments on commit 9823faa

Please sign in to comment.