Skip to content

Commit

Permalink
Merge pull request #39 from gottsch/1.3.5
Browse files Browse the repository at this point in the history
1.3.5
  • Loading branch information
gottsch authored Jul 6, 2019
2 parents b88e58e + 9f5077b commit e57e33c
Show file tree
Hide file tree
Showing 114 changed files with 2,333 additions and 506 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.1
mod_version=1.3.5

mc_version=1.12.2
forge_version=14.23.5.2768
mappings_version=snapshot_20171003

gottschcore_version=1.6.0
gottschcore_version=1.7.0
18 changes: 16 additions & 2 deletions Treasure2-1.12.2/src/com/someguyssoftware/treasure2/Treasure.java
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,9 @@

import org.apache.logging.log4j.LogManager;
import org.apache.logging.log4j.Logger;
import org.apache.logging.log4j.core.Appender;

import com.someguyssoftware.gottschcore.GottschCore;
import com.someguyssoftware.gottschcore.annotation.Credits;
import com.someguyssoftware.gottschcore.command.ShowVersionCommand;
import com.someguyssoftware.gottschcore.config.IConfig;
Expand All @@ -32,6 +34,7 @@
import com.someguyssoftware.treasure2.eventhandler.WorldEventHandler;
import com.someguyssoftware.treasure2.item.PaintingItem;
import com.someguyssoftware.treasure2.item.TreasureItems;
import com.someguyssoftware.treasure2.loot.TreasureLootTableMaster;
import com.someguyssoftware.treasure2.worldgen.ChestWorldGenerator;
import com.someguyssoftware.treasure2.worldgen.GemOreWorldGenerator;
import com.someguyssoftware.treasure2.worldgen.WellWorldGenerator;
Expand Down Expand Up @@ -63,7 +66,7 @@
modid=Treasure.MODID,
name=Treasure.NAME,
version=Treasure.VERSION,
dependencies="required-after:gottschcore@[1.6.0,)",
dependencies="required-after:gottschcore@[1.7.0,)",
acceptedMinecraftVersions = "[1.12.2]",
updateJSON = Treasure.UPDATE_JSON_URL
)
Expand All @@ -78,7 +81,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.1";
protected static final String VERSION = "1.3.5";
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 All @@ -93,6 +96,9 @@ public class Treasure extends AbstractMod {
@Instance(value=Treasure.MODID)
public static Treasure instance;

// loot tables management
public static TreasureLootTableMaster LOOT_TABLES;

/*
* Treasure Creative Tab
* Must be initialized <b>before</b> any registry events so that it is available to assign to blocks and items.
Expand Down Expand Up @@ -132,6 +138,12 @@ public void preInt(FMLPreInitializationEvent event) {

// configure logging
addRollingFileAppenderToLogger(Treasure.NAME, Treasure.NAME + "Appender", (ILoggerConfig) getConfig());
// create a rolling file appender
// Appender appender = createRollingFileAppender(Treasure.NAME + "Appender", (ILoggerConfig) getConfig());
// add appender to mod logger
// addAppenderToLogger(appender, Treasure.NAME, (ILoggerConfig) getConfig());
// add appender to the GottschCore logger
// addAppenderToLogger(appender, GottschCore.instance.getName(), (ILoggerConfig) getConfig());

// register the GUI handler
NetworkRegistry.INSTANCE.registerGuiHandler(this, new GuiHandler());
Expand Down Expand Up @@ -192,6 +204,8 @@ public void init(FMLInitializationEvent event) {
GameRegistry.registerWorldGenerator(gen.getValue(), genWeight++);
}

// add the loot table managers
LOOT_TABLES = new TreasureLootTableMaster(Treasure.instance, "", "loot_tables");
}

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
import javax.annotation.Nullable;

import com.someguyssoftware.gottschcore.block.ModFallingBlock;
import com.someguyssoftware.gottschcore.world.WorldInfo;
import com.someguyssoftware.treasure2.Treasure;
import com.someguyssoftware.treasure2.enums.FogHeight;
import com.someguyssoftware.treasure2.enums.FogType;
Expand Down Expand Up @@ -159,7 +160,7 @@ public static boolean canFallThrough(IBlockState state) {
public void updateTick(World worldIn, BlockPos pos, IBlockState state, Random rand) {

// Treasure.logger.debug("updateTick on FogBlock @ {}. CD: {}, D: {}", pos.toString(), state.getValue(CHECK_DECAY), state.getValue(DECAYABLE));
if (!worldIn.isRemote) {
if (WorldInfo.isServerSide(worldIn)) {
if ((Boolean)state.getValue(CHECK_DECAY) && (Boolean)state.getValue(DECAYABLE)
&& ((Boolean)state.getValue(ACTIVATED))) {
// Treasure.logger.debug("Fog @ {} has CHECK_DECAY = true", pos.toString());
Expand Down Expand Up @@ -264,7 +265,7 @@ private void checkFallable(World worldIn, BlockPos pos) {
int i = 32;

if (worldIn.isAreaLoaded(pos.add(-32, -32, -32), pos.add(32, 32, 32))) {
if (!worldIn.isRemote) {
if (WorldInfo.isServerSide(worldIn)) {
EntityFallingBlock entityfallingblock = new EntityFallingBlock(worldIn, (double) pos.getX() + 0.5D,
(double) pos.getY(), (double) pos.getZ() + 0.5D, worldIn.getBlockState(pos).withProperty(CHECK_DECAY,(Boolean)true).withProperty(ACTIVATED, (Boolean)false));
worldIn.spawnEntity(entityfallingblock);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
import java.util.Random;

import com.someguyssoftware.gottschcore.enums.Direction;
import com.someguyssoftware.gottschcore.world.WorldInfo;
import com.someguyssoftware.treasure2.Treasure;
import com.someguyssoftware.treasure2.chest.TreasureChestType;
import com.someguyssoftware.treasure2.entity.monster.MimicEntity;
Expand Down Expand Up @@ -115,7 +116,7 @@ public boolean onBlockActivated(World worldIn, BlockPos pos, IBlockState state,
AbstractTreasureChestTileEntity te = (AbstractTreasureChestTileEntity) worldIn.getTileEntity(pos);

// exit if on the client
if (worldIn.isRemote) {
if (WorldInfo.isClientSide(worldIn)) {
return true;
}

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

import java.util.Random;

import com.someguyssoftware.gottschcore.world.WorldInfo;

import net.minecraft.block.Block;
import net.minecraft.block.material.Material;
import net.minecraft.block.properties.IProperty;
import net.minecraft.block.properties.PropertyEnum;
import net.minecraft.block.state.BlockFaceShape;
import net.minecraft.block.state.BlockStateContainer;
import net.minecraft.block.state.IBlockState;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.init.Items;
import net.minecraft.item.Item;
import net.minecraft.util.BlockRenderLayer;
import net.minecraft.util.EnumFacing;
import net.minecraft.util.IStringSerializable;
import net.minecraft.util.math.AxisAlignedBB;
import net.minecraft.util.math.BlockPos;
import net.minecraft.world.IBlockAccess;
import net.minecraft.world.World;
import net.minecraftforge.fml.relauncher.Side;
import net.minecraftforge.fml.relauncher.SideOnly;

/**
* @author Mark Gottschling on Feb 2, 2019
*
*/
public class SkeletonBlock extends SkullAndBonesBlock {

public static final PropertyEnum<SkeletonBlock.EnumPartType> PART = PropertyEnum.<SkeletonBlock.EnumPartType>create("part", SkeletonBlock.EnumPartType.class);

/**
*
*/
public SkeletonBlock(String modID, String name, Material material) {
super(modID, name, material);
this.setDefaultState(this.blockState.getBaseState().withProperty(PART, SkeletonBlock.EnumPartType.BOTTOM));
this.bounds[0] =new AxisAlignedBB(0F, 0F, 0F, 1F, 0.375F, 1F); // S
this.bounds[1] = new AxisAlignedBB(0F, 0F, 0F, 1F, 0.375F, 1F); // W
this.bounds[2] = new AxisAlignedBB(0F, 0F, 0F, 1F, 0.375F, 1F); // N
this.bounds[3] = new AxisAlignedBB(0F, 0F, 0F, 1F, 0.375F, 1F); // E
}

@Override
protected BlockStateContainer createBlockState() {
return new BlockStateContainer(this, new IProperty[] {FACING, PART});
}

/**
* This is required to process alpha channels in block textures
*/
@SideOnly(Side.CLIENT)
public BlockRenderLayer getBlockLayer() {
return BlockRenderLayer.CUTOUT;
}

/**
* Called when a neighboring block was changed and marks that this state should
* perform any checks during a neighbor change. Cases may include when redstone
* power is updated, cactus blocks popping off due to a neighboring solid block,
* etc.
*/
public void neighborChanged(IBlockState state, World worldIn, BlockPos pos, Block blockIn, BlockPos fromPos) {
EnumFacing enumfacing = (EnumFacing) state.getValue(FACING);
if (state.getValue(PART) == SkeletonBlock.EnumPartType.BOTTOM) {
// if the head is something other than SkeletonBlock, indicating that is has been destroyed
if (worldIn.getBlockState(pos.offset(enumfacing.getOpposite())).getBlock() != this) {
worldIn.setBlockToAir(pos);
}
}
// this is the the head
else if (worldIn.getBlockState(pos.offset(enumfacing)).getBlock() != this) {
if (WorldInfo.isServerSide(worldIn)) {
this.dropBlockAsItem(worldIn, pos, state, 0);
}
worldIn.setBlockToAir(pos);
}
}

@Override
public Item getItemDropped(IBlockState state, Random rand, int fortune) {
if (state.getValue(PART) == SkeletonBlock.EnumPartType.BOTTOM)
return Items.AIR;

int value = rand.nextInt(100);

// 5% of the time, drop skull
if (value < 5) {
return Items.SKULL;
}
// 20%, drop block item
else if (value >= 5 && value < 25) {
return Item.getItemFromBlock(this);
}
// 75%, drop bone
else {
return Items.BONE;
}
}

/**
* Called before the Block is set to air in the world. Called regardless of if
* the player's tool can actually collect this block
*/
public void onBlockHarvested(World worldIn, BlockPos pos, IBlockState state, EntityPlayer player) {
if (player.capabilities.isCreativeMode && state.getValue(PART) == SkeletonBlock.EnumPartType.BOTTOM) {
BlockPos blockpos = pos.offset((EnumFacing) state.getValue(FACING));

if (worldIn.getBlockState(blockpos).getBlock() == this) {
worldIn.setBlockToAir(blockpos);
}
}
}

/**
* Convert the given metadata into a BlockState for this Block
*/
public IBlockState getStateFromMeta(int meta) {
IBlockState blockState = super.getStateFromMeta(meta);
return (meta & 8) > 0 ? blockState.withProperty(PART, SkeletonBlock.EnumPartType.TOP)
: blockState.withProperty(PART, SkeletonBlock.EnumPartType.BOTTOM);
}

/**
* Convert the BlockState into the correct metadata value
*/
public int getMetaFromState(IBlockState state) {
int i = 0;
// i = i | ((EnumFacing) state.getValue(FACING)).getHorizontalIndex();
i = i | super.getMetaFromState(state);

if (state.getValue(PART) == SkeletonBlock.EnumPartType.TOP) {
i |= 8;
}

return i;
}

/**
* Get the geometry of the queried face at the given position and state. This is
* used to decide whether things like buttons are allowed to be placed on the
* face, or how glass panes connect to the face, among other things.
* <p>
* Common values are {@code SOLID}, which is the default, and {@code UNDEFINED},
* which represents something that does not fit the other descriptions and will
* generally cause other things not to connect to the face.
*
* @return an approximation of the form of the given face
*/
public BlockFaceShape getBlockFaceShape(IBlockAccess worldIn, IBlockState state, BlockPos pos, EnumFacing face) {
return BlockFaceShape.UNDEFINED;
}

/**
*
* @author Mark Gottschling on Feb 2, 2019
*
*/
public static enum EnumPartType implements IStringSerializable {
TOP("top"), BOTTOM("bottom");

private final String name;

private EnumPartType(String name) {
this.name = name;
}

public String toString() {
return this.name;
}

public String getName() {
return this.name;
}
}

}
Loading

0 comments on commit e57e33c

Please sign in to comment.