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() {
|
public void registerRenderers() {
|
||||||
ClientRegistry.bindTileEntitySpecialRenderer(TileEntityVerticalEntranceRift.class, new RenderDimDoor());
|
ClientRegistry.bindTileEntitySpecialRenderer(TileEntityVerticalEntranceRift.class, new RenderVerticalEntranceRift());
|
||||||
ClientRegistry.bindTileEntitySpecialRenderer(TileEntityHorizontalEntranceRift.class, new RenderTransTrapdoor());
|
ClientRegistry.bindTileEntitySpecialRenderer(TileEntityHorizontalEntranceRift.class, new RenderHorizontalEntranceRift());
|
||||||
ClientRegistry.bindTileEntitySpecialRenderer(TileEntityFloatingRift.class, new RenderRift());
|
ClientRegistry.bindTileEntitySpecialRenderer(TileEntityFloatingRift.class, new RenderRift());
|
||||||
RenderingRegistry.registerEntityRenderingHandler(MobMonolith.class, manager -> new RenderMobObelisk(manager, 0.5f));
|
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;
|
import org.lwjgl.opengl.GL11;
|
||||||
|
|
||||||
@SideOnly(Side.CLIENT)
|
@SideOnly(Side.CLIENT)
|
||||||
public class RenderTransTrapdoor extends TileEntitySpecialRenderer<TileEntityHorizontalEntranceRift> {
|
public class RenderHorizontalEntranceRift extends TileEntitySpecialRenderer<TileEntityHorizontalEntranceRift> {
|
||||||
|
|
||||||
private FloatBuffer buffer = GLAllocation.createDirectFloatBuffer(16);
|
private FloatBuffer buffer = GLAllocation.createDirectFloatBuffer(16);
|
||||||
private ResourceLocation riftPath = new ResourceLocation(DimDoors.MODID + ":textures/other/rift.png");
|
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.DimDoors;
|
||||||
import com.zixiken.dimdoors.shared.blocks.BlockDimDoorBase;
|
import com.zixiken.dimdoors.shared.blocks.BlockDimDoorBase;
|
||||||
import com.zixiken.dimdoors.shared.tileentities.TileEntityVerticalEntranceRift;
|
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.*;
|
||||||
import net.minecraft.client.renderer.vertex.*;
|
import net.minecraft.client.renderer.vertex.*;
|
||||||
import net.minecraft.util.EnumFacing;
|
import net.minecraft.util.EnumFacing;
|
||||||
|
@ -19,7 +22,7 @@ import net.minecraft.util.ResourceLocation;
|
||||||
|
|
||||||
import static org.lwjgl.opengl.GL11.*;
|
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 FloatBuffer buffer = GLAllocation.createDirectFloatBuffer(16);
|
||||||
private ResourceLocation warpPath = new ResourceLocation(DimDoors.MODID + ":textures/other/warp.png");
|
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);
|
GL11.glDisable(GL11.GL_LIGHTING);
|
||||||
Random rand = new Random(31100L);
|
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) {
|
for (int count = 0; count < 16; ++count) {
|
||||||
GlStateManager.pushMatrix();
|
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.R, GL11.GL_OBJECT_LINEAR);
|
||||||
GlStateManager.texGen(GlStateManager.TexGen.Q, GL11.GL_OBJECT_LINEAR);
|
GlStateManager.texGen(GlStateManager.TexGen.Q, GL11.GL_OBJECT_LINEAR);
|
||||||
|
|
||||||
EnumFacing orientation = tile.orientation.rotateYCCW();
|
|
||||||
|
|
||||||
switch (orientation) {
|
switch (orientation) {
|
||||||
case SOUTH:
|
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.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.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.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));
|
GlStateManager.texGen(GlStateManager.TexGen.Q, GL11.GL_OBJECT_PLANE, getFloatBuffer(1.0F, 0.0F, 0.0F, 0.15F));
|
||||||
break;
|
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.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.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.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));
|
GlStateManager.texGen(GlStateManager.TexGen.Q, GL11.GL_OBJECT_PLANE, getFloatBuffer(0.0F, 0.0F, 1.0F, 0.15F));
|
||||||
break;
|
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.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.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.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));
|
GlStateManager.texGen(GlStateManager.TexGen.Q, GL11.GL_OBJECT_PLANE, getFloatBuffer(1.0F, 0.0F, 0.0F, -0.15F));
|
||||||
break;
|
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);
|
GlStateManager.enableTexGenCoord(GlStateManager.TexGen.S);
|
||||||
|
@ -115,58 +121,34 @@ public class RenderDimDoor extends TileEntitySpecialRenderer<TileEntityVerticalE
|
||||||
BufferBuilder worldRenderer = tessellator.getBuffer();
|
BufferBuilder worldRenderer = tessellator.getBuffer();
|
||||||
worldRenderer.begin(GL11.GL_QUADS, DefaultVertexFormats.POSITION);
|
worldRenderer.begin(GL11.GL_QUADS, DefaultVertexFormats.POSITION);
|
||||||
|
|
||||||
float[] color = tile.getEntranceRenderColor(rand); // TODO: cache this since it's constant
|
RGBA color = tile.getEntranceRenderColor(rand); // TODO: cache this since it's constant
|
||||||
GlStateManager.color(color[0] * var17, color[1] * var17, color[2] * var17, color[3]);
|
GlStateManager.color(color.getRed() * var17, color.getGreen() * var17, color.getBlue() * var17, color.getAlpha());
|
||||||
|
|
||||||
switch (orientation) {
|
switch (orientation) {
|
||||||
case SOUTH:
|
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, 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 + 1, y + 1, z + .99).endVertex();
|
worldRenderer.pos(x + 1, y + 1, z + .99).endVertex();
|
||||||
worldRenderer.pos(x, y + 1, z + .99).endVertex();
|
worldRenderer.pos(x, y + 1, z + .99).endVertex();
|
||||||
break;
|
break;
|
||||||
/*case 4:
|
case WEST:
|
||||||
GL11.glVertex3d(x + .15F, y - 1 , z);
|
worldRenderer.pos(x + .01, y - 1, z).endVertex();
|
||||||
GL11.glVertex3d(x + .15, y - 1, z + 1.0D);
|
worldRenderer.pos(x + .01, y - 1, z + 1.0D).endVertex();
|
||||||
GL11.glVertex3d(x + .15, y + 1, z + 1.0D);
|
worldRenderer.pos(x + .01, y + 1, z + 1.0D).endVertex();
|
||||||
GL11.glVertex3d(x + .15, y + 1, z);
|
worldRenderer.pos(x + .01, y + 1, z).endVertex();
|
||||||
break;
|
break;
|
||||||
case 5:
|
case NORTH:
|
||||||
GL11.glVertex3d(x, y + 1, z + .15);
|
worldRenderer.pos(x, y + 1, z + .01).endVertex();
|
||||||
GL11.glVertex3d(x + 1, y + 1, z + .15);
|
worldRenderer.pos(x + 1, y + 1, z + .01).endVertex();
|
||||||
GL11.glVertex3d(x + 1, y - 1, z + .15);
|
worldRenderer.pos(x + 1, y - 1, z + .01).endVertex();
|
||||||
GL11.glVertex3d(x, y - 1, z + .15);
|
worldRenderer.pos(x, y - 1, z + .01).endVertex();
|
||||||
break;
|
break;
|
||||||
case 6:
|
case EAST:
|
||||||
GL11.glVertex3d(x + .85, y + 1, z);
|
worldRenderer.pos(x + .99, y + 1, z).endVertex();
|
||||||
GL11.glVertex3d(x + .85, y + 1, z + 1.0D);
|
worldRenderer.pos(x + .99, y + 1, z + 1.0D).endVertex();
|
||||||
GL11.glVertex3d(x + .85, y - 1, z + 1.0D);
|
worldRenderer.pos(x + .99, y - 1, z + 1.0D).endVertex();
|
||||||
GL11.glVertex3d(x + .85, y - 1, z);
|
worldRenderer.pos(x + .99, y - 1, z).endVertex();
|
||||||
break;
|
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();
|
tessellator.draw();
|
||||||
|
@ -207,16 +189,17 @@ public class RenderDimDoor extends TileEntitySpecialRenderer<TileEntityVerticalE
|
||||||
|
|
||||||
switch (rotation) {
|
switch (rotation) {
|
||||||
case SOUTH:
|
case SOUTH:
|
||||||
GL11.glTranslatef(-0.5F, 0, -0.03F);
|
GL11.glTranslatef(0.5F, 0F, -0.03F);
|
||||||
break;
|
break;
|
||||||
case WEST:
|
case WEST:
|
||||||
GL11.glTranslatef(-.5F, 0F, .97F);
|
GL11.glTranslatef(-0.5F, 0, -0.03F);
|
||||||
break;
|
break;
|
||||||
case NORTH:
|
case NORTH:
|
||||||
GL11.glTranslatef(.5F, 0F, .97F);
|
GL11.glTranslatef(-.5F, 0F, .97F);
|
||||||
break;
|
break;
|
||||||
case EAST:
|
case EAST:
|
||||||
GL11.glTranslatef(0.5F, 0F, -0.03F);
|
GL11.glTranslatef(.5F, 0F, .97F);
|
||||||
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
GL11.glDisable(GL_LIGHTING);
|
GL11.glDisable(GL_LIGHTING);
|
|
@ -48,9 +48,9 @@ public abstract class DDProxyCommon implements IDDProxy {
|
||||||
if (tile instanceof TileEntityVerticalEntranceRift) {
|
if (tile instanceof TileEntityVerticalEntranceRift) {
|
||||||
TileEntityVerticalEntranceRift dimTile = (TileEntityVerticalEntranceRift) tile;
|
TileEntityVerticalEntranceRift dimTile = (TileEntityVerticalEntranceRift) tile;
|
||||||
IBlockState state = world.getBlockState(pos.down());
|
IBlockState state = world.getBlockState(pos.down());
|
||||||
dimTile.orientation = state.getBlock() instanceof BlockDimDoorBase
|
//dimTile.orientation = state.getBlock() instanceof BlockDimDoorBase
|
||||||
? state.getValue(BlockDoor.FACING).getOpposite()
|
// ? state.getValue(BlockDoor.FACING).getOpposite()
|
||||||
: ModBlocks.DIMENSIONAL_DOOR.getDefaultState().getValue(BlockDoor.FACING);
|
// : ModBlocks.DIMENSIONAL_DOOR.getDefaultState().getValue(BlockDoor.FACING);
|
||||||
// dimTile.doorShouldRender = door.isDoorOnRift(world, pos) && door.isUpperDoorBlock(world.getBlockState(pos));
|
// dimTile.doorShouldRender = door.isDoorOnRift(world, pos) && door.isUpperDoorBlock(world.getBlockState(pos));
|
||||||
dimTile.lockStatus = 0; //@todo
|
dimTile.lockStatus = 0; //@todo
|
||||||
dimTile.markDirty();
|
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;
|
package com.zixiken.dimdoors.shared;
|
||||||
|
|
||||||
import net.minecraft.entity.player.EntityPlayer;
|
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.TileEntityEntranceRift;
|
||||||
import com.zixiken.dimdoors.shared.tileentities.TileEntityVerticalEntranceRift;
|
import com.zixiken.dimdoors.shared.tileentities.TileEntityVerticalEntranceRift;
|
||||||
import com.zixiken.dimdoors.shared.rifts.TileEntityRift;
|
import com.zixiken.dimdoors.shared.rifts.TileEntityRift;
|
||||||
|
import net.minecraft.block.Block;
|
||||||
import net.minecraft.block.BlockDoor;
|
import net.minecraft.block.BlockDoor;
|
||||||
import net.minecraft.block.ITileEntityProvider;
|
import net.minecraft.block.ITileEntityProvider;
|
||||||
import net.minecraft.block.material.Material;
|
import net.minecraft.block.material.Material;
|
||||||
|
@ -21,7 +22,7 @@ import net.minecraft.util.EnumHand;
|
||||||
import net.minecraft.util.math.BlockPos;
|
import net.minecraft.util.math.BlockPos;
|
||||||
import net.minecraft.world.World;
|
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) {
|
public BlockDimDoorBase(Material material) {
|
||||||
super(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) {
|
public void onEntityCollidedWithBlock(World worldIn, BlockPos pos, IBlockState state, Entity entityIn) {
|
||||||
if (state.getValue(HALF) == EnumDoorHalf.UPPER) pos = pos.down();
|
if (state.getValue(HALF) == EnumDoorHalf.UPPER) pos = pos.down();
|
||||||
IBlockState doorState = worldIn.getBlockState(pos);
|
IBlockState doorState = worldIn.getBlockState(pos);
|
||||||
|
if (!(doorState.getBlock() instanceof BlockDoor)) return;
|
||||||
if (doorState.getValue(BlockDoor.OPEN) && entityIn.timeUntilPortal == 0) {
|
if (doorState.getValue(BlockDoor.OPEN) && entityIn.timeUntilPortal == 0) {
|
||||||
entityIn.timeUntilPortal = 50; // 2.5s
|
entityIn.timeUntilPortal = 50; // 2.5s
|
||||||
toggleDoor(worldIn, pos, false);
|
toggleDoor(worldIn, pos, false);
|
||||||
TileEntityRift rift = getRiftTile(worldIn, pos, worldIn.getBlockState(pos));
|
TileEntityEntranceRift rift = getRift(worldIn, pos, state);
|
||||||
if (!rift.teleport(entityIn) && entityIn instanceof EntityPlayer) {
|
if (!rift.teleport(entityIn) && entityIn instanceof EntityPlayer) {
|
||||||
DimDoors.chat((EntityPlayer) entityIn, "Teleporting failed because this entrance has no destinations!");
|
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) {
|
if (iblockstate.getBlock() != this) {
|
||||||
return false;
|
return false;
|
||||||
} else {
|
} 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;
|
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
|
public boolean checkCanOpen(World world, BlockPos pos, EntityPlayer player) { // TODO: locking system
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
@ -88,31 +105,44 @@ public abstract class BlockDimDoorBase extends BlockDoor implements ITileEntityP
|
||||||
return new ItemStack(getItem());
|
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
|
@Override
|
||||||
public TileEntity createNewTileEntity(World worldIn, int meta) {
|
public TileEntityVerticalEntranceRift createNewTileEntity(World worldIn, int meta) {
|
||||||
return new TileEntityVerticalEntranceRift();
|
return new TileEntityVerticalEntranceRift();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void breakBlock(World worldIn, BlockPos pos, IBlockState state) {
|
public void breakBlock(World worldIn, BlockPos pos, IBlockState state) {
|
||||||
if (!hasTileEntity(state)) return;
|
if (!hasTileEntity(state)) return;
|
||||||
|
TileEntityEntranceRift origRift = getRift(worldIn, pos, state);
|
||||||
TileEntityEntranceRift origRift = (TileEntityEntranceRift) worldIn.getTileEntity(pos);
|
|
||||||
super.breakBlock(worldIn, pos, state);
|
super.breakBlock(worldIn, pos, state);
|
||||||
if (origRift.isPlaceRiftOnBreak()) {
|
if (origRift.isPlaceRiftOnBreak()) {
|
||||||
worldIn.setBlockState(pos, ModBlocks.RIFT.getDefaultState());
|
worldIn.setBlockState(pos, ModBlocks.RIFT.getDefaultState());
|
||||||
TileEntityRift newRift = (TileEntityRift) worldIn.getTileEntity(pos);
|
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;
|
TileEntity tileEntity;
|
||||||
if (state.getValue(BlockDoor.HALF) == EnumDoorHalf.LOWER) {
|
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 {
|
} else {
|
||||||
tileEntity = world.getTileEntity(pos);
|
tileEntity = world.getTileEntity(pos);
|
||||||
|
if (!(tileEntity instanceof TileEntityRift)) tileEntity = world.getTileEntity(pos.down());
|
||||||
}
|
}
|
||||||
return (TileEntityEntranceRift) tileEntity;
|
return (TileEntityEntranceRift) tileEntity;
|
||||||
}
|
}
|
||||||
|
|
|
@ -24,9 +24,4 @@ public class BlockDimDoorGold extends BlockDimDoorBase {
|
||||||
public Item getItem() {
|
public Item getItem() {
|
||||||
return ModItems.GOLD_DIMENSIONAL_DOOR;
|
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() {
|
public Item getItem() {
|
||||||
return ModItems.PERSONAL_DIMENSIONAL_DOOR;
|
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));
|
setRegistryName(new ResourceLocation(DimDoors.MODID, ID));
|
||||||
}
|
}
|
||||||
|
|
||||||
// TODO: close after use
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Item getItem() {
|
public Item getItem() {
|
||||||
return null;
|
return null;
|
||||||
|
@ -25,6 +23,6 @@ public class BlockDimDoorTransient extends BlockDimDoorBase { // TODO: convert t
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean isCollidable() {
|
public boolean isCollidable() {
|
||||||
return true;
|
return false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -5,6 +5,7 @@ import com.zixiken.dimdoors.shared.items.ModItems;
|
||||||
import java.util.Random;
|
import java.util.Random;
|
||||||
|
|
||||||
import com.zixiken.dimdoors.shared.tileentities.TileEntityVerticalEntranceRift;
|
import com.zixiken.dimdoors.shared.tileentities.TileEntityVerticalEntranceRift;
|
||||||
|
import net.minecraft.block.BlockDoor;
|
||||||
import net.minecraft.block.material.Material;
|
import net.minecraft.block.material.Material;
|
||||||
import net.minecraft.block.state.IBlockState;
|
import net.minecraft.block.state.IBlockState;
|
||||||
import net.minecraft.init.Items;
|
import net.minecraft.init.Items;
|
||||||
|
@ -22,7 +23,7 @@ public class BlockDimDoorUnstable extends BlockDimDoorBase {
|
||||||
setHardness(.2F);
|
setHardness(.2F);
|
||||||
setUnlocalizedName(ID);
|
setUnlocalizedName(ID);
|
||||||
setRegistryName(new ResourceLocation(DimDoors.MODID, ID));
|
setRegistryName(new ResourceLocation(DimDoors.MODID, ID));
|
||||||
setLightLevel(.0F);
|
setLightLevel(0.0F);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -32,11 +33,6 @@ public class BlockDimDoorUnstable extends BlockDimDoorBase {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Item getItemDropped(IBlockState state, Random rand, int fortune) {
|
public Item getItemDropped(IBlockState state, Random rand, int fortune) {
|
||||||
return Items.IRON_DOOR;
|
return state.getValue(HALF) == BlockDoor.EnumDoorHalf.UPPER ? Items.AIR : Items.IRON_DOOR;
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public TileEntity createNewTileEntity(World worldIn, int meta) {
|
|
||||||
return new TileEntityVerticalEntranceRift();
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -24,9 +24,4 @@ public class BlockDimDoorWarp extends BlockDimDoorBase {
|
||||||
public Item getItem() {
|
public Item getItem() {
|
||||||
return ModItems.WARP_DIMENSIONAL_DOOR;
|
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.Side;
|
||||||
import net.minecraftforge.fml.relauncher.SideOnly;
|
import net.minecraftforge.fml.relauncher.SideOnly;
|
||||||
|
|
||||||
@SuppressWarnings("deprecation")
|
|
||||||
public class BlockFabric extends Block {
|
public class BlockFabric extends Block {
|
||||||
|
|
||||||
public static final String ID = "fabric";
|
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_HIGH_HARDNESS = 10000000000000F;
|
||||||
private static final float SUPER_EXPLOSION_RESISTANCE = 18000000F;
|
private static final float SUPER_EXPLOSION_RESISTANCE = 18000000F;
|
||||||
|
@ -55,7 +54,6 @@ public class BlockFabric extends Block {
|
||||||
public String toString() {
|
public String toString() {
|
||||||
return name;
|
return name;
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public BlockFabric() {
|
public BlockFabric() {
|
||||||
|
|
|
@ -1,11 +1,14 @@
|
||||||
package com.zixiken.dimdoors.shared.blocks;
|
package com.zixiken.dimdoors.shared.blocks;
|
||||||
|
|
||||||
import com.zixiken.dimdoors.DimDoors;
|
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.items.ModItems;
|
||||||
import com.zixiken.dimdoors.shared.tileentities.TileEntityFloatingRift;
|
import com.zixiken.dimdoors.shared.tileentities.TileEntityFloatingRift;
|
||||||
|
|
||||||
import java.util.*;
|
import java.util.*;
|
||||||
import net.minecraft.block.Block;
|
import net.minecraft.block.Block;
|
||||||
|
import net.minecraft.block.BlockDoor;
|
||||||
import net.minecraft.block.BlockLiquid;
|
import net.minecraft.block.BlockLiquid;
|
||||||
import net.minecraft.block.ITileEntityProvider;
|
import net.minecraft.block.ITileEntityProvider;
|
||||||
import net.minecraft.block.material.EnumPushReaction;
|
import net.minecraft.block.material.EnumPushReaction;
|
||||||
|
@ -19,6 +22,7 @@ import net.minecraft.item.ItemStack;
|
||||||
import net.minecraft.tileentity.TileEntity;
|
import net.minecraft.tileentity.TileEntity;
|
||||||
import net.minecraft.util.EnumBlockRenderType;
|
import net.minecraft.util.EnumBlockRenderType;
|
||||||
import net.minecraft.util.EnumFacing;
|
import net.minecraft.util.EnumFacing;
|
||||||
|
import net.minecraft.util.EnumHand;
|
||||||
import net.minecraft.util.ResourceLocation;
|
import net.minecraft.util.ResourceLocation;
|
||||||
import net.minecraft.util.math.AxisAlignedBB;
|
import net.minecraft.util.math.AxisAlignedBB;
|
||||||
import net.minecraft.util.math.BlockPos;
|
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.IBlockAccess;
|
||||||
import net.minecraft.world.World;
|
import net.minecraft.world.World;
|
||||||
import net.minecraftforge.fluids.IFluidBlock;
|
import net.minecraftforge.fluids.IFluidBlock;
|
||||||
|
import net.minecraftforge.fml.client.FMLClientHandler;
|
||||||
import net.minecraftforge.fml.relauncher.Side;
|
import net.minecraftforge.fml.relauncher.Side;
|
||||||
import net.minecraftforge.fml.relauncher.SideOnly;
|
import net.minecraftforge.fml.relauncher.SideOnly;
|
||||||
|
|
||||||
@SuppressWarnings("deprecation")
|
|
||||||
public class BlockRift extends Block implements ITileEntityProvider {
|
public class BlockRift extends Block implements ITileEntityProvider {
|
||||||
|
|
||||||
public static final String ID = "rift";
|
public static final String ID = "rift";
|
||||||
|
|
||||||
private final ArrayList<Block> blocksImmuneToRift; // List of Vanilla blocks immune to rifts
|
private final ArrayList<Block> blocksImmuneToRift; // TODO
|
||||||
private final ArrayList<Block> modBlocksImmuneToRift; // List of DD blocks immune to rifts
|
|
||||||
|
|
||||||
public BlockRift() {
|
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...
|
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);
|
setUnlocalizedName(ID);
|
||||||
setRegistryName(new ResourceLocation(DimDoors.MODID, 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 = 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.LAPIS_BLOCK);
|
||||||
blocksImmuneToRift.add(Blocks.IRON_BLOCK);
|
blocksImmuneToRift.add(Blocks.IRON_BLOCK);
|
||||||
blocksImmuneToRift.add(Blocks.GOLD_BLOCK);
|
blocksImmuneToRift.add(Blocks.GOLD_BLOCK);
|
||||||
|
@ -141,39 +143,19 @@ public class BlockRift extends Block implements ITileEntityProvider {
|
||||||
TileEntityFloatingRift tile = (TileEntityFloatingRift) worldIn.getTileEntity(pos);
|
TileEntityFloatingRift tile = (TileEntityFloatingRift) worldIn.getTileEntity(pos);
|
||||||
//renders an extra little blob on top of the actual rift location so its easier to find.
|
//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.
|
// 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,
|
worldIn,
|
||||||
x + .5, y + .5, z + .5,
|
x + .5, y + .5, z + .5,
|
||||||
rand.nextGaussian() * 0.01D, rand.nextGaussian() * 0.01D, rand.nextGaussian() * 0.01D));
|
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
|
@Override
|
||||||
|
@ -193,8 +175,8 @@ public class BlockRift extends Block implements ITileEntityProvider {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void breakBlock(World worldIn, BlockPos pos, IBlockState state) {
|
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
|
@Override
|
||||||
|
@ -205,4 +187,9 @@ public class BlockRift extends Block implements ITileEntityProvider {
|
||||||
public TileEntityFloatingRift getRiftTile(World world, BlockPos pos, IBlockState state) {
|
public TileEntityFloatingRift getRiftTile(World world, BlockPos pos, IBlockState state) {
|
||||||
return (TileEntityFloatingRift) world.getTileEntity(pos);
|
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);
|
RayTraceResult hit = rayTrace(worldIn, playerIn, true);
|
||||||
if (RayTraceHelper.isRift(hit, worldIn)) {
|
if (RayTraceHelper.isRift(hit, worldIn)) {
|
||||||
TileEntityFloatingRift rift = (TileEntityFloatingRift) worldIn.getTileEntity(hit.getBlockPos());
|
TileEntityFloatingRift rift = (TileEntityFloatingRift) worldIn.getTileEntity(hit.getBlockPos());
|
||||||
rift.teleport(playerIn); // TODO: is this right?
|
rift.teleport(playerIn);
|
||||||
|
|
||||||
stack.damageItem(1, playerIn);
|
stack.damageItem(1, playerIn);
|
||||||
return new ActionResult<>(EnumActionResult.SUCCESS, stack);
|
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;
|
package com.zixiken.dimdoors.shared.items;
|
||||||
|
|
||||||
import com.zixiken.dimdoors.DimDoors;
|
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;
|
package com.zixiken.dimdoors.shared.pockets;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
|
@ -132,7 +132,7 @@ public class Pocket { // TODO: better visibilities
|
||||||
int index = 0;
|
int index = 0;
|
||||||
for (TileEntityRift rift : rifts) { // Find an entrance
|
for (TileEntityRift rift : rifts) { // Find an entrance
|
||||||
for (WeightedRiftDestination weightedPocketEntranceDest : rift.getDestinations()) {
|
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());
|
entranceIndexWeights.put(index, weightedPocketEntranceDest.getWeight());
|
||||||
rift.markDirty();
|
rift.markDirty();
|
||||||
index++;
|
index++;
|
||||||
|
@ -148,7 +148,7 @@ public class Pocket { // TODO: better visibilities
|
||||||
while (destIterator.hasNext()) {
|
while (destIterator.hasNext()) {
|
||||||
WeightedRiftDestination wdest = destIterator.next();
|
WeightedRiftDestination wdest = destIterator.next();
|
||||||
RiftDestination dest = wdest.getDestination();
|
RiftDestination dest = wdest.getDestination();
|
||||||
if (dest.getType() == RiftDestination.DestinationType.POCKET_ENTRANCE) {
|
if (dest.getType() == RiftDestination.EnumType.POCKET_ENTRANCE) {
|
||||||
destIterator.remove();
|
destIterator.remove();
|
||||||
if (index == selectedEntranceIndex) {
|
if (index == selectedEntranceIndex) {
|
||||||
entrance = new Location(rift.getWorld(), rift.getPos());
|
entrance = new Location(rift.getWorld(), rift.getPos());
|
||||||
|
@ -176,7 +176,7 @@ public class Pocket { // TODO: better visibilities
|
||||||
while (destIterator.hasNext()) {
|
while (destIterator.hasNext()) {
|
||||||
WeightedRiftDestination wdest = destIterator.next();
|
WeightedRiftDestination wdest = destIterator.next();
|
||||||
RiftDestination dest = wdest.getDestination();
|
RiftDestination dest = wdest.getDestination();
|
||||||
if (dest.getType() == RiftDestination.DestinationType.POCKET_EXIT) {
|
if (dest.getType() == RiftDestination.EnumType.POCKET_EXIT) {
|
||||||
destIterator.remove();
|
destIterator.remove();
|
||||||
linkTo.withOldDestination(dest);
|
linkTo.withOldDestination(dest);
|
||||||
rift.addDestination(linkTo, wdest.getWeight(), wdest.getGroup());
|
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;
|
package com.zixiken.dimdoors.shared.pockets;
|
||||||
|
|
||||||
import com.zixiken.dimdoors.shared.tileentities.TileEntityVerticalEntranceRift;
|
import com.zixiken.dimdoors.shared.tileentities.TileEntityVerticalEntranceRift;
|
||||||
|
|
|
@ -12,10 +12,10 @@ import java.util.List;
|
||||||
|
|
||||||
@Getter @ToString @EqualsAndHashCode @AllArgsConstructor(access = AccessLevel.PRIVATE)
|
@Getter @ToString @EqualsAndHashCode @AllArgsConstructor(access = AccessLevel.PRIVATE)
|
||||||
public /*abstract*/ class RiftDestination implements INBTStorable { // TODO: fix lombok and make this abstract
|
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;
|
@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;
|
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
|
public static RiftDestination readDestinationNBT(NBTTagCompound nbt) { // TODO: store old RANDOM_RIFT_LINK
|
||||||
RiftDestination destination = null;
|
RiftDestination destination = null;
|
||||||
DestinationType type = DestinationType.valueOf(nbt.getString("type"));
|
EnumType type = EnumType.valueOf(nbt.getString("type"));
|
||||||
switch (type) {
|
switch (type) {
|
||||||
case RELATIVE:
|
case RELATIVE:
|
||||||
destination = new RelativeDestination();
|
destination = new RelativeDestination();
|
||||||
|
@ -93,7 +93,7 @@ public /*abstract*/ class RiftDestination implements INBTStorable { // TODO: fix
|
||||||
@Override
|
@Override
|
||||||
public NBTTagCompound writeToNBT(NBTTagCompound nbt) {
|
public NBTTagCompound writeToNBT(NBTTagCompound nbt) {
|
||||||
nbt = super.writeToNBT(nbt);
|
nbt = super.writeToNBT(nbt);
|
||||||
nbt.setString("type", DestinationType.RELATIVE.name());
|
nbt.setString("type", EnumType.RELATIVE.name());
|
||||||
nbt.setInteger("xOffset", xOffset);
|
nbt.setInteger("xOffset", xOffset);
|
||||||
nbt.setInteger("yOffset", yOffset);
|
nbt.setInteger("yOffset", yOffset);
|
||||||
nbt.setInteger("yOffset", zOffset);
|
nbt.setInteger("yOffset", zOffset);
|
||||||
|
@ -120,7 +120,7 @@ public /*abstract*/ class RiftDestination implements INBTStorable { // TODO: fix
|
||||||
@Override
|
@Override
|
||||||
public NBTTagCompound writeToNBT(NBTTagCompound nbt) {
|
public NBTTagCompound writeToNBT(NBTTagCompound nbt) {
|
||||||
nbt = super.writeToNBT(nbt);
|
nbt = super.writeToNBT(nbt);
|
||||||
nbt.setString("type", DestinationType.LOCAL.name());
|
nbt.setString("type", EnumType.LOCAL.name());
|
||||||
nbt.setInteger("x", x);
|
nbt.setInteger("x", x);
|
||||||
nbt.setInteger("y", y);
|
nbt.setInteger("y", y);
|
||||||
nbt.setInteger("y", z);
|
nbt.setInteger("y", z);
|
||||||
|
@ -149,7 +149,7 @@ public /*abstract*/ class RiftDestination implements INBTStorable { // TODO: fix
|
||||||
@Override
|
@Override
|
||||||
public NBTTagCompound writeToNBT(NBTTagCompound nbt) {
|
public NBTTagCompound writeToNBT(NBTTagCompound nbt) {
|
||||||
nbt = super.writeToNBT(nbt);
|
nbt = super.writeToNBT(nbt);
|
||||||
nbt.setString("type", DestinationType.GLOBAL.name());
|
nbt.setString("type", EnumType.GLOBAL.name());
|
||||||
nbt.setInteger("dim", dim);
|
nbt.setInteger("dim", dim);
|
||||||
nbt.setInteger("x", x);
|
nbt.setInteger("x", x);
|
||||||
nbt.setInteger("y", y);
|
nbt.setInteger("y", y);
|
||||||
|
@ -171,7 +171,7 @@ public /*abstract*/ class RiftDestination implements INBTStorable { // TODO: fix
|
||||||
@Override
|
@Override
|
||||||
public NBTTagCompound writeToNBT(NBTTagCompound nbt) {
|
public NBTTagCompound writeToNBT(NBTTagCompound nbt) {
|
||||||
nbt = super.writeToNBT(nbt);
|
nbt = super.writeToNBT(nbt);
|
||||||
nbt.setString("type", DestinationType.NEW_PUBLIC.name());
|
nbt.setString("type", EnumType.NEW_PUBLIC.name());
|
||||||
return nbt;
|
return nbt;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -189,7 +189,7 @@ public /*abstract*/ class RiftDestination implements INBTStorable { // TODO: fix
|
||||||
@Override
|
@Override
|
||||||
public NBTTagCompound writeToNBT(NBTTagCompound nbt) {
|
public NBTTagCompound writeToNBT(NBTTagCompound nbt) {
|
||||||
nbt = super.writeToNBT(nbt);
|
nbt = super.writeToNBT(nbt);
|
||||||
nbt.setString("type", DestinationType.PRIVATE.name());
|
nbt.setString("type", EnumType.PRIVATE.name());
|
||||||
return nbt;
|
return nbt;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -207,7 +207,7 @@ public /*abstract*/ class RiftDestination implements INBTStorable { // TODO: fix
|
||||||
@Override
|
@Override
|
||||||
public NBTTagCompound writeToNBT(NBTTagCompound nbt) {
|
public NBTTagCompound writeToNBT(NBTTagCompound nbt) {
|
||||||
nbt = super.writeToNBT(nbt);
|
nbt = super.writeToNBT(nbt);
|
||||||
nbt.setString("type", DestinationType.PRIVATE.name());
|
nbt.setString("type", EnumType.PRIVATE.name());
|
||||||
return nbt;
|
return nbt;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -243,7 +243,7 @@ public /*abstract*/ class RiftDestination implements INBTStorable { // TODO: fix
|
||||||
@Override
|
@Override
|
||||||
public NBTTagCompound writeToNBT(NBTTagCompound nbt) {
|
public NBTTagCompound writeToNBT(NBTTagCompound nbt) {
|
||||||
nbt = super.writeToNBT(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("newDungeonRiftProbability", newDungeonRiftProbability);
|
||||||
nbt.setFloat("depthPenalization", depthPenalization);
|
nbt.setFloat("depthPenalization", depthPenalization);
|
||||||
nbt.setFloat("distancePenalization", distancePenalization);
|
nbt.setFloat("distancePenalization", distancePenalization);
|
||||||
|
@ -286,7 +286,7 @@ public /*abstract*/ class RiftDestination implements INBTStorable { // TODO: fix
|
||||||
@Override
|
@Override
|
||||||
public NBTTagCompound writeToNBT(NBTTagCompound nbt) {
|
public NBTTagCompound writeToNBT(NBTTagCompound nbt) {
|
||||||
nbt = super.writeToNBT(nbt);
|
nbt = super.writeToNBT(nbt);
|
||||||
nbt.setString("type", DestinationType.POCKET_ENTRANCE.name());
|
nbt.setString("type", EnumType.POCKET_ENTRANCE.name());
|
||||||
nbt.setFloat("weight", weight);
|
nbt.setFloat("weight", weight);
|
||||||
|
|
||||||
NBTTagList ifDestinationsNBT = new NBTTagList();
|
NBTTagList ifDestinationsNBT = new NBTTagList();
|
||||||
|
@ -318,7 +318,7 @@ public /*abstract*/ class RiftDestination implements INBTStorable { // TODO: fix
|
||||||
@Override
|
@Override
|
||||||
public NBTTagCompound writeToNBT(NBTTagCompound nbt) {
|
public NBTTagCompound writeToNBT(NBTTagCompound nbt) {
|
||||||
nbt = super.writeToNBT(nbt);
|
nbt = super.writeToNBT(nbt);
|
||||||
nbt.setString("type", DestinationType.POCKET_EXIT.name());
|
nbt.setString("type", EnumType.POCKET_EXIT.name());
|
||||||
return nbt;
|
return nbt;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -336,7 +336,7 @@ public /*abstract*/ class RiftDestination implements INBTStorable { // TODO: fix
|
||||||
@Override
|
@Override
|
||||||
public NBTTagCompound writeToNBT(NBTTagCompound nbt) {
|
public NBTTagCompound writeToNBT(NBTTagCompound nbt) {
|
||||||
nbt = super.writeToNBT(nbt);
|
nbt = super.writeToNBT(nbt);
|
||||||
nbt.setString("type", DestinationType.PRIVATE_POCKET_EXIT.name());
|
nbt.setString("type", EnumType.PRIVATE_POCKET_EXIT.name());
|
||||||
return nbt;
|
return nbt;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -352,7 +352,7 @@ public /*abstract*/ class RiftDestination implements INBTStorable { // TODO: fix
|
||||||
@Override
|
@Override
|
||||||
public NBTTagCompound writeToNBT(NBTTagCompound nbt) {
|
public NBTTagCompound writeToNBT(NBTTagCompound nbt) {
|
||||||
nbt = super.writeToNBT(nbt);
|
nbt = super.writeToNBT(nbt);
|
||||||
nbt.setString("type", DestinationType.ESCAPE.name());
|
nbt.setString("type", EnumType.ESCAPE.name());
|
||||||
return nbt;
|
return nbt;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -19,6 +19,8 @@ import net.minecraft.entity.player.EntityPlayer;
|
||||||
import net.minecraft.nbt.NBTBase;
|
import net.minecraft.nbt.NBTBase;
|
||||||
import net.minecraft.nbt.NBTTagCompound;
|
import net.minecraft.nbt.NBTTagCompound;
|
||||||
import net.minecraft.nbt.NBTTagList;
|
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.tileentity.TileEntity;
|
||||||
import net.minecraft.util.ITickable;
|
import net.minecraft.util.ITickable;
|
||||||
import net.minecraft.util.math.BlockPos;
|
import net.minecraft.util.math.BlockPos;
|
||||||
|
@ -75,7 +77,7 @@ public abstract class TileEntityRift extends TileEntity implements ITickable { /
|
||||||
|
|
||||||
NBTTagList destinationsNBT = (NBTTagList) nbt.getTag("destinations");
|
NBTTagList destinationsNBT = (NBTTagList) nbt.getTag("destinations");
|
||||||
destinations = new ArrayList<>();
|
destinations = new ArrayList<>();
|
||||||
for (NBTBase destinationNBT : destinationsNBT) {
|
if (destinationsNBT != null) for (NBTBase destinationNBT : destinationsNBT) {
|
||||||
WeightedRiftDestination destination = new WeightedRiftDestination();
|
WeightedRiftDestination destination = new WeightedRiftDestination();
|
||||||
destination.readFromNBT((NBTTagCompound) destinationNBT);
|
destination.readFromNBT((NBTTagCompound) destinationNBT);
|
||||||
destinations.add(destination);
|
destinations.add(destination);
|
||||||
|
@ -91,12 +93,13 @@ public abstract class TileEntityRift extends TileEntity implements ITickable { /
|
||||||
public NBTTagCompound writeToNBT(NBTTagCompound nbt) {
|
public NBTTagCompound writeToNBT(NBTTagCompound nbt) {
|
||||||
super.writeToNBT(nbt);
|
super.writeToNBT(nbt);
|
||||||
|
|
||||||
nbt.setTag("virtualLocation", virtualLocation.writeToNBT());
|
if (virtualLocation != null) nbt.setTag("virtualLocation", virtualLocation.writeToNBT());
|
||||||
|
|
||||||
NBTTagList destinationsNBT = new NBTTagList();
|
NBTTagList destinationsNBT = new NBTTagList();
|
||||||
for (WeightedRiftDestination destination : destinations) {
|
for (WeightedRiftDestination destination : destinations) {
|
||||||
destinationsNBT.appendTag(destination.writeToNBT(nbt));
|
destinationsNBT.appendTag(destination.writeToNBT(nbt));
|
||||||
}
|
}
|
||||||
|
nbt.setTag("destinations", destinationsNBT);
|
||||||
|
|
||||||
nbt.setBoolean("makeDestinationPermanent", makeDestinationPermanent);
|
nbt.setBoolean("makeDestinationPermanent", makeDestinationPermanent);
|
||||||
nbt.setBoolean("preserveRotation", preserveRotation);
|
nbt.setBoolean("preserveRotation", preserveRotation);
|
||||||
|
@ -134,7 +137,7 @@ public abstract class TileEntityRift extends TileEntity implements ITickable { /
|
||||||
Iterator<WeightedRiftDestination> destinationIterator = destinations.iterator();
|
Iterator<WeightedRiftDestination> destinationIterator = destinations.iterator();
|
||||||
while (destinationIterator.hasNext()) {
|
while (destinationIterator.hasNext()) {
|
||||||
RiftDestination dest = destinationIterator.next().getDestination();
|
RiftDestination dest = destinationIterator.next().getDestination();
|
||||||
if (dest.getType() == DestinationType.GLOBAL) {
|
if (dest.getType() == EnumType.GLOBAL) {
|
||||||
GlobalDestination globalDest = (GlobalDestination) dest;
|
GlobalDestination globalDest = (GlobalDestination) dest;
|
||||||
if (globalDest.getDim() == location.getDimID()
|
if (globalDest.getDim() == location.getDimID()
|
||||||
&& globalDest.getX() == location.getPos().getX()
|
&& globalDest.getX() == location.getPos().getX()
|
||||||
|
@ -144,7 +147,7 @@ public abstract class TileEntityRift extends TileEntity implements ITickable { /
|
||||||
destinationIterator.remove();
|
destinationIterator.remove();
|
||||||
}
|
}
|
||||||
if (location.getDimID() == WorldUtils.getDim(world)) {
|
if (location.getDimID() == WorldUtils.getDim(world)) {
|
||||||
if (dest.getType() == DestinationType.LOCAL) {
|
if (dest.getType() == EnumType.LOCAL) {
|
||||||
LocalDestination localDest = (LocalDestination) dest;
|
LocalDestination localDest = (LocalDestination) dest;
|
||||||
if (localDest.getX() == location.getPos().getX()
|
if (localDest.getX() == location.getPos().getX()
|
||||||
&& localDest.getY() == location.getPos().getY()
|
&& localDest.getY() == location.getPos().getY()
|
||||||
|
@ -152,7 +155,7 @@ public abstract class TileEntityRift extends TileEntity implements ITickable { /
|
||||||
unregisterDest(dest);
|
unregisterDest(dest);
|
||||||
destinationIterator.remove();
|
destinationIterator.remove();
|
||||||
}
|
}
|
||||||
} else if (dest.getType() == DestinationType.RELATIVE) {
|
} else if (dest.getType() == EnumType.RELATIVE) {
|
||||||
RelativeDestination relativeDest = (RelativeDestination) dest;
|
RelativeDestination relativeDest = (RelativeDestination) dest;
|
||||||
if (location.getPos().equals(pos.add(relativeDest.getXOffset(), relativeDest.getYOffset(), relativeDest.getZOffset()))) {
|
if (location.getPos().equals(pos.add(relativeDest.getXOffset(), relativeDest.getYOffset(), relativeDest.getZOffset()))) {
|
||||||
unregisterDest(dest);
|
unregisterDest(dest);
|
||||||
|
@ -301,7 +304,7 @@ public abstract class TileEntityRift extends TileEntity implements ITickable { /
|
||||||
if (uuid != null) {
|
if (uuid != null) {
|
||||||
RiftRegistry privateRiftRegistry = RiftRegistry.getForDim(DimDoorDimensions.getPrivateDimID());
|
RiftRegistry privateRiftRegistry = RiftRegistry.getForDim(DimDoorDimensions.getPrivateDimID());
|
||||||
destLoc = RiftRegistry.getEscapeRift(uuid);
|
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
|
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?
|
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) {
|
public boolean shouldRefresh(World world, BlockPos pos, IBlockState oldState, IBlockState newSate) {
|
||||||
return oldState.getBlock() != newSate.getBlock();
|
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;
|
package com.zixiken.dimdoors.shared.tileentities;
|
||||||
|
|
||||||
import com.zixiken.dimdoors.shared.rifts.TileEntityRift;
|
import com.zixiken.dimdoors.shared.rifts.TileEntityRift;
|
||||||
|
import com.zixiken.dimdoors.shared.util.RGBA;
|
||||||
import lombok.Getter;
|
import lombok.Getter;
|
||||||
import net.minecraft.entity.Entity;
|
import net.minecraft.entity.Entity;
|
||||||
import net.minecraft.nbt.NBTTagCompound;
|
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
|
// TODO: merge horizontal and vertical entrances' render code into one, and support custom sizes
|
||||||
public abstract class TileEntityEntranceRift extends TileEntityRift {
|
public abstract class TileEntityEntranceRift extends TileEntityRift {
|
||||||
@Getter private boolean placeRiftOnBreak = false;
|
@Getter private boolean placeRiftOnBreak = false;
|
||||||
|
@Getter private boolean closeAfterPassThrough = false;
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void copyFrom(TileEntityRift oldRift) {
|
public void copyFrom(TileEntityRift oldRift) {
|
||||||
super.copyFrom(oldRift);
|
super.copyFrom(oldRift);
|
||||||
|
if (oldRift instanceof TileEntityEntranceRift) {
|
||||||
|
TileEntityEntranceRift oldEntranceRift = (TileEntityEntranceRift) oldRift;
|
||||||
|
closeAfterPassThrough = oldEntranceRift.closeAfterPassThrough;
|
||||||
|
}
|
||||||
placeRiftOnBreak = true;
|
placeRiftOnBreak = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -21,12 +27,14 @@ public abstract class TileEntityEntranceRift extends TileEntityRift {
|
||||||
public void readFromNBT(NBTTagCompound nbt) {
|
public void readFromNBT(NBTTagCompound nbt) {
|
||||||
super.readFromNBT(nbt);
|
super.readFromNBT(nbt);
|
||||||
placeRiftOnBreak = nbt.getBoolean("placeRiftOnBreak");
|
placeRiftOnBreak = nbt.getBoolean("placeRiftOnBreak");
|
||||||
|
closeAfterPassThrough = nbt.getBoolean("closeAfterPassThrough");
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public NBTTagCompound writeToNBT(NBTTagCompound nbt) {
|
public NBTTagCompound writeToNBT(NBTTagCompound nbt) {
|
||||||
super.writeToNBT(nbt);
|
super.writeToNBT(nbt);
|
||||||
nbt.setBoolean("placeRiftOnBreak", placeRiftOnBreak);
|
nbt.setBoolean("placeRiftOnBreak", placeRiftOnBreak);
|
||||||
|
nbt.setBoolean("closeAfterPassThrough", closeAfterPassThrough);
|
||||||
return nbt;
|
return nbt;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -52,21 +60,21 @@ public abstract class TileEntityEntranceRift extends TileEntityRift {
|
||||||
return status;
|
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;
|
float red, green, blue;
|
||||||
switch(world.provider.getDimension()) {
|
switch(world.provider.getDimension()) {
|
||||||
case -1: // Nether
|
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;
|
red = rand.nextFloat() * 0.5F + 0.4F;
|
||||||
green = rand.nextFloat() * 0.05F;
|
green = rand.nextFloat() * 0.05F;
|
||||||
blue = rand.nextFloat() * 0.05F;
|
blue = rand.nextFloat() * 0.05F;
|
||||||
break;
|
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:
|
//Need to be saved:
|
||||||
private int updateTimer;
|
private int updateTimer;
|
||||||
public boolean shouldClose = false;
|
public boolean shouldClose = false; // TODO
|
||||||
public int spawnedEndermenID = 0;
|
public int spawnedEndermenID = 0;
|
||||||
public float growth = 0;
|
public float growth = 0;
|
||||||
|
|
||||||
|
|
|
@ -5,7 +5,7 @@ import net.minecraft.nbt.NBTTagCompound;
|
||||||
import net.minecraft.util.EnumFacing;
|
import net.minecraft.util.EnumFacing;
|
||||||
import net.minecraft.util.math.BlockPos;
|
import net.minecraft.util.math.BlockPos;
|
||||||
|
|
||||||
public class TileEntityVerticalEntranceRift extends TileEntityEntranceRift {
|
public class TileEntityVerticalEntranceRift extends TileEntityEntranceRift { // TODO: make builder?
|
||||||
|
|
||||||
public boolean doorShouldRender = true;
|
public boolean doorShouldRender = true;
|
||||||
public EnumFacing orientation = EnumFacing.SOUTH;
|
public EnumFacing orientation = EnumFacing.SOUTH;
|
||||||
|
@ -34,6 +34,8 @@ public class TileEntityVerticalEntranceRift extends TileEntityEntranceRift {
|
||||||
public void teleportTo(Entity entity) {
|
public void teleportTo(Entity entity) {
|
||||||
super.teleportTo(entity);
|
super.teleportTo(entity);
|
||||||
BlockPos offsetPos = entity.getPosition().offset(orientation);
|
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;
|
package com.zixiken.dimdoors.shared.util;
|
||||||
|
|
||||||
import java.util.Map;
|
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;
|
package com.zixiken.dimdoors.shared.util;
|
||||||
|
|
||||||
import com.zixiken.dimdoors.DimDoors;
|
import com.zixiken.dimdoors.DimDoors;
|
||||||
|
|
|
@ -124,7 +124,7 @@ public class SchematicConverter {
|
||||||
blockInt = schematic.pallette.indexOf(additionalState);
|
blockInt = schematic.pallette.indexOf(additionalState);
|
||||||
} else {
|
} else {
|
||||||
schematic.pallette.add(additionalState);
|
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;
|
blockInt = schematic.pallette.size() - 1;
|
||||||
}
|
}
|
||||||
} else { //if this is ancient fabric
|
} else { //if this is ancient fabric
|
||||||
|
|
|
@ -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;
|
package com.zixiken.dimdoors.shared.util;
|
||||||
|
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
|
|
Loading…
Reference in a new issue