It compiles and runs in 1.10.2

This commit is contained in:
Waterpicker 2016-11-07 02:56:55 -06:00
parent baf6e16620
commit 35c3d1aae8
8 changed files with 99 additions and 124 deletions

View file

@ -49,7 +49,6 @@ public abstract class BlockDimDoorBase extends BlockDoor implements IDimDoor, IT
state = state.cycleProperty(BlockDoor.OPEN);
world.setBlockState(pos, state, 2);
world.markBlockRangeForRenderUpdate(pos, pos.up());
world.playAuxSFXAtEntity(player, state.getValue(BlockDoor.OPEN) ? 1003 : 1006, pos, 0);
return true;
}
}
@ -98,7 +97,7 @@ public abstract class BlockDimDoorBase extends BlockDoor implements IDimDoor, IT
@Override
@SideOnly(Side.CLIENT)
public ItemStack getItem(World world, BlockPos pos, IBlockState state) { return new ItemStack(this.getItemDoor(), 1, 0) }
public ItemStack getItem(World world, BlockPos pos, IBlockState state) { return new ItemStack(this.getItemDoor(), 1, 0); }
@Override
public TileEntity createNewTileEntity(World world, int metadata) {return new TileEntityDimDoor();}

View file

@ -6,6 +6,7 @@ import java.util.Random;
import com.zixiken.dimdoors.DimDoors;
import net.minecraft.block.Block;
import net.minecraft.block.BlockContainer;
import net.minecraft.block.SoundType;
import net.minecraft.block.material.Material;
import net.minecraft.block.properties.PropertyInteger;
import net.minecraft.block.state.BlockStateContainer;
@ -16,12 +17,16 @@ import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.item.Item;
import net.minecraft.item.ItemStack;
import net.minecraft.util.EnumFacing;
import net.minecraft.util.EnumHand;
import net.minecraft.util.math.BlockPos;
import net.minecraft.util.math.RayTraceResult;
import net.minecraft.world.Explosion;
import net.minecraft.world.World;
import net.minecraftforge.fml.relauncher.Side;
import net.minecraftforge.fml.relauncher.SideOnly;
import javax.annotation.Nullable;
public class BlockDimWall extends Block {
public static final String ID = "blockDimWall";
public static final PropertyInteger TYPE = PropertyInteger.create("type", 0, 2);
@ -36,6 +41,7 @@ public class BlockDimWall extends Block {
setHardness(0.1F);
setUnlocalizedName(ID);
setDefaultState(blockState.getBaseState().withProperty(TYPE, 0));
setSoundType(SoundType.STONE);
}
@Override
@ -84,7 +90,7 @@ public class BlockDimWall extends Block {
}
@Override
public ItemStack getPickBlock(MovingObjectPosition target, World world, BlockPos pos, EntityPlayer player) {
public ItemStack getPickBlock(IBlockState state, RayTraceResult target, World world, BlockPos pos, EntityPlayer player) {
return new ItemStack(Item.getItemFromBlock(this), 1, getMetaFromState(world.getBlockState(pos)));
}
@ -98,13 +104,13 @@ public class BlockDimWall extends Block {
* replaces the block clicked with the held block, instead of placing the block on top of it. Shift click to disable.
*/
@Override
public boolean onBlockActivated(World world, BlockPos pos, IBlockState state, EntityPlayer player, EnumFacing side, float hitX, float hitY, float hitZ) {
public boolean onBlockActivated(World world, BlockPos pos, IBlockState state, EntityPlayer player, EnumHand hand, @Nullable ItemStack heldItem, EnumFacing side, float hitX, float hitY, float hitZ) {
//Check if the metadata value is 0 -- we don't want the user to replace Ancient Fabric
ItemStack playerEquip = player.getCurrentEquippedItem();
ItemStack playerEquip = player.getHeldItemMainhand();
if (playerEquip != null && state.getValue(TYPE) != 1) {
Block block = Block.getBlockFromItem(playerEquip.getItem());
if (block != null) {
if (!block.isNormalCube(world, pos) || block instanceof BlockContainer || block == this)
if (!block.isNormalCube(state) || block instanceof BlockContainer || block == this)
return false;
if (!world.isRemote) {
if (!player.capabilities.isCreativeMode) playerEquip.stackSize--;

View file

@ -8,6 +8,7 @@ import com.zixiken.dimdoors.tileentities.TileEntityRift;
import net.minecraft.block.Block;
import net.minecraft.block.BlockLiquid;
import net.minecraft.block.ITileEntityProvider;
import net.minecraft.block.material.EnumPushReaction;
import net.minecraft.block.material.Material;
import net.minecraft.block.state.IBlockState;
import net.minecraft.entity.item.EntityItem;
@ -16,10 +17,11 @@ import net.minecraft.init.Blocks;
import net.minecraft.item.Item;
import net.minecraft.item.ItemStack;
import net.minecraft.tileentity.TileEntity;
import net.minecraft.util.AxisAlignedBB;
import net.minecraft.util.BlockPos;
import net.minecraft.util.EnumBlockRenderType;
import net.minecraft.util.EnumFacing;
import net.minecraft.util.MovingObjectPosition;
import net.minecraft.util.math.AxisAlignedBB;
import net.minecraft.util.math.BlockPos;
import net.minecraft.util.math.RayTraceResult;
import net.minecraft.world.IBlockAccess;
import net.minecraft.world.World;
import net.minecraftforge.fluids.IFluidBlock;
@ -36,7 +38,7 @@ public class BlockRift extends Block implements ITileEntityProvider {
private final ArrayList<Block> modBlocksImmuneToRift; // List of DD blocks immune to rifts
public BlockRift() {
super(Material.fire);
super(Material.FIRE);
setTickRandomly(true);
setHardness(1.0F);
setUnlocalizedName(ID);
@ -55,21 +57,23 @@ public class BlockRift extends Block implements ITileEntityProvider {
modBlocksImmuneToRift.add(ModBlocks.blockDoorQuartz);
blocksImmuneToRift = new ArrayList<Block>();
blocksImmuneToRift.add(Blocks.lapis_block);
blocksImmuneToRift.add(Blocks.iron_block);
blocksImmuneToRift.add(Blocks.gold_block);
blocksImmuneToRift.add(Blocks.diamond_block);
blocksImmuneToRift.add(Blocks.emerald_block);
blocksImmuneToRift.add(Blocks.LAPIS_BLOCK);
blocksImmuneToRift.add(Blocks.IRON_BLOCK);
blocksImmuneToRift.add(Blocks.GOLD_BLOCK);
blocksImmuneToRift.add(Blocks.DIAMOND_BLOCK);
blocksImmuneToRift.add(Blocks.EMERALD_BLOCK);
}
@Override
public boolean isCollidable() {return false;}
@Override
public boolean isOpaqueCube() {return false;}
public boolean isOpaqueCube(IBlockState state) {return false;}
@Override
public AxisAlignedBB getCollisionBoundingBox(World worldIn, BlockPos pos, IBlockState state) {return null;}
public AxisAlignedBB getCollisionBoundingBox(IBlockState state, World world, BlockPos pos) {
return null;
}
/**
* Returns whether this block is collideable based on the arguments passed in Args: blockMetaData, unknownFlag
@ -91,14 +95,14 @@ public class BlockRift extends Block implements ITileEntityProvider {
}
@Override
public int getRenderType() {
return 2; //Tile Entity Special Renderer
public EnumBlockRenderType getRenderType(IBlockState state) {
return EnumBlockRenderType.INVISIBLE; //Tile Entity Special Renderer
}
public void dropWorldThread(World world, BlockPos pos, Random random) {
Block block = world.getBlockState(pos).getBlock();
if (!block.isAir(world, pos) && !(block instanceof BlockLiquid || block instanceof IFluidBlock)) {
if (!world.getBlockState(pos).equals(Blocks.AIR) && !(block instanceof BlockLiquid || block instanceof IFluidBlock)) {
ItemStack thread = new ItemStack(ModItems.itemWorldThread, 1);
world.spawnEntityInWorld(new EntityItem(world, pos.getX(), pos.getY(), pos.getZ(), thread));
}
@ -108,7 +112,9 @@ public class BlockRift extends Block implements ITileEntityProvider {
* Lets pistons push through rifts, destroying them
*/
@Override
public int getMobilityFlag() {return 1;}
public EnumPushReaction getMobilityFlag(IBlockState state) {
return EnumPushReaction.NORMAL;
}
/**
* regulates the render effect, especially when multiple rifts start to link up.
@ -116,7 +122,7 @@ public class BlockRift extends Block implements ITileEntityProvider {
*/
@Override
@SideOnly(Side.CLIENT)
public void randomDisplayTick(World worldIn, BlockPos pos, IBlockState state, Random rand) {
public void randomDisplayTick(IBlockState state, World worldIn, BlockPos pos, Random rand) {
//ArrayList<BlockPos> targets = findReachableBlocks(worldIn, pos, 2, false);
//TODO: implement the parts specified in the method comment?
int x = pos.getX(), y = pos.getY(), z = pos.getZ();
@ -127,16 +133,14 @@ public class BlockRift extends Block implements ITileEntityProvider {
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,
FMLClientHandler.instance().getClient().effectRenderer));
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,
FMLClientHandler.instance().getClient().effectRenderer));
rand.nextGaussian()*0.01D, rand.nextGaussian()*0.01D, rand.nextGaussian()*0.01D));
}
public boolean tryPlacingRift(World world, BlockPos pos) {
@ -150,10 +154,10 @@ public class BlockRift extends Block implements ITileEntityProvider {
// 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.blockResistance >= MIN_IMMUNE_RESISTANCE ||
return block != null /*&&
(block >= MIN_IMMUNE_RESISTANCE*/ ||
modBlocksImmuneToRift.contains(block) ||
blocksImmuneToRift.contains(block));
blocksImmuneToRift.contains(block);
}
public boolean isModBlockImmune(World world, BlockPos pos) {
@ -164,7 +168,7 @@ public class BlockRift extends Block implements ITileEntityProvider {
}
@Override
public ItemStack getPickBlock(MovingObjectPosition target, World world, BlockPos pos, EntityPlayer player) {
public ItemStack getPickBlock(IBlockState state, RayTraceResult target, World world, BlockPos pos, EntityPlayer player) {
return null;
}

View file

@ -6,6 +6,7 @@ import com.zixiken.dimdoors.DimDoors;
import net.minecraft.block.Block;
import net.minecraft.block.BlockTrapDoor;
import net.minecraft.block.ITileEntityProvider;
import net.minecraft.block.SoundType;
import net.minecraft.block.material.Material;
import net.minecraft.block.state.IBlockState;
import net.minecraft.entity.Entity;
@ -15,7 +16,9 @@ import net.minecraft.item.Item;
import net.minecraft.item.ItemStack;
import net.minecraft.tileentity.TileEntity;
import net.minecraft.util.EnumFacing;
import net.minecraft.util.EnumHand;
import net.minecraft.util.math.BlockPos;
import net.minecraft.util.math.RayTraceResult;
import net.minecraft.world.World;
import com.zixiken.dimdoors.tileentities.TileEntityTransTrapdoor;
import net.minecraftforge.fml.relauncher.Side;
@ -25,15 +28,18 @@ public class BlockTransTrapdoor extends BlockTrapDoor implements IDimDoor, ITile
public static final String ID = "blockDimHatch";
public BlockTransTrapdoor() {
super(Material.wood);
super(Material.WOOD);
this.setCreativeTab(DimDoors.dimDoorsCreativeTab);
setHardness(1.0F);
setUnlocalizedName(ID);
setSoundType(SoundType.WOOD);
}
//Teleports the player to the exit link of that dimension, assuming it is a pocket
@Override
public void onEntityCollidedWithBlock(World world, BlockPos pos, Entity entity) {enterDimDoor(world, pos, entity);}
public void onEntityCollidedWithBlock(World world, BlockPos pos, IBlockState state, Entity entity) {
enterDimDoor(world, pos, entity);
}
public boolean checkCanOpen(World world, BlockPos pos) {return this.checkCanOpen(world, pos, null);}
@ -42,14 +48,14 @@ public class BlockTransTrapdoor extends BlockTrapDoor implements IDimDoor, ITile
}
@Override
public boolean onBlockActivated(World worldIn, BlockPos pos, IBlockState state, EntityPlayer playerIn, EnumFacing side, float hitX, float hitY, float hitZ) {
public boolean onBlockActivated(World worldIn, BlockPos pos, IBlockState state, EntityPlayer playerIn, EnumHand hand, ItemStack heldItem, EnumFacing side, float hitX, float hitY, float hitZ) {
return checkCanOpen(worldIn, pos, playerIn) &&
super.onBlockActivated(worldIn, pos, state, playerIn, side, hitX, hitY, hitZ);
super.onBlockActivated(worldIn, pos, state, playerIn, hand, heldItem, side, hitX, hitY, hitZ);
}
@Override
public void onNeighborBlockChange(World worldIn, BlockPos pos, IBlockState state, Block neighborBlock) {
if(checkCanOpen(worldIn, pos)) super.onNeighborBlockChange(worldIn, pos, state, neighborBlock);
public void neighborChanged(IBlockState state, World worldIn, BlockPos pos, Block neighborBlock) {
if(checkCanOpen(worldIn, pos)) super.neighborChanged(state, worldIn, pos, neighborBlock);
}
@Override
@ -59,7 +65,6 @@ public class BlockTransTrapdoor extends BlockTrapDoor implements IDimDoor, ITile
if (entity instanceof EntityPlayer) {
state.cycleProperty(BlockTrapDoor.OPEN);
world.markBlockRangeForRenderUpdate(pos, pos);
world.playAuxSFXAtEntity(null, 1006, pos, 0);
}
}
}
@ -79,13 +84,13 @@ public class BlockTransTrapdoor extends BlockTrapDoor implements IDimDoor, ITile
@Override
@SideOnly(Side.CLIENT)
public ItemStack getPickBlock(MovingObjectPosition target, World world, BlockPos pos, EntityPlayer player) {
public ItemStack getPickBlock(IBlockState state, RayTraceResult target, World world, BlockPos pos, EntityPlayer player) {
return new ItemStack(this.getItemDoor(), 1, 0);
}
@Override
public Item getItemDropped(IBlockState state, Random random, int fortuneLevel) {
return Item.getItemFromBlock(Blocks.trapdoor);
return Item.getItemFromBlock(Blocks.TRAPDOOR);
}
@Override

View file

@ -1,58 +1,38 @@
package com.zixiken.dimdoors.client;
import net.minecraft.client.particle.EffectRenderer;
import net.minecraft.client.particle.EntityFX;
import net.minecraft.client.renderer.WorldRenderer;
import net.minecraft.client.particle.Particle;
import net.minecraft.client.particle.ParticleManager;
import net.minecraft.client.renderer.VertexBuffer;
import net.minecraft.entity.Entity;
import net.minecraft.util.math.AxisAlignedBB;
import net.minecraft.world.World;
import net.minecraftforge.fml.relauncher.Side;
import net.minecraftforge.fml.relauncher.SideOnly;
@SideOnly(Side.CLIENT)
public class ClosingRiftFX extends EntityFX
public class ClosingRiftFX extends Particle
{
private int baseTextureIndex = 160;
private boolean trail;
private boolean twinkle;
private EffectRenderer effectRenderer;
private float fadeColourRed;
private float fadeColourGreen;
private float fadeColourBlue;
private boolean hasFadeColour;
public ClosingRiftFX(World world, double x, double y, double z, double motionX, double motionY,
double motionZ, EffectRenderer effectRenderer) {
public ClosingRiftFX(World world, double x, double y, double z, double motionX, double motionY, double motionZ) {
super(world, x, y, z);
this.motionX = motionX;
this.motionY = motionY;
this.motionZ = motionZ;
this.effectRenderer = effectRenderer;
this.particleScale *= .55F;
this.particleMaxAge = 30 + this.rand.nextInt(16);
this.noClip = true;
}
/**
* returns the bounding box for this entity
*/
@Override
public AxisAlignedBB getCollisionBoundingBox()
{
return null;
}
/**
* Returns true if this entity should push and be pushed by other entities when colliding.
*/
@Override
public boolean canBePushed() {
return false;
}
@Override
public void renderParticle(WorldRenderer worldRenderer, Entity entityIn, float partialTicks,float p_180434_4_,
float p_180434_5_, float p_180434_6_, float p_180434_7_, float p_180434_8_) {
@Override
public void renderParticle(VertexBuffer worldRenderer, Entity entityIn, float partialTicks, float p_180434_4_,
float p_180434_5_, float p_180434_6_, float p_180434_7_, float p_180434_8_) {
if (!this.twinkle
|| this.particleAge < this.particleMaxAge / 3
|| (this.particleAge + this.particleMaxAge) / 3 % 2 == 0)
@ -60,7 +40,7 @@ public class ClosingRiftFX extends EntityFX
p_180434_5_, p_180434_6_, p_180434_7_, p_180434_8_);
}
public void doRenderParticle(WorldRenderer worldRenderer, float par2, float par3, float par4,
public void doRenderParticle(VertexBuffer worldRenderer, float par2, float par3, float par4,
float par5, float par6, float par7) {
float var8 = super.particleTextureIndexX % 16 / 16.0F;
float var9 = var8 + 0.0624375F;
@ -100,7 +80,7 @@ public class ClosingRiftFX extends EntityFX
this.prevPosZ = this.posZ;
if (this.particleAge++ >= this.particleMaxAge) {
this.setDead();
this.setExpired();
} if (this.particleAge > this.particleMaxAge / 2) {
this.setAlphaF(1.0F - ((float)this.particleAge - (float)(this.particleMaxAge / 2)) / this.particleMaxAge);
@ -118,12 +98,8 @@ public class ClosingRiftFX extends EntityFX
this.motionY *= 0.9100000262260437D;
this.motionZ *= 0.9100000262260437D;
if (this.onGround) {
this.motionX *= 0.699999988079071D;
this.motionZ *= 0.699999988079071D;}
if (this.trail && this.particleAge < this.particleMaxAge / 2 && (this.particleAge + this.particleMaxAge) % 2 == 0) {
ClosingRiftFX var1 = new ClosingRiftFX(this.worldObj, this.posX, this.posY, this.posZ, 0.0D, 0.0D, 0.0D, this.effectRenderer);
ClosingRiftFX var1 = new ClosingRiftFX(this.worldObj, this.posX, this.posY, this.posZ, 0.0D, 0.0D, 0.0D);
var1.setRBGColorF(this.particleRed, this.particleGreen, this.particleBlue);
var1.particleAge = var1.particleMaxAge / 2;
@ -135,7 +111,6 @@ public class ClosingRiftFX extends EntityFX
}
var1.twinkle = this.twinkle;
this.effectRenderer.addEffect(var1);
}
}
@ -143,12 +118,4 @@ public class ClosingRiftFX extends EntityFX
public int getBrightnessForRender(float par1) {
return 15728880;
}
/**
* Gets how bright this entity is.
*/
@Override
public float getBrightness(float par1) {
return 1.0F;
}
}

View file

@ -1,17 +1,16 @@
package com.zixiken.dimdoors.client;
import net.minecraft.client.particle.EffectRenderer;
import net.minecraft.client.particle.EntityFirework;
import net.minecraft.client.particle.ParticleCloud;
import net.minecraft.client.renderer.vertex.VertexBuffer;
import net.minecraft.world.World;
import net.minecraftforge.fml.relauncher.Side;
import net.minecraftforge.fml.relauncher.SideOnly;
@SideOnly(Side.CLIENT)
public class GoggleRiftFX extends EntityFirework.SparkFX {
public class GoggleRiftFX extends ParticleCloud {
public GoggleRiftFX(World par1World, double par2, double par4, double par6,
double par8, double par10, double par12, EffectRenderer par14EffectRenderer) {
super(par1World, par2, par4, par6, par12, par12, par12, par14EffectRenderer);
double par8, double par10, double par12) {
super(par1World, par2, par4, par6, par12, par12, par12);
this.particleMaxAge = 40 + this.rand.nextInt(26);
this.noClip = true;
}
}

View file

@ -13,7 +13,6 @@ import net.minecraft.client.renderer.GLAllocation;
import net.minecraft.client.renderer.GlStateManager;
import net.minecraft.client.renderer.Tessellator;
import net.minecraft.client.renderer.VertexBuffer;
import net.minecraft.client.renderer.WorldRenderer;
import net.minecraft.client.renderer.tileentity.TileEntitySpecialRenderer;
import net.minecraft.client.renderer.vertex.DefaultVertexFormats;
import net.minecraft.util.ResourceLocation;

View file

@ -9,9 +9,14 @@ import com.zixiken.dimdoors.blocks.ModBlocks;
import net.minecraft.block.Block;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.entity.player.EntityPlayerMP;
import net.minecraft.init.Blocks;
import net.minecraft.item.ItemDoor;
import net.minecraft.item.ItemStack;
import net.minecraft.util.*;
import net.minecraft.util.math.BlockPos;
import net.minecraft.util.math.MathHelper;
import net.minecraft.util.math.RayTraceResult;
import net.minecraft.util.math.Vec3d;
import net.minecraft.world.World;
import com.zixiken.dimdoors.tileentities.TileEntityDimDoor;
@ -22,7 +27,6 @@ public abstract class ItemDoorBase extends ItemDoor {
/**
* door represents the non-dimensional door this item is associated with. Leave null for none.
* @param material
* @param vanillaDoor
*/
public ItemDoorBase(Block block, ItemDoor vanillaDoor) {
@ -51,8 +55,7 @@ public abstract class ItemDoorBase extends ItemDoor {
* dimensional doors, we handle this in the EventHookContainer
*/
@Override
public boolean onItemUse(ItemStack stack, EntityPlayer playerIn, World worldIn, BlockPos pos,
EnumFacing side, float hitX, float hitY, float hitZ) {return false;}
public EnumActionResult onItemUse(ItemStack stack, EntityPlayer playerIn, World worldIn, BlockPos pos, EnumHand hand, EnumFacing side, float hitX, float hitY, float hitZ) {return EnumActionResult.FAIL;}
/**
* Tries to place a door as a dimensional door
@ -60,14 +63,10 @@ public abstract class ItemDoorBase extends ItemDoor {
* @param stack
* @param player
* @param world
* @param x
* @param y
* @param z
* @param side
* @return
*/
public static boolean tryToPlaceDoor(ItemStack stack, EntityPlayer player, World world,
BlockPos pos, EnumFacing side) {
public static boolean tryToPlaceDoor(ItemStack stack, EntityPlayer player, World world, BlockPos pos, EnumFacing side) {
if (world.isRemote) return false;
// Retrieve the actual door type that we want to use here.
@ -75,7 +74,6 @@ public abstract class ItemDoorBase extends ItemDoor {
// return null, just as if the item was an unrecognized door type.
ItemDoorBase mappedItem = doorItemMapping.get(stack.getItem());
if (mappedItem == null) return false;
BlockDimDoorBase doorBlock = mappedItem.getDoorBlock();
if (ItemDoorBase.placeDoorOnBlock(doorBlock, stack, player, world, pos, side)) return true;
return ItemDoorBase.placeDoorOnRift(doorBlock, world, player, stack);
@ -87,9 +85,7 @@ public abstract class ItemDoorBase extends ItemDoor {
* @param stack
* @param player
* @param world
* @param x
* @param y
* @param z
* @param pos
* @param side
* @return
*/
@ -101,13 +97,13 @@ public abstract class ItemDoorBase extends ItemDoor {
// side
if (side == EnumFacing.UP) {
Block block = world.getBlockState(pos).getBlock();
if (!block.isAir(world, pos) && !block.isReplaceable(world, pos)) pos = pos.up();
if (!world.getBlockState(pos).equals(Blocks.AIR) && !block.isReplaceable(world, pos)) pos = pos.up();
BlockPos upPos = pos.up();
if (canPlace(world, pos) && canPlace(world, upPos) && player.canPlayerEdit(pos, side, stack)
&& player.canPlayerEdit(upPos, side, stack) && stack.stackSize > 0
&& stack.getItem() instanceof ItemDoorBase) {
placeDoor(world, pos, EnumFacing.fromAngle(player.rotationYaw), doorBlock);
placeDoor(world, pos, EnumFacing.fromAngle(player.rotationYaw), doorBlock, true);
if (!player.capabilities.isCreativeMode) stack.stackSize--;
return true;
}
@ -127,7 +123,7 @@ public abstract class ItemDoorBase extends ItemDoor {
public static boolean placeDoorOnRift(Block doorBlock, World world, EntityPlayer player, ItemStack stack) {
if (world.isRemote) return false;
MovingObjectPosition hit = ItemDoorBase.doRayTrace(world, player, true);
RayTraceResult hit = ItemDoorBase.doRayTrace(world, player, true);
if (hit != null) {
BlockPos pos = hit.getBlockPos();
if (world.getBlockState(pos).getBlock() == ModBlocks.blockRift) {
@ -135,7 +131,7 @@ public abstract class ItemDoorBase extends ItemDoor {
if (player.canPlayerEdit(pos, hit.sideHit, stack) &&
player.canPlayerEdit(downPos, hit.sideHit, stack) &&
canPlace(world, pos) && canPlace(world, downPos)) {
placeDoor(world, downPos, EnumFacing.fromAngle(player.rotationYaw), doorBlock);
placeDoor(world, downPos, EnumFacing.fromAngle(player.rotationYaw), doorBlock, true);
if (!(stack.getItem() instanceof ItemDoorBase))
((TileEntityDimDoor) world.getTileEntity(pos)).hasGennedPair = true;
if (!player.capabilities.isCreativeMode) stack.stackSize--;
@ -149,25 +145,25 @@ public abstract class ItemDoorBase extends ItemDoor {
public static boolean canPlace(World world, BlockPos pos) {
Block block = world.getBlockState(pos).getBlock();
return (block == ModBlocks.blockRift || block.isAir(world, pos) || block.getMaterial().isReplaceable());
return (block == ModBlocks.blockRift || world.getBlockState(pos).equals(Blocks.AIR) || block.getMaterial(world.getBlockState(pos)).isReplaceable());
}
/**
* Copied from minecraft Item.class
* TODO we probably can improve this
*
* @param par1World
* @param par2EntityPlayer
* @param par3
* @param world
* @param player
* @param useLiquids
* @return
*/
protected static MovingObjectPosition doRayTrace(World worldIn, EntityPlayer playerIn, boolean useLiquids) {
float f = playerIn.rotationPitch;
float f1 = playerIn.rotationYaw;
double d0 = playerIn.posX;
double d1 = playerIn.posY + (double)playerIn.getEyeHeight();
double d2 = playerIn.posZ;
Vec3 vec3 = new Vec3(d0, d1, d2);
protected static RayTraceResult doRayTrace(World world, EntityPlayer player, boolean useLiquids) {
float f = player.rotationPitch;
float f1 = player.rotationYaw;
double d0 = player.posX;
double d1 = player.posY + (double)player.getEyeHeight();
double d2 = player.posZ;
Vec3d vec3 = new Vec3d(d0, d1, d2);
float f2 = MathHelper.cos(-f1 * 0.017453292F - (float)Math.PI);
float f3 = MathHelper.sin(-f1 * 0.017453292F - (float)Math.PI);
float f4 = -MathHelper.cos(-f * 0.017453292F);
@ -175,18 +171,18 @@ public abstract class ItemDoorBase extends ItemDoor {
float f6 = f3 * f4;
float f7 = f2 * f4;
double d3 = 5.0D;
if (playerIn instanceof EntityPlayerMP)
d3 = ((EntityPlayerMP)playerIn).theItemInWorldManager.getBlockReachDistance();
Vec3 vec31 = vec3.addVector((double)f6 * d3, (double)f5 * d3, (double)f7 * d3);
return worldIn.rayTraceBlocks(vec3, vec31, useLiquids, !useLiquids, false);
if (player instanceof EntityPlayerMP)
d3 = ((EntityPlayerMP)player).interactionManager.getBlockReachDistance();
Vec3d vec31 = vec3.addVector((double)f6 * d3, (double)f5 * d3, (double)f7 * d3);
return world.rayTraceBlocks(vec3, vec31, useLiquids, !useLiquids, false);
}
public void translateAndAdd(String key, List<String> list) {
for(int i=0;i<10;i++) {
if(StatCollector.canTranslate(key+Integer.toString(i))) {
/*if(StatCollector.canTranslate(key+Integer.toString(i))) {
String line = StatCollector.translateToLocal(key + Integer.toString(i));
list.add(line);
} else break;
} else */ break;
}
}
}