Started on TransTrapdoor.\nThese may need fixing later; trapdoors lost some functionality since 1.7.10
This commit is contained in:
parent
b1fa82fc63
commit
bce429e17e
6 changed files with 73 additions and 71 deletions
src/main
java/com/zixiken/dimdoors/blocks
resources/assets/dimdoors
blockstates
models/block
textures/blocks
|
@ -2,28 +2,26 @@ package com.zixiken.dimdoors.blocks;
|
|||
|
||||
import java.util.Random;
|
||||
|
||||
import com.zixiken.dimdoors.core.DimLink;
|
||||
import com.zixiken.dimdoors.DimDoors;
|
||||
import cpw.mods.fml.relauncher.Side;
|
||||
import cpw.mods.fml.relauncher.SideOnly;
|
||||
|
||||
import com.zixiken.dimdoors.core.DDTeleporter;
|
||||
import com.zixiken.dimdoors.core.DimLink;
|
||||
import com.zixiken.dimdoors.core.LinkType;
|
||||
import com.zixiken.dimdoors.core.PocketManager;
|
||||
import net.minecraft.block.Block;
|
||||
import net.minecraft.block.BlockTrapDoor;
|
||||
import net.minecraft.block.ITileEntityProvider;
|
||||
import net.minecraft.block.material.Material;
|
||||
import net.minecraft.client.renderer.texture.IIconRegister;
|
||||
import net.minecraft.block.state.IBlockState;
|
||||
import net.minecraft.entity.Entity;
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.init.Blocks;
|
||||
import net.minecraft.item.Item;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.tileentity.TileEntity;
|
||||
import net.minecraft.util.BlockPos;
|
||||
import net.minecraft.util.EnumFacing;
|
||||
import net.minecraft.util.MovingObjectPosition;
|
||||
import net.minecraft.world.World;
|
||||
import com.zixiken.dimdoors.core.DDTeleporter;
|
||||
import com.zixiken.dimdoors.core.LinkType;
|
||||
import com.zixiken.dimdoors.core.NewDimData;
|
||||
import com.zixiken.dimdoors.core.PocketManager;
|
||||
import com.zixiken.dimdoors.items.ItemDDKey;
|
||||
import com.zixiken.dimdoors.tileentities.TileEntityTransTrapdoor;
|
||||
|
||||
|
@ -37,79 +35,45 @@ public class TransTrapdoor extends BlockTrapDoor implements IDimDoor, ITileEntit
|
|||
setUnlocalizedName(ID);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void registerBlockIcons(IIconRegister par1IconRegister)
|
||||
{
|
||||
this.blockIcon = par1IconRegister.registerIcon(DimDoors.modid + ":" + this.getUnlocalizedName());
|
||||
}
|
||||
|
||||
//Teleports the player to the exit link of that dimension, assuming it is a pocket
|
||||
@Override
|
||||
public void onEntityCollidedWithBlock(World world, int x, int y, int z, Entity entity)
|
||||
{
|
||||
enterDimDoor(world, x, y, z, entity);
|
||||
}
|
||||
public void onEntityCollidedWithBlock(World world, BlockPos pos, Entity entity) {enterDimDoor(world, pos, entity);}
|
||||
|
||||
public boolean checkCanOpen(World world, int x, int y, int z)
|
||||
{
|
||||
return this.checkCanOpen(world, x, y, z, null);
|
||||
}
|
||||
public boolean checkCanOpen(World world, BlockPos pos) {return this.checkCanOpen(world, pos, null);}
|
||||
|
||||
public boolean checkCanOpen(World world, int x, int y, int z, EntityPlayer player)
|
||||
{
|
||||
DimLink link = PocketManager.getLink( x, y, z, world);
|
||||
if(link==null||player==null)
|
||||
{
|
||||
return link==null;
|
||||
}
|
||||
if(!link.getLockState())
|
||||
{
|
||||
return true;
|
||||
}
|
||||
public boolean checkCanOpen(World world, BlockPos pos, EntityPlayer player) {
|
||||
DimLink link = PocketManager.getLink(pos, world);
|
||||
if(link == null || player == null) return link == null;
|
||||
|
||||
if(!link.getLockState()) return true;
|
||||
|
||||
for(ItemStack item : player.inventory.mainInventory)
|
||||
{
|
||||
if(item != null)
|
||||
{
|
||||
if(item.getItem() instanceof ItemDDKey)
|
||||
{
|
||||
if(link.tryToOpen(item))
|
||||
{
|
||||
return true;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
if(item != null && item.getItem() instanceof ItemDDKey && link.tryToOpen(item)) return true;
|
||||
return false;
|
||||
}
|
||||
|
||||
public boolean onBlockActivated(World par1World, int par2, int par3, int par4, EntityPlayer par5EntityPlayer, int par6, float par7, float par8, float par9)
|
||||
{
|
||||
if(this.checkCanOpen(par1World, par2, par3, par4, par5EntityPlayer))
|
||||
{
|
||||
return super.onBlockActivated(par1World, par2, par3, par4, par5EntityPlayer, par6, par7, par8, par9);
|
||||
}
|
||||
return false;
|
||||
|
||||
@Override
|
||||
public boolean onBlockActivated(World worldIn, BlockPos pos, IBlockState state, EntityPlayer playerIn, EnumFacing side, float hitX, float hitY, float hitZ) {
|
||||
return checkCanOpen(worldIn, pos, playerIn) &&
|
||||
super.onBlockActivated(worldIn, pos, state, playerIn, side, hitX, hitY, hitZ);
|
||||
}
|
||||
|
||||
public void onPoweredBlockChange(World par1World, int par2, int par3, int par4, boolean par5)
|
||||
{
|
||||
if(this.checkCanOpen(par1World, par2, par3, par4))
|
||||
{
|
||||
super.func_150120_a(par1World, par2, par3, par4, par5);
|
||||
}
|
||||
@Override
|
||||
public void onNeighborBlockChange(World worldIn, BlockPos pos, IBlockState state, Block neighborBlock) {
|
||||
if(checkCanOpen(worldIn, pos)) super.onNeighborBlockChange(worldIn, pos, state, neighborBlock);
|
||||
}
|
||||
@Override
|
||||
public void enterDimDoor(World world, int x, int y, int z, Entity entity)
|
||||
{
|
||||
if (!world.isRemote && func_150118_d(world.getBlockMetadata(x, y, z)))
|
||||
{
|
||||
DimLink link = PocketManager.getLink(x, y, z, world);
|
||||
if (link != null && (link.linkType() != LinkType.PERSONAL || entity instanceof EntityPlayer))
|
||||
{
|
||||
DDTeleporter.traverseDimDoor(world, link, entity,this);
|
||||
}
|
||||
super.func_150120_a(world, x, y, z, false);
|
||||
|
||||
@Override
|
||||
public void enterDimDoor(World world, BlockPos pos, Entity entity) {
|
||||
IBlockState state = world.getBlockState(pos);
|
||||
if (!world.isRemote && state.getValue(BlockTrapDoor.OPEN)) {
|
||||
DimLink link = PocketManager.getLink(pos, world);
|
||||
if (link != null && (link.linkType() != LinkType.PERSONAL || entity instanceof EntityPlayer)) {
|
||||
DDTeleporter.traverseDimDoor(world, link, entity, this);
|
||||
state.cycleProperty(BlockTrapDoor.OPEN);
|
||||
world.markBlockRangeForRenderUpdate(pos, pos);
|
||||
world.playAuxSFXAtEntity(null, 1006, pos, 0);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
|
20
src/main/resources/assets/dimdoors/blockstates/dimHatch.json
Normal file
20
src/main/resources/assets/dimdoors/blockstates/dimHatch.json
Normal file
|
@ -0,0 +1,20 @@
|
|||
{
|
||||
"variants": {
|
||||
"facing=north,half=bottom,open=false": { "model": "dimHatch_bottom" },
|
||||
"facing=south,half=bottom,open=false": { "model": "dimHatch_bottom" },
|
||||
"facing=east,half=bottom,open=false": { "model": "dimHatch_bottom" },
|
||||
"facing=west,half=bottom,open=false": { "model": "dimHatch_bottom" },
|
||||
"facing=north,half=top,open=false": { "model": "dimHatch_top" },
|
||||
"facing=south,half=top,open=false": { "model": "dimHatch_top" },
|
||||
"facing=east,half=top,open=false": { "model": "dimHatch_top" },
|
||||
"facing=west,half=top,open=false": { "model": "dimHatch_top" },
|
||||
"facing=north,half=bottom,open=true": { "model": "dimHatch_open" },
|
||||
"facing=south,half=bottom,open=true": { "model": "dimHatch_open", "y": 180 },
|
||||
"facing=east,half=bottom,open=true": { "model": "dimHatch_open", "y": 90 },
|
||||
"facing=west,half=bottom,open=true": { "model": "dimHatch_open", "y": 270 },
|
||||
"facing=north,half=top,open=true": { "model": "dimHatch_open" },
|
||||
"facing=south,half=top,open=true": { "model": "dimHatch_open", "y": 180 },
|
||||
"facing=east,half=top,open=true": { "model": "dimHatch_open", "y": 90 },
|
||||
"facing=west,half=top,open=true": { "model": "dimHatch_open", "y": 270 }
|
||||
}
|
||||
}
|
|
@ -0,0 +1,6 @@
|
|||
{
|
||||
"parent": "block/trapdoor_bottom",
|
||||
"textures": {
|
||||
"texture": "blocks/dimHatch"
|
||||
}
|
||||
}
|
|
@ -0,0 +1,6 @@
|
|||
{
|
||||
"parent": "block/trapdoor_open",
|
||||
"textures": {
|
||||
"texture": "blocks/dimHatch"
|
||||
}
|
||||
}
|
|
@ -0,0 +1,6 @@
|
|||
{
|
||||
"parent": "block/trapdoor_top",
|
||||
"textures": {
|
||||
"texture": "blocks/dimHatch"
|
||||
}
|
||||
}
|
Before ![]() (image error) Size: 676 B After ![]() (image error) Size: 676 B ![]() ![]() |
Loading…
Add table
Reference in a new issue