Initial sources added.
This commit is contained in:
parent
67d3b6e922
commit
f8aaf132a6
77 changed files with 2977 additions and 0 deletions
108
src/main/java/wile/engineersdecor/ModEngineersDecor.java
Normal file
108
src/main/java/wile/engineersdecor/ModEngineersDecor.java
Normal file
|
@ -0,0 +1,108 @@
|
|||
/*
|
||||
* @file ModEngineersDecor.java
|
||||
* @author Stefan Wilhelm (wile)
|
||||
* @copyright (C) 2019 Stefan Wilhelm
|
||||
* @license MIT (see https://opensource.org/licenses/MIT)
|
||||
*
|
||||
* Main mod class.
|
||||
*/
|
||||
package wile.engineersdecor;
|
||||
|
||||
import wile.engineersdecor.detail.ModConfig;
|
||||
import wile.engineersdecor.blocks.ModBlocks;
|
||||
import net.minecraftforge.client.event.ModelRegistryEvent;
|
||||
import net.minecraftforge.fml.common.Mod;
|
||||
import net.minecraftforge.fml.common.SidedProxy;
|
||||
import net.minecraftforge.fml.relauncher.SideOnly;
|
||||
import net.minecraftforge.fml.common.eventhandler.SubscribeEvent;
|
||||
import net.minecraftforge.event.RegistryEvent;
|
||||
import net.minecraftforge.fml.common.event.FMLInitializationEvent;
|
||||
import net.minecraftforge.fml.common.event.FMLPostInitializationEvent;
|
||||
import net.minecraftforge.fml.common.event.FMLPreInitializationEvent;
|
||||
import net.minecraftforge.fml.relauncher.Side;
|
||||
import net.minecraft.creativetab.CreativeTabs;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.block.Block;
|
||||
import net.minecraft.item.Item;
|
||||
import org.apache.logging.log4j.Logger;
|
||||
import javax.annotation.Nonnull;
|
||||
|
||||
@Mod(
|
||||
modid = ModEngineersDecor.MODID,
|
||||
name = ModEngineersDecor.MODNAME,
|
||||
version = ModEngineersDecor.MODVERSION,
|
||||
dependencies = "required-after:forge@[14.23.5.2768,)",
|
||||
useMetadata = true,
|
||||
updateJSON = "https://raw.githubusercontent.com/stfwi/engineersdecor/develop/meta/update.json",
|
||||
certificateFingerprint = ((ModEngineersDecor.MODFINGERPRINT==("@"+"MOD_SIGNSHA1"+"@")) ? "" : ModEngineersDecor.MODFINGERPRINT)
|
||||
)
|
||||
@SuppressWarnings({"unused", "ConstantConditions"})
|
||||
public class ModEngineersDecor
|
||||
{
|
||||
public static final String MODID = "engineersdecor";
|
||||
public static final String MODNAME = "Engineer's Decor";
|
||||
public static final String MODVERSION = "@MOD_VERSION@";
|
||||
public static final String MODMCVERSION = "@MOD_MCVERSION@";
|
||||
public static final String MODFINGERPRINT = "@MOD_SIGNSHA1@";
|
||||
public static final String MODBUILDID = "@MOD_BUILDID@";
|
||||
public static Logger logger;
|
||||
|
||||
@Mod.Instance
|
||||
public static ModEngineersDecor instance;
|
||||
|
||||
@SidedProxy(clientSide = "wile.engineersdecor.detail.ClientProxy", serverSide = "wile.engineersdecor.detail.ServerProxy")
|
||||
public static IProxy proxy;
|
||||
|
||||
public interface IProxy
|
||||
{
|
||||
default void preInit(FMLPreInitializationEvent e) {}
|
||||
default void init(FMLInitializationEvent e) {}
|
||||
default void postInit(FMLPostInitializationEvent e) {}
|
||||
}
|
||||
|
||||
@Mod.EventHandler
|
||||
public void preInit(FMLPreInitializationEvent event)
|
||||
{
|
||||
logger = event.getModLog();
|
||||
logger.info(MODNAME + ": Version " + MODMCVERSION + "-" + MODVERSION + ( (MODBUILDID=="@"+"MOD_BUILDID"+"@") ? "" : (" "+MODBUILDID) ) + ".");
|
||||
if(MODFINGERPRINT=="@"+"MOD_SIGNSHA1"+"@") {
|
||||
logger.warn(MODNAME + ": Mod is NOT signed by the author.");
|
||||
} else {
|
||||
logger.info(MODNAME + ": Found valid fingerprint " + MODFINGERPRINT + ".");
|
||||
}
|
||||
proxy.preInit(event);
|
||||
}
|
||||
|
||||
@Mod.EventHandler
|
||||
public void init(FMLInitializationEvent event)
|
||||
{ proxy.init(event); }
|
||||
|
||||
@Mod.EventHandler
|
||||
public void postInit(FMLPostInitializationEvent event)
|
||||
{ ModConfig.onPostInit(event); proxy.postInit(event); }
|
||||
|
||||
@Mod.EventBusSubscriber
|
||||
public static final class RegistrationSubscriptions
|
||||
{
|
||||
@SubscribeEvent
|
||||
public static void registerBlocks(RegistryEvent.Register<Block> event)
|
||||
{ ModBlocks.registerBlocks(event); }
|
||||
|
||||
@SubscribeEvent
|
||||
public static void registerItems(RegistryEvent.Register<Item> event)
|
||||
{ ModBlocks.registerItemBlocks(event); }
|
||||
|
||||
@SideOnly(Side.CLIENT)
|
||||
@SubscribeEvent
|
||||
public static void registerModels(ModelRegistryEvent event)
|
||||
{ ModBlocks.initModels(); }
|
||||
}
|
||||
|
||||
public static final CreativeTabs CREATIVE_TAB_ENGINEERSDECOR = (new CreativeTabs("tabengineersdecor") {
|
||||
@Override
|
||||
@SideOnly(Side.CLIENT)
|
||||
public @Nonnull ItemStack createIcon()
|
||||
{ return new ItemStack(ModBlocks.CLINKER_BRICK_WALL); }
|
||||
});
|
||||
|
||||
}
|
159
src/main/java/wile/engineersdecor/blocks/BlockDecor.java
Normal file
159
src/main/java/wile/engineersdecor/blocks/BlockDecor.java
Normal file
|
@ -0,0 +1,159 @@
|
|||
/*
|
||||
* @file BlockDecorFull.java
|
||||
* @author Stefan Wilhelm (wile)
|
||||
* @copyright (C) 2019 Stefan Wilhelm
|
||||
* @license MIT (see https://opensource.org/licenses/MIT)
|
||||
*
|
||||
* Common functionality class for decor blocks.
|
||||
* Mainly needed for:
|
||||
* - MC block defaults.
|
||||
* - Tooltip functionality
|
||||
* - Model initialisation
|
||||
*/
|
||||
package wile.engineersdecor.blocks;
|
||||
|
||||
import net.minecraft.block.SoundType;
|
||||
import net.minecraft.util.*;
|
||||
import wile.engineersdecor.ModEngineersDecor;
|
||||
import wile.engineersdecor.detail.ModAuxiliaries;
|
||||
import net.minecraft.block.Block;
|
||||
import net.minecraft.block.material.EnumPushReaction;
|
||||
import net.minecraft.block.material.Material;
|
||||
import net.minecraft.block.state.BlockStateContainer;
|
||||
import net.minecraft.block.state.IBlockState;
|
||||
import net.minecraft.world.IBlockAccess;
|
||||
import net.minecraft.world.World;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.client.util.ITooltipFlag;
|
||||
import net.minecraft.entity.EntityLivingBase;
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.util.math.AxisAlignedBB;
|
||||
import net.minecraft.util.math.BlockPos;
|
||||
import net.minecraftforge.fml.relauncher.Side;
|
||||
import net.minecraftforge.fml.relauncher.SideOnly;
|
||||
import javax.annotation.Nonnull;
|
||||
import javax.annotation.Nullable;
|
||||
import java.util.List;
|
||||
|
||||
public class BlockDecor extends Block
|
||||
{
|
||||
|
||||
public final long config;
|
||||
public static final long CFG_CUTOUT = 0x0000000000000001L;
|
||||
|
||||
|
||||
public BlockDecor(@Nonnull String registryName, long config, @Nullable Material material, float hardness, float resistance, @Nullable SoundType sound)
|
||||
{
|
||||
super((material!=null) ? (material) : (Material.IRON));
|
||||
setCreativeTab(ModEngineersDecor.CREATIVE_TAB_ENGINEERSDECOR);
|
||||
setRegistryName(ModEngineersDecor.MODID, registryName);
|
||||
setTranslationKey(ModEngineersDecor.MODID + "." + registryName);
|
||||
setTickRandomly(false);
|
||||
setHardness((hardness > 0) ? hardness : 5.0f);
|
||||
setResistance((resistance > 0) ? resistance : 10.0f);
|
||||
setSoundType((sound==null) ? SoundType.STONE : sound);
|
||||
this.config = config;
|
||||
}
|
||||
|
||||
@Override
|
||||
@Nullable
|
||||
@SuppressWarnings("deprecation")
|
||||
public AxisAlignedBB getCollisionBoundingBox(IBlockState state, IBlockAccess world, BlockPos pos)
|
||||
{ return getBoundingBox(state, world, pos); }
|
||||
|
||||
@Override
|
||||
@SideOnly(Side.CLIENT)
|
||||
public void addInformation(ItemStack stack, @Nullable World world, List<String> tooltip, ITooltipFlag flag)
|
||||
{ ModAuxiliaries.Tooltip.addInformation(stack, world, tooltip, flag, true); }
|
||||
|
||||
@Override
|
||||
@SideOnly(Side.CLIENT)
|
||||
public BlockRenderLayer getRenderLayer()
|
||||
{ return ((config & CFG_CUTOUT)!=0) ? BlockRenderLayer.CUTOUT : BlockRenderLayer.SOLID; }
|
||||
|
||||
@Override
|
||||
@SuppressWarnings("deprecation")
|
||||
public boolean isFullCube(IBlockState state)
|
||||
{ return ((config & CFG_CUTOUT)==0); }
|
||||
|
||||
@Override
|
||||
@SuppressWarnings("deprecation")
|
||||
public boolean isNormalCube(IBlockState state)
|
||||
{ return ((config & CFG_CUTOUT)==0); }
|
||||
|
||||
@Override
|
||||
@SuppressWarnings("deprecation")
|
||||
public boolean isOpaqueCube(IBlockState state)
|
||||
{ return ((config & CFG_CUTOUT)==0); }
|
||||
|
||||
@Override
|
||||
public boolean canSpawnInBlock()
|
||||
{ return false; }
|
||||
|
||||
@Override
|
||||
@SuppressWarnings("deprecation")
|
||||
public EnumPushReaction getPushReaction(IBlockState state)
|
||||
{ return EnumPushReaction.NORMAL; }
|
||||
|
||||
@Override
|
||||
@SuppressWarnings("deprecation")
|
||||
public IBlockState getStateFromMeta(int meta)
|
||||
{ return getDefaultState(); }
|
||||
|
||||
@Override
|
||||
public int getMetaFromState(IBlockState state)
|
||||
{ return 0; }
|
||||
|
||||
@Override
|
||||
protected BlockStateContainer createBlockState()
|
||||
{ return new BlockStateContainer(this); }
|
||||
|
||||
@Override
|
||||
@SuppressWarnings("deprecation")
|
||||
public IBlockState getActualState(IBlockState state, IBlockAccess world, BlockPos pos)
|
||||
{ return state; }
|
||||
|
||||
@Override
|
||||
@SuppressWarnings("deprecation")
|
||||
public IBlockState withRotation(IBlockState state, Rotation rot)
|
||||
{ return state; }
|
||||
|
||||
@Override
|
||||
@SuppressWarnings("deprecation")
|
||||
public IBlockState withMirror(IBlockState state, Mirror mirrorIn)
|
||||
{ return state; }
|
||||
|
||||
@Override
|
||||
public boolean hasTileEntity(IBlockState state)
|
||||
{ return false; }
|
||||
|
||||
@Override
|
||||
public void onBlockPlacedBy(World world, BlockPos pos, IBlockState state, EntityLivingBase placer, ItemStack stack)
|
||||
{}
|
||||
|
||||
@Override
|
||||
public boolean onBlockActivated(World world, BlockPos pos, IBlockState state, EntityPlayer player, EnumHand hand, EnumFacing facing, float hitX, float hitY, float hitZ)
|
||||
{ return false; }
|
||||
|
||||
@Override
|
||||
public void onBlockClicked(World world, BlockPos pos, EntityPlayer player)
|
||||
{}
|
||||
|
||||
@Override
|
||||
@SuppressWarnings("deprecation")
|
||||
public void neighborChanged(IBlockState state, World world, BlockPos pos, Block blockIn, BlockPos fromPos)
|
||||
{}
|
||||
|
||||
@Override
|
||||
public boolean canPlaceBlockOnSide(World world, BlockPos pos, EnumFacing side)
|
||||
{ return super.canPlaceBlockOnSide(world, pos, side); }
|
||||
|
||||
@Override
|
||||
public IBlockState getStateForPlacement(World world, BlockPos pos, EnumFacing facing, float hitX, float hitY, float hitZ, int meta, EntityLivingBase placer, EnumHand hand)
|
||||
{ return super.getStateForPlacement(world, pos, facing, hitX, hitY, hitZ, meta, placer, hand); }
|
||||
|
||||
@Override
|
||||
public boolean removedByPlayer(IBlockState state, World world, BlockPos pos, EntityPlayer player, boolean willHarvest)
|
||||
{ return super.removedByPlayer(state, world, pos, player, willHarvest); }
|
||||
|
||||
}
|
112
src/main/java/wile/engineersdecor/blocks/BlockDecorDirected.java
Normal file
112
src/main/java/wile/engineersdecor/blocks/BlockDecorDirected.java
Normal file
|
@ -0,0 +1,112 @@
|
|||
/*
|
||||
* @file BlockDecorDirected.java
|
||||
* @author Stefan Wilhelm (wile)
|
||||
* @copyright (C) 2019 Stefan Wilhelm
|
||||
* @license MIT (see https://opensource.org/licenses/MIT)
|
||||
*
|
||||
* Smaller (cutout) block with a defined facing.
|
||||
*/
|
||||
package wile.engineersdecor.blocks;
|
||||
|
||||
import net.minecraft.block.SoundType;
|
||||
import wile.engineersdecor.detail.ModAuxiliaries;
|
||||
import net.minecraft.block.state.BlockStateContainer;
|
||||
import net.minecraft.block.BlockDirectional;
|
||||
import net.minecraft.block.material.Material;
|
||||
import net.minecraft.block.properties.PropertyDirection;
|
||||
import net.minecraft.block.state.BlockFaceShape;
|
||||
import net.minecraft.block.state.IBlockState;
|
||||
import net.minecraft.entity.EntityLivingBase;
|
||||
import net.minecraft.world.World;
|
||||
import net.minecraft.world.IBlockAccess;
|
||||
import net.minecraft.util.Mirror;
|
||||
import net.minecraft.util.Rotation;
|
||||
import net.minecraft.util.BlockRenderLayer;
|
||||
import net.minecraft.util.EnumFacing;
|
||||
import net.minecraft.util.math.AxisAlignedBB;
|
||||
import net.minecraft.util.math.BlockPos;
|
||||
import net.minecraftforge.fml.relauncher.Side;
|
||||
import net.minecraftforge.fml.relauncher.SideOnly;
|
||||
import javax.annotation.Nonnull;
|
||||
import javax.annotation.Nullable;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Arrays;
|
||||
|
||||
|
||||
public class BlockDecorDirected extends BlockDecor
|
||||
{
|
||||
public static final PropertyDirection FACING = BlockDirectional.FACING;
|
||||
protected final ArrayList<AxisAlignedBB> AABBs;
|
||||
|
||||
public BlockDecorDirected(@Nonnull String registryName, long config, @Nullable Material material, float hardness, float resistance, @Nullable SoundType sound, @Nonnull AxisAlignedBB unrotatedAABB)
|
||||
{
|
||||
super(registryName, config, material, hardness, resistance, sound);
|
||||
AABBs = new ArrayList<AxisAlignedBB>(Arrays.asList(
|
||||
ModAuxiliaries.getRotatedAABB(unrotatedAABB, EnumFacing.DOWN),
|
||||
ModAuxiliaries.getRotatedAABB(unrotatedAABB, EnumFacing.UP),
|
||||
ModAuxiliaries.getRotatedAABB(unrotatedAABB, EnumFacing.NORTH),
|
||||
ModAuxiliaries.getRotatedAABB(unrotatedAABB, EnumFacing.SOUTH),
|
||||
ModAuxiliaries.getRotatedAABB(unrotatedAABB, EnumFacing.WEST),
|
||||
ModAuxiliaries.getRotatedAABB(unrotatedAABB, EnumFacing.EAST),
|
||||
ModAuxiliaries.getRotatedAABB(unrotatedAABB, EnumFacing.EAST),
|
||||
ModAuxiliaries.getRotatedAABB(unrotatedAABB, EnumFacing.EAST)
|
||||
));
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isOpaqueCube(IBlockState state)
|
||||
{ return false; }
|
||||
|
||||
@Override
|
||||
public boolean isFullCube(IBlockState state)
|
||||
{ return false; }
|
||||
|
||||
@Override
|
||||
public boolean isNormalCube(IBlockState state)
|
||||
{ return false; }
|
||||
|
||||
@Override
|
||||
@SuppressWarnings("deprecation")
|
||||
public BlockFaceShape getBlockFaceShape(IBlockAccess world, IBlockState state, BlockPos pos, EnumFacing face)
|
||||
{ return BlockFaceShape.UNDEFINED; }
|
||||
|
||||
@Override
|
||||
@SuppressWarnings("deprecation")
|
||||
public AxisAlignedBB getBoundingBox(IBlockState state, IBlockAccess source, BlockPos pos)
|
||||
{ return AABBs.get(((EnumFacing)state.getValue(FACING)).getIndex() & 0x7); }
|
||||
|
||||
@Override
|
||||
@Nullable
|
||||
public AxisAlignedBB getCollisionBoundingBox(IBlockState state, IBlockAccess world, BlockPos pos)
|
||||
{ return getBoundingBox(state, world, pos); }
|
||||
|
||||
@Override
|
||||
@SideOnly(Side.CLIENT)
|
||||
public BlockRenderLayer getRenderLayer()
|
||||
{ return BlockRenderLayer.CUTOUT; }
|
||||
|
||||
@Override
|
||||
public IBlockState getStateFromMeta(int meta)
|
||||
{ return this.getDefaultState().withProperty(FACING, EnumFacing.byIndex(meta & 0x7)); }
|
||||
|
||||
@Override
|
||||
public int getMetaFromState(IBlockState state)
|
||||
{ return state.getValue(FACING).getIndex(); }
|
||||
|
||||
@Override
|
||||
protected BlockStateContainer createBlockState()
|
||||
{ return new BlockStateContainer(this, FACING); }
|
||||
|
||||
@Override
|
||||
public IBlockState withRotation(IBlockState state, Rotation rot)
|
||||
{ return state.withProperty(FACING, rot.rotate((EnumFacing)state.getValue(FACING))); }
|
||||
|
||||
@Override
|
||||
public IBlockState withMirror(IBlockState state, Mirror mirrorIn)
|
||||
{ return state.withRotation(mirrorIn.toRotation((EnumFacing)state.getValue(FACING))); }
|
||||
|
||||
@Override
|
||||
@SuppressWarnings("deprecation")
|
||||
public IBlockState getStateForPlacement(World world, BlockPos pos, EnumFacing facing, float hitX, float hitY, float hitZ, int meta, EntityLivingBase placer)
|
||||
{ return this.getDefaultState().withProperty(FACING, facing); }
|
||||
}
|
60
src/main/java/wile/engineersdecor/blocks/BlockDecorFull.java
Normal file
60
src/main/java/wile/engineersdecor/blocks/BlockDecorFull.java
Normal file
|
@ -0,0 +1,60 @@
|
|||
/*
|
||||
* @file BlockDecorFull.java
|
||||
* @author Stefan Wilhelm (wile)
|
||||
* @copyright (C) 2019 Stefan Wilhelm
|
||||
* @license MIT (see https://opensource.org/licenses/MIT)
|
||||
*
|
||||
* Full block characteristics class.
|
||||
*/
|
||||
package wile.engineersdecor.blocks;
|
||||
|
||||
import net.minecraft.block.SoundType;
|
||||
import net.minecraft.block.material.Material;
|
||||
import net.minecraft.block.state.BlockFaceShape;
|
||||
import net.minecraft.block.state.IBlockState;
|
||||
import net.minecraft.world.IBlockAccess;
|
||||
import net.minecraft.util.EnumFacing;
|
||||
import net.minecraft.util.math.AxisAlignedBB;
|
||||
import net.minecraft.util.math.BlockPos;
|
||||
import javax.annotation.Nonnull;
|
||||
import javax.annotation.Nullable;
|
||||
|
||||
|
||||
public class BlockDecorFull extends BlockDecor
|
||||
{
|
||||
public BlockDecorFull(@Nonnull String registryName, long config, @Nullable Material material, float hardness, float resistance, @Nullable SoundType sound)
|
||||
{
|
||||
super(registryName, config, material, hardness, resistance, sound);
|
||||
setLightOpacity(1);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isOpaqueCube(IBlockState state)
|
||||
{ return true; }
|
||||
|
||||
@Override
|
||||
@SuppressWarnings("deprecation")
|
||||
public BlockFaceShape getBlockFaceShape(IBlockAccess world, IBlockState state, BlockPos pos, EnumFacing face)
|
||||
{ return BlockFaceShape.SOLID; }
|
||||
|
||||
@Override
|
||||
@SuppressWarnings("deprecation")
|
||||
public AxisAlignedBB getBoundingBox(IBlockState state, IBlockAccess source, BlockPos pos)
|
||||
{ return FULL_BLOCK_AABB; }
|
||||
|
||||
@Override
|
||||
@Nullable
|
||||
public AxisAlignedBB getCollisionBoundingBox(IBlockState state, IBlockAccess world, BlockPos pos)
|
||||
{ return FULL_BLOCK_AABB; }
|
||||
|
||||
@Override
|
||||
@SuppressWarnings("deprecation")
|
||||
public boolean isFullCube(IBlockState state)
|
||||
{ return true; }
|
||||
|
||||
@Override
|
||||
@SuppressWarnings("deprecation")
|
||||
public boolean isNormalCube(IBlockState state)
|
||||
{ return true; }
|
||||
|
||||
}
|
134
src/main/java/wile/engineersdecor/blocks/BlockDecorLadder.java
Normal file
134
src/main/java/wile/engineersdecor/blocks/BlockDecorLadder.java
Normal file
|
@ -0,0 +1,134 @@
|
|||
/*
|
||||
* @file BlockDecorLadder.java
|
||||
* @author Stefan Wilhelm (wile)
|
||||
* @copyright (C) 2019 Stefan Wilhelm
|
||||
* @license MIT (see https://opensource.org/licenses/MIT)
|
||||
*
|
||||
* Ladder block. The implementation is based on the vanilla
|
||||
* net.minecraft.block.BlockLadder. Minor changes to enable
|
||||
* later configuration (for block list based construction
|
||||
* time configuration), does not drop when the block behind
|
||||
* is broken, etc.
|
||||
*/
|
||||
package wile.engineersdecor.blocks;
|
||||
|
||||
import net.minecraft.block.SoundType;
|
||||
import wile.engineersdecor.detail.ModAuxiliaries;
|
||||
import net.minecraft.block.BlockHorizontal;
|
||||
import net.minecraft.block.properties.PropertyDirection;
|
||||
import net.minecraft.block.material.Material;
|
||||
import net.minecraft.block.state.BlockFaceShape;
|
||||
import net.minecraft.block.state.BlockStateContainer;
|
||||
import net.minecraft.block.state.IBlockState;
|
||||
import net.minecraft.world.IBlockAccess;
|
||||
import net.minecraft.world.World;
|
||||
import net.minecraft.entity.EntityLivingBase;
|
||||
import net.minecraft.util.*;
|
||||
import net.minecraft.util.math.AxisAlignedBB;
|
||||
import net.minecraft.util.math.BlockPos;
|
||||
import net.minecraftforge.fml.relauncher.Side;
|
||||
import net.minecraftforge.fml.relauncher.SideOnly;
|
||||
import javax.annotation.Nonnull;
|
||||
import javax.annotation.Nullable;
|
||||
|
||||
|
||||
public class BlockDecorLadder extends BlockDecor
|
||||
{
|
||||
public static final PropertyDirection FACING = BlockHorizontal.FACING;
|
||||
protected static final AxisAlignedBB EDLADDER_SOUTH_AABB = ModAuxiliaries.getPixeledAABB(3, 0, 0, 13, 16, 2);
|
||||
protected static final AxisAlignedBB EDLADDER_EAST_AABB = ModAuxiliaries.getRotatedAABB(EDLADDER_SOUTH_AABB, EnumFacing.EAST);
|
||||
protected static final AxisAlignedBB EDLADDER_WEST_AABB = ModAuxiliaries.getRotatedAABB(EDLADDER_SOUTH_AABB, EnumFacing.WEST);
|
||||
protected static final AxisAlignedBB EDLADDER_NORTH_AABB = ModAuxiliaries.getRotatedAABB(EDLADDER_SOUTH_AABB, EnumFacing.NORTH);
|
||||
|
||||
|
||||
public BlockDecorLadder(@Nonnull String registryName, long config, @Nullable Material material, float hardness, float resistance, @Nullable SoundType sound)
|
||||
{
|
||||
super(registryName, config, material, hardness, resistance, sound);
|
||||
setLightOpacity(0);
|
||||
setResistance(2.0f);
|
||||
setHardness(0.3f);
|
||||
}
|
||||
|
||||
@Override
|
||||
@SideOnly(Side.CLIENT)
|
||||
public BlockRenderLayer getRenderLayer()
|
||||
{ return BlockRenderLayer.CUTOUT; }
|
||||
|
||||
@Override
|
||||
public boolean isOpaqueCube(IBlockState state)
|
||||
{ return false; }
|
||||
|
||||
@Override
|
||||
public boolean isFullCube(IBlockState state)
|
||||
{ return false; }
|
||||
|
||||
@Override
|
||||
public boolean isNormalCube(IBlockState state)
|
||||
{ return false; }
|
||||
|
||||
@Override
|
||||
public boolean isLadder(IBlockState state, IBlockAccess world, BlockPos pos, EntityLivingBase entity)
|
||||
{ return true; }
|
||||
|
||||
@Override
|
||||
@SuppressWarnings("deprecation")
|
||||
public BlockFaceShape getBlockFaceShape(IBlockAccess world, IBlockState state, BlockPos pos, EnumFacing face)
|
||||
{ return BlockFaceShape.UNDEFINED; }
|
||||
|
||||
@Override
|
||||
@SuppressWarnings("deprecation")
|
||||
public AxisAlignedBB getBoundingBox(IBlockState state, IBlockAccess source, BlockPos pos)
|
||||
{
|
||||
switch ((EnumFacing)state.getValue(FACING)) {
|
||||
case NORTH: return EDLADDER_NORTH_AABB;
|
||||
case SOUTH: return EDLADDER_SOUTH_AABB;
|
||||
case WEST: return EDLADDER_WEST_AABB;
|
||||
default: return EDLADDER_EAST_AABB;
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public IBlockState getStateFromMeta(int meta)
|
||||
{
|
||||
final EnumFacing facing = EnumFacing.byIndex(meta & 0x7);
|
||||
return this.getDefaultState().withProperty(FACING, (facing.getAxis()==EnumFacing.Axis.Y) ? EnumFacing.NORTH : facing);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getMetaFromState(IBlockState state)
|
||||
{ return state.getValue(FACING).getIndex(); }
|
||||
|
||||
@Override
|
||||
protected BlockStateContainer createBlockState()
|
||||
{ return new BlockStateContainer(this, FACING); }
|
||||
|
||||
@Override
|
||||
public IBlockState withRotation(IBlockState state, Rotation rot)
|
||||
{ return state.withProperty(FACING, rot.rotate((EnumFacing)state.getValue(FACING))); }
|
||||
|
||||
@Override
|
||||
public IBlockState withMirror(IBlockState state, Mirror mirrorIn)
|
||||
{ return state.withRotation(mirrorIn.toRotation((EnumFacing)state.getValue(FACING))); }
|
||||
|
||||
@Override
|
||||
public boolean canPlaceBlockOnSide(World world, BlockPos pos, EnumFacing side)
|
||||
{ return canAttachTo(world, pos.west(), side) || canAttachTo(world, pos.east(), side) || canAttachTo(world, pos.north(), side) || canAttachTo(world, pos.south(), side); }
|
||||
|
||||
@Override
|
||||
@SuppressWarnings("deprecation")
|
||||
public IBlockState getStateForPlacement(World world, BlockPos pos, EnumFacing facing, float hitX, float hitY, float hitZ, int meta, EntityLivingBase placer)
|
||||
{
|
||||
if(facing.getAxis().isHorizontal() && canAttachTo(world, pos.offset(facing.getOpposite()), facing)) return this.getDefaultState().withProperty(FACING, facing);
|
||||
for(EnumFacing e:EnumFacing.Plane.HORIZONTAL) {
|
||||
if(this.canAttachTo(world, pos.offset(e.getOpposite()), e)) return this.getDefaultState().withProperty(FACING, e);
|
||||
}
|
||||
return this.getDefaultState();
|
||||
}
|
||||
|
||||
private boolean canAttachTo(World world, BlockPos pos, EnumFacing side)
|
||||
{
|
||||
final IBlockState state = world.getBlockState(pos);
|
||||
return (!isExceptBlockForAttachWithPiston(state.getBlock())) && (state.getBlockFaceShape(world, pos, side) == BlockFaceShape.SOLID);
|
||||
}
|
||||
|
||||
}
|
|
@ -0,0 +1,27 @@
|
|||
/*
|
||||
* @file BlockDecorStairs.java
|
||||
* @author Stefan Wilhelm (wile)
|
||||
* @copyright (C) 2019 Stefan Wilhelm
|
||||
* @license MIT (see https://opensource.org/licenses/MIT)
|
||||
*
|
||||
* Stairs and roof blocks, almost entirely based on vanilla stairs.
|
||||
*/
|
||||
package wile.engineersdecor.blocks;
|
||||
|
||||
import net.minecraft.block.SoundType;
|
||||
import net.minecraft.block.state.IBlockState;
|
||||
import wile.engineersdecor.ModEngineersDecor;
|
||||
import javax.annotation.Nonnull;
|
||||
import javax.annotation.Nullable;
|
||||
|
||||
|
||||
public class BlockDecorStairs extends net.minecraft.block.BlockStairs
|
||||
{
|
||||
public BlockDecorStairs(@Nonnull String registryName, IBlockState modelState)
|
||||
{
|
||||
super(modelState);
|
||||
setCreativeTab(ModEngineersDecor.CREATIVE_TAB_ENGINEERSDECOR);
|
||||
setRegistryName(ModEngineersDecor.MODID, registryName);
|
||||
setTranslationKey(ModEngineersDecor.MODID + "." + registryName);
|
||||
}
|
||||
}
|
109
src/main/java/wile/engineersdecor/blocks/ModBlocks.java
Normal file
109
src/main/java/wile/engineersdecor/blocks/ModBlocks.java
Normal file
|
@ -0,0 +1,109 @@
|
|||
/*
|
||||
* @file ModBlocks.java
|
||||
* @author Stefan Wilhelm (wile)
|
||||
* @copyright (C) 2018 Stefan Wilhelm
|
||||
* @license MIT (see https://opensource.org/licenses/MIT)
|
||||
*
|
||||
* Definition and initialisation of blocks of this
|
||||
* module, along with their tile entities if applicable.
|
||||
*
|
||||
* Note: Straight forward definition of different blocks/entities
|
||||
* to make recipes, models and texture definitions easier.
|
||||
*/
|
||||
package wile.engineersdecor.blocks;
|
||||
|
||||
import net.minecraft.block.SoundType;
|
||||
import net.minecraft.block.material.Material;
|
||||
import net.minecraft.client.renderer.block.model.ModelResourceLocation;
|
||||
import net.minecraftforge.client.model.ModelLoader;
|
||||
import wile.engineersdecor.ModEngineersDecor;
|
||||
import wile.engineersdecor.detail.ModAuxiliaries;
|
||||
import wile.engineersdecor.detail.ModConfig;
|
||||
import net.minecraft.block.Block;
|
||||
import net.minecraft.item.Item;
|
||||
import net.minecraft.item.ItemBlock;
|
||||
import net.minecraft.util.ResourceLocation;
|
||||
import net.minecraftforge.event.RegistryEvent;
|
||||
import net.minecraftforge.fml.relauncher.Side;
|
||||
import net.minecraftforge.fml.relauncher.SideOnly;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.Collections;
|
||||
import javax.annotation.Nonnull;
|
||||
|
||||
@SuppressWarnings("unused")
|
||||
public class ModBlocks
|
||||
{
|
||||
// Full blocks
|
||||
public static final BlockDecorFull CLINKER_BRICK_WALL = new BlockDecorFull("clinker_brick_block", 0, Material.ROCK, 1.5f, 20f, SoundType.STONE);
|
||||
public static final BlockDecorFull SLAG_BRICK_WALL = new BlockDecorFull("slag_brick_block", 0, Material.ROCK, 1.8f, 25f, SoundType.STONE);
|
||||
public static final BlockDecorFull IRON_SHEET_ROOF_FULLBLOCK = new BlockDecorFull("iron_sheet_roof_block", 0, Material.IRON, 1.8f, 25f, SoundType.METAL);
|
||||
// Ladders
|
||||
public static final BlockDecorLadder METAL_RUNG_LADDER = new BlockDecorLadder("metal_rung_ladder", 0, Material.IRON, 1.8f, 25f, SoundType.METAL);
|
||||
public static final BlockDecorLadder METAL_RUNG_STEPS = new BlockDecorLadder("metal_rung_steps", 0, Material.IRON, 1.8f, 25f, SoundType.METAL);
|
||||
public static final BlockDecorLadder TREATED_WOOD_LADDER = new BlockDecorLadder("treated_wood_ladder", 0, Material.WOOD, 1.0f, 15f, SoundType.WOOD);
|
||||
// Stairs or stairs-like
|
||||
public static final BlockDecorStairs CLINKER_BRICK_STAIRS = new BlockDecorStairs("clinker_brick_stairs", CLINKER_BRICK_WALL.getDefaultState());
|
||||
public static final BlockDecorStairs SLAG_BRICK_STAIRS = new BlockDecorStairs("slag_brick_stairs", SLAG_BRICK_WALL.getDefaultState());
|
||||
public static final BlockDecorStairs IRON_SHEET_ROOF = new BlockDecorStairs("iron_sheet_roof", IRON_SHEET_ROOF_FULLBLOCK.getDefaultState());
|
||||
// Oblongs and poles
|
||||
public static final BlockDecorDirected TREATED_WOOD_POLE = new BlockDecorDirected("treated_wood_pole", 0, Material.WOOD, 1.0f, 15f, SoundType.WOOD, ModAuxiliaries.getPixeledAABB(5.8,5.8,0, 10.2,10.2,16));
|
||||
// Furniture
|
||||
public static final BlockDecor TREATED_WOOD_TABLE = new BlockDecor("treated_wood_table", BlockDecor.CFG_CUTOUT, Material.WOOD, 1.0f, 15f, SoundType.WOOD);
|
||||
|
||||
private static final Block modBlocks[] = {
|
||||
SLAG_BRICK_WALL,
|
||||
CLINKER_BRICK_WALL,
|
||||
METAL_RUNG_LADDER,
|
||||
METAL_RUNG_STEPS,
|
||||
TREATED_WOOD_LADDER,
|
||||
CLINKER_BRICK_STAIRS,
|
||||
SLAG_BRICK_STAIRS,
|
||||
TREATED_WOOD_POLE,
|
||||
TREATED_WOOD_TABLE
|
||||
};
|
||||
|
||||
private static final Block devBlocks[] = {
|
||||
IRON_SHEET_ROOF, // model looks not good enough yet
|
||||
};
|
||||
|
||||
private static ArrayList<Block> registeredBlocks = new ArrayList<>();
|
||||
|
||||
@Nonnull
|
||||
public static List getRegisteredBlocks()
|
||||
{ return Collections.unmodifiableList(registeredBlocks); }
|
||||
|
||||
// Invoked from CommonProxy.registerBlocks()
|
||||
public static final void registerBlocks(RegistryEvent.Register<Block> event)
|
||||
{
|
||||
// Config based registry selection
|
||||
ArrayList<Block> allBlocks = new ArrayList<>();
|
||||
Collections.addAll(allBlocks, modBlocks);
|
||||
if(ModConfig.zmisc.with_experimental) Collections.addAll(allBlocks, devBlocks);
|
||||
for(Block e:allBlocks) registeredBlocks.add(e);
|
||||
for(Block e:registeredBlocks) event.getRegistry().register(e);
|
||||
ModEngineersDecor.logger.info("Registered " + Integer.toString(registeredBlocks.size()) + " blocks.");
|
||||
}
|
||||
|
||||
// Invoked from ClientProxy.registerModels()
|
||||
@SideOnly(Side.CLIENT)
|
||||
public static final void initModels()
|
||||
{
|
||||
for(Block e:registeredBlocks) {
|
||||
ModelLoader.setCustomModelResourceLocation(Item.getItemFromBlock(e), 0, new ModelResourceLocation(e.getRegistryName(), "inventory"));
|
||||
}
|
||||
}
|
||||
|
||||
// Invoked from CommonProxy.registerItems()
|
||||
public static final void registerItemBlocks(RegistryEvent.Register<Item> event)
|
||||
{
|
||||
int n = 0;
|
||||
for(Block e:registeredBlocks) {
|
||||
ResourceLocation rl = e.getRegistryName();
|
||||
if(rl == null) continue;
|
||||
event.getRegistry().register(new ItemBlock(e).setRegistryName(rl));
|
||||
++n;
|
||||
}
|
||||
}
|
||||
|
||||
}
|
27
src/main/java/wile/engineersdecor/detail/ClientProxy.java
Normal file
27
src/main/java/wile/engineersdecor/detail/ClientProxy.java
Normal file
|
@ -0,0 +1,27 @@
|
|||
/*
|
||||
* @file ClientProxy.java
|
||||
* @author Stefan Wilhelm (wile)
|
||||
* @copyright (C) 2018 Stefan Wilhelm
|
||||
* @license MIT (see https://opensource.org/licenses/MIT)
|
||||
*
|
||||
* Client side only initialisation.
|
||||
*/
|
||||
package wile.engineersdecor.detail;
|
||||
|
||||
import wile.engineersdecor.ModEngineersDecor;
|
||||
import net.minecraftforge.client.model.obj.OBJLoader;
|
||||
import net.minecraftforge.fml.common.event.FMLInitializationEvent;
|
||||
import net.minecraftforge.fml.common.event.FMLPostInitializationEvent;
|
||||
import net.minecraftforge.fml.common.event.FMLPreInitializationEvent;
|
||||
|
||||
public class ClientProxy implements ModEngineersDecor.IProxy
|
||||
{
|
||||
public void preInit(FMLPreInitializationEvent e)
|
||||
{ OBJLoader.INSTANCE.addDomain(ModEngineersDecor.MODID); }
|
||||
|
||||
public void init(FMLInitializationEvent e)
|
||||
{}
|
||||
|
||||
public void postInit(FMLPostInitializationEvent e)
|
||||
{}
|
||||
}
|
136
src/main/java/wile/engineersdecor/detail/ModAuxiliaries.java
Normal file
136
src/main/java/wile/engineersdecor/detail/ModAuxiliaries.java
Normal file
|
@ -0,0 +1,136 @@
|
|||
/*
|
||||
* @file ModAuxiliaries.java
|
||||
* @author Stefan Wilhelm (wile)
|
||||
* @copyright (C) 2018 Stefan Wilhelm
|
||||
* @license MIT (see https://opensource.org/licenses/MIT)
|
||||
*
|
||||
* General commonly used functionality.
|
||||
*/
|
||||
package wile.engineersdecor.detail;
|
||||
|
||||
import net.minecraft.util.EnumFacing;
|
||||
import wile.engineersdecor.ModEngineersDecor;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.client.util.ITooltipFlag;
|
||||
import net.minecraft.world.World;
|
||||
import net.minecraft.util.text.TextComponentTranslation;
|
||||
import net.minecraft.util.text.TextFormatting;
|
||||
import net.minecraftforge.fml.relauncher.Side;
|
||||
import net.minecraft.util.math.AxisAlignedBB;
|
||||
import net.minecraftforge.fml.relauncher.SideOnly;
|
||||
|
||||
import org.lwjgl.input.Keyboard;
|
||||
import javax.annotation.Nullable;
|
||||
import java.util.*;
|
||||
import java.util.regex.Matcher;
|
||||
import java.util.regex.Pattern;
|
||||
|
||||
public class ModAuxiliaries
|
||||
{
|
||||
/**
|
||||
* Text localisation wrapper, implicitly prepends `ModEngineersDecor.MODID` to the
|
||||
* translation keys. Forces formatting argument, nullable if no special formatting shall be applied..
|
||||
*/
|
||||
public static TextComponentTranslation localizable(String modtrkey, @Nullable TextFormatting color, Object... args)
|
||||
{
|
||||
TextComponentTranslation tr = new TextComponentTranslation(ModEngineersDecor.MODID+"."+modtrkey, args);
|
||||
if(color!=null) tr.getStyle().setColor(color);
|
||||
return tr;
|
||||
}
|
||||
|
||||
@SideOnly(Side.CLIENT)
|
||||
public static String localize(String translationKey, Object... args)
|
||||
{
|
||||
TextComponentTranslation tr = new TextComponentTranslation(translationKey, args);
|
||||
tr.getStyle().setColor(TextFormatting.RESET);
|
||||
final String ft = tr.getFormattedText();
|
||||
if(ft.contains("${")) {
|
||||
// Non-recursive, non-argument lang file entry cross referencing.
|
||||
Pattern pt = Pattern.compile("\\$\\{([\\w\\.]+)\\}");
|
||||
Matcher mt = pt.matcher(ft);
|
||||
StringBuffer sb = new StringBuffer();
|
||||
while(mt.find()) mt.appendReplacement(sb, (new TextComponentTranslation(mt.group(1))).getFormattedText().trim());
|
||||
mt.appendTail(sb);
|
||||
return sb.toString();
|
||||
} else {
|
||||
return ft;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns true if a given key is translated for the current language.
|
||||
*/
|
||||
@SideOnly(Side.CLIENT)
|
||||
public static boolean hasTranslation(String key)
|
||||
{ return net.minecraft.client.resources.I18n.hasKey(key); }
|
||||
|
||||
public static final class Tooltip
|
||||
{
|
||||
@SideOnly(Side.CLIENT)
|
||||
public static boolean extendedTipCondition()
|
||||
{ return (Keyboard.isKeyDown(Keyboard.KEY_LSHIFT)||Keyboard.isKeyDown(Keyboard.KEY_RSHIFT)); }
|
||||
|
||||
@SideOnly(Side.CLIENT)
|
||||
public static boolean helpCondition()
|
||||
{ return extendedTipCondition() && ((Keyboard.isKeyDown(Keyboard.KEY_LCONTROL)||Keyboard.isKeyDown(Keyboard.KEY_RCONTROL))); }
|
||||
|
||||
/**
|
||||
* Adds an extended tooltip or help tooltip depending on the key states of CTRL and SHIFT.
|
||||
* Returns true if the localisable help/tip was added, false if not (either not CTL/SHIFT or
|
||||
* no translation found).
|
||||
*/
|
||||
@SideOnly(Side.CLIENT)
|
||||
public static boolean addInformation(@Nullable String advancedTooltipTranslationKey, @Nullable String helpTranslationKey, List<String> tooltip, ITooltipFlag flag, boolean addAdvancedTooltipHints)
|
||||
{
|
||||
// Note: intentionally not using keybinding here, this must be `control` or `shift`. MC uses lwjgl Keyboard,
|
||||
// so using this also here should be ok.
|
||||
final boolean help_available = (helpTranslationKey != null) && ModAuxiliaries.hasTranslation(helpTranslationKey + ".help");
|
||||
final boolean tip_available = (advancedTooltipTranslationKey != null) && ModAuxiliaries.hasTranslation(helpTranslationKey + ".tip");
|
||||
if((!help_available) && (!tip_available)) return false;
|
||||
if(helpCondition()) {
|
||||
if(!help_available) return false;
|
||||
String s = localize(helpTranslationKey + ".help");
|
||||
if(s.isEmpty()) return false;
|
||||
tooltip.add(s);
|
||||
return true;
|
||||
} else if(extendedTipCondition()) {
|
||||
if(!tip_available) return false;
|
||||
String s = localize(advancedTooltipTranslationKey + ".tip");
|
||||
if(s.isEmpty()) return false;
|
||||
tooltip.add(s);
|
||||
return true;
|
||||
} else if(addAdvancedTooltipHints) {
|
||||
String s = "";
|
||||
if(tip_available) s += localize(ModEngineersDecor.MODID + ".tooltip.hint.extended") + (help_available ? " " : "");
|
||||
if(help_available) s += localize(ModEngineersDecor.MODID + ".tooltip.hint.help");
|
||||
tooltip.add(s);
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
* Adds an extended tooltip or help tooltip for a given stack depending on the key states of CTRL and SHIFT.
|
||||
* Format in the lang file is (e.g. for items): "item.MODID.REGISTRYNAME.tip" and "item.MODID.REGISTRYNAME.help".
|
||||
* Return value see method pattern above.
|
||||
*/
|
||||
@SideOnly(Side.CLIENT)
|
||||
public static boolean addInformation(ItemStack stack, @Nullable World world, List<String> tooltip, ITooltipFlag flag, boolean addAdvancedTooltipHints)
|
||||
{ return addInformation(stack.getTranslationKey(), stack.getTranslationKey(), tooltip, flag, addAdvancedTooltipHints); }
|
||||
}
|
||||
|
||||
public static final AxisAlignedBB getPixeledAABB(double x0, double y0, double z0, double x1, double y1, double z1)
|
||||
{ return new AxisAlignedBB(x0/16.0, y0/16.0, z0/16.0, x1/16.0, y1/16.0, z1/16.0); }
|
||||
|
||||
public static final AxisAlignedBB getRotatedAABB(AxisAlignedBB bb, EnumFacing new_facing)
|
||||
{
|
||||
switch(new_facing.getIndex()) {
|
||||
case 0: return new AxisAlignedBB(1-bb.maxX, 1-bb.maxZ, 1-bb.maxY, 1-bb.minX, 1-bb.minZ, 1-bb.minY); // D
|
||||
case 1: return new AxisAlignedBB(1-bb.maxX, bb.minZ, bb.minY, 1-bb.minX, bb.maxZ, bb.maxY); // U
|
||||
case 2: return new AxisAlignedBB(1-bb.maxX, bb.minY, 1-bb.maxZ, 1-bb.minX, bb.maxY, 1-bb.minZ); // N
|
||||
case 3: return new AxisAlignedBB( bb.minX, bb.minY, bb.minZ, bb.maxX, bb.maxY, bb.maxZ); // S --> bb
|
||||
case 4: return new AxisAlignedBB(1-bb.maxZ, bb.minY, bb.minX, 1-bb.minZ, bb.maxY, bb.maxX); // W
|
||||
case 5: return new AxisAlignedBB( bb.minZ, bb.minY, 1-bb.maxX, bb.maxZ, bb.maxY, 1-bb.minX); // E
|
||||
}
|
||||
return bb;
|
||||
}
|
||||
}
|
52
src/main/java/wile/engineersdecor/detail/ModConfig.java
Normal file
52
src/main/java/wile/engineersdecor/detail/ModConfig.java
Normal file
|
@ -0,0 +1,52 @@
|
|||
/*
|
||||
* @file ModConfig.java
|
||||
* @author Stefan Wilhelm (wile)
|
||||
* @copyright (C) 2018 Stefan Wilhelm
|
||||
* @license MIT (see https://opensource.org/licenses/MIT)
|
||||
*
|
||||
* Main class for module settings. Handles reading and
|
||||
* saving the config file.
|
||||
*/
|
||||
package wile.engineersdecor.detail;
|
||||
|
||||
import wile.engineersdecor.ModEngineersDecor;
|
||||
import net.minecraftforge.common.config.Config;
|
||||
import net.minecraftforge.common.config.ConfigManager;
|
||||
import net.minecraftforge.fml.common.Mod;
|
||||
import net.minecraftforge.fml.common.event.FMLPostInitializationEvent;
|
||||
import net.minecraftforge.fml.common.eventhandler.SubscribeEvent;
|
||||
import net.minecraftforge.fml.client.event.ConfigChangedEvent;
|
||||
|
||||
@Config(modid = ModEngineersDecor.MODID)
|
||||
@Config.LangKey("engineersdecor.config.title")
|
||||
public class ModConfig
|
||||
{
|
||||
@Config.Comment({
|
||||
"Settings for beta testing and trouble shooting. Some of the settings " +
|
||||
"may be moved to other categories after testing."
|
||||
})
|
||||
@Config.Name("Miscellaneous")
|
||||
public static final SettingsZTesting zmisc = new SettingsZTesting();
|
||||
public static final class SettingsZTesting
|
||||
{
|
||||
@Config.Comment({ "Enables experimental features. Use at own risk." })
|
||||
@Config.Name("With experimental")
|
||||
public boolean with_experimental = false;
|
||||
}
|
||||
|
||||
@SuppressWarnings("unused")
|
||||
@Mod.EventBusSubscriber(modid=ModEngineersDecor.MODID)
|
||||
private static final class EventHandler
|
||||
{
|
||||
@SubscribeEvent
|
||||
public static void onConfigChanged(final ConfigChangedEvent.OnConfigChangedEvent event) {
|
||||
if(!event.getModID().equals(ModEngineersDecor.MODID)) return;
|
||||
ConfigManager.sync(ModEngineersDecor.MODID, Config.Type.INSTANCE);
|
||||
}
|
||||
}
|
||||
|
||||
@SuppressWarnings("unused")
|
||||
public static final void onPostInit(FMLPostInitializationEvent event)
|
||||
{}
|
||||
|
||||
}
|
|
@ -0,0 +1,69 @@
|
|||
/*
|
||||
* @file RecipeCondRegistered.java
|
||||
* @author Stefan Wilhelm (wile)
|
||||
* @copyright (C) 2018 Stefan Wilhelm
|
||||
* @license MIT (see https://opensource.org/licenses/MIT)
|
||||
*
|
||||
* Recipe condition to enable opt'ing out JSON based recipes, referenced
|
||||
* in assets/engineersdecor/recipes/_factories.json with full path (therefore
|
||||
* I had to make a separate file for that instead of a few lines in
|
||||
* ModAuxiliaries).
|
||||
*/
|
||||
package wile.engineersdecor.detail;
|
||||
|
||||
import wile.engineersdecor.ModEngineersDecor;
|
||||
import net.minecraft.block.Block;
|
||||
import net.minecraft.item.Item;
|
||||
import net.minecraft.util.ResourceLocation;
|
||||
import net.minecraftforge.common.crafting.IConditionFactory;
|
||||
import net.minecraftforge.common.crafting.JsonContext;
|
||||
import net.minecraftforge.registries.IForgeRegistry;
|
||||
import net.minecraftforge.fml.common.registry.ForgeRegistries;
|
||||
|
||||
import com.google.gson.*;
|
||||
import java.util.function.BooleanSupplier;
|
||||
|
||||
|
||||
public class RecipeCondModSpecific implements IConditionFactory
|
||||
{
|
||||
public static final BooleanSupplier RECIPE_INCLUDE = ()->true;
|
||||
public static final BooleanSupplier RECIPE_EXCLUDE = ()->false;
|
||||
|
||||
@Override
|
||||
public BooleanSupplier parse(JsonContext context, JsonObject json) {
|
||||
try {
|
||||
final IForgeRegistry<Block> block_registry = ForgeRegistries.BLOCKS;
|
||||
final IForgeRegistry<Item> item_registry = ForgeRegistries.ITEMS;
|
||||
final JsonArray items = json.getAsJsonArray("required");
|
||||
if(items!=null) {
|
||||
for(JsonElement e: items) {
|
||||
if(!e.isJsonPrimitive()) continue;
|
||||
final ResourceLocation rl = new ResourceLocation(((JsonPrimitive)e).getAsString());
|
||||
if((!block_registry.containsKey(rl)) && (!item_registry.containsKey(rl))) return RECIPE_EXCLUDE; // required item not registered
|
||||
}
|
||||
}
|
||||
final JsonPrimitive result = json.getAsJsonPrimitive("result");
|
||||
if(result != null) {
|
||||
final ResourceLocation rl = new ResourceLocation(result.getAsString());
|
||||
if((!block_registry.containsKey(rl)) && (!item_registry.containsKey(rl))) return RECIPE_EXCLUDE; // required result not registered
|
||||
}
|
||||
final JsonArray missing = json.getAsJsonArray("missing");
|
||||
if((missing!=null) && (missing.size() > 0)) {
|
||||
for(JsonElement e: missing) {
|
||||
if(!e.isJsonPrimitive()) continue;
|
||||
final ResourceLocation rl = new ResourceLocation(((JsonPrimitive)e).getAsString());
|
||||
// At least one item missing, enable this recipe as alternative recipe for another one that check the missing item as required item.
|
||||
// --> e.g. if IE not installed there is no slag. One recipe requires slag, and another one (for the same result) is used if there
|
||||
// is no slag.
|
||||
if((!block_registry.containsKey(rl)) && (!item_registry.containsKey(rl))) return RECIPE_INCLUDE;
|
||||
}
|
||||
return RECIPE_EXCLUDE; // all required there, but there is no item missing, so another recipe
|
||||
} else {
|
||||
return RECIPE_INCLUDE; // no missing given, means include if result and required are all there.
|
||||
}
|
||||
} catch(Throwable ex) {
|
||||
ModEngineersDecor.logger.error("rsgauges::ResultRegisteredCondition failed: " + ex.toString());
|
||||
}
|
||||
return RECIPE_EXCLUDE; // skip on exception.
|
||||
}
|
||||
}
|
26
src/main/java/wile/engineersdecor/detail/ServerProxy.java
Normal file
26
src/main/java/wile/engineersdecor/detail/ServerProxy.java
Normal file
|
@ -0,0 +1,26 @@
|
|||
/*
|
||||
* @file ServerProxy.java
|
||||
* @author Stefan Wilhelm (wile)
|
||||
* @copyright (C) 2018 Stefan Wilhelm
|
||||
* @license MIT (see https://opensource.org/licenses/MIT)
|
||||
*
|
||||
* Module initialisation event handling, server side only.
|
||||
*/
|
||||
package wile.engineersdecor.detail;
|
||||
|
||||
import wile.engineersdecor.ModEngineersDecor;
|
||||
import net.minecraftforge.fml.common.event.FMLPreInitializationEvent;
|
||||
import net.minecraftforge.fml.common.event.FMLInitializationEvent;
|
||||
import net.minecraftforge.fml.common.event.FMLPostInitializationEvent;
|
||||
|
||||
public class ServerProxy implements ModEngineersDecor.IProxy
|
||||
{
|
||||
public void preInit(FMLPreInitializationEvent e)
|
||||
{}
|
||||
|
||||
public void init(FMLInitializationEvent e)
|
||||
{}
|
||||
|
||||
public void postInit(FMLPostInitializationEvent e)
|
||||
{}
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue