Factory area sign added. Electrical furnace recipe changed. Config extended. Experimental micro slabs added. Experimental stained clinker added.

This commit is contained in:
stfwi 2019-06-05 19:41:40 +02:00
parent ee1c82dee5
commit 291debfde1
57 changed files with 1172 additions and 39 deletions

View file

@ -56,6 +56,7 @@ public class BlockDecor extends Block
public static final long CFG_ELECTRICAL = 0x0000000000010000L; // Denotes if a component is mainly flux driven.
public static final long CFG_REDSTONE_CONTROLLED = 0x0000000000020000L; // Denotes if a component has somehow a redstone control input
public static final long CFG_ANALOG = 0x0000000000040000L; // Denotes if a component has analog behaviour
public static final long CFG_HARD_IE_DEPENDENT = 0x8000000000000000L; // Defines that this block abolutely needs IE to be installed.
protected final AxisAlignedBB aabb;
@ -70,6 +71,8 @@ public class BlockDecor extends Block
setResistance((resistance > 0) ? resistance : 10.0f);
setSoundType((sound==null) ? SoundType.STONE : sound);
setLightOpacity(0);
// @todo double check that instance variable
// not sure here ... if((config & CFG_TRANSLUCENT) != 0) this.translucent = true;
this.config = config;
this.aabb = (boundingbox==null) ? (FULL_BLOCK_AABB) : (boundingbox);
}

View file

@ -0,0 +1,202 @@
/*
* @file BlockDecorHalfSlab.java
* @author Stefan Wilhelm (wile)
* @copyright (C) 2019 Stefan Wilhelm
* @license MIT (see https://opensource.org/licenses/MIT)
*
* Half slab characteristics class.
*/
package wile.engineersdecor.blocks;
import net.minecraft.block.Block;
import net.minecraft.block.SoundType;
import net.minecraft.block.material.Material;
import net.minecraft.block.properties.PropertyInteger;
import net.minecraft.block.state.BlockFaceShape;
import net.minecraft.block.state.BlockStateContainer;
import net.minecraft.block.state.IBlockState;
import net.minecraft.entity.Entity;
import net.minecraft.entity.EntityLivingBase;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.item.Item;
import net.minecraft.item.ItemStack;
import net.minecraft.tileentity.TileEntity;
import net.minecraft.util.BlockRenderLayer;
import net.minecraft.util.EnumHand;
import net.minecraft.util.SoundCategory;
import net.minecraft.util.math.MathHelper;
import net.minecraft.util.math.Vec3d;
import net.minecraft.world.IBlockAccess;
import net.minecraft.util.EnumFacing;
import net.minecraft.util.math.AxisAlignedBB;
import net.minecraft.util.math.BlockPos;
import net.minecraft.world.World;
import net.minecraftforge.fml.relauncher.Side;
import net.minecraftforge.fml.relauncher.SideOnly;
import javax.annotation.Nonnull;
import javax.annotation.Nullable;
public class BlockDecorHalfSlab extends BlockDecor
{
public static final PropertyInteger PARTS = PropertyInteger.create("parts", 0, 14);
protected static final AxisAlignedBB AABBs[] = {
new AxisAlignedBB(0, 0./16, 0, 1, 2./16, 1), new AxisAlignedBB(0, 0./16, 0, 1, 4./16, 1),
new AxisAlignedBB(0, 0./16, 0, 1, 6./16, 1), new AxisAlignedBB(0, 0./16, 0, 1, 8./16, 1),
new AxisAlignedBB(0, 0./16, 0, 1, 10./16, 1), new AxisAlignedBB(0, 0./16, 0, 1, 12./16, 1),
new AxisAlignedBB(0, 0./16, 0, 1, 14./16, 1), new AxisAlignedBB(0, 0./16, 0, 1, 16./16, 1),
new AxisAlignedBB(0, 2./16, 0, 1, 16./16, 1), new AxisAlignedBB(0, 4./16, 0, 1, 16./16, 1),
new AxisAlignedBB(0, 6./16, 0, 1, 16./16, 1), new AxisAlignedBB(0, 8./16, 0, 1, 16./16, 1),
new AxisAlignedBB(0, 10./16, 0, 1, 16./16, 1), new AxisAlignedBB(0, 12./16, 0, 1, 16./16, 1),
new AxisAlignedBB(0, 14./16, 0, 1, 16./16, 1), new AxisAlignedBB(0,0,0,1,1,1), // <- with 4bit fill
};
protected static final int num_slabs_contained_in_parts_[] = {
1,2,3,4,5,6,7,8,7,6,5,4,3,2,1 ,0x1 // <- with 4bit fill
};
public BlockDecorHalfSlab(@Nonnull String registryName, long config, @Nullable Material material, float hardness, float resistance, @Nullable SoundType sound)
{ super(registryName, config, material, hardness, resistance, sound); }
protected boolean is_cube(IBlockState state)
{ return state.getValue(PARTS) == 0x07; }
@Override
@SideOnly(Side.CLIENT)
public BlockRenderLayer getRenderLayer()
{ return (((config & CFG_TRANSLUCENT)!=0) ? (BlockRenderLayer.TRANSLUCENT) : (BlockRenderLayer.CUTOUT)); }
@Override
@SuppressWarnings("deprecation")
public IBlockState getStateFromMeta(int meta)
{ return getDefaultState().withProperty(PARTS, MathHelper.clamp(meta, 0,14)); }
@Override
public int getMetaFromState(IBlockState state)
{ return state.getValue(PARTS); }
@Override
protected BlockStateContainer createBlockState()
{ return new BlockStateContainer(this, PARTS); }
@Override
@SuppressWarnings("deprecation")
public boolean isOpaqueCube(IBlockState state)
{ return ((config & CFG_TRANSLUCENT)==0) && is_cube(state); }
@Override
@SuppressWarnings("deprecation")
public BlockFaceShape getBlockFaceShape(IBlockAccess world, IBlockState state, BlockPos pos, EnumFacing face)
{
final int parts = state.getValue(PARTS);
switch(face) {
case UP:
if(parts >= 0x07) return BlockFaceShape.SOLID;
break;
case DOWN:
if(parts <= 0x07) return BlockFaceShape.SOLID;
break;
default:
if((parts > 0x05) && (parts < 0x0a)) return BlockFaceShape.SOLID;
}
return BlockFaceShape.UNDEFINED;
}
@Override
@SuppressWarnings("deprecation")
public AxisAlignedBB getBoundingBox(IBlockState state, IBlockAccess source, BlockPos pos)
{ return AABBs[state.getValue(PARTS) & 0xf]; }
@Override
@Nullable
public AxisAlignedBB getCollisionBoundingBox(IBlockState state, IBlockAccess world, BlockPos pos)
{ return getBoundingBox(state, world, pos); }
@Override
@SuppressWarnings("deprecation")
public boolean isFullCube(IBlockState state)
{ return is_cube(state); }
@Override
@SuppressWarnings("deprecation")
public boolean isNormalCube(IBlockState state)
{ return is_cube(state); }
@Override
@SuppressWarnings("deprecation")
public boolean canEntitySpawn(IBlockState state, Entity entity)
{ return false; }
@Override
public void harvestBlock(World world, EntityPlayer player, BlockPos pos, IBlockState state, @Nullable TileEntity te, ItemStack stack)
{ spawnAsEntity(world, pos, new ItemStack(Item.getItemFromBlock(this), num_slabs_contained_in_parts_[state.getValue(PARTS) & 0xf])); }
@Override
public boolean canPlaceBlockOnSide(World world, BlockPos pos, EnumFacing side)
{ return world.getBlockState(pos).getBlock() != this; }
@Override
@SuppressWarnings("deprecation")
public IBlockState getStateForPlacement(World world, BlockPos pos, EnumFacing facing, float hitX, float hitY, float hitZ, int meta, EntityLivingBase placer)
{ return getDefaultState().withProperty(PARTS, ((facing==EnumFacing.UP) || ((facing!=EnumFacing.DOWN) && (hitY < 0.6))) ? 0 : 14); }
@Override
public boolean onBlockActivated(World world, BlockPos pos, IBlockState state, EntityPlayer player, EnumHand hand, EnumFacing facing, float hitX, float hitY, float hitZ)
{
final ItemStack stack = player.getHeldItem(hand);
if(stack.isEmpty() || (Block.getBlockFromItem(stack.getItem()) != this)) return false;
if((facing != EnumFacing.UP) && (facing != EnumFacing.DOWN)) return false;
int parts = state.getValue(PARTS);
if((facing != EnumFacing.UP) && (parts > 7)) {
world.setBlockState(pos, state.withProperty(PARTS, parts-1), 3);
} else if((facing != EnumFacing.DOWN) && (parts < 7)) {
world.setBlockState(pos, state.withProperty(PARTS, parts+1), 3);
} else {
return (parts != 7);
}
if(world.isRemote) return true;
if(!player.isCreative()) {
stack.shrink(1);
if(player.inventory != null) player.inventory.markDirty(); // @todo: check if inventory can actually be null
}
SoundType st = this.getSoundType(state, world, pos, null);
world.playSound(null, pos, st.getPlaceSound(), SoundCategory.BLOCKS, (st.getVolume()+1f)/2.5f, 0.9f*st.getPitch());
return true;
}
@Override
public void onBlockClicked(World world, BlockPos pos, EntityPlayer player)
{
if(world.isRemote) return;
final ItemStack stack = player.getHeldItemMainhand();
if(stack.isEmpty() || (Block.getBlockFromItem(stack.getItem()) != this)) return;
if(stack.getCount() >= stack.getMaxStackSize()) return;
Vec3d lv = player.getLookVec();
EnumFacing facing = EnumFacing.getFacingFromVector((float)lv.x, (float)lv.y, (float)lv.z);
if((facing != EnumFacing.UP) && (facing != EnumFacing.DOWN)) return;
IBlockState state = world.getBlockState(pos);
if(state.getBlock() != this) return;
int parts = state.getValue(PARTS);
if((facing == EnumFacing.DOWN) && (parts <= 7)) {
if(parts > 0) {
world.setBlockState(pos, state.withProperty(PARTS, parts-1), 3);
} else {
world.setBlockToAir(pos);
}
} else if((facing == EnumFacing.UP) && (parts >= 7)) {
if(parts < 14) {
world.setBlockState(pos, state.withProperty(PARTS, parts + 1), 3);
} else {
world.setBlockToAir(pos);
}
} else {
return;
}
if(!player.isCreative()) {
stack.grow(1);
if(player.inventory != null) player.inventory.markDirty(); // @todo: check if inventory can actually be null
}
SoundType st = this.getSoundType(state, world, pos, null);
world.playSound(player, pos, st.getPlaceSound(), SoundCategory.BLOCKS, (st.getVolume()+1f)/2.5f, 0.9f*st.getPitch());
}
}

View file

@ -24,8 +24,9 @@ import net.minecraft.item.ItemBlock;
import net.minecraft.util.ResourceLocation;
import net.minecraft.client.renderer.block.model.ModelResourceLocation;
import net.minecraftforge.client.model.ModelLoader;
import net.minecraftforge.fml.common.registry.GameRegistry;
import net.minecraftforge.event.RegistryEvent;
import net.minecraftforge.fml.common.Loader;
import net.minecraftforge.fml.common.registry.GameRegistry;
import net.minecraftforge.fml.relauncher.Side;
import net.minecraftforge.fml.relauncher.SideOnly;
import java.util.ArrayList;
@ -44,6 +45,9 @@ public class ModBlocks
public static final BlockDecorStairs CLINKER_BRICK_STAIRS = new BlockDecorStairs("clinker_brick_stairs", CLINKER_BRICK_BLOCK.getDefaultState());
public static final BlockDecorWall CLINKER_BRICK_WALL = new BlockDecorWall("clinker_brick_wall", BlockDecor.CFG_DEFAULT, Material.ROCK, 2f, 20f, SoundType.STONE);
public static final BlockDecorFull CLINKER_BRICK_STAINED_BLOCK = new BlockDecorFull("clinker_brick_stained_block", 0, Material.ROCK, 2f, 15f, SoundType.STONE);
public static final BlockDecorStairs CLINKER_BRICK_STAINED_STAIRS = new BlockDecorStairs("clinker_brick_stained_stairs", CLINKER_BRICK_STAINED_BLOCK.getDefaultState());
public static final BlockDecorFull SLAG_BRICK_BLOCK = new BlockDecorFull("slag_brick_block", 0, Material.ROCK, 2f, 15f, SoundType.STONE);
public static final BlockDecorStairs SLAG_BRICK_STAIRS = new BlockDecorStairs("slag_brick_stairs", SLAG_BRICK_BLOCK.getDefaultState());
public static final BlockDecorWall SLAG_BRICK_WALL = new BlockDecorWall("slag_brick_wall", BlockDecor.CFG_DEFAULT, Material.ROCK, 2f, 15f, SoundType.STONE);
@ -263,6 +267,54 @@ public class ModBlocks
ModAuxiliaries.getPixeledAABB(0,0,0, 16,16,15)
);
public static final BlockDecorDirected SIGN_FACTORY_AREA = new BlockDecorDirected(
"sign_factoryarea",
BlockDecor.CFG_CUTOUT|BlockDecor.CFG_OPPOSITE_PLACEMENT,
Material.WOOD, 0.1f, 1f, SoundType.WOOD,
ModAuxiliaries.getPixeledAABB(2,2,15.6, 15,15,16)
);
public static final BlockDecorHalfSlab HALFSLAB_REBARCONCRETE = new BlockDecorHalfSlab(
"halfslab_rebar_concrete",
BlockDecor.CFG_CUTOUT,
Material.ROCK, 2f, 2000f, SoundType.STONE
);
public static final BlockDecorHalfSlab HALFSLAB_CONCRETE = new BlockDecorHalfSlab(
"halfslab_concrete",
BlockDecor.CFG_CUTOUT|BlockDecor.CFG_HARD_IE_DEPENDENT,
Material.ROCK, 0.4f, 10f, SoundType.STONE
);
public static final BlockDecorHalfSlab HALFSLAB_TREATEDWOOD = new BlockDecorHalfSlab(
"halfslab_treated_wood",
BlockDecor.CFG_CUTOUT|BlockDecor.CFG_HARD_IE_DEPENDENT,
Material.WOOD, 0.4f, 4f, SoundType.WOOD
);
public static final BlockDecorHalfSlab HALFSLAB_SHEETMETALIRON = new BlockDecorHalfSlab(
"halfslab_sheetmetal_iron",
BlockDecor.CFG_CUTOUT|BlockDecor.CFG_HARD_IE_DEPENDENT,
Material.IRON, 0.4f, 10f, SoundType.METAL
);
public static final BlockDecorHalfSlab HALFSLAB_SHEETMETALSTEEL = new BlockDecorHalfSlab(
"halfslab_sheetmetal_steel",
BlockDecor.CFG_CUTOUT|BlockDecor.CFG_HARD_IE_DEPENDENT,
Material.IRON, 0.4f, 10f, SoundType.METAL
);
public static final BlockDecorHalfSlab HALFSLAB_SHEETMETALCOPPER = new BlockDecorHalfSlab(
"halfslab_sheetmetal_copper",
BlockDecor.CFG_CUTOUT|BlockDecor.CFG_HARD_IE_DEPENDENT,
Material.IRON, 0.4f, 10f, SoundType.METAL
);
public static final BlockDecorHalfSlab HALFSLAB_SHEETMETALGOLD = new BlockDecorHalfSlab(
"halfslab_sheetmetal_gold",
BlockDecor.CFG_CUTOUT|BlockDecor.CFG_HARD_IE_DEPENDENT,
Material.IRON, 0.4f, 10f, SoundType.METAL
);
public static final BlockDecorHalfSlab HALFSLAB_SHEETMETALALUMINIUM = new BlockDecorHalfSlab(
"halfslab_sheetmetal_aluminum",
BlockDecor.CFG_CUTOUT|BlockDecor.CFG_HARD_IE_DEPENDENT,
Material.IRON, 0.4f, 10f, SoundType.METAL
);
//--------------------------------------------------------------------------------------------------------------------
//-- Tile entities
//--------------------------------------------------------------------------------------------------------------------
@ -322,29 +374,39 @@ public class ModBlocks
TREATED_WOOD_TABLE,
TREATED_WOOD_STOOL,
TREATED_WOOD_WINDOW,
STEEL_FRAMED_WINDOW,
TREATED_WOOD_WINDOWSILL,
INSET_LIGHT_IRON,
SMALL_LAB_FURNACE, SMALL_LAB_FURNACE_TEI,
STEEL_FRAMED_WINDOW,
TREATED_WOOD_POLE_SUPPORT,
TREATED_WOOD_POLE_HEAD,
SIGN_MODLOGO,
THIN_STEEL_POLE,
THICK_STEEL_POLE,
THIN_STEEL_POLE_HEAD,
THICK_STEEL_POLE_HEAD,
STEEL_DOUBLE_T_SUPPORT,
SIGN_HOTWIRE, SIGN_DANGER, SIGN_DEFENSE, SIGN_FACTORY_AREA, SIGN_MODLOGO,
SMALL_LAB_FURNACE, SMALL_LAB_FURNACE_TEI,
SMALL_ELECTRICAL_FURNACE, SMALL_ELECTRICAL_FURNACE_TEI,
FACTORY_DROPPER, FACTORY_DROPPER_TEI,
SMALL_WASTE_INCINERATOR, WASTE_INCINERATOR_TEI,
STRAIGHT_CHECK_VALVE, STRAIGHT_REDSTONE_VALVE, STRAIGHT_REDSTONE_ANALOG_VALVE, STRAIGHT_PIPE_VALVE_TEI,
PASSIVE_FLUID_ACCUMULATOR, PASSIVE_FLUID_ACCUMULATOR_TEI,
SMALL_ELECTRICAL_FURNACE, SMALL_ELECTRICAL_FURNACE_TEI,
SIGN_HOTWIRE, SIGN_DANGER,
SMALL_WASTE_INCINERATOR, WASTE_INCINERATOR_TEI,
SIGN_DEFENSE,
FACTORY_DROPPER, FACTORY_DROPPER_TEI
};
private static final Object dev_content[] = {
SIGN_MINDSTEP,
// design not sure yet ...
CLINKER_BRICK_STAINED_BLOCK,
CLINKER_BRICK_STAINED_STAIRS,
// handling not sure yet ...
HALFSLAB_REBARCONCRETE,
HALFSLAB_CONCRETE,
HALFSLAB_TREATEDWOOD,
HALFSLAB_SHEETMETALIRON,
HALFSLAB_SHEETMETALSTEEL,
HALFSLAB_SHEETMETALCOPPER,
HALFSLAB_SHEETMETALGOLD,
HALFSLAB_SHEETMETALALUMINIUM,
};
//--------------------------------------------------------------------------------------------------------------------
@ -362,15 +424,22 @@ public class ModBlocks
public static final void registerBlocks(RegistryEvent.Register<Block> event)
{
// Config based registry selection
final boolean ie_installed = Loader.isModLoaded("immersiveengineering");
int num_block_registrations_skipped = 0;
int num_block_registrations_skipped_noie = 0;
final boolean woor = ModConfig.isWithoutOptOutRegistration();
for(Object e:content) {
if(e instanceof Block) {
if((!woor) || (!ModConfig.isOptedOut((Block)e)) || (e==SIGN_MODLOGO)) {
registeredBlocks.add((Block) e);
} else {
if((!ie_installed) && ((e instanceof BlockDecor) && ((((BlockDecor)e).config & BlockDecor.CFG_HARD_IE_DEPENDENT)!=0))) {
++num_block_registrations_skipped;
++num_block_registrations_skipped_noie;
continue;
}
if((woor) && (ModConfig.isOptedOut((Block)e)) && (e!=SIGN_MODLOGO)) {
++num_block_registrations_skipped;
continue;
}
registeredBlocks.add((Block) e);
} else if(e instanceof TileEntityRegistrationData) {
registeredTileEntityInits.add((TileEntityRegistrationData)e);
}
@ -386,7 +455,7 @@ public class ModBlocks
}
for(Block e:registeredBlocks) event.getRegistry().register(e);
ModEngineersDecor.logger.info("Registered " + Integer.toString(registeredBlocks.size()) + " blocks.");
if(num_block_registrations_skipped > 0) ModEngineersDecor.logger.info("Skipped registration of " + num_block_registrations_skipped + " blocks.");
if(num_block_registrations_skipped > 0) ModEngineersDecor.logger.info("Skipped registration of " + num_block_registrations_skipped + " blocks, " + num_block_registrations_skipped_noie + " because IE is not installed.");
for(TileEntityRegistrationData e:registeredTileEntityInits) GameRegistry.registerTileEntity(e.clazz, e.key);
ModEngineersDecor.logger.info("Registered " + Integer.toString(registeredTileEntityInits.size()) + " tile entities.");
}

View file

@ -135,6 +135,16 @@ public class ModConfig
@Config.Name("Without signs")
@Config.RequiresMcRestart
public boolean without_sign_plates = false;
@Config.Comment({"Disable the factory dropper."})
@Config.Name("Without factory dropper")
@Config.RequiresMcRestart
public boolean without_factory_dropper = false;
@Config.Comment({"Disable stackable 1/8 block slices."})
@Config.Name("Without slab slices")
@Config.RequiresMcRestart
public boolean without_halfslabs = false;
}
@Config.Comment({
@ -305,6 +315,8 @@ public class ModConfig
if(optout.without_electrical_furnace && (block instanceof BlockDecorFurnaceElectrical)) return true;
if(optout.without_passive_fluid_accumulator && (block instanceof BlockDecorPassiveFluidAccumulator)) return true;
if(optout.without_waste_incinerator && (block instanceof BlockDecorWasteIncinerator)) return true;
if(optout.without_factory_dropper && (block instanceof BlockDecorDropper)) return true;
if(optout.without_halfslabs && (block instanceof BlockDecorHalfSlab)) return true;
if(optout.without_windows && rn.endsWith("_window")) return true;
if(optout.without_light_sources && rn.endsWith("_light")) return true;
if(optout.without_ladders && (block instanceof BlockDecorLadder)) return true;