A few fixes
This commit is contained in:
parent
b1efc3592c
commit
a92e657b12
27 changed files with 195 additions and 220 deletions
|
@ -37,8 +37,8 @@ public class DDProxyClient extends DDProxyCommon {
|
|||
}
|
||||
|
||||
public void registerRenderers() {
|
||||
ClientRegistry.bindTileEntitySpecialRenderer(TileEntityVerticalEntranceRift.class, new RenderDimDoor());
|
||||
ClientRegistry.bindTileEntitySpecialRenderer(TileEntityHorizontalEntranceRift.class, new RenderTransTrapdoor());
|
||||
ClientRegistry.bindTileEntitySpecialRenderer(TileEntityVerticalEntranceRift.class, new RenderVerticalEntranceRift());
|
||||
ClientRegistry.bindTileEntitySpecialRenderer(TileEntityHorizontalEntranceRift.class, new RenderHorizontalEntranceRift());
|
||||
ClientRegistry.bindTileEntitySpecialRenderer(TileEntityFloatingRift.class, new RenderRift());
|
||||
RenderingRegistry.registerEntityRenderingHandler(MobMonolith.class, manager -> new RenderMobObelisk(manager, 0.5f));
|
||||
}
|
||||
|
|
|
@ -22,7 +22,7 @@ import net.minecraftforge.fml.relauncher.SideOnly;
|
|||
import org.lwjgl.opengl.GL11;
|
||||
|
||||
@SideOnly(Side.CLIENT)
|
||||
public class RenderTransTrapdoor extends TileEntitySpecialRenderer<TileEntityHorizontalEntranceRift> {
|
||||
public class RenderHorizontalEntranceRift extends TileEntitySpecialRenderer<TileEntityHorizontalEntranceRift> {
|
||||
|
||||
private FloatBuffer buffer = GLAllocation.createDirectFloatBuffer(16);
|
||||
private ResourceLocation riftPath = new ResourceLocation(DimDoors.MODID + ":textures/other/rift.png");
|
|
@ -6,6 +6,9 @@ import java.util.Random;
|
|||
import com.zixiken.dimdoors.DimDoors;
|
||||
import com.zixiken.dimdoors.shared.blocks.BlockDimDoorBase;
|
||||
import com.zixiken.dimdoors.shared.tileentities.TileEntityVerticalEntranceRift;
|
||||
import com.zixiken.dimdoors.shared.util.RGBA;
|
||||
import net.minecraft.block.BlockDoor;
|
||||
import net.minecraft.block.state.IBlockState;
|
||||
import net.minecraft.client.renderer.*;
|
||||
import net.minecraft.client.renderer.vertex.*;
|
||||
import net.minecraft.util.EnumFacing;
|
||||
|
@ -19,7 +22,7 @@ import net.minecraft.util.ResourceLocation;
|
|||
|
||||
import static org.lwjgl.opengl.GL11.*;
|
||||
|
||||
public class RenderDimDoor extends TileEntitySpecialRenderer<TileEntityVerticalEntranceRift> {
|
||||
public class RenderVerticalEntranceRift extends TileEntitySpecialRenderer<TileEntityVerticalEntranceRift> {
|
||||
|
||||
private FloatBuffer buffer = GLAllocation.createDirectFloatBuffer(16);
|
||||
private ResourceLocation warpPath = new ResourceLocation(DimDoors.MODID + ":textures/other/warp.png");
|
||||
|
@ -33,6 +36,11 @@ public class RenderDimDoor extends TileEntitySpecialRenderer<TileEntityVerticalE
|
|||
GL11.glDisable(GL11.GL_LIGHTING);
|
||||
Random rand = new Random(31100L);
|
||||
|
||||
EnumFacing orientation = tile.orientation;
|
||||
IBlockState state = tile.getWorld().getBlockState(tile.getPos());
|
||||
if (state.getBlock() instanceof BlockDoor && state.getValue(BlockDoor.HALF) == BlockDoor.EnumDoorHalf.LOWER) y += 1;
|
||||
// TODO: option for non-doors in the TileEntityEntranceRift
|
||||
|
||||
for (int count = 0; count < 16; ++count) {
|
||||
GlStateManager.pushMatrix();
|
||||
|
||||
|
@ -66,33 +74,31 @@ public class RenderDimDoor extends TileEntitySpecialRenderer<TileEntityVerticalE
|
|||
GlStateManager.texGen(GlStateManager.TexGen.R, GL11.GL_OBJECT_LINEAR);
|
||||
GlStateManager.texGen(GlStateManager.TexGen.Q, GL11.GL_OBJECT_LINEAR);
|
||||
|
||||
EnumFacing orientation = tile.orientation.rotateYCCW();
|
||||
|
||||
switch (orientation) {
|
||||
case SOUTH:
|
||||
GlStateManager.texGen(GlStateManager.TexGen.S, GL11.GL_OBJECT_PLANE, getFloatBuffer(0.0F, 1.0F, 0.0F, 0.0F));
|
||||
GlStateManager.texGen(GlStateManager.TexGen.T, GL11.GL_OBJECT_PLANE, getFloatBuffer(1.0F, 0.0F, 0.0F, 0.0F));
|
||||
GlStateManager.texGen(GlStateManager.TexGen.R, GL11.GL_OBJECT_PLANE, getFloatBuffer(0.0F, 0.0F, 0.0F, 1.0F));
|
||||
GlStateManager.texGen(GlStateManager.TexGen.Q, GL11.GL_OBJECT_PLANE, getFloatBuffer(0.0F, 0.0F, 1.0F, -0.15F));
|
||||
break;
|
||||
case WEST:
|
||||
GlStateManager.texGen(GlStateManager.TexGen.S, GL11.GL_OBJECT_PLANE, getFloatBuffer(0.0F, 1.0F, 0.0F, 0.0F));
|
||||
GlStateManager.texGen(GlStateManager.TexGen.T, GL11.GL_OBJECT_PLANE, getFloatBuffer(0.0F, 0.0F, 1.0F, 0.0F));
|
||||
GlStateManager.texGen(GlStateManager.TexGen.R, GL11.GL_OBJECT_PLANE, getFloatBuffer(0.0F, 0.0F, 0.0F, 1.0F));
|
||||
GlStateManager.texGen(GlStateManager.TexGen.Q, GL11.GL_OBJECT_PLANE, getFloatBuffer(1.0F, 0.0F, 0.0F, 0.15F));
|
||||
break;
|
||||
case WEST:
|
||||
case NORTH:
|
||||
GlStateManager.texGen(GlStateManager.TexGen.S, GL11.GL_OBJECT_PLANE, getFloatBuffer(0.0F, 1.0F, 0.0F, 0.0F));
|
||||
GlStateManager.texGen(GlStateManager.TexGen.T, GL11.GL_OBJECT_PLANE, getFloatBuffer(1.0F, 0.0F, 0.0F, 0.0F));
|
||||
GlStateManager.texGen(GlStateManager.TexGen.R, GL11.GL_OBJECT_PLANE, getFloatBuffer(0.0F, 0.0F, 0.0F, 1.0F));
|
||||
GlStateManager.texGen(GlStateManager.TexGen.Q, GL11.GL_OBJECT_PLANE, getFloatBuffer(0.0F, 0.0F, 1.0F, 0.15F));
|
||||
break;
|
||||
case NORTH:
|
||||
case EAST:
|
||||
GlStateManager.texGen(GlStateManager.TexGen.S, GL11.GL_OBJECT_PLANE, getFloatBuffer(0.0F, 1.0F, 0.0F, 0.0F));
|
||||
GlStateManager.texGen(GlStateManager.TexGen.T, GL11.GL_OBJECT_PLANE, getFloatBuffer(0.0F, 0.0F, 1.0F, 0.0F));
|
||||
GlStateManager.texGen(GlStateManager.TexGen.R, GL11.GL_OBJECT_PLANE, getFloatBuffer(0.0F, 0.0F, 0.0F, 1.0F));
|
||||
GlStateManager.texGen(GlStateManager.TexGen.Q, GL11.GL_OBJECT_PLANE, getFloatBuffer(1.0F, 0.0F, 0.0F, -0.15F));
|
||||
break;
|
||||
case EAST:
|
||||
GlStateManager.texGen(GlStateManager.TexGen.S, GL11.GL_OBJECT_PLANE, getFloatBuffer(0.0F, 1.0F, 0.0F, 0.0F));
|
||||
GlStateManager.texGen(GlStateManager.TexGen.T, GL11.GL_OBJECT_PLANE, getFloatBuffer(1.0F, 0.0F, 0.0F, 0.0F));
|
||||
GlStateManager.texGen(GlStateManager.TexGen.R, GL11.GL_OBJECT_PLANE, getFloatBuffer(0.0F, 0.0F, 0.0F, 1.0F));
|
||||
GlStateManager.texGen(GlStateManager.TexGen.Q, GL11.GL_OBJECT_PLANE, getFloatBuffer(0.0F, 0.0F, 1.0F, -0.15F));
|
||||
break;
|
||||
}
|
||||
|
||||
GlStateManager.enableTexGenCoord(GlStateManager.TexGen.S);
|
||||
|
@ -115,58 +121,34 @@ public class RenderDimDoor extends TileEntitySpecialRenderer<TileEntityVerticalE
|
|||
BufferBuilder worldRenderer = tessellator.getBuffer();
|
||||
worldRenderer.begin(GL11.GL_QUADS, DefaultVertexFormats.POSITION);
|
||||
|
||||
float[] color = tile.getEntranceRenderColor(rand); // TODO: cache this since it's constant
|
||||
GlStateManager.color(color[0] * var17, color[1] * var17, color[2] * var17, color[3]);
|
||||
RGBA color = tile.getEntranceRenderColor(rand); // TODO: cache this since it's constant
|
||||
GlStateManager.color(color.getRed() * var17, color.getGreen() * var17, color.getBlue() * var17, color.getAlpha());
|
||||
|
||||
switch (orientation) {
|
||||
case SOUTH:
|
||||
worldRenderer.pos(x + .01, y - 1, z).endVertex();
|
||||
worldRenderer.pos(x + .01, y - 1, z + 1.0D).endVertex();
|
||||
worldRenderer.pos(x + .01, y + 1, z + 1.0D).endVertex();
|
||||
worldRenderer.pos(x + .01, y + 1, z).endVertex();
|
||||
break;
|
||||
case WEST:
|
||||
worldRenderer.pos(x, y + 1, z + .01).endVertex();
|
||||
worldRenderer.pos(x + 1, y + 1, z + .01).endVertex();
|
||||
worldRenderer.pos(x + 1, y - 1, z + .01).endVertex();
|
||||
worldRenderer.pos(x, y - 1, z + .01).endVertex();
|
||||
break;
|
||||
case NORTH:
|
||||
worldRenderer.pos(x + .99, y + 1, z).endVertex();
|
||||
worldRenderer.pos(x + .99, y + 1, z + 1.0D).endVertex();
|
||||
worldRenderer.pos(x + .99, y - 1, z + 1.0D).endVertex();
|
||||
worldRenderer.pos(x + .99, y - 1, z).endVertex();
|
||||
break;
|
||||
case EAST:
|
||||
worldRenderer.pos(x, y - 1, z + .99).endVertex();
|
||||
worldRenderer.pos(x + 1, y - 1, z + .99).endVertex();
|
||||
worldRenderer.pos(x + 1, y + 1, z + .99).endVertex();
|
||||
worldRenderer.pos(x, y + 1, z + .99).endVertex();
|
||||
break;
|
||||
/*case 4:
|
||||
GL11.glVertex3d(x + .15F, y - 1 , z);
|
||||
GL11.glVertex3d(x + .15, y - 1, z + 1.0D);
|
||||
GL11.glVertex3d(x + .15, y + 1, z + 1.0D);
|
||||
GL11.glVertex3d(x + .15, y + 1, z);
|
||||
case WEST:
|
||||
worldRenderer.pos(x + .01, y - 1, z).endVertex();
|
||||
worldRenderer.pos(x + .01, y - 1, z + 1.0D).endVertex();
|
||||
worldRenderer.pos(x + .01, y + 1, z + 1.0D).endVertex();
|
||||
worldRenderer.pos(x + .01, y + 1, z).endVertex();
|
||||
break;
|
||||
case 5:
|
||||
GL11.glVertex3d(x, y + 1, z + .15);
|
||||
GL11.glVertex3d(x + 1, y + 1, z + .15);
|
||||
GL11.glVertex3d(x + 1, y - 1, z + .15);
|
||||
GL11.glVertex3d(x, y - 1, z + .15);
|
||||
case NORTH:
|
||||
worldRenderer.pos(x, y + 1, z + .01).endVertex();
|
||||
worldRenderer.pos(x + 1, y + 1, z + .01).endVertex();
|
||||
worldRenderer.pos(x + 1, y - 1, z + .01).endVertex();
|
||||
worldRenderer.pos(x, y - 1, z + .01).endVertex();
|
||||
break;
|
||||
case 6:
|
||||
GL11.glVertex3d(x + .85, y + 1, z);
|
||||
GL11.glVertex3d(x + .85, y + 1, z + 1.0D);
|
||||
GL11.glVertex3d(x + .85, y - 1, z + 1.0D);
|
||||
GL11.glVertex3d(x + .85, y - 1, z);
|
||||
case EAST:
|
||||
worldRenderer.pos(x + .99, y + 1, z).endVertex();
|
||||
worldRenderer.pos(x + .99, y + 1, z + 1.0D).endVertex();
|
||||
worldRenderer.pos(x + .99, y - 1, z + 1.0D).endVertex();
|
||||
worldRenderer.pos(x + .99, y - 1, z).endVertex();
|
||||
break;
|
||||
case 7:
|
||||
GL11.glVertex3d(x, y - 1, z + .85);
|
||||
GL11.glVertex3d(x + 1, y - 1, z + .85);
|
||||
GL11.glVertex3d(x + 1, y + 1, z + .85);
|
||||
GL11.glVertex3d(x, y + 1, z + .85);
|
||||
break;*/
|
||||
}
|
||||
|
||||
tessellator.draw();
|
||||
|
@ -207,16 +189,17 @@ public class RenderDimDoor extends TileEntitySpecialRenderer<TileEntityVerticalE
|
|||
|
||||
switch (rotation) {
|
||||
case SOUTH:
|
||||
GL11.glTranslatef(-0.5F, 0, -0.03F);
|
||||
GL11.glTranslatef(0.5F, 0F, -0.03F);
|
||||
break;
|
||||
case WEST:
|
||||
GL11.glTranslatef(-.5F, 0F, .97F);
|
||||
GL11.glTranslatef(-0.5F, 0, -0.03F);
|
||||
break;
|
||||
case NORTH:
|
||||
GL11.glTranslatef(.5F, 0F, .97F);
|
||||
GL11.glTranslatef(-.5F, 0F, .97F);
|
||||
break;
|
||||
case EAST:
|
||||
GL11.glTranslatef(0.5F, 0F, -0.03F);
|
||||
GL11.glTranslatef(.5F, 0F, .97F);
|
||||
break;
|
||||
}
|
||||
|
||||
GL11.glDisable(GL_LIGHTING);
|
|
@ -48,9 +48,9 @@ public abstract class DDProxyCommon implements IDDProxy {
|
|||
if (tile instanceof TileEntityVerticalEntranceRift) {
|
||||
TileEntityVerticalEntranceRift dimTile = (TileEntityVerticalEntranceRift) tile;
|
||||
IBlockState state = world.getBlockState(pos.down());
|
||||
dimTile.orientation = state.getBlock() instanceof BlockDimDoorBase
|
||||
? state.getValue(BlockDoor.FACING).getOpposite()
|
||||
: ModBlocks.DIMENSIONAL_DOOR.getDefaultState().getValue(BlockDoor.FACING);
|
||||
//dimTile.orientation = state.getBlock() instanceof BlockDimDoorBase
|
||||
// ? state.getValue(BlockDoor.FACING).getOpposite()
|
||||
// : ModBlocks.DIMENSIONAL_DOOR.getDefaultState().getValue(BlockDoor.FACING);
|
||||
// dimTile.doorShouldRender = door.isDoorOnRift(world, pos) && door.isUpperDoorBlock(world.getBlockState(pos));
|
||||
dimTile.lockStatus = 0; //@todo
|
||||
dimTile.markDirty();
|
||||
|
|
|
@ -1,8 +1,3 @@
|
|||
/*
|
||||
* To change this license header, choose License Headers in Project Properties.
|
||||
* To change this template file, choose Tools | Templates
|
||||
* and open the template in the editor.
|
||||
*/
|
||||
package com.zixiken.dimdoors.shared;
|
||||
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
|
|
|
@ -6,6 +6,7 @@ import com.zixiken.dimdoors.DimDoors;
|
|||
import com.zixiken.dimdoors.shared.tileentities.TileEntityEntranceRift;
|
||||
import com.zixiken.dimdoors.shared.tileentities.TileEntityVerticalEntranceRift;
|
||||
import com.zixiken.dimdoors.shared.rifts.TileEntityRift;
|
||||
import net.minecraft.block.Block;
|
||||
import net.minecraft.block.BlockDoor;
|
||||
import net.minecraft.block.ITileEntityProvider;
|
||||
import net.minecraft.block.material.Material;
|
||||
|
@ -21,7 +22,7 @@ import net.minecraft.util.EnumHand;
|
|||
import net.minecraft.util.math.BlockPos;
|
||||
import net.minecraft.world.World;
|
||||
|
||||
public abstract class BlockDimDoorBase extends BlockDoor implements ITileEntityProvider {
|
||||
public abstract class BlockDimDoorBase extends BlockDoor implements ITileEntityProvider { // TODO: implement RiftProvider
|
||||
|
||||
public BlockDimDoorBase(Material material) {
|
||||
super(material);
|
||||
|
@ -31,12 +32,15 @@ public abstract class BlockDimDoorBase extends BlockDoor implements ITileEntityP
|
|||
public void onEntityCollidedWithBlock(World worldIn, BlockPos pos, IBlockState state, Entity entityIn) {
|
||||
if (state.getValue(HALF) == EnumDoorHalf.UPPER) pos = pos.down();
|
||||
IBlockState doorState = worldIn.getBlockState(pos);
|
||||
if (!(doorState.getBlock() instanceof BlockDoor)) return;
|
||||
if (doorState.getValue(BlockDoor.OPEN) && entityIn.timeUntilPortal == 0) {
|
||||
entityIn.timeUntilPortal = 50; // 2.5s
|
||||
toggleDoor(worldIn, pos, false);
|
||||
TileEntityRift rift = getRiftTile(worldIn, pos, worldIn.getBlockState(pos));
|
||||
if(!rift.teleport(entityIn) && entityIn instanceof EntityPlayer) {
|
||||
TileEntityEntranceRift rift = getRift(worldIn, pos, state);
|
||||
if (!rift.teleport(entityIn) && entityIn instanceof EntityPlayer) {
|
||||
DimDoors.chat((EntityPlayer) entityIn, "Teleporting failed because this entrance has no destinations!");
|
||||
} else if (rift.isCloseAfterPassThrough()) { // TODO: move logic to TileEntityEntranceRift?
|
||||
worldIn.destroyBlock(pos, false);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -53,11 +57,24 @@ public abstract class BlockDimDoorBase extends BlockDoor implements ITileEntityP
|
|||
if (iblockstate.getBlock() != this) {
|
||||
return false;
|
||||
} else {
|
||||
super.onBlockActivated(worldIn, pos, state, playerIn, hand, facing, hitX, hitY, hitZ);
|
||||
state = iblockstate.cycleProperty(OPEN);
|
||||
worldIn.setBlockState(blockpos, state, 10);
|
||||
worldIn.markBlockRangeForRenderUpdate(blockpos, pos);
|
||||
worldIn.playEvent(playerIn, state.getValue(OPEN) ? getOpenSound() : getCloseSound(), pos, 0);
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
private int getCloseSound()
|
||||
{
|
||||
return blockMaterial == Material.IRON ? 1011 : 1012;
|
||||
}
|
||||
|
||||
private int getOpenSound()
|
||||
{
|
||||
return blockMaterial == Material.IRON ? 1005 : 1006;
|
||||
}
|
||||
|
||||
public boolean checkCanOpen(World world, BlockPos pos, EntityPlayer player) { // TODO: locking system
|
||||
return true;
|
||||
}
|
||||
|
@ -88,31 +105,44 @@ public abstract class BlockDimDoorBase extends BlockDoor implements ITileEntityP
|
|||
return new ItemStack(getItem());
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onBlockAdded(World worldIn, BlockPos pos, IBlockState state) {
|
||||
super.onBlockAdded(worldIn, pos, state);
|
||||
if (hasTileEntity(state)) {
|
||||
TileEntityVerticalEntranceRift rift = createNewTileEntity(worldIn, getMetaFromState(state));
|
||||
rift.orientation = state.getValue(BlockDoor.FACING).getOpposite();
|
||||
worldIn.setTileEntity(pos, rift);
|
||||
rift.markDirty();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public TileEntity createNewTileEntity(World worldIn, int meta) {
|
||||
public TileEntityVerticalEntranceRift createNewTileEntity(World worldIn, int meta) {
|
||||
return new TileEntityVerticalEntranceRift();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void breakBlock(World worldIn, BlockPos pos, IBlockState state) {
|
||||
if (!hasTileEntity(state)) return;
|
||||
|
||||
TileEntityEntranceRift origRift = (TileEntityEntranceRift) worldIn.getTileEntity(pos);
|
||||
TileEntityEntranceRift origRift = getRift(worldIn, pos, state);
|
||||
super.breakBlock(worldIn, pos, state);
|
||||
if (origRift.isPlaceRiftOnBreak()) {
|
||||
worldIn.setBlockState(pos, ModBlocks.RIFT.getDefaultState());
|
||||
TileEntityRift newRift = (TileEntityRift) worldIn.getTileEntity(pos);
|
||||
newRift.copyFrom(origRift); // TODO: make sure this works
|
||||
newRift.copyFrom(origRift);
|
||||
worldIn.setBlockState(pos, ModBlocks.RIFT.getDefaultState()); // TODO: send the TileEntity
|
||||
}
|
||||
}
|
||||
|
||||
public TileEntityEntranceRift getRiftTile(World world, BlockPos pos, IBlockState state) {
|
||||
public TileEntityEntranceRift getRift(World world, BlockPos pos, IBlockState state) {
|
||||
TileEntity tileEntity;
|
||||
if (state.getValue(BlockDoor.HALF) == EnumDoorHalf.LOWER) {
|
||||
tileEntity = world.getTileEntity(pos.up());
|
||||
tileEntity = world.getTileEntity(pos);
|
||||
if (!(tileEntity instanceof TileEntityRift)) tileEntity = world.getTileEntity(pos.up());
|
||||
} else {
|
||||
tileEntity = world.getTileEntity(pos);
|
||||
if (!(tileEntity instanceof TileEntityRift)) tileEntity = world.getTileEntity(pos.down());
|
||||
}
|
||||
return (TileEntityEntranceRift) tileEntity;
|
||||
}
|
||||
|
|
|
@ -24,9 +24,4 @@ public class BlockDimDoorGold extends BlockDimDoorBase {
|
|||
public Item getItem() {
|
||||
return ModItems.GOLD_DIMENSIONAL_DOOR;
|
||||
}
|
||||
|
||||
@Override
|
||||
public TileEntity createNewTileEntity(World worldIn, int meta) {
|
||||
return new TileEntityVerticalEntranceRift();
|
||||
}
|
||||
}
|
||||
|
|
|
@ -24,9 +24,4 @@ public class BlockDimDoorPersonal extends BlockDimDoorBase {
|
|||
public Item getItem() {
|
||||
return ModItems.PERSONAL_DIMENSIONAL_DOOR;
|
||||
}
|
||||
|
||||
@Override
|
||||
public TileEntity createNewTileEntity(World worldIn, int meta) {
|
||||
return new TileEntityVerticalEntranceRift();
|
||||
}
|
||||
}
|
||||
|
|
|
@ -16,8 +16,6 @@ public class BlockDimDoorTransient extends BlockDimDoorBase { // TODO: convert t
|
|||
setRegistryName(new ResourceLocation(DimDoors.MODID, ID));
|
||||
}
|
||||
|
||||
// TODO: close after use
|
||||
|
||||
@Override
|
||||
public Item getItem() {
|
||||
return null;
|
||||
|
@ -25,6 +23,6 @@ public class BlockDimDoorTransient extends BlockDimDoorBase { // TODO: convert t
|
|||
|
||||
@Override
|
||||
public boolean isCollidable() {
|
||||
return true;
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -5,6 +5,7 @@ import com.zixiken.dimdoors.shared.items.ModItems;
|
|||
import java.util.Random;
|
||||
|
||||
import com.zixiken.dimdoors.shared.tileentities.TileEntityVerticalEntranceRift;
|
||||
import net.minecraft.block.BlockDoor;
|
||||
import net.minecraft.block.material.Material;
|
||||
import net.minecraft.block.state.IBlockState;
|
||||
import net.minecraft.init.Items;
|
||||
|
@ -22,7 +23,7 @@ public class BlockDimDoorUnstable extends BlockDimDoorBase {
|
|||
setHardness(.2F);
|
||||
setUnlocalizedName(ID);
|
||||
setRegistryName(new ResourceLocation(DimDoors.MODID, ID));
|
||||
setLightLevel(.0F);
|
||||
setLightLevel(0.0F);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -32,11 +33,6 @@ public class BlockDimDoorUnstable extends BlockDimDoorBase {
|
|||
|
||||
@Override
|
||||
public Item getItemDropped(IBlockState state, Random rand, int fortune) {
|
||||
return Items.IRON_DOOR;
|
||||
}
|
||||
|
||||
@Override
|
||||
public TileEntity createNewTileEntity(World worldIn, int meta) {
|
||||
return new TileEntityVerticalEntranceRift();
|
||||
return state.getValue(HALF) == BlockDoor.EnumDoorHalf.UPPER ? Items.AIR : Items.IRON_DOOR;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -24,9 +24,4 @@ public class BlockDimDoorWarp extends BlockDimDoorBase {
|
|||
public Item getItem() {
|
||||
return ModItems.WARP_DIMENSIONAL_DOOR;
|
||||
}
|
||||
|
||||
@Override
|
||||
public TileEntity createNewTileEntity(World worldIn, int meta) {
|
||||
return new TileEntityVerticalEntranceRift();
|
||||
}
|
||||
}
|
||||
|
|
|
@ -31,11 +31,10 @@ import net.minecraft.world.World;
|
|||
import net.minecraftforge.fml.relauncher.Side;
|
||||
import net.minecraftforge.fml.relauncher.SideOnly;
|
||||
|
||||
@SuppressWarnings("deprecation")
|
||||
public class BlockFabric extends Block {
|
||||
|
||||
public static final String ID = "fabric";
|
||||
public static final PropertyEnum<BlockFabric.EnumType> TYPE = PropertyEnum.create("type", BlockFabric.EnumType.class);
|
||||
public static final PropertyEnum<EnumType> TYPE = PropertyEnum.create("type", BlockFabric.EnumType.class);
|
||||
|
||||
private static final float SUPER_HIGH_HARDNESS = 10000000000000F;
|
||||
private static final float SUPER_EXPLOSION_RESISTANCE = 18000000F;
|
||||
|
@ -55,7 +54,6 @@ public class BlockFabric extends Block {
|
|||
public String toString() {
|
||||
return name;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
public BlockFabric() {
|
||||
|
|
|
@ -1,11 +1,14 @@
|
|||
package com.zixiken.dimdoors.shared.blocks;
|
||||
|
||||
import com.zixiken.dimdoors.DimDoors;
|
||||
import com.zixiken.dimdoors.client.ClosingRiftFX;
|
||||
import com.zixiken.dimdoors.client.GoggleRiftFX;
|
||||
import com.zixiken.dimdoors.shared.items.ModItems;
|
||||
import com.zixiken.dimdoors.shared.tileentities.TileEntityFloatingRift;
|
||||
|
||||
import java.util.*;
|
||||
import net.minecraft.block.Block;
|
||||
import net.minecraft.block.BlockDoor;
|
||||
import net.minecraft.block.BlockLiquid;
|
||||
import net.minecraft.block.ITileEntityProvider;
|
||||
import net.minecraft.block.material.EnumPushReaction;
|
||||
|
@ -19,6 +22,7 @@ import net.minecraft.item.ItemStack;
|
|||
import net.minecraft.tileentity.TileEntity;
|
||||
import net.minecraft.util.EnumBlockRenderType;
|
||||
import net.minecraft.util.EnumFacing;
|
||||
import net.minecraft.util.EnumHand;
|
||||
import net.minecraft.util.ResourceLocation;
|
||||
import net.minecraft.util.math.AxisAlignedBB;
|
||||
import net.minecraft.util.math.BlockPos;
|
||||
|
@ -26,16 +30,15 @@ import net.minecraft.util.math.RayTraceResult;
|
|||
import net.minecraft.world.IBlockAccess;
|
||||
import net.minecraft.world.World;
|
||||
import net.minecraftforge.fluids.IFluidBlock;
|
||||
import net.minecraftforge.fml.client.FMLClientHandler;
|
||||
import net.minecraftforge.fml.relauncher.Side;
|
||||
import net.minecraftforge.fml.relauncher.SideOnly;
|
||||
|
||||
@SuppressWarnings("deprecation")
|
||||
public class BlockRift extends Block implements ITileEntityProvider {
|
||||
|
||||
public static final String ID = "rift";
|
||||
|
||||
private final ArrayList<Block> blocksImmuneToRift; // List of Vanilla blocks immune to rifts
|
||||
private final ArrayList<Block> modBlocksImmuneToRift; // List of DD blocks immune to rifts
|
||||
private final ArrayList<Block> blocksImmuneToRift; // TODO
|
||||
|
||||
public BlockRift() {
|
||||
super(Material.LEAVES); //Fire is replacable. We do not want this block to be replacable. We do want to walk through it though...
|
||||
|
@ -44,20 +47,19 @@ public class BlockRift extends Block implements ITileEntityProvider {
|
|||
setUnlocalizedName(ID);
|
||||
setRegistryName(new ResourceLocation(DimDoors.MODID, ID));
|
||||
|
||||
modBlocksImmuneToRift = new ArrayList<>();
|
||||
modBlocksImmuneToRift.add(ModBlocks.FABRIC);
|
||||
modBlocksImmuneToRift.add(ModBlocks.DIMENSIONAL_DOOR);
|
||||
modBlocksImmuneToRift.add(ModBlocks.WARP_DIMENSIONAL_DOOR);
|
||||
modBlocksImmuneToRift.add(ModBlocks.DIMENSIONAL_TRAPDOOR);
|
||||
modBlocksImmuneToRift.add(ModBlocks.UNSTABLE_DIMENSIONAL_DOOR);
|
||||
modBlocksImmuneToRift.add(ModBlocks.RIFT);
|
||||
modBlocksImmuneToRift.add(ModBlocks.TRANSIENT_DIMENSIONAL_DOOR);
|
||||
modBlocksImmuneToRift.add(ModBlocks.GOLD_DIMENSIONAL_DOOR);
|
||||
modBlocksImmuneToRift.add(ModBlocks.GOLD_DOOR);
|
||||
modBlocksImmuneToRift.add(ModBlocks.PERSONAL_DIMENSIONAL_DOOR);
|
||||
modBlocksImmuneToRift.add(ModBlocks.QUARTZ_DOOR);
|
||||
|
||||
blocksImmuneToRift = new ArrayList<>();
|
||||
blocksImmuneToRift.add(ModBlocks.FABRIC);
|
||||
blocksImmuneToRift.add(ModBlocks.DIMENSIONAL_DOOR);
|
||||
blocksImmuneToRift.add(ModBlocks.WARP_DIMENSIONAL_DOOR);
|
||||
blocksImmuneToRift.add(ModBlocks.DIMENSIONAL_TRAPDOOR);
|
||||
blocksImmuneToRift.add(ModBlocks.UNSTABLE_DIMENSIONAL_DOOR);
|
||||
blocksImmuneToRift.add(ModBlocks.RIFT);
|
||||
blocksImmuneToRift.add(ModBlocks.TRANSIENT_DIMENSIONAL_DOOR);
|
||||
blocksImmuneToRift.add(ModBlocks.GOLD_DIMENSIONAL_DOOR);
|
||||
blocksImmuneToRift.add(ModBlocks.GOLD_DOOR);
|
||||
blocksImmuneToRift.add(ModBlocks.PERSONAL_DIMENSIONAL_DOOR);
|
||||
blocksImmuneToRift.add(ModBlocks.QUARTZ_DOOR);
|
||||
|
||||
blocksImmuneToRift.add(Blocks.LAPIS_BLOCK);
|
||||
blocksImmuneToRift.add(Blocks.IRON_BLOCK);
|
||||
blocksImmuneToRift.add(Blocks.GOLD_BLOCK);
|
||||
|
@ -141,39 +143,19 @@ public class BlockRift extends Block implements ITileEntityProvider {
|
|||
TileEntityFloatingRift tile = (TileEntityFloatingRift) worldIn.getTileEntity(pos);
|
||||
//renders an extra little blob on top of the actual rift location so its easier to find.
|
||||
// Eventually will only renderDoorRift if the player has the goggles.
|
||||
/*FMLClientHandler.instance().getClient().effectRenderer.addEffect(new GoggleRiftFX(
|
||||
//FMLClientHandler.instance().getClient().effectRenderer.addEffect(new GoggleRiftFX(
|
||||
/* worldIn,
|
||||
x + .5, y + .5, z + .5,
|
||||
rand.nextGaussian() * 0.01D,
|
||||
rand.nextGaussian() * 0.01D,
|
||||
rand.nextGaussian() * 0.01D));*/
|
||||
|
||||
if (tile.shouldClose) {//renders an opposite color effect if it is being closed by the rift remover
|
||||
FMLClientHandler.instance().getClient().effectRenderer.addEffect(new ClosingRiftFX(
|
||||
worldIn,
|
||||
x + .5, y + .5, z + .5,
|
||||
rand.nextGaussian() * 0.01D, rand.nextGaussian() * 0.01D, rand.nextGaussian() * 0.01D));
|
||||
*/
|
||||
//if (tile.shouldClose) {//renders an opposite color effect if it is being closed by the rift remover
|
||||
// FMLClientHandler.instance().getClient().effectRenderer.addEffect(new ClosingRiftFX(
|
||||
// worldIn,
|
||||
// x + .5, y + .5, z + .5,
|
||||
// rand.nextGaussian() * 0.01D, rand.nextGaussian() * 0.01D, rand.nextGaussian() * 0.01D));
|
||||
//} // TODO
|
||||
}
|
||||
|
||||
public boolean tryPlacingRift(World world, BlockPos pos) {
|
||||
return world != null && !isBlockImmune(world, pos)
|
||||
&& world.setBlockState(pos, getDefaultState()); //@todo This returns false, because this block does not have blockstates configured correctly. !isBlockImmune doesn't seem to be true either though...
|
||||
}
|
||||
|
||||
public boolean isBlockImmune(World world, BlockPos pos) {
|
||||
Block block = world.getBlockState(pos).getBlock();
|
||||
// SenseiKiwi: I've switched to using the block's blast resistance instead of its
|
||||
// hardness since most defensive blocks are meant to defend against explosions and
|
||||
// may have low hardness to make them easier to build with. However, block.getExplosionResistance()
|
||||
// is designed to receive an entity, the source of the blast. We have no entity so
|
||||
// I've set this to access blockResistance directly. Might need changing later.
|
||||
return block != null /* && block >= MIN_IMMUNE_RESISTANCE */ || modBlocksImmuneToRift.contains(block) || blocksImmuneToRift.contains(block);
|
||||
}
|
||||
|
||||
public boolean isModBlockImmune(World world, BlockPos pos) {
|
||||
// Check whether the block at the specified location is one of the
|
||||
// rift-resistant blocks from DD.
|
||||
Block block = world.getBlockState(pos).getBlock();
|
||||
return block != null && modBlocksImmuneToRift.contains(block);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -193,8 +175,8 @@ public class BlockRift extends Block implements ITileEntityProvider {
|
|||
|
||||
@Override
|
||||
public void breakBlock(World worldIn, BlockPos pos, IBlockState state) {
|
||||
TileEntityFloatingRift riftTile = (TileEntityFloatingRift) worldIn.getTileEntity(pos);
|
||||
|
||||
TileEntityFloatingRift rift = (TileEntityFloatingRift) worldIn.getTileEntity(pos);
|
||||
super.breakBlock(worldIn, pos, state);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -205,4 +187,9 @@ public class BlockRift extends Block implements ITileEntityProvider {
|
|||
public TileEntityFloatingRift getRiftTile(World world, BlockPos pos, IBlockState state) {
|
||||
return (TileEntityFloatingRift) world.getTileEntity(pos);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean onBlockActivated(World worldIn, BlockPos pos, IBlockState state, EntityPlayer playerIn, EnumHand hand, EnumFacing facing, float hitX, float hitY, float hitZ) {
|
||||
return false; // TODO
|
||||
}
|
||||
}
|
||||
|
|
|
@ -59,7 +59,7 @@ public class ItemRiftBlade extends ItemSword {
|
|||
RayTraceResult hit = rayTrace(worldIn, playerIn, true);
|
||||
if (RayTraceHelper.isRift(hit, worldIn)) {
|
||||
TileEntityFloatingRift rift = (TileEntityFloatingRift) worldIn.getTileEntity(hit.getBlockPos());
|
||||
rift.teleport(playerIn); // TODO: is this right?
|
||||
rift.teleport(playerIn);
|
||||
|
||||
stack.damageItem(1, playerIn);
|
||||
return new ActionResult<>(EnumActionResult.SUCCESS, stack);
|
||||
|
|
|
@ -1,8 +1,3 @@
|
|||
/*
|
||||
* To change this license header, choose License Headers in Project Properties.
|
||||
* To change this template file, choose Tools | Templates
|
||||
* and open the template in the editor.
|
||||
*/
|
||||
package com.zixiken.dimdoors.shared.items;
|
||||
|
||||
import com.zixiken.dimdoors.DimDoors;
|
||||
|
|
|
@ -1,8 +1,3 @@
|
|||
/*
|
||||
* To change this license header, choose License Headers in Project Properties.
|
||||
* To change this template file, choose Tools | Templates
|
||||
* and open the template in the editor.
|
||||
*/
|
||||
package com.zixiken.dimdoors.shared.pockets;
|
||||
|
||||
/**
|
||||
|
|
|
@ -132,7 +132,7 @@ public class Pocket { // TODO: better visibilities
|
|||
int index = 0;
|
||||
for (TileEntityRift rift : rifts) { // Find an entrance
|
||||
for (WeightedRiftDestination weightedPocketEntranceDest : rift.getDestinations()) {
|
||||
if (weightedPocketEntranceDest.getDestination().getType() == RiftDestination.DestinationType.POCKET_ENTRANCE) {
|
||||
if (weightedPocketEntranceDest.getDestination().getType() == RiftDestination.EnumType.POCKET_ENTRANCE) {
|
||||
entranceIndexWeights.put(index, weightedPocketEntranceDest.getWeight());
|
||||
rift.markDirty();
|
||||
index++;
|
||||
|
@ -148,7 +148,7 @@ public class Pocket { // TODO: better visibilities
|
|||
while (destIterator.hasNext()) {
|
||||
WeightedRiftDestination wdest = destIterator.next();
|
||||
RiftDestination dest = wdest.getDestination();
|
||||
if (dest.getType() == RiftDestination.DestinationType.POCKET_ENTRANCE) {
|
||||
if (dest.getType() == RiftDestination.EnumType.POCKET_ENTRANCE) {
|
||||
destIterator.remove();
|
||||
if (index == selectedEntranceIndex) {
|
||||
entrance = new Location(rift.getWorld(), rift.getPos());
|
||||
|
@ -176,7 +176,7 @@ public class Pocket { // TODO: better visibilities
|
|||
while (destIterator.hasNext()) {
|
||||
WeightedRiftDestination wdest = destIterator.next();
|
||||
RiftDestination dest = wdest.getDestination();
|
||||
if (dest.getType() == RiftDestination.DestinationType.POCKET_EXIT) {
|
||||
if (dest.getType() == RiftDestination.EnumType.POCKET_EXIT) {
|
||||
destIterator.remove();
|
||||
linkTo.withOldDestination(dest);
|
||||
rift.addDestination(linkTo, wdest.getWeight(), wdest.getGroup());
|
||||
|
|
|
@ -1,8 +1,3 @@
|
|||
/*
|
||||
* To change this license header, choose License Headers in Project Properties.
|
||||
* To change this template file, choose Tools | Templates
|
||||
* and open the template in the editor.
|
||||
*/
|
||||
package com.zixiken.dimdoors.shared.pockets;
|
||||
|
||||
import com.zixiken.dimdoors.shared.tileentities.TileEntityVerticalEntranceRift;
|
||||
|
|
|
@ -12,10 +12,10 @@ import java.util.List;
|
|||
|
||||
@Getter @ToString @EqualsAndHashCode @AllArgsConstructor(access = AccessLevel.PRIVATE)
|
||||
public /*abstract*/ class RiftDestination implements INBTStorable { // TODO: fix lombok and make this abstract
|
||||
@Getter private DestinationType type;
|
||||
@Getter private EnumType type;
|
||||
@Wither @Getter private RiftDestination oldDestination;
|
||||
|
||||
public enum DestinationType {
|
||||
public enum EnumType {
|
||||
RELATIVE, LOCAL, GLOBAL, NEW_PUBLIC, PRIVATE, LIMBO, RANDOM_RIFT_LINK, POCKET_ENTRANCE, POCKET_EXIT, PRIVATE_POCKET_EXIT, ESCAPE;
|
||||
}
|
||||
|
||||
|
@ -24,7 +24,7 @@ public /*abstract*/ class RiftDestination implements INBTStorable { // TODO: fix
|
|||
|
||||
public static RiftDestination readDestinationNBT(NBTTagCompound nbt) { // TODO: store old RANDOM_RIFT_LINK
|
||||
RiftDestination destination = null;
|
||||
DestinationType type = DestinationType.valueOf(nbt.getString("type"));
|
||||
EnumType type = EnumType.valueOf(nbt.getString("type"));
|
||||
switch (type) {
|
||||
case RELATIVE:
|
||||
destination = new RelativeDestination();
|
||||
|
@ -93,7 +93,7 @@ public /*abstract*/ class RiftDestination implements INBTStorable { // TODO: fix
|
|||
@Override
|
||||
public NBTTagCompound writeToNBT(NBTTagCompound nbt) {
|
||||
nbt = super.writeToNBT(nbt);
|
||||
nbt.setString("type", DestinationType.RELATIVE.name());
|
||||
nbt.setString("type", EnumType.RELATIVE.name());
|
||||
nbt.setInteger("xOffset", xOffset);
|
||||
nbt.setInteger("yOffset", yOffset);
|
||||
nbt.setInteger("yOffset", zOffset);
|
||||
|
@ -120,7 +120,7 @@ public /*abstract*/ class RiftDestination implements INBTStorable { // TODO: fix
|
|||
@Override
|
||||
public NBTTagCompound writeToNBT(NBTTagCompound nbt) {
|
||||
nbt = super.writeToNBT(nbt);
|
||||
nbt.setString("type", DestinationType.LOCAL.name());
|
||||
nbt.setString("type", EnumType.LOCAL.name());
|
||||
nbt.setInteger("x", x);
|
||||
nbt.setInteger("y", y);
|
||||
nbt.setInteger("y", z);
|
||||
|
@ -149,7 +149,7 @@ public /*abstract*/ class RiftDestination implements INBTStorable { // TODO: fix
|
|||
@Override
|
||||
public NBTTagCompound writeToNBT(NBTTagCompound nbt) {
|
||||
nbt = super.writeToNBT(nbt);
|
||||
nbt.setString("type", DestinationType.GLOBAL.name());
|
||||
nbt.setString("type", EnumType.GLOBAL.name());
|
||||
nbt.setInteger("dim", dim);
|
||||
nbt.setInteger("x", x);
|
||||
nbt.setInteger("y", y);
|
||||
|
@ -171,7 +171,7 @@ public /*abstract*/ class RiftDestination implements INBTStorable { // TODO: fix
|
|||
@Override
|
||||
public NBTTagCompound writeToNBT(NBTTagCompound nbt) {
|
||||
nbt = super.writeToNBT(nbt);
|
||||
nbt.setString("type", DestinationType.NEW_PUBLIC.name());
|
||||
nbt.setString("type", EnumType.NEW_PUBLIC.name());
|
||||
return nbt;
|
||||
}
|
||||
}
|
||||
|
@ -189,7 +189,7 @@ public /*abstract*/ class RiftDestination implements INBTStorable { // TODO: fix
|
|||
@Override
|
||||
public NBTTagCompound writeToNBT(NBTTagCompound nbt) {
|
||||
nbt = super.writeToNBT(nbt);
|
||||
nbt.setString("type", DestinationType.PRIVATE.name());
|
||||
nbt.setString("type", EnumType.PRIVATE.name());
|
||||
return nbt;
|
||||
}
|
||||
}
|
||||
|
@ -207,7 +207,7 @@ public /*abstract*/ class RiftDestination implements INBTStorable { // TODO: fix
|
|||
@Override
|
||||
public NBTTagCompound writeToNBT(NBTTagCompound nbt) {
|
||||
nbt = super.writeToNBT(nbt);
|
||||
nbt.setString("type", DestinationType.PRIVATE.name());
|
||||
nbt.setString("type", EnumType.PRIVATE.name());
|
||||
return nbt;
|
||||
}
|
||||
}
|
||||
|
@ -243,7 +243,7 @@ public /*abstract*/ class RiftDestination implements INBTStorable { // TODO: fix
|
|||
@Override
|
||||
public NBTTagCompound writeToNBT(NBTTagCompound nbt) {
|
||||
nbt = super.writeToNBT(nbt);
|
||||
nbt.setString("type", DestinationType.RANDOM_RIFT_LINK.name());
|
||||
nbt.setString("type", EnumType.RANDOM_RIFT_LINK.name());
|
||||
nbt.setFloat("newDungeonRiftProbability", newDungeonRiftProbability);
|
||||
nbt.setFloat("depthPenalization", depthPenalization);
|
||||
nbt.setFloat("distancePenalization", distancePenalization);
|
||||
|
@ -286,7 +286,7 @@ public /*abstract*/ class RiftDestination implements INBTStorable { // TODO: fix
|
|||
@Override
|
||||
public NBTTagCompound writeToNBT(NBTTagCompound nbt) {
|
||||
nbt = super.writeToNBT(nbt);
|
||||
nbt.setString("type", DestinationType.POCKET_ENTRANCE.name());
|
||||
nbt.setString("type", EnumType.POCKET_ENTRANCE.name());
|
||||
nbt.setFloat("weight", weight);
|
||||
|
||||
NBTTagList ifDestinationsNBT = new NBTTagList();
|
||||
|
@ -318,7 +318,7 @@ public /*abstract*/ class RiftDestination implements INBTStorable { // TODO: fix
|
|||
@Override
|
||||
public NBTTagCompound writeToNBT(NBTTagCompound nbt) {
|
||||
nbt = super.writeToNBT(nbt);
|
||||
nbt.setString("type", DestinationType.POCKET_EXIT.name());
|
||||
nbt.setString("type", EnumType.POCKET_EXIT.name());
|
||||
return nbt;
|
||||
}
|
||||
}
|
||||
|
@ -336,7 +336,7 @@ public /*abstract*/ class RiftDestination implements INBTStorable { // TODO: fix
|
|||
@Override
|
||||
public NBTTagCompound writeToNBT(NBTTagCompound nbt) {
|
||||
nbt = super.writeToNBT(nbt);
|
||||
nbt.setString("type", DestinationType.PRIVATE_POCKET_EXIT.name());
|
||||
nbt.setString("type", EnumType.PRIVATE_POCKET_EXIT.name());
|
||||
return nbt;
|
||||
}
|
||||
}
|
||||
|
@ -352,7 +352,7 @@ public /*abstract*/ class RiftDestination implements INBTStorable { // TODO: fix
|
|||
@Override
|
||||
public NBTTagCompound writeToNBT(NBTTagCompound nbt) {
|
||||
nbt = super.writeToNBT(nbt);
|
||||
nbt.setString("type", DestinationType.ESCAPE.name());
|
||||
nbt.setString("type", EnumType.ESCAPE.name());
|
||||
return nbt;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -19,6 +19,8 @@ import net.minecraft.entity.player.EntityPlayer;
|
|||
import net.minecraft.nbt.NBTBase;
|
||||
import net.minecraft.nbt.NBTTagCompound;
|
||||
import net.minecraft.nbt.NBTTagList;
|
||||
import net.minecraft.network.NetworkManager;
|
||||
import net.minecraft.network.play.server.SPacketUpdateTileEntity;
|
||||
import net.minecraft.tileentity.TileEntity;
|
||||
import net.minecraft.util.ITickable;
|
||||
import net.minecraft.util.math.BlockPos;
|
||||
|
@ -75,7 +77,7 @@ public abstract class TileEntityRift extends TileEntity implements ITickable { /
|
|||
|
||||
NBTTagList destinationsNBT = (NBTTagList) nbt.getTag("destinations");
|
||||
destinations = new ArrayList<>();
|
||||
for (NBTBase destinationNBT : destinationsNBT) {
|
||||
if (destinationsNBT != null) for (NBTBase destinationNBT : destinationsNBT) {
|
||||
WeightedRiftDestination destination = new WeightedRiftDestination();
|
||||
destination.readFromNBT((NBTTagCompound) destinationNBT);
|
||||
destinations.add(destination);
|
||||
|
@ -91,12 +93,13 @@ public abstract class TileEntityRift extends TileEntity implements ITickable { /
|
|||
public NBTTagCompound writeToNBT(NBTTagCompound nbt) {
|
||||
super.writeToNBT(nbt);
|
||||
|
||||
nbt.setTag("virtualLocation", virtualLocation.writeToNBT());
|
||||
if (virtualLocation != null) nbt.setTag("virtualLocation", virtualLocation.writeToNBT());
|
||||
|
||||
NBTTagList destinationsNBT = new NBTTagList();
|
||||
for (WeightedRiftDestination destination : destinations) {
|
||||
destinationsNBT.appendTag(destination.writeToNBT(nbt));
|
||||
}
|
||||
nbt.setTag("destinations", destinationsNBT);
|
||||
|
||||
nbt.setBoolean("makeDestinationPermanent", makeDestinationPermanent);
|
||||
nbt.setBoolean("preserveRotation", preserveRotation);
|
||||
|
@ -134,7 +137,7 @@ public abstract class TileEntityRift extends TileEntity implements ITickable { /
|
|||
Iterator<WeightedRiftDestination> destinationIterator = destinations.iterator();
|
||||
while (destinationIterator.hasNext()) {
|
||||
RiftDestination dest = destinationIterator.next().getDestination();
|
||||
if (dest.getType() == DestinationType.GLOBAL) {
|
||||
if (dest.getType() == EnumType.GLOBAL) {
|
||||
GlobalDestination globalDest = (GlobalDestination) dest;
|
||||
if (globalDest.getDim() == location.getDimID()
|
||||
&& globalDest.getX() == location.getPos().getX()
|
||||
|
@ -144,7 +147,7 @@ public abstract class TileEntityRift extends TileEntity implements ITickable { /
|
|||
destinationIterator.remove();
|
||||
}
|
||||
if (location.getDimID() == WorldUtils.getDim(world)) {
|
||||
if (dest.getType() == DestinationType.LOCAL) {
|
||||
if (dest.getType() == EnumType.LOCAL) {
|
||||
LocalDestination localDest = (LocalDestination) dest;
|
||||
if (localDest.getX() == location.getPos().getX()
|
||||
&& localDest.getY() == location.getPos().getY()
|
||||
|
@ -152,7 +155,7 @@ public abstract class TileEntityRift extends TileEntity implements ITickable { /
|
|||
unregisterDest(dest);
|
||||
destinationIterator.remove();
|
||||
}
|
||||
} else if (dest.getType() == DestinationType.RELATIVE) {
|
||||
} else if (dest.getType() == EnumType.RELATIVE) {
|
||||
RelativeDestination relativeDest = (RelativeDestination) dest;
|
||||
if (location.getPos().equals(pos.add(relativeDest.getXOffset(), relativeDest.getYOffset(), relativeDest.getZOffset()))) {
|
||||
unregisterDest(dest);
|
||||
|
@ -301,7 +304,7 @@ public abstract class TileEntityRift extends TileEntity implements ITickable { /
|
|||
if (uuid != null) {
|
||||
RiftRegistry privateRiftRegistry = RiftRegistry.getForDim(DimDoorDimensions.getPrivateDimID());
|
||||
destLoc = RiftRegistry.getEscapeRift(uuid);
|
||||
if (dest.getType() == DestinationType.PRIVATE_POCKET_EXIT) {
|
||||
if (dest.getType() == EnumType.PRIVATE_POCKET_EXIT) {
|
||||
privateRiftRegistry.setPrivatePocketEntrance(uuid, new Location(world, pos)); // Remember which exit was used for next time the pocket is entered
|
||||
}
|
||||
if (destLoc == null) return false; // TODO: The player probably teleported into the dungeon/private pocket and is now trying to escape... What should we do? Limbo?
|
||||
|
@ -368,4 +371,24 @@ public abstract class TileEntityRift extends TileEntity implements ITickable { /
|
|||
public boolean shouldRefresh(World world, BlockPos pos, IBlockState oldState, IBlockState newSate) {
|
||||
return oldState.getBlock() != newSate.getBlock();
|
||||
}
|
||||
|
||||
@Override
|
||||
public NBTTagCompound getUpdateTag() {
|
||||
return serializeNBT();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void handleUpdateTag(NBTTagCompound tag) {
|
||||
deserializeNBT(tag);
|
||||
}
|
||||
|
||||
@Override
|
||||
public SPacketUpdateTileEntity getUpdatePacket() {
|
||||
return new SPacketUpdateTileEntity(getPos(), 1, serializeNBT());
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onDataPacket(NetworkManager net, SPacketUpdateTileEntity pkt) {
|
||||
deserializeNBT(pkt.getNbtCompound());
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,6 +1,7 @@
|
|||
package com.zixiken.dimdoors.shared.tileentities;
|
||||
|
||||
import com.zixiken.dimdoors.shared.rifts.TileEntityRift;
|
||||
import com.zixiken.dimdoors.shared.util.RGBA;
|
||||
import lombok.Getter;
|
||||
import net.minecraft.entity.Entity;
|
||||
import net.minecraft.nbt.NBTTagCompound;
|
||||
|
@ -10,10 +11,15 @@ import java.util.Random;
|
|||
// TODO: merge horizontal and vertical entrances' render code into one, and support custom sizes
|
||||
public abstract class TileEntityEntranceRift extends TileEntityRift {
|
||||
@Getter private boolean placeRiftOnBreak = false;
|
||||
@Getter private boolean closeAfterPassThrough = false;
|
||||
|
||||
@Override
|
||||
public void copyFrom(TileEntityRift oldRift) {
|
||||
super.copyFrom(oldRift);
|
||||
if (oldRift instanceof TileEntityEntranceRift) {
|
||||
TileEntityEntranceRift oldEntranceRift = (TileEntityEntranceRift) oldRift;
|
||||
closeAfterPassThrough = oldEntranceRift.closeAfterPassThrough;
|
||||
}
|
||||
placeRiftOnBreak = true;
|
||||
}
|
||||
|
||||
|
@ -21,12 +27,14 @@ public abstract class TileEntityEntranceRift extends TileEntityRift {
|
|||
public void readFromNBT(NBTTagCompound nbt) {
|
||||
super.readFromNBT(nbt);
|
||||
placeRiftOnBreak = nbt.getBoolean("placeRiftOnBreak");
|
||||
closeAfterPassThrough = nbt.getBoolean("closeAfterPassThrough");
|
||||
}
|
||||
|
||||
@Override
|
||||
public NBTTagCompound writeToNBT(NBTTagCompound nbt) {
|
||||
super.writeToNBT(nbt);
|
||||
nbt.setBoolean("placeRiftOnBreak", placeRiftOnBreak);
|
||||
nbt.setBoolean("closeAfterPassThrough", closeAfterPassThrough);
|
||||
return nbt;
|
||||
}
|
||||
|
||||
|
@ -52,21 +60,21 @@ public abstract class TileEntityEntranceRift extends TileEntityRift {
|
|||
return status;
|
||||
}
|
||||
|
||||
public float[] getEntranceRenderColor(Random rand) { // Use RGBA instead? Would that be slow because of object creation?
|
||||
public RGBA getEntranceRenderColor(Random rand) { // TODO: custom color
|
||||
float red, green, blue;
|
||||
switch(world.provider.getDimension()) {
|
||||
case -1: // Nether
|
||||
red = rand.nextFloat() * 0.5F + 0.1F;
|
||||
green = rand.nextFloat() * 0.4F + 0.4F;
|
||||
blue = rand.nextFloat() * 0.6F + 0.5F;
|
||||
break;
|
||||
default:
|
||||
red = rand.nextFloat() * 0.5F + 0.4F;
|
||||
green = rand.nextFloat() * 0.05F;
|
||||
blue = rand.nextFloat() * 0.05F;
|
||||
break;
|
||||
default:
|
||||
red = rand.nextFloat() * 0.5F + 0.1F;
|
||||
green = rand.nextFloat() * 0.4F + 0.4F;
|
||||
blue = rand.nextFloat() * 0.6F + 0.5F;
|
||||
break;
|
||||
}
|
||||
return new float[] {red, green, blue, 1};
|
||||
return new RGBA(red, green, blue, 1);
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -26,7 +26,7 @@ public class TileEntityFloatingRift extends TileEntityRift implements ITickable
|
|||
|
||||
//Need to be saved:
|
||||
private int updateTimer;
|
||||
public boolean shouldClose = false;
|
||||
public boolean shouldClose = false; // TODO
|
||||
public int spawnedEndermenID = 0;
|
||||
public float growth = 0;
|
||||
|
||||
|
|
|
@ -5,7 +5,7 @@ import net.minecraft.nbt.NBTTagCompound;
|
|||
import net.minecraft.util.EnumFacing;
|
||||
import net.minecraft.util.math.BlockPos;
|
||||
|
||||
public class TileEntityVerticalEntranceRift extends TileEntityEntranceRift {
|
||||
public class TileEntityVerticalEntranceRift extends TileEntityEntranceRift { // TODO: make builder?
|
||||
|
||||
public boolean doorShouldRender = true;
|
||||
public EnumFacing orientation = EnumFacing.SOUTH;
|
||||
|
@ -34,6 +34,8 @@ public class TileEntityVerticalEntranceRift extends TileEntityEntranceRift {
|
|||
public void teleportTo(Entity entity) {
|
||||
super.teleportTo(entity);
|
||||
BlockPos offsetPos = entity.getPosition().offset(orientation);
|
||||
entity.setPosition(offsetPos.getX(), offsetPos.getY(), offsetPos.getZ());
|
||||
entity.setPositionAndRotation(offsetPos.getX(), offsetPos.getY(), offsetPos.getZ(), orientation.getHorizontalAngle(), 0); // TODO: let TileEntityRift handle rotation?
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
|
|
@ -1,8 +1,3 @@
|
|||
/*
|
||||
* To change this license header, choose License Headers in Project Properties.
|
||||
* To change this template file, choose Tools | Templates
|
||||
* and open the template in the editor.
|
||||
*/
|
||||
package com.zixiken.dimdoors.shared.util;
|
||||
|
||||
import java.util.Map;
|
||||
|
|
|
@ -1,8 +1,3 @@
|
|||
/*
|
||||
* To change this license header, choose License Headers in Project Properties.
|
||||
* To change this template file, choose Tools | Templates
|
||||
* and open the template in the editor.
|
||||
*/
|
||||
package com.zixiken.dimdoors.shared.util;
|
||||
|
||||
import com.zixiken.dimdoors.DimDoors;
|
||||
|
|
|
@ -124,11 +124,11 @@ public class SchematicConverter {
|
|||
blockInt = schematic.pallette.indexOf(additionalState);
|
||||
} else {
|
||||
schematic.pallette.add(additionalState);
|
||||
DimDoors.log(Schematic.class, "New blockstate detected. Original blockInt = " + blockInt + " and baseState is " + baseState);
|
||||
// DimDoors.log(Schematic.class, "New blockstate detected. Original blockInt = " + blockInt + " and baseState is " + baseState);
|
||||
blockInt = schematic.pallette.size() - 1;
|
||||
}
|
||||
} else { //if this is ancient fabric
|
||||
//DimDoors.log(Schematic.class, "Non-default blockstate in palette detected. Original blockInt = " + blockInt + " and baseState is " + baseState.toString()); //@todo should only print a line on load of ancient fabric
|
||||
// DimDoors.log(Schematic.class, "Non-default blockstate in palette detected. Original blockInt = " + blockInt + " and baseState is " + baseState.toString()); //@todo should only print a line on load of ancient fabric
|
||||
blockInt = schematic.pallette.indexOf(baseState);
|
||||
}
|
||||
schematic.blockData[x][y][z] = blockInt;
|
||||
|
|
|
@ -1,8 +1,3 @@
|
|||
/*
|
||||
* To change this license header, choose License Headers in Project Properties.
|
||||
* To change this template file, choose Tools | Templates
|
||||
* and open the template in the editor.
|
||||
*/
|
||||
package com.zixiken.dimdoors.shared.util;
|
||||
|
||||
import java.util.ArrayList;
|
||||
|
|
Loading…
Reference in a new issue