Merged BlockDimWall and BlockLimbo

-Merged BlockDimWall and BlockLimbo classes into one
-Added a setup for teleportation to the overworld by Eternal Fabric

TODO
-Rename BlockDimWall to BlockFabric
-Redo the Eternal and Unraveled Fabric textures
-Make Eternal Fabric teleportation actually work on impact
This commit is contained in:
Mathijs Riezebos 2017-04-12 12:51:18 +02:00
parent 85f2eee6c5
commit 18a185603d
33 changed files with 166 additions and 113 deletions

View file

@ -18,9 +18,11 @@ public class ModelManager {
public static void registerModels() {
//ItemBlock registration
register(getItemFromBlock(ModBlocks.blockDimWall));
register(getItemFromBlock(ModBlocks.blockDimWall), 1, "Ancient");
register(getItemFromBlock(ModBlocks.blockDimWall), 2, "Altered");
register(getItemFromBlock(ModBlocks.blockFabric), 0, "Reality");
register(getItemFromBlock(ModBlocks.blockFabric), 1, "Ancient");
register(getItemFromBlock(ModBlocks.blockFabric), 2, "Altered");
register(getItemFromBlock(ModBlocks.blockFabric), 3, "Unraveled");
register(getItemFromBlock(ModBlocks.blockFabric), 4, "Eternal");
register(getItemFromBlock(ModBlocks.blockRift));
register(getItemFromBlock(ModBlocks.blockDimHatch));
@ -40,10 +42,12 @@ public class ModelManager {
}
public static void registerModelVariants() {
ModelBakery.registerItemVariants(getItemFromBlock(ModBlocks.blockDimWall),
ModBlocks.blockDimWall.getRegistryName(),
new ResourceLocation(ModBlocks.blockDimWall.getRegistryName() + "Ancient"),
new ResourceLocation(ModBlocks.blockDimWall.getRegistryName() + "Altered"));
ModelBakery.registerItemVariants(getItemFromBlock(ModBlocks.blockFabric),
new ResourceLocation(ModBlocks.blockFabric.getRegistryName() + "Reality"),
new ResourceLocation(ModBlocks.blockFabric.getRegistryName() + "Ancient"),
new ResourceLocation(ModBlocks.blockFabric.getRegistryName() + "Altered"),
new ResourceLocation(ModBlocks.blockFabric.getRegistryName() + "Unraveled"),
new ResourceLocation(ModBlocks.blockFabric.getRegistryName() + "Eternal"));
}
private static void register(Item item) {

View file

@ -4,9 +4,13 @@ import java.util.List;
import java.util.Random;
import com.zixiken.dimdoors.DimDoors;
import com.zixiken.dimdoors.shared.items.ItemDimDoor;
import com.zixiken.dimdoors.shared.DDConfig;
import com.zixiken.dimdoors.shared.TeleporterDimDoors;
import com.zixiken.dimdoors.shared.util.DDRandomUtils;
import com.zixiken.dimdoors.shared.util.Location;
import com.zixiken.dimdoors.shared.world.limbodimension.LimboDecay;
import com.zixiken.dimdoors.shared.world.limbodimension.WorldProviderLimbo;
import net.minecraft.block.Block;
import net.minecraft.block.BlockDoor;
import net.minecraft.block.SoundType;
import net.minecraft.block.material.Material;
import net.minecraft.block.properties.PropertyEnum;
@ -33,7 +37,7 @@ import javax.annotation.Nullable;
@SuppressWarnings("deprecation")
public class BlockDimWall extends Block {
public static final String ID = "blockDimWall";
public static final String ID = "blockFabric";
public static final PropertyEnum<BlockDimWall.EnumType> TYPE = PropertyEnum.<BlockDimWall.EnumType>create("type", BlockDimWall.EnumType.class);
private static final float SUPER_HIGH_HARDNESS = 10000000000000F;
@ -48,11 +52,13 @@ public class BlockDimWall extends Block {
setRegistryName(ID);
setDefaultState(blockState.getBaseState().withProperty(TYPE, EnumType.REALITY));
setSoundType(SoundType.STONE);
setTickRandomly(true);
}
@Override
public IBlockState getStateFromMeta(int meta) {
if (meta >= 0 && meta <= 2) {
if (meta >= 0 && meta <= 4) {
return getDefaultState().withProperty(TYPE, EnumType.values()[meta]);
} else {
return getDefaultState();
@ -71,34 +77,38 @@ public class BlockDimWall extends Block {
@Override
public float getBlockHardness(IBlockState state, World world, BlockPos pos) {
if (!state.getValue(TYPE).equals(EnumType.ANCIENT)) {
return this.blockHardness;
} else {
if (state.getValue(TYPE).equals(EnumType.ANCIENT) || state.getValue(TYPE).equals(EnumType.ETERNAL)) {
return SUPER_HIGH_HARDNESS;
} else {
return this.blockHardness;
}
}
@Override
public float getExplosionResistance(World world, BlockPos pos, Entity exploder, Explosion explosion) {
if (!world.getBlockState(pos).getValue(TYPE).equals(EnumType.ANCIENT)) {
return super.getExplosionResistance(world, pos, exploder, explosion);
} else {
IBlockState state = world.getBlockState(pos);
if (state.getValue(TYPE).equals(EnumType.ANCIENT) || state.getValue(TYPE).equals(EnumType.ETERNAL)) {
return SUPER_EXPLOSION_RESISTANCE;
} else {
return super.getExplosionResistance(world, pos, exploder, explosion);
}
}
@Override
public int damageDropped(IBlockState state) {
int metadata = state.getValue(TYPE).ordinal();
//Return 0 to avoid dropping Ancient Fabric even if the player somehow manages to break it
return metadata == 1 ? 0 : metadata;
if (state.getValue(TYPE).equals(EnumType.ANCIENT) || state.getValue(TYPE).equals(EnumType.ETERNAL)) {
//Return 0 to avoid dropping Ancient or Eternal Fabric even if the player somehow manages to break it
return EnumType.REALITY.ordinal();
} else {
return state.getValue(TYPE).ordinal();
}
}
@Override
@SideOnly(Side.CLIENT)
public void getSubBlocks(Item itemIn, CreativeTabs tab, List<ItemStack> subItems) {
for (int ix = 0; ix < 3; ix++) {
subItems.add(new ItemStack(itemIn, 1, ix));
for (int i = 0; i < 5; i++) {
subItems.add(new ItemStack(itemIn, 1, i));
}
}
@ -120,34 +130,48 @@ public class BlockDimWall extends Block {
/**
* replaces the block clicked with the held block, instead of placing the
* block on top of it. Shift click to disable.
*
* @param world the world that this block is in
* @param pos the position this block is at
* @param state the state this block is in
* @param player the player right-clicking the block
* @param hand the hand the player is using
* @param heldItem the item the player is holding in that hand
* @param side the side of the block that is being clicked
* @param hitX the x coordinate of the exact place the player is clicking on
* the block
* @param hitY the y coordinate ...
* @param hitZ the z coordinate ...
* @return whether or not the item in the player's hand should be used or
* not?
*/
@Override
public boolean onBlockActivated(World world, BlockPos pos, IBlockState state, EntityPlayer player, EnumHand hand, @Nullable ItemStack heldItem, EnumFacing side, float hitX, float hitY, float hitZ) {
//Check if the metadata value is 0 -- we don't want the user to replace Ancient Fabric
if (heldItem != null && !state.getValue(TYPE).equals(EnumType.ANCIENT)) {
if(heldItem.getItem() instanceof ItemBlock) {
Block block = Block.getBlockFromItem(heldItem.getItem());
if (!state.isNormalCube() || block.hasTileEntity(block.getDefaultState())
|| block == this //this also keeps it from being replaced by Ancient Fabric
|| player.isSneaking()) {
return false;
}
if (!world.isRemote) { //@todo on a server, returning false or true determines where the block gets placed?
if (!player.isCreative()) {
heldItem.stackSize--;
}
world.setBlockState(pos, block.getStateForPlacement(world, pos, side, hitX, hitY, hitZ, heldItem.getMetadata(), player, heldItem)); //choosing getStateForPlacement over getDefaultState, because it will cause directional blocks, like logs to rotate correctly
}
return true;
if (heldItem != null && heldItem.getItem() instanceof ItemBlock
&& (state.getValue(TYPE).equals(EnumType.REALITY) || state.getValue(TYPE).equals(EnumType.ALTERED))) {
Block block = Block.getBlockFromItem(heldItem.getItem());
if (!state.isNormalCube() || block.hasTileEntity(block.getDefaultState())
|| block == this //this also keeps it from being replaced by Ancient Fabric
|| player.isSneaking()) {
return false;
}
if (!world.isRemote) { //@todo on a server, returning false or true determines where the block gets placed?
if (!player.isCreative()) {
heldItem.stackSize--;
}
world.setBlockState(pos, block.getStateForPlacement(world, pos, side, hitX, hitY, hitZ, heldItem.getMetadata(), player, heldItem)); //choosing getStateForPlacement over getDefaultState, because it will cause directional blocks, like logs to rotate correctly
}
return true;
}
return false;
}
public enum EnumType implements IStringSerializable {
REALITY("fabric"),
REALITY("reality"),
ANCIENT("ancient"),
ALTERED("altered");
ALTERED("altered"),
UNRAVELED("unraveled"),
ETERNAL("eternal");
private final String name;
@ -159,8 +183,29 @@ public class BlockDimWall extends Block {
return this.name;
}
@Override
public String getName() {
return this.name;
}
}
@Override
public void onEntityCollidedWithBlock(World world, BlockPos pos, IBlockState state, Entity entity) { //@todo move this to update or updateTick, because of the teleport and because you now have to fall through the block in order to teleport (wouldn't that be nice though?)
if (state.getValue(TYPE) == EnumType.ETERNAL && world.provider instanceof WorldProviderLimbo && entity instanceof EntityPlayer) {
Location origLocation = new Location(world, pos);
Location transFormedLocation = DDRandomUtils.transformLocationRandomly(DDConfig.getOwCoordinateOffsetBase(), DDConfig.getOwCoordinateOffsetPower(), DDConfig.getMaxDungeonDepth(), origLocation);
BlockPos correctedPos = DimDoors.proxy.getWorldServer(0).getTopSolidOrLiquidBlock(transFormedLocation.getPos());
Location correctedLocation = new Location(0, correctedPos);
TeleporterDimDoors.instance().teleport(entity, correctedLocation);
}
}
@Override
public void updateTick(World world, BlockPos pos, IBlockState state, Random random) { //if this creates more problems, because everything ticks, we should probably move this to its own class again
//Make sure this block is unraveled fabric in Limbo
if (state.getValue(TYPE) == EnumType.UNRAVELED && world.provider instanceof WorldProviderLimbo) {
LimboDecay.applySpreadDecay(world, pos);
}
}
}

View file

@ -1,32 +0,0 @@
package com.zixiken.dimdoors.shared.blocks;
import com.zixiken.dimdoors.shared.world.limbodimension.LimboDecay;
import com.zixiken.dimdoors.shared.world.limbodimension.WorldProviderLimbo;
import net.minecraft.block.Block;
import net.minecraft.block.material.MapColor;
import net.minecraft.block.material.Material;
import net.minecraft.block.state.IBlockState;
import net.minecraft.util.math.BlockPos;
import net.minecraft.world.World;
import java.util.Random;
public class BlockLimbo extends Block {
public static final String ID = "blockLimbo";
public BlockLimbo() {
super(Material.GROUND, MapColor.BLACK);
setUnlocalizedName(ID);
setRegistryName(ID);
setTickRandomly(true);
}
@Override
public void updateTick(World world, BlockPos pos, IBlockState state, Random random) {
//Make sure this block is in Limbo
if (world.provider instanceof WorldProviderLimbo) {
LimboDecay.applySpreadDecay(world, pos);
}
}
}

View file

@ -47,7 +47,7 @@ public class BlockRift extends Block implements ITileEntityProvider {
setRegistryName(ID);
modBlocksImmuneToRift = new ArrayList<Block>();
modBlocksImmuneToRift.add(ModBlocks.blockDimWall);
modBlocksImmuneToRift.add(ModBlocks.blockFabric);
modBlocksImmuneToRift.add(ModBlocks.blockDimDoor);
modBlocksImmuneToRift.add(ModBlocks.blockDimDoorWarp);
modBlocksImmuneToRift.add(ModBlocks.blockDimHatch);

View file

@ -13,9 +13,8 @@ public class ModBlocks {
public static BlockDimDoorChaos blockDimDoorChaos;
public static BlockDimDoor blockDimDoor;
public static BlockTransTrapdoor blockDimHatch;
public static BlockDimWall blockDimWall;
public static BlockDimWall blockFabric;
public static BlockRift blockRift;
public static BlockLimbo blockLimbo;
public static void registerBlocks() {
GameRegistry.register(blockDoorQuartz = new BlockDoorQuartz());
@ -26,9 +25,8 @@ public class ModBlocks {
GameRegistry.register(blockDimDoorWarp = new BlockDimDoorWarp());
GameRegistry.register(blockDimDoor = new BlockDimDoor());
GameRegistry.register(blockDimHatch = new BlockTransTrapdoor());
GameRegistry.register(blockDimWall = new BlockDimWall());
GameRegistry.register(blockFabric = new BlockDimWall());
GameRegistry.register(blockDimDoorTransient = new BlockDimDoorTransient());
GameRegistry.register(blockRift = new BlockRift());
GameRegistry.register(blockLimbo = new BlockLimbo());
}
}

View file

@ -8,10 +8,10 @@ import net.minecraft.item.ItemStack;
public class ItemBlockDimWall extends ItemBlock {
private final static String[] subNames = {"", "Ancient", "Altered"};
private final static String[] subNames = {"Reality", "Ancient", "Altered", "Unraveled", "Eternal"};
public ItemBlockDimWall() {
super(ModBlocks.blockDimWall);
super(ModBlocks.blockFabric);
setCreativeTab(DimDoors.dimDoorsCreativeTab);
setMaxDamage(0);
setHasSubtypes(true);
@ -23,6 +23,7 @@ public class ItemBlockDimWall extends ItemBlock {
return damageValue;
}
@Override
public String getUnlocalizedName(ItemStack stack) {
return super.getUnlocalizedName() + subNames[this.getDamage(stack)];
}

View file

@ -37,6 +37,7 @@ public abstract class DDTileEntityBase extends TileEntity implements ITickable {
/**
*
* @param rand
* @return an array of floats representing RGBA color where 1.0 = 255.
*/
public abstract float[] getRenderColor(Random rand);

View file

@ -34,7 +34,7 @@ public class LimboDecay {
public static IBlockState[] getDecaySequence() {
if (decaySequence == null) {
decaySequence = new IBlockState[] {
ModBlocks.blockLimbo.getDefaultState(),
ModBlocks.blockFabric.getDefaultState().withProperty(BlockDimWall.TYPE, BlockDimWall.EnumType.UNRAVELED),
Blocks.GRAVEL.getDefaultState(),
Blocks.COBBLESTONE.getDefaultState(),
Blocks.STONE.getDefaultState()
@ -47,8 +47,8 @@ public class LimboDecay {
public static IBlockState[] getBlocksImmuneToDecay() {
if (blocksImmuneToDecay == null) {
blocksImmuneToDecay = new IBlockState[] {
ModBlocks.blockLimbo.getDefaultState(),
ModBlocks.blockDimWall.getDefaultState().withProperty(BlockDimWall.TYPE, BlockDimWall.EnumType.ANCIENT),
ModBlocks.blockFabric.getDefaultState().withProperty(BlockDimWall.TYPE, BlockDimWall.EnumType.UNRAVELED),
ModBlocks.blockFabric.getDefaultState().withProperty(BlockDimWall.TYPE, BlockDimWall.EnumType.ETERNAL),
ModBlocks.blockDimDoorTransient.getDefaultState(),
ModBlocks.blockDimDoor.getDefaultState(),
ModBlocks.blockDimDoorWarp.getDefaultState(),
@ -120,7 +120,7 @@ public class LimboDecay {
private static boolean decayBlockFast(World world, BlockPos pos) {
IBlockState block = world.getBlockState(pos);
if (canDecayBlock(block, world, pos)) {
world.setBlockState(pos, ModBlocks.blockLimbo.getDefaultState());
world.setBlockState(pos, ModBlocks.blockFabric.getDefaultState().withProperty(BlockDimWall.TYPE, BlockDimWall.EnumType.UNRAVELED));
return true;
}
return false;

View file

@ -306,9 +306,11 @@ public class LimboGenerator implements IChunkGenerator
for (int zRel = 0; zRel < xzSectionSize; ++zRel) {
int zCoord = zSectionPart + zRel;
if(vxyz > 0) {
primer.setBlockState(xCoord, yCoord, zCoord, ModBlocks.blockLimbo.getDefaultState());
primer.setBlockState(xCoord, yCoord, zCoord,
ModBlocks.blockFabric.getDefaultState().withProperty(BlockDimWall.TYPE, BlockDimWall.EnumType.UNRAVELED));
} else if(yCoord < 6) {
primer.setBlockState(xCoord, yCoord, zCoord, ModBlocks.blockDimWall.getDefaultState().withProperty(BlockDimWall.TYPE, BlockDimWall.EnumType.ANCIENT));
primer.setBlockState(xCoord, yCoord, zCoord,
ModBlocks.blockFabric.getDefaultState().withProperty(BlockDimWall.TYPE, BlockDimWall.EnumType.ETERNAL));
}
}

View file

@ -1,6 +1,7 @@
package com.zixiken.dimdoors.shared.world.limbodimension;
import com.zixiken.dimdoors.client.CloudRenderBlank;
import com.zixiken.dimdoors.shared.blocks.BlockDimWall;
import com.zixiken.dimdoors.shared.blocks.ModBlocks;
import com.zixiken.dimdoors.shared.util.Location;
import com.zixiken.dimdoors.shared.world.DimDoorDimensions;
@ -91,7 +92,7 @@ public class WorldProviderLimbo extends WorldProvider {
@Override
public boolean canCoordinateBeSpawn(int x, int z) {
BlockPos pos = this.world.getTopSolidOrLiquidBlock(new BlockPos(x, 0, z));
return world.getBlockState(pos).equals(ModBlocks.blockLimbo.getDefaultState());
return world.getBlockState(pos).equals(ModBlocks.blockFabric.getDefaultState().withProperty(BlockDimWall.TYPE, BlockDimWall.EnumType.UNRAVELED));
}
@Override

View file

@ -1,7 +0,0 @@
{
"variants": {
"type=fabric": { "model": "dimdoors:blockDimWall" },
"type=ancient": { "model": "dimdoors:blockDimWallAncient" },
"type=altered": { "model": "dimdoors:blockDimWallAltered" }
}
}

View file

@ -0,0 +1,9 @@
{
"variants": {
"type=reality": { "model": "dimdoors:blockFabricReality" },
"type=ancient": { "model": "dimdoors:blockFabricAncient" },
"type=altered": { "model": "dimdoors:blockFabricAltered" },
"type=unraveled": { "model": "dimdoors:blockFabricUnraveled" },
"type=eternal": { "model": "dimdoors:blockFabricEternal" }
}
}

View file

@ -4,13 +4,13 @@ tile.transientDoor.name=Transient Door
tile.dimDoorGold.name=Golden Dimensional Door
tile.doorQuartz.name=Quartz Door
tile.dimDoorPersonal.name=Personal Dimensional Door
tile.blockDimWall.name=Fabric of Reality
tile.blockDimWallAltered.name=Altered Fabric
tile.blockDimWallAncient.name=Ancient Fabric
tile.blockDimWallPerm.name=Eternal Fabric
tile.blockFabricReality.name=Fabric of Reality
tile.blockFabricAltered.name=Altered Fabric
tile.blockFabricAncient.name=Ancient Fabric
tile.blockFabricEternal.name=Eternal Fabric
tile.blockFabricUnraveled.name=Unraveled Fabric
tile.dimDoorWarp.name=Warp Door
tile.blockRift.name=Rift
tile.BlockLimbo.name=Unraveled Fabric
tile.chaosDoor.name=Unstable Door
tile.dimDoor.name=Dimensional Door
tile.blockDimHatch.name=Transdimensional Trapdoor

View file

@ -1,4 +0,0 @@
{
"parent": "block/cube_all",
"textures": { "all": "dimdoors:blocks/blockDimWall" }
}

View file

@ -1,4 +0,0 @@
{
"parent": "block/cube_all",
"textures": { "all": "dimdoors:blocks/blockDimWallAltered" }
}

View file

@ -1,4 +0,0 @@
{
"parent": "block/cube_all",
"textures": { "all": "dimdoors:blocks/blockDimWallAncient" }
}

View file

@ -0,0 +1,4 @@
{
"parent": "block/cube_all",
"textures": { "all": "dimdoors:blocks/blockFabricAltered" }
}

View file

@ -0,0 +1,4 @@
{
"parent": "block/cube_all",
"textures": { "all": "dimdoors:blocks/blockFabricAncient" }
}

View file

@ -0,0 +1,4 @@
{
"parent": "block/cube_all",
"textures": { "all": "dimdoors:blocks/blockFabricEternal" }
}

View file

@ -0,0 +1,4 @@
{
"parent": "block/cube_all",
"textures": { "all": "dimdoors:blocks/blockFabricReality" }
}

View file

@ -0,0 +1,4 @@
{
"parent": "block/cube_all",
"textures": { "all": "dimdoors:blocks/blockFabricUnraveled" }
}

View file

@ -1,5 +1,5 @@
{
"parent": "dimdoors:block/blockDimWall",
"parent": "dimdoors:block/blockFabricAltered",
"display": {
"thirdperson": {
"rotation": [ 10, -45, 170 ],

View file

@ -1,5 +1,5 @@
{
"parent": "dimdoors:block/blockDimWallAltered",
"parent": "dimdoors:block/blockFabricAncient",
"display": {
"thirdperson": {
"rotation": [ 10, -45, 170 ],

View file

@ -1,5 +1,5 @@
{
"parent": "dimdoors:block/blockDimWallAncient",
"parent": "dimdoors:block/blockFabricEternal",
"display": {
"thirdperson": {
"rotation": [ 10, -45, 170 ],

View file

@ -0,0 +1,10 @@
{
"parent": "dimdoors:block/blockFabricReality",
"display": {
"thirdperson": {
"rotation": [ 10, -45, 170 ],
"translation": [ 0, 1.5, -2.75 ],
"scale": [ 0.375, 0.375, 0.375 ]
}
}
}

View file

@ -0,0 +1,10 @@
{
"parent": "dimdoors:block/blockFabricUnraveled",
"display": {
"thirdperson": {
"rotation": [ 10, -45, 170 ],
"translation": [ 0, 1.5, -2.75 ],
"scale": [ 0.375, 0.375, 0.375 ]
}
}
}

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.8 KiB

View file

Before

Width:  |  Height:  |  Size: 2.7 KiB

After

Width:  |  Height:  |  Size: 2.7 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.3 KiB

View file

@ -0,0 +1,3 @@
{
"animation": { "frametime": 10 }
}