Skip to content

Commit

Permalink
Merge pull request #37 from gottsch/1.3.1
Browse files Browse the repository at this point in the history
1.3.1
  • Loading branch information
gottsch authored Jun 28, 2019
2 parents 9190f71 + 7bfaf6b commit f602c65
Show file tree
Hide file tree
Showing 16 changed files with 586 additions and 31 deletions.
4 changes: 2 additions & 2 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.3.0
mod_version=1.3.1

mc_version=1.12.2
forge_version=14.23.5.2768
mappings_version=snapshot_20171003

gottschcore_version=1.5.1
gottschcore_version=1.6.0
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@
modid=Treasure.MODID,
name=Treasure.NAME,
version=Treasure.VERSION,
dependencies="required-after:gottschcore@[1.5.0,)",
dependencies="required-after:gottschcore@[1.6.0,)",
acceptedMinecraftVersions = "[1.12.2]",
updateJSON = Treasure.UPDATE_JSON_URL
)
Expand All @@ -78,7 +78,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.3.0";
protected static final String VERSION = "1.3.1";
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 @@ -93,6 +93,14 @@ public boolean isNormalCube(IBlockState state, IBlockAccess world, BlockPos pos)
return false;
}

/**
* Prevent torches and buttons from being placed on block.
*/
@Override
public BlockFaceShape getBlockFaceShape(IBlockAccess worldIn, IBlockState state, BlockPos pos, EnumFacing face) {
return BlockFaceShape.UNDEFINED;
}

/**
*
*/
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,146 @@
/**
*
*/
package com.someguyssoftware.treasure2.block;

import javax.annotation.Nullable;

import com.someguyssoftware.gottschcore.block.ModBlock;
import com.someguyssoftware.treasure2.tileentity.AbstractProximityTileEntity;

import net.minecraft.block.ITileEntityProvider;
import net.minecraft.block.material.MapColor;
import net.minecraft.block.material.Material;
import net.minecraft.block.state.BlockFaceShape;
import net.minecraft.block.state.IBlockState;
import net.minecraft.tileentity.TileEntity;
import net.minecraft.util.EnumBlockRenderType;
import net.minecraft.util.EnumFacing;
import net.minecraft.util.math.AxisAlignedBB;
import net.minecraft.util.math.BlockPos;
import net.minecraft.world.IBlockAccess;
import net.minecraft.world.World;

/**
* An invisible non-collision block (like AIR) that creates an IProximityTileEntity.
* @author Mark Gottschling on Jan 17, 2019
*
*/
public class ProximityBlock extends ModBlock implements ITileEntityProvider {
/*
* the class of the tileEntityClass this BlockChest should use.
*/
private Class<? extends AbstractProximityTileEntity> tileEntityClass;

/**
*
* @param modID
* @param name
*/
public ProximityBlock(String modID, String name, Class<? extends AbstractProximityTileEntity> te) {
this(modID, name, Material.AIR);
setTileEntityClass(te);
}

/**
* @param modID
* @param name
* @param material
*/
private ProximityBlock(String modID, String name, Material material) {
super(modID, name, material);
}

/**
* @param modID
* @param name
* @param material
* @param mapColor
*/
private ProximityBlock(String modID, String name, Material material, MapColor mapColor) {
super(modID, name, material, mapColor);
}

/**
* Create the proximity tile entity.
*/
@Override
public TileEntity createNewTileEntity(World worldIn, int meta) {
AbstractProximityTileEntity proximityTileEntity = null;
try {
proximityTileEntity = (AbstractProximityTileEntity) getTileEntityClass().newInstance();
}
catch(Exception e) {
e.printStackTrace();
}
return (TileEntity) proximityTileEntity;
}

/**
*
*/
public EnumBlockRenderType getRenderType(IBlockState state) {
return EnumBlockRenderType.INVISIBLE;
}

@Nullable
public AxisAlignedBB getCollisionBoundingBox(IBlockState blockState, IBlockAccess worldIn, BlockPos pos) {
return NULL_AABB;
}

/**
* Used to determine ambient occlusion and culling when rebuilding chunks for render
*/
public boolean isOpaqueCube(IBlockState state) {
return false;
}

/**
*
*/
public boolean canCollideCheck(IBlockState state, boolean hitIfLiquid) {
return false;
}

/**
* Spawns this Block's drops into the World as EntityItems.
*/
public void dropBlockAsItemWithChance(World worldIn, BlockPos pos, IBlockState state, float chance, int fortune) {
}

/**
* Whether this Block can be replaced directly by other blocks (true for e.g. tall grass)
*/
public boolean isReplaceable(IBlockAccess worldIn, BlockPos pos) {
return true;
}

/**
*
*/
public BlockFaceShape getBlockFaceShape(IBlockAccess worldIn, IBlockState state, BlockPos pos, EnumFacing face) {
return BlockFaceShape.UNDEFINED;
}

/**
*
*/
public boolean isFullCube(IBlockState state) {
return false;
}

/**
* @return the tileEntityClass
*/
public Class<? extends AbstractProximityTileEntity> getTileEntityClass() {
return tileEntityClass;
}

/**
* @param tileEntityClass the tileEntityClass to set
*/
public void setTileEntityClass(Class<? extends AbstractProximityTileEntity> tileEntityClass) {
this.tileEntityClass = tileEntityClass;
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -41,16 +41,34 @@ public SkullAndBonesBlock(String modID, String name, Material material) {
setSoundType(SoundType.STONE);
setCreativeTab(Treasure.TREASURE_TAB);
setHardness(3.0F);
setBoundingBox(
new AxisAlignedBB(0F, 0F, 0F, 1F, 1F, 1F), // N
new AxisAlignedBB(0F, 0F, 0F, 1F, 1F, 1F), // E
new AxisAlignedBB(0F, 0F, 0F, 1F, 1F, 1F), // S
new AxisAlignedBB(0F, 0F, 0F, 1F, 1F, 1F) // W
);
this.bounds[EnumFacing.SOUTH.getHorizontalIndex()] =new AxisAlignedBB(0.0625D, 0.0D, 0.0625D, 0.9375D, 0.375D, 0.9375D); // S
this.bounds[EnumFacing.WEST.getHorizontalIndex()] = new AxisAlignedBB(0.0625D, 0.0D, 0.0625D, 0.9375D, 0.375D, 0.9375D); // W
this.bounds[EnumFacing.NORTH.getHorizontalIndex()] = new AxisAlignedBB(0.0625D, 0.0D, 0.0625D, 0.9375D, 0.375D, 0.9375D); // N
this.bounds[EnumFacing.EAST.getHorizontalIndex()] = new AxisAlignedBB(0.0625D, 0.0D, 0.0625D, 0.9375D, 0.375D, 0.9375D); // E
}

// used by the renderer to control lighting and visibility of other blocks.
// set to false because this block doesn't fill the entire 1x1x1 space
@Override
public boolean isOpaqueCube(IBlockState state) {
return false;
}

// used by the renderer to control lighting and visibility of other blocks, also by
// (eg) wall or fence to control whether the fence joins itself to this block
// set to false because this block doesn't fill the entire 1x1x1 space
@Override
public boolean isFullCube(IBlockState state) {
return false;
}

@Override
public boolean isNormalCube(IBlockState state, IBlockAccess world, BlockPos pos) {
return false;
}

/**
* Determines if this block can prevent leaves connected to it from decaying.
* Determines if this block can prevent fog connected to it from decaying.
* @param state The current state
* @param world The current world
* @param pos Block position in world
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@
import com.someguyssoftware.treasure2.tileentity.IronboundChestTileEntity;
import com.someguyssoftware.treasure2.tileentity.MoldyCrateChestTileEntity;
import com.someguyssoftware.treasure2.tileentity.PirateChestTileEntity;
import com.someguyssoftware.treasure2.tileentity.ProximitySpawnerTileEntity;
import com.someguyssoftware.treasure2.tileentity.SafeTileEntity;
import com.someguyssoftware.treasure2.tileentity.SkullChestTileEntity;
import com.someguyssoftware.treasure2.tileentity.WitherChestTileEntity;
Expand Down Expand Up @@ -154,6 +155,8 @@ public class TreasureBlocks {
public static final AbstractPaintingBlock PAINTING_BLOCKS_WATER;
public static final AbstractPaintingBlock PAINTING_BLOCKS_WOOD;

public static final ProximityBlock PROXIMITY_SPAWNER;

// initialize blocks
static {
// standard chest bounds
Expand Down Expand Up @@ -381,8 +384,7 @@ public class TreasureBlocks {
SKULL_CROSSBONES = new SkullAndBonesBlock(
Treasure.MODID,
TreasureConfig.SKULL_CROSSBONES_ID,
Material.ROCK)
.setBounds(stdChestBounds);
Material.ROCK);

// add all the gravestones to the list
gravestones = new ArrayList<>();
Expand Down Expand Up @@ -475,6 +477,10 @@ public class TreasureBlocks {
.setBounds(pbs);
PAINTING_BLOCKS_WOOD = new Painting1x1Block(Treasure.MODID, TreasureConfig.PAINTING_BLOCKS_WOOD_ID, Material.CLOTH, Rarity.RARE)
.setBounds(pbs);

// proximity blocks
PROXIMITY_SPAWNER = new ProximityBlock(Treasure.MODID, TreasureConfig.PROXIMITY_SPAWNER_ID, ProximitySpawnerTileEntity.class);

}


Expand Down Expand Up @@ -566,6 +572,7 @@ public static void registerBlocks(final RegistryEvent.Register<Block> event) {
registry.register(WITHER_CHEST);
registry.register(SKULL_CHEST);
registry.register(GOLD_SKULL_CHEST);
registry.register(PROXIMITY_SPAWNER);

// map the block by rarity
for (Block block : blocks) {
Expand Down Expand Up @@ -641,7 +648,8 @@ public static void registerItemBlocks(final RegistryEvent.Register<Item> event)
new ItemBlock(WITHER_LOG_SOUL),
new ItemBlock(WITHER_PLANKS),
new ItemBlock(SAPPHIRE_ORE),
new ItemBlock(RUBY_ORE)
new ItemBlock(RUBY_ORE),
new ItemBlock(PROXIMITY_SPAWNER)
};

for (final ItemBlock item : items) {
Expand Down Expand Up @@ -670,6 +678,7 @@ public static void registerItemBlocks(final RegistryEvent.Register<Item> event)
GameRegistry.registerTileEntity(WitherChestTileEntity.class, new ResourceLocation(Treasure.MODID+":"+TreasureConfig.WITHER_CHEST_TE_ID));
GameRegistry.registerTileEntity(SkullChestTileEntity.class, new ResourceLocation(Treasure.MODID+":"+TreasureConfig.SKULL_CHEST_TE_ID));
GameRegistry.registerTileEntity(GoldSkullChestTileEntity.class, new ResourceLocation(Treasure.MODID+":"+TreasureConfig.GOLD_SKULL_CHEST_TE_ID));
GameRegistry.registerTileEntity(ProximitySpawnerTileEntity.class, new ResourceLocation(Treasure.MODID+":"+TreasureConfig.PROXIMITY_SPAWNER_TE_ID));

}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -153,6 +153,8 @@ public class TreasureConfig extends AbstractConfig {
public static final String RUBY_ORE_ID = "ruby_ore";
public static final String RUBY_ID = "ruby";

public static final String PROXIMITY_SPAWNER_ID = "proximity_spawner";

public static final String TREASURE_TOOL_ITEM_ID = "treasure_tool";

// TEs
Expand All @@ -169,7 +171,8 @@ public class TreasureConfig extends AbstractConfig {
public static final String WITHER_CHEST_TE_ID = "wither_chest_tile_entity";
public static final String SKULL_CHEST_TE_ID = "skull_chest_tile_entity";
public static final String GOLD_SKULL_CHEST_TE_ID = "gold_skull_chest_tile_entity";

public static final String PROXIMITY_SPAWNER_TE_ID = "proximity_spawner_tile_entity";

/*
* mod settings
*/
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,19 +2,25 @@

import java.util.Random;

import com.someguyssoftware.gottschcore.Quantity;
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.Treasure;
import com.someguyssoftware.treasure2.block.TreasureBlocks;
import com.someguyssoftware.treasure2.generator.GenUtil;
import com.someguyssoftware.treasure2.tileentity.ProximitySpawnerTileEntity;
import com.sun.media.jfxmedia.logging.Logger;

import net.minecraft.block.Block;
import net.minecraft.block.material.Material;
import net.minecraft.block.state.IBlockState;
import net.minecraft.init.Blocks;
import net.minecraft.util.ResourceLocation;
import net.minecraft.world.World;
import net.minecraftforge.common.DungeonHooks;


/**
Expand Down Expand Up @@ -90,7 +96,8 @@ public boolean generate(World world, Random random, ICoords surfaceCoords, ICoor
buildTrapLayer(world, random, spawnCoords, null);

// build the pit
buildPit(world, random, nextCoords, surfaceCoords, getBlockLayers());
// NOTE must add nextCoords by Y_OFFSET, because the AbstractPitGen.buildPit() starts with the Y_OFFSET, which is above the standard chest area.
buildPit(world, random, nextCoords.down(Y_OFFSET), surfaceCoords, getBlockLayers());
}
// shaft is only 2-6 blocks long - can only support small covering
else if (yDist >= 2) {
Expand Down Expand Up @@ -128,11 +135,26 @@ private ICoords build6WideLayer(World world, Random random, ICoords coords, Bloc
* @return
*/
public ICoords buildTrapLayer(final World world, final Random random, final ICoords coords, final Block block) {
// spawn the mobs
spawnMob(world, coords.add(-2, 0, 0), "skeleton");
spawnMob(world, coords.add(0, 0, -2), "zombie");
spawnMob(world, coords.add(2, 0, 0), "zombie");
spawnMob(world, coords.add(0, 0, 2), "skeleton");

// spawn random registered mobs on either side of the chest
world.setBlockState(coords.add(-1, 0, 0).toPos(), TreasureBlocks.PROXIMITY_SPAWNER.getDefaultState());
ProximitySpawnerTileEntity te = (ProximitySpawnerTileEntity) world.getTileEntity(coords.add(-1, 0, 0).toPos());
ResourceLocation r = DungeonHooks.getRandomDungeonMob(random);
te.setMobName(r);
te.setMobNum(new Quantity(2, 4));
te.setProximity(5D);
te.setSpawnRange(1.5D);
Treasure.logger.debug("placed proximity spawner @ {}", coords.add(-1,0,0).toShortString());

world.setBlockState(coords.add(1, 0, 0).toPos(), TreasureBlocks.PROXIMITY_SPAWNER.getDefaultState());
te = (ProximitySpawnerTileEntity) world.getTileEntity(coords.add(1, 0, 0).toPos());
r = DungeonHooks.getRandomDungeonMob(random);
te.setMobName(r);
te.setMobNum(new Quantity(2, 4));
te.setProximity(5.5D); // slightly larger proximity to fire first without entity collision
te.setSpawnRange(2D);
Treasure.logger.debug("placed proximity spawner @ {}", coords.add(1,0,0).toShortString());

return coords;
}

Expand Down
Loading

0 comments on commit f602c65

Please sign in to comment.