1.12.2: Treated wood window added. Model files auto-sanatized. Explicit spwan-in-block prevention.
This commit is contained in:
parent
9f6bb3262b
commit
0cb6deb97c
41 changed files with 500 additions and 53 deletions
|
@ -13,9 +13,12 @@ import net.minecraft.entity.player.EntityPlayer;
|
|||
import net.minecraft.tileentity.TileEntity;
|
||||
import net.minecraft.util.math.BlockPos;
|
||||
import net.minecraft.world.World;
|
||||
import net.minecraftforge.common.MinecraftForge;
|
||||
import net.minecraftforge.event.entity.living.LivingEvent;
|
||||
import net.minecraftforge.fml.common.network.IGuiHandler;
|
||||
import net.minecraftforge.fml.common.network.NetworkRegistry;
|
||||
import wile.engineersdecor.blocks.BlockDecorCraftingTable;
|
||||
import wile.engineersdecor.blocks.BlockDecorLadder;
|
||||
import wile.engineersdecor.detail.ModConfig;
|
||||
import wile.engineersdecor.blocks.ModBlocks;
|
||||
import net.minecraftforge.client.event.ModelRegistryEvent;
|
||||
|
@ -63,13 +66,13 @@ public class ModEngineersDecor
|
|||
|
||||
public interface IProxy
|
||||
{
|
||||
default void preInit(FMLPreInitializationEvent e) {}
|
||||
default void init(FMLInitializationEvent e) {}
|
||||
default void postInit(FMLPostInitializationEvent e) {}
|
||||
default void preInit(final FMLPreInitializationEvent e) {}
|
||||
default void init(final FMLInitializationEvent e) {}
|
||||
default void postInit(final FMLPostInitializationEvent e) {}
|
||||
}
|
||||
|
||||
@Mod.EventHandler
|
||||
public void preInit(FMLPreInitializationEvent event)
|
||||
public void preInit(final FMLPreInitializationEvent event)
|
||||
{
|
||||
logger = event.getModLog();
|
||||
logger.info(MODNAME + ": Version " + MODMCVERSION + "-" + MODVERSION + ( (MODBUILDID=="@"+"MOD_BUILDID"+"@") ? "" : (" "+MODBUILDID) ) + ".");
|
||||
|
@ -79,33 +82,34 @@ public class ModEngineersDecor
|
|||
logger.info(MODNAME + ": Found valid fingerprint " + MODFINGERPRINT + ".");
|
||||
}
|
||||
proxy.preInit(event);
|
||||
MinecraftForge.EVENT_BUS.register(new PlayerEventHandler());
|
||||
}
|
||||
|
||||
@Mod.EventHandler
|
||||
public void init(FMLInitializationEvent event)
|
||||
public void init(final FMLInitializationEvent event)
|
||||
{
|
||||
proxy.init(event);
|
||||
NetworkRegistry.INSTANCE.registerGuiHandler(this, new ModEngineersDecor.GuiHandler());
|
||||
}
|
||||
|
||||
@Mod.EventHandler
|
||||
public void postInit(FMLPostInitializationEvent event)
|
||||
public void postInit(final FMLPostInitializationEvent event)
|
||||
{ ModConfig.onPostInit(event); proxy.postInit(event); }
|
||||
|
||||
@Mod.EventBusSubscriber
|
||||
public static final class RegistrationSubscriptions
|
||||
{
|
||||
@SubscribeEvent
|
||||
public static void registerBlocks(RegistryEvent.Register<Block> event)
|
||||
public static void registerBlocks(final RegistryEvent.Register<Block> event)
|
||||
{ ModBlocks.registerBlocks(event); }
|
||||
|
||||
@SubscribeEvent
|
||||
public static void registerItems(RegistryEvent.Register<Item> event)
|
||||
public static void registerItems(final RegistryEvent.Register<Item> event)
|
||||
{ ModBlocks.registerItemBlocks(event); }
|
||||
|
||||
@SideOnly(Side.CLIENT)
|
||||
@SubscribeEvent
|
||||
public static void registerModels(ModelRegistryEvent event)
|
||||
public static void registerModels(final ModelRegistryEvent event)
|
||||
{ ModBlocks.initModels(); }
|
||||
}
|
||||
|
||||
|
@ -145,4 +149,17 @@ public class ModEngineersDecor
|
|||
|
||||
}
|
||||
|
||||
@Mod.EventBusSubscriber
|
||||
public static class PlayerEventHandler
|
||||
{
|
||||
@SubscribeEvent
|
||||
public void update(final LivingEvent.LivingUpdateEvent event)
|
||||
{
|
||||
if(!(event.getEntity() instanceof EntityPlayer)) return;
|
||||
final EntityPlayer player = (EntityPlayer)event.getEntity();
|
||||
if(player.world == null) return;
|
||||
if(player.isOnLadder()) BlockDecorLadder.onPlayerUpdateEvent(player);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -47,7 +47,7 @@ public class BlockDecor extends Block
|
|||
public static final long CFG_LOOK_PLACEMENT = 0x0000000000000004L; // placed in direction the player is looking when placing.
|
||||
public static final long CFG_FACING_PLACEMENT = 0x0000000000000008L; // placed on the facing the player has clicked.
|
||||
public static final long CFG_OPPOSITE_PLACEMENT = 0x0000000000000020L; // placed placed in the opposite direction of the face the player clicked.
|
||||
|
||||
public static final long CFG_TRANSLUCENT = 0x0000000000000040L; // indicates a block/pane is glass like (transparent, etc)
|
||||
public static final long CFG_LIGHT_VALUE_MASK = 0x0000000000000f00L; // fixed value for getLightValue()
|
||||
public static final long CFG_LIGHT_VALUE_SHIFT = 8L;
|
||||
|
||||
|
@ -79,7 +79,13 @@ public class BlockDecor extends Block
|
|||
@Override
|
||||
@SideOnly(Side.CLIENT)
|
||||
public BlockRenderLayer getRenderLayer()
|
||||
{ return ((config & CFG_CUTOUT)!=0) ? BlockRenderLayer.CUTOUT : BlockRenderLayer.SOLID; }
|
||||
{ return ((config & CFG_CUTOUT)!=0) ? (BlockRenderLayer.CUTOUT) : ( ((config & CFG_TRANSLUCENT)!=0) ? (BlockRenderLayer.TRANSLUCENT) : (BlockRenderLayer.SOLID)); }
|
||||
|
||||
@Override
|
||||
@SideOnly(Side.CLIENT)
|
||||
@SuppressWarnings("deprecation")
|
||||
public boolean shouldSideBeRendered(IBlockState state, IBlockAccess world, BlockPos pos, EnumFacing side)
|
||||
{ return true; }
|
||||
|
||||
@Override
|
||||
@SuppressWarnings("deprecation")
|
||||
|
@ -89,17 +95,21 @@ public class BlockDecor extends Block
|
|||
@Override
|
||||
@SuppressWarnings("deprecation")
|
||||
public boolean isNormalCube(IBlockState state)
|
||||
{ return ((config & CFG_CUTOUT)==0); }
|
||||
{ return ((config & (CFG_CUTOUT|CFG_TRANSLUCENT))==0); }
|
||||
|
||||
@Override
|
||||
@SuppressWarnings("deprecation")
|
||||
public boolean isOpaqueCube(IBlockState state)
|
||||
{ return ((config & CFG_CUTOUT)==0); }
|
||||
{ return ((config & (CFG_CUTOUT|CFG_TRANSLUCENT))==0); }
|
||||
|
||||
@Override
|
||||
public boolean canSpawnInBlock()
|
||||
{ return false; }
|
||||
|
||||
@Override
|
||||
public boolean canHarvestBlock(IBlockAccess world, BlockPos pos, EntityPlayer player)
|
||||
{ return true; }
|
||||
|
||||
@Override
|
||||
@SuppressWarnings("deprecation")
|
||||
public EnumPushReaction getPushReaction(IBlockState state)
|
||||
|
@ -166,7 +176,4 @@ public class BlockDecor extends Block
|
|||
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 canHarvestBlock(IBlockAccess world, BlockPos pos, EntityPlayer player)
|
||||
{ return true; }
|
||||
}
|
||||
|
|
|
@ -21,12 +21,9 @@ 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;
|
||||
|
@ -65,6 +62,10 @@ public class BlockDecorDirected extends BlockDecor
|
|||
public boolean isNormalCube(IBlockState state)
|
||||
{ return false; }
|
||||
|
||||
@Override
|
||||
public boolean canCreatureSpawn(IBlockState state, IBlockAccess world, BlockPos pos, net.minecraft.entity.EntityLiving.SpawnPlacementType type)
|
||||
{ return false; }
|
||||
|
||||
@Override
|
||||
@SuppressWarnings("deprecation")
|
||||
public BlockFaceShape getBlockFaceShape(IBlockAccess world, IBlockState state, BlockPos pos, EnumFacing face)
|
||||
|
@ -80,11 +81,6 @@ public class BlockDecorDirected extends BlockDecor
|
|||
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)); }
|
||||
|
|
|
@ -56,6 +56,10 @@ public class BlockDecorGlassBlock extends BlockDecor
|
|||
public boolean isOpaqueCube(IBlockState state)
|
||||
{ return false; }
|
||||
|
||||
@Override
|
||||
public boolean canCreatureSpawn(IBlockState state, IBlockAccess world, BlockPos pos, net.minecraft.entity.EntityLiving.SpawnPlacementType type)
|
||||
{ return false; }
|
||||
|
||||
@Override
|
||||
@SuppressWarnings("deprecation")
|
||||
public BlockFaceShape getBlockFaceShape(IBlockAccess world, IBlockState state, BlockPos pos, EnumFacing face)
|
||||
|
@ -74,11 +78,11 @@ public class BlockDecorGlassBlock extends BlockDecor
|
|||
@Override
|
||||
@SuppressWarnings("deprecation")
|
||||
public boolean isFullCube(IBlockState state)
|
||||
{ return true; }
|
||||
{ return false; }
|
||||
|
||||
@Override
|
||||
@SuppressWarnings("deprecation")
|
||||
public boolean isNormalCube(IBlockState state)
|
||||
{ return true; }
|
||||
{ return false; }
|
||||
|
||||
}
|
||||
|
|
|
@ -16,7 +16,10 @@ import net.minecraft.block.BlockLadder;
|
|||
import net.minecraft.block.SoundType;
|
||||
import net.minecraft.block.material.EnumPushReaction;
|
||||
import net.minecraft.client.util.ITooltipFlag;
|
||||
import net.minecraft.entity.MoverType;
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.util.math.MathHelper;
|
||||
import net.minecraftforge.fml.relauncher.Side;
|
||||
import net.minecraftforge.fml.relauncher.SideOnly;
|
||||
import wile.engineersdecor.ModEngineersDecor;
|
||||
|
@ -77,6 +80,10 @@ public class BlockDecorLadder extends BlockLadder
|
|||
public boolean canSpawnInBlock()
|
||||
{ return false; }
|
||||
|
||||
@Override
|
||||
public boolean canCreatureSpawn(IBlockState state, IBlockAccess world, BlockPos pos, net.minecraft.entity.EntityLiving.SpawnPlacementType type)
|
||||
{ return false; }
|
||||
|
||||
@Override
|
||||
@SuppressWarnings("deprecation")
|
||||
public EnumPushReaction getPushReaction(IBlockState state)
|
||||
|
@ -103,4 +110,18 @@ public class BlockDecorLadder extends BlockLadder
|
|||
return (!isExceptBlockForAttachWithPiston(state.getBlock())) && (state.getBlockFaceShape(world, pos, side) == BlockFaceShape.SOLID);
|
||||
}
|
||||
|
||||
// Player update event, forwarded from the main mod instance.
|
||||
public static void onPlayerUpdateEvent(final EntityPlayer player)
|
||||
{
|
||||
if(!player.isOnLadder() || (player.isSneaking()) || (player.isSpectator())) return;
|
||||
if((Math.abs(player.motionY) < 0.1) || (Math.abs(player.motionY) > 0.7) || ((player.getLookVec().y > 0) != (player.motionY > 0))) return;
|
||||
if(Math.abs(player.getLookVec().y) < 0.9) return;
|
||||
final BlockPos pos = new BlockPos(player.posX, player.posY, player.posZ);
|
||||
if(!(player.world.getBlockState(pos).getBlock() instanceof BlockDecorLadder)) return;
|
||||
player.fallDistance = 0;
|
||||
player.motionY = (player.motionY < -0.25) ? (-0.7) : ((player.motionY > 0.25) ? (0.7) : (player.motionY));
|
||||
player.motionX = MathHelper.clamp(player.motionX, -0.15, 0.15);
|
||||
player.motionZ = MathHelper.clamp(player.motionX, -0.15, 0.15);
|
||||
player.move(MoverType.PLAYER, player.motionX, player.motionY, player.motionZ);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -22,4 +22,9 @@ public class BlockDecorStairs extends net.minecraft.block.BlockStairs
|
|||
setRegistryName(ModEngineersDecor.MODID, registryName);
|
||||
setTranslationKey(ModEngineersDecor.MODID + "." + registryName);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean canSpawnInBlock()
|
||||
{ return false; }
|
||||
|
||||
}
|
||||
|
|
|
@ -118,6 +118,14 @@ public class BlockDecorWall extends BlockDecor
|
|||
public boolean isNormalCube(IBlockState state)
|
||||
{ return false; }
|
||||
|
||||
@Override
|
||||
public boolean canCreatureSpawn(IBlockState state, IBlockAccess world, BlockPos pos, net.minecraft.entity.EntityLiving.SpawnPlacementType type)
|
||||
{ return false; }
|
||||
|
||||
@Override
|
||||
public boolean canSpawnInBlock()
|
||||
{ return false; }
|
||||
|
||||
private boolean canConnectTo(IBlockAccess world, BlockPos pos, BlockPos other, EnumFacing facing)
|
||||
{
|
||||
final IBlockState state = world.getBlockState(other);
|
||||
|
|
|
@ -41,6 +41,7 @@ public class ModBlocks
|
|||
|
||||
public static final BlockDecorFull SLAG_BRICK_BLOCK = new BlockDecorFull("slag_brick_block", 0, Material.ROCK, 2f, 50f, 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, 8f, 50f, SoundType.STONE);
|
||||
|
||||
public static final BlockDecorFull REBAR_CONCRETE_BLOCK = new BlockDecorFull("rebar_concrete", 0, Material.ROCK, 8f, 2000f, SoundType.STONE);
|
||||
public static final BlockDecorStairs REBAR_CONCRETE_STAIRS = new BlockDecorStairs("rebar_concrete_stairs", REBAR_CONCRETE_BLOCK.getDefaultState());
|
||||
|
@ -54,7 +55,7 @@ public class ModBlocks
|
|||
public static final BlockDecorLadder METAL_RUNG_STEPS = new BlockDecorLadder("metal_rung_steps", 0, Material.IRON, 1.0f, 25f, SoundType.METAL);
|
||||
public static final BlockDecorLadder TREATED_WOOD_LADDER = new BlockDecorLadder("treated_wood_ladder", 0, Material.WOOD, 1.0f, 15f, SoundType.WOOD);
|
||||
|
||||
public static final BlockDecorGlassBlock PANZERGLASS_BLOCK = new BlockDecorGlassBlock("panzerglass_block", 0, Material.ROCK, 3f, 2000f, SoundType.GLASS);
|
||||
public static final BlockDecorGlassBlock PANZERGLASS_BLOCK = new BlockDecorGlassBlock("panzerglass_block", 0, Material.GLASS, 0.8f, 2000f, SoundType.GLASS);
|
||||
|
||||
public static final BlockDecorDirected TREATED_WOOD_POLE = new BlockDecorDirected(
|
||||
"treated_wood_pole",
|
||||
|
@ -68,6 +69,7 @@ public class ModBlocks
|
|||
BlockDecor.CFG_CUTOUT|BlockDecor.CFG_HORIZIONTAL|BlockDecor.CFG_LOOK_PLACEMENT,
|
||||
Material.WOOD, 1.0f, 15f, SoundType.WOOD
|
||||
);
|
||||
|
||||
public static final BlockDecorChair TREATED_WOOD_STOOL = new BlockDecorChair(
|
||||
"treated_wood_stool",
|
||||
BlockDecor.CFG_CUTOUT|BlockDecor.CFG_HORIZIONTAL|BlockDecor.CFG_LOOK_PLACEMENT,
|
||||
|
@ -96,6 +98,13 @@ public class ModBlocks
|
|||
ModAuxiliaries.getPixeledAABB(0.5,15,10.5, 15.5,16,16)
|
||||
);
|
||||
|
||||
public static final BlockDecorDirected TREATED_WOOD_WINDOW = new BlockDecorDirected(
|
||||
"treated_wood_window",
|
||||
BlockDecor.CFG_TRANSLUCENT|BlockDecor.CFG_HORIZIONTAL|BlockDecor.CFG_LOOK_PLACEMENT,
|
||||
Material.WOOD, 0.5f, 15f, SoundType.GLASS,
|
||||
ModAuxiliaries.getPixeledAABB(0,0,7, 16,16,9)
|
||||
);
|
||||
|
||||
public static final BlockDecorFull IRON_SHEET_ROOF_FULLBLOCK = new BlockDecorFull("iron_sheet_roof_block", 0, Material.IRON, 1.8f, 25f, SoundType.METAL);
|
||||
public static final BlockDecorStairs IRON_SHEET_ROOF = new BlockDecorStairs("iron_sheet_roof", IRON_SHEET_ROOF_FULLBLOCK.getDefaultState());
|
||||
|
||||
|
@ -106,6 +115,7 @@ public class ModBlocks
|
|||
CLINKER_BRICK_WALL,
|
||||
SLAG_BRICK_BLOCK,
|
||||
SLAG_BRICK_STAIRS,
|
||||
SLAG_BRICK_WALL,
|
||||
REBAR_CONCRETE_BLOCK,
|
||||
REBAR_CONCRETE_STAIRS,
|
||||
REBAR_CONCRETE_WALL,
|
||||
|
@ -119,6 +129,7 @@ public class ModBlocks
|
|||
TREATED_WOOD_POLE,
|
||||
TREATED_WOOD_TABLE,
|
||||
TREATED_WOOD_STOOL,
|
||||
TREATED_WOOD_WINDOW,
|
||||
TREATED_WOOD_WINDOWSILL,
|
||||
INSET_LIGHT_IRON,
|
||||
};
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue