Merge pull request #170 from SenseiKiwi/master

Fixed Pick Block Results
This commit is contained in:
StevenRS11 2014-07-11 10:38:21 -05:00
commit 349f162a7c
19 changed files with 164 additions and 147 deletions

View file

@ -13,14 +13,15 @@ buildscript {
apply plugin: 'forge'
version = "2.2.4-" + System.getenv("BUILD_NUMBER")
group= "com.stevenrs11.dimdoors" // http://maven.apache.org/guides/mini/guide-naming-conventions.html
group = "com.stevenrs11.dimdoors" // http://maven.apache.org/guides/mini/guide-naming-conventions.html
archivesBaseName = "DimensionalDoors"
minecraft {
version = "1.6.4-9.11.1.964"
version = "1.6.4-9.11.1.964"
replaceIn "mod_pocketDim.java"
replace "@VERSION@", project.version
}
targetCompatibility = '1.6'
@ -28,15 +29,15 @@ sourceCompatibility = '1.6'
processResources
{
// replace stuff in mcmod.info, nothing else
// Replace stuff $version and $mcversion in mcmod.info
from(sourceSets.main.resources.srcDirs) {
include 'mcmod.info'
// replace version and mcversion
// Replace version and mcversion
expand 'version':project.version, 'mcversion':project.minecraft.version
}
// copy everything else, thats not the mcmod.info
// Copy everything else
from(sourceSets.main.resources.srcDirs) {
exclude 'mcmod.info'
}

View file

@ -11,7 +11,6 @@ import net.minecraft.client.renderer.texture.IconRegister;
import net.minecraft.entity.Entity;
import net.minecraft.entity.EntityLivingBase;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.item.Item;
import net.minecraft.tileentity.TileEntity;
import net.minecraft.util.Icon;
import net.minecraft.util.MathHelper;
@ -22,7 +21,6 @@ import StevenDimDoors.mod_pocketDim.config.DDProperties;
import StevenDimDoors.mod_pocketDim.core.DDTeleporter;
import StevenDimDoors.mod_pocketDim.core.DimLink;
import StevenDimDoors.mod_pocketDim.core.PocketManager;
import StevenDimDoors.mod_pocketDim.schematic.BlockRotator;
import StevenDimDoors.mod_pocketDim.tileentities.TileEntityDimDoor;
import cpw.mods.fml.relauncher.Side;
import cpw.mods.fml.relauncher.SideOnly;
@ -159,16 +157,13 @@ public abstract class BaseDimDoor extends BlockDoor implements IDimDoor, ITileEn
reversed = !reversed;
}
}
if (isUpperDoorBlock(fullMetadata))
{
return this.upperTextures[reversed ? 1 : 0];
else
return this.lowerTextures[reversed ? 1 : 0];
}
else
{
return this.lowerTextures[0];
}
return this.lowerTextures[reversed ? 1 : 0];
}
return this.lowerTextures[0];
}
//Called to update the render information on the tile entity. Could probably implement a data watcher,
@ -180,29 +175,23 @@ public abstract class BaseDimDoor extends BlockDoor implements IDimDoor, ITileEn
{
int metadata = world.getBlockMetadata(x, y, z);
TileEntityDimDoor dimTile = (TileEntityDimDoor) tile;
dimTile.openOrClosed = this.isDoorOnRift(world, x, y, z)&&this.isUpperDoorBlock(metadata);
dimTile.openOrClosed = isDoorOnRift(world, x, y, z) && isUpperDoorBlock(metadata);
dimTile.orientation = this.getFullMetadata(world, x, y, z) & 7;
}
return this;
}
public boolean isDoorOnRift(World world, int x, int y, int z)
public static boolean isDoorOnRift(World world, int x, int y, int z)
{
if(this.isUpperDoorBlock( world.getBlockMetadata(x, y, z)))
if (isUpperDoorBlock(world.getBlockMetadata(x, y, z)))
{
if(PocketManager.getLink(x, y, z, world.provider.dimensionId) != null||PocketManager.getLink(x, y-1, z, world.provider.dimensionId) != null)
{
return true;
}
// Target block is the upper block
return (PocketManager.getLink(x, y, z, world.provider.dimensionId) != null ||
PocketManager.getLink(x, y - 1, z, world.provider.dimensionId) != null);
}
else
{
if(PocketManager.getLink(x, y, z, world.provider.dimensionId) != null||PocketManager.getLink(x, y+1, z, world.provider.dimensionId) != null)
{
return true;
}
}
return false;
// Target block is the lower block
return (PocketManager.getLink(x, y, z, world.provider.dimensionId) != null ||
PocketManager.getLink(x, y + 1, z, world.provider.dimensionId) != null);
}
/**
@ -351,15 +340,16 @@ public abstract class BaseDimDoor extends BlockDoor implements IDimDoor, ITileEn
*/
@Override
@SideOnly(Side.CLIENT)
public int idPicked(World par1World, int par2, int par3, int par4)
public int idPicked(World world, int x, int y, int z)
{
return this.getDrops();
return this.getDoorItem();
}
/**
* Returns the ID of the items to drop on destruction.
*/
public int idDropped(int metadata, Random random, int fortune)
@Override
public int idDropped(int metadata, Random random, int fortune)
{
return isUpperDoorBlock(metadata) ? 0 : this.getDrops();
}

View file

@ -88,6 +88,7 @@ public class BlockDimWall extends Block
subItems.add(new ItemStack(this, 1, ix));
}
}
@Override
public void onBlockDestroyedByPlayer(World par1World, int par2, int par3, int par4, int par5) {}

View file

@ -2,17 +2,16 @@ package StevenDimDoors.mod_pocketDim.blocks;
import java.util.Random;
import cpw.mods.fml.relauncher.Side;
import cpw.mods.fml.relauncher.SideOnly;
import StevenDimDoors.mod_pocketDim.mod_pocketDim;
import StevenDimDoors.mod_pocketDim.config.DDProperties;
import net.minecraft.block.BlockDoor;
import net.minecraft.block.material.Material;
import net.minecraft.client.renderer.IconFlipped;
import net.minecraft.client.renderer.texture.IconRegister;
import net.minecraft.item.Item;
import net.minecraft.util.Icon;
import net.minecraft.world.IBlockAccess;
import net.minecraft.world.World;
import StevenDimDoors.mod_pocketDim.mod_pocketDim;
import cpw.mods.fml.relauncher.Side;
import cpw.mods.fml.relauncher.SideOnly;
public class BlockDoorGold extends BlockDoor
{
@ -37,6 +36,13 @@ public class BlockDoorGold extends BlockDoor
upperTextures[1] = new IconFlipped(upperTextures[0], true, false);
lowerTextures[1] = new IconFlipped(lowerTextures[0], true, false);
}
@Override
@SideOnly(Side.CLIENT)
public int idPicked(World world, int x, int y, int z)
{
return mod_pocketDim.itemGoldenDoor.itemID;
}
@Override
public int idDropped(int par1, Random par2Random, int par3)
@ -110,15 +116,12 @@ public class BlockDoorGold extends BlockDoor
reversed = !reversed;
}
}
if (BaseDimDoor.isUpperDoorBlock(fullMetadata))
{
return this.upperTextures[reversed ? 1 : 0];
else
return this.lowerTextures[reversed ? 1 : 0];
}
else
{
return this.lowerTextures[0];
}
return this.lowerTextures[reversed ? 1 : 0];
}
return this.lowerTextures[0];
}
}

View file

@ -34,6 +34,12 @@ public class BlockGoldDimDoor extends BaseDimDoor
}
}
@Override
public int getDoorItem()
{
return mod_pocketDim.itemGoldenDimensionalDoor.itemID;
}
@Override
public int getDrops()
{

View file

@ -3,16 +3,15 @@ package StevenDimDoors.mod_pocketDim.blocks;
import net.minecraft.block.material.Material;
import net.minecraft.item.Item;
import net.minecraft.world.World;
import StevenDimDoors.mod_pocketDim.mod_pocketDim;
import StevenDimDoors.mod_pocketDim.config.DDProperties;
import StevenDimDoors.mod_pocketDim.core.DimLink;
import StevenDimDoors.mod_pocketDim.core.LinkTypes;
import StevenDimDoors.mod_pocketDim.core.NewDimData;
import StevenDimDoors.mod_pocketDim.core.PocketManager;
@SuppressWarnings("deprecation")
public class DimensionalDoor extends BaseDimDoor
{
public DimensionalDoor(int blockID, Material material, DDProperties properties)
{
super(blockID, material, properties);
@ -27,10 +26,17 @@ public class DimensionalDoor extends BaseDimDoor
DimLink link = dimension.getLink(x, y, z);
if (link == null)
{
dimension.createLink(x, y, z, LinkTypes.POCKET,world.getBlockMetadata(x, y - 1, z));
dimension.createLink(x, y, z, LinkTypes.POCKET, world.getBlockMetadata(x, y - 1, z));
}
}
}
@Override
public int getDoorItem()
{
return mod_pocketDim.itemDimensionalDoor.itemID;
}
@Override
public int getDrops()
{

View file

@ -12,5 +12,7 @@ public interface IDimDoor
public int getDrops();
public int getDoorItem();
public TileEntity initDoorTE(World world, int x, int y, int z);
}

View file

@ -2,6 +2,9 @@ package StevenDimDoors.mod_pocketDim.blocks;
import java.util.Random;
import cpw.mods.fml.relauncher.Side;
import cpw.mods.fml.relauncher.SideOnly;
import net.minecraft.block.Block;
import net.minecraft.block.BlockTrapDoor;
import net.minecraft.block.ITileEntityProvider;
@ -18,7 +21,6 @@ import StevenDimDoors.mod_pocketDim.core.NewDimData;
import StevenDimDoors.mod_pocketDim.core.PocketManager;
import StevenDimDoors.mod_pocketDim.tileentities.TileEntityTransTrapdoor;
@SuppressWarnings("deprecation")
public class TransTrapdoor extends BlockTrapDoor implements IDimDoor, ITileEntityProvider
{
@ -61,7 +63,7 @@ public class TransTrapdoor extends BlockTrapDoor implements IDimDoor, ITileEntit
{
this.placeLink(world, x, y, z);
world.setBlockTileEntity(x, y, z, this.createNewTileEntity(world));
this.updateAttachedTile(world, x, y, z);
updateAttachedTile(world, x, y, z);
}
@Override
@ -76,8 +78,8 @@ public class TransTrapdoor extends BlockTrapDoor implements IDimDoor, ITileEntit
{
return new TileEntityTransTrapdoor();
}
public void updateAttachedTile(World world, int x, int y, int z)
public static void updateAttachedTile(World world, int x, int y, int z)
{
TileEntity tile = world.getBlockTileEntity(x, y, z);
if (tile instanceof TileEntityTransTrapdoor)
@ -100,18 +102,30 @@ public class TransTrapdoor extends BlockTrapDoor implements IDimDoor, ITileEntit
}
}
}
@Override
@SideOnly(Side.CLIENT)
public int idPicked(World world, int x, int y, int z)
{
return this.getDoorItem();
}
@Override
public int idDropped(int metadata, Random random, int fortuneLevel)
{
return getDrops();
return this.getDrops();
}
@Override
public int getDoorItem()
{
return mod_pocketDim.transTrapdoor.blockID;
}
@Override
public int getDrops()
{
return Block.trapdoor.blockID;
return Block.trapdoor.blockID;
}
public static boolean isTrapdoorSetLow(int metadata)

View file

@ -72,6 +72,12 @@ public class TransientDoor extends BaseDimDoor
}
}
}
@Override
public int getDoorItem()
{
return 0;
}
@Override
public int getDrops()

View file

@ -3,6 +3,7 @@ package StevenDimDoors.mod_pocketDim.blocks;
import net.minecraft.block.material.Material;
import net.minecraft.item.Item;
import net.minecraft.world.World;
import StevenDimDoors.mod_pocketDim.mod_pocketDim;
import StevenDimDoors.mod_pocketDim.config.DDProperties;
import StevenDimDoors.mod_pocketDim.core.LinkTypes;
import StevenDimDoors.mod_pocketDim.core.NewDimData;
@ -24,6 +25,13 @@ public class UnstableDoor extends BaseDimDoor
dimension.createLink(x, y, z, LinkTypes.RANDOM,world.getBlockMetadata(x, y - 1, z));
}
}
@Override
public int getDoorItem()
{
return mod_pocketDim.itemUnstableDoor.itemID;
}
@Override
public int getDrops()
{

View file

@ -3,13 +3,13 @@ package StevenDimDoors.mod_pocketDim.blocks;
import net.minecraft.block.material.Material;
import net.minecraft.item.Item;
import net.minecraft.world.World;
import StevenDimDoors.mod_pocketDim.mod_pocketDim;
import StevenDimDoors.mod_pocketDim.config.DDProperties;
import StevenDimDoors.mod_pocketDim.core.DimLink;
import StevenDimDoors.mod_pocketDim.core.LinkTypes;
import StevenDimDoors.mod_pocketDim.core.NewDimData;
import StevenDimDoors.mod_pocketDim.core.PocketManager;
@SuppressWarnings("deprecation")
public class WarpDoor extends BaseDimDoor
{
public WarpDoor(int blockID, Material material, DDProperties properties)
@ -31,6 +31,12 @@ public class WarpDoor extends BaseDimDoor
}
}
@Override
public int getDoorItem()
{
return mod_pocketDim.itemWarpDoor.itemID;
}
@Override
public int getDrops()
{

View file

@ -51,59 +51,49 @@ public class DDTeleporter
private DDTeleporter() { }
/**Checks if the destination supplied is valid, ie, filled by any non-replaceable block.
*
* @param entity
* @param world
* @param destination
* @param properties
* @return
/**
* Checks if the destination supplied is safe (i.e. filled by any replaceable or non-opaque blocks)
*/
private static boolean checkDestination(Entity entity, WorldServer world, Point4D destination,DDProperties properties)
private static boolean checkDestination(WorldServer world, Point4D destination, int orientation)
{
int x = destination.getX();
int y = destination.getY();
int z = destination.getZ();
int blockIDTop;
int blockIDBottom;
int blockIDBottom;
Point3D point;
int orientation;
orientation = getDestinationOrientation(destination, properties);
entity.rotationYaw = (orientation * 90) + 90;
switch (orientation)
{
case 0:
point = new Point3D(MathHelper.floor_double(x - 0.5), y - 1, MathHelper.floor_double(z + 0.5));
point = new Point3D(x - 1, y - 1, z);
break;
case 1:
point = new Point3D(MathHelper.floor_double(x + 0.5), y - 1, MathHelper.floor_double(z - 0.5));
point = new Point3D(x, y - 1, z - 1);
break;
case 2:
point = new Point3D(MathHelper.floor_double(x + 1.5), y - 1, MathHelper.floor_double(z + 0.5));
point = new Point3D(x + 1, y - 1, z);
break;
case 3:
point = new Point3D(MathHelper.floor_double(x + 0.5), y - 1, MathHelper.floor_double(z + 1.5));
point = new Point3D(x, y - 1, z + 1);
break;
default:
point = new Point3D(x, y - 1, z);
break;
}
blockIDBottom = world.getBlockId(point.getX(), point.getY(), point.getZ());
blockIDTop = world.getBlockId(point.getX(), point.getY()+1, point.getZ());
blockIDTop = world.getBlockId(point.getX(), point.getY() + 1, point.getZ());
if (Block.blocksList[blockIDBottom] != null)
{
if(!Block.blocksList[blockIDBottom].isBlockReplaceable(world, point.getX(), point.getY(), point.getZ())&&world.isBlockOpaqueCube(point.getX(), point.getY(), point.getZ()))
if (!Block.blocksList[blockIDBottom].isBlockReplaceable(world, point.getX(), point.getY(), point.getZ()) && world.isBlockOpaqueCube(point.getX(), point.getY(), point.getZ()))
{
return false;
}
}
if (Block.blocksList[blockIDTop] != null)
{
if (!Block.blocksList[blockIDTop].isBlockReplaceable(world, point.getX(), point.getY()+1, point.getZ()))
if (!Block.blocksList[blockIDTop].isBlockReplaceable(world, point.getX(), point.getY() + 1, point.getZ()))
{
return false;
}
@ -125,56 +115,37 @@ public class DDTeleporter
}
else
{
//Teleport the entity to the precise destination point
// Teleport the entity to the precise destination point
orientation = -1;
}
if (!checkDestination(entity, world, destination, properties))
{
if (entity instanceof EntityPlayerMP)
{
EntityPlayer player = (EntityPlayer) entity;
player.rotationYaw = (orientation * 90) + 90;
switch (orientation)
{
case 0:
player.setPositionAndUpdate(x + 0.5, y - 1, z + 0.5);
break;
case 1:
player.setPositionAndUpdate(x + 0.5, y - 1, z + 0.5);
break;
case 2:
player.setPositionAndUpdate(x + 0.5, y - 1, z + 0.5);
break;
case 3:
player.setPositionAndUpdate(x + 0.5, y - 1, z + 0.5);
break;
default:
player.setPositionAndUpdate(x, y - 1, z);
break;
}
}
}
else if (entity instanceof EntityPlayer)
if (entity instanceof EntityPlayer)
{
EntityPlayer player = (EntityPlayer) entity;
switch (orientation)
if (checkDestination(world, destination, orientation))
{
case 0:
player.setPositionAndUpdate(x - 0.5, y - 1, z + 0.5);
break;
case 1:
player.setPositionAndUpdate(x + 0.5, y - 1, z - 0.5);
break;
case 2:
player.setPositionAndUpdate(x + 1.5, y - 1, z + 0.5);
break;
case 3:
player.setPositionAndUpdate(x + 0.5, y - 1, z + 1.5);
break;
default:
player.setPositionAndUpdate(x + 0.5, y - 1, z + 0.5);
break;
switch (orientation)
{
case 0:
player.setPositionAndUpdate(x - 0.5, y - 1, z + 0.5);
break;
case 1:
player.setPositionAndUpdate(x + 0.5, y - 1, z - 0.5);
break;
case 2:
player.setPositionAndUpdate(x + 1.5, y - 1, z + 0.5);
break;
case 3:
player.setPositionAndUpdate(x + 0.5, y - 1, z + 1.5);
break;
default:
player.setPositionAndUpdate(x + 0.5, y - 1, z + 0.5);
break;
}
}
else
{
player.setPositionAndUpdate(x + 0.5, y - 1, z + 0.5);
}
}
else if (entity instanceof EntityMinecart)
@ -200,7 +171,7 @@ public class DDTeleporter
entity.worldObj.updateEntityWithOptionalForce(entity, false);
break;
case 3:
DDTeleporter.setEntityPosition(entity, x + 0.5, y, z + 1.5 );
DDTeleporter.setEntityPosition(entity, x + 0.5, y, z + 1.5);
entity.motionZ = 0.39;
entity.worldObj.updateEntityWithOptionalForce(entity, false);
break;

View file

@ -162,7 +162,7 @@ public class DungeonSchematic extends Schematic {
applyFilter(standardizer);
}
private Map<Short, Short> getAssignedToStandardIDMapping(DDProperties properties)
private static Map<Short, Short> getAssignedToStandardIDMapping(DDProperties properties)
{
//If we ever need this broadly or support other mods, this should be moved to a separate class
TreeMap<Short, Short> mapping = new TreeMap<Short, Short>();

View file

@ -97,7 +97,7 @@ serverPacketHandlerSpec =
@SidedPacketHandler(channels = {PacketConstants.CHANNEL_NAME}, packetHandler = ServerPacketHandler.class))
public class mod_pocketDim
{
public static final String version = "1.6.4-R2.2.4";
public static final String version = "@VERSION@";
public static final String modid = "dimdoors";
//TODO need a place to stick all these constants
@ -107,8 +107,8 @@ public class mod_pocketDim
@SidedProxy(clientSide = "StevenDimDoors.mod_pocketDimClient.ClientProxy", serverSide = "StevenDimDoors.mod_pocketDim.CommonProxy")
public static CommonProxy proxy;
@Instance("PocketDimensions")
public static mod_pocketDim instance = new mod_pocketDim();
@Instance(mod_pocketDim.modid)
public static mod_pocketDim instance;
public static Block transientDoor;
public static Block warpDoor;
@ -169,7 +169,6 @@ public class mod_pocketDim
@EventHandler
public void onPreInitialization(FMLPreInitializationEvent event)
{
instance = this;
//This should be the FIRST thing that gets done.
String path = event.getSuggestedConfigurationFile().getAbsolutePath().replace(modid, "DimDoors");

View file

@ -36,19 +36,20 @@ public class TileEntityDimDoor extends DDTileEntityBase
}
return null;
}
public void invalidate()
{
this.tileEntityInvalid = true;
if(this.worldObj.getBlockId(xCoord, yCoord, zCoord)==0&&!this.worldObj.isRemote)
{
if(PocketManager.getLink(xCoord, yCoord, zCoord, worldObj)!=null)
{
mod_pocketDim.instance.fastRiftRegenerator.registerRiftForRegen(xCoord, yCoord, zCoord, this.worldObj.provider.dimensionId);
}
}
}
@Override
public void invalidate()
{
this.tileEntityInvalid = true;
if(this.worldObj.getBlockId(xCoord, yCoord, zCoord)==0&&!this.worldObj.isRemote)
{
if(PocketManager.getLink(xCoord, yCoord, zCoord, worldObj)!=null)
{
mod_pocketDim.fastRiftRegenerator.registerRiftForRegen(xCoord, yCoord, zCoord, this.worldObj.provider.dimensionId);
}
}
}
@Override
public void readFromNBT(NBTTagCompound nbt)

View file

@ -66,7 +66,8 @@ public class ComponentNetherGateway extends StructureComponent
* second Part of Structure generating, this for example places Spiderwebs, Mob Spawners, it closes Mineshafts at
* the end, it adds Fences...
*/
public boolean addComponentParts(World world, Random random, StructureBoundingBox bounds)
@Override
public boolean addComponentParts(World world, Random random, StructureBoundingBox bounds)
{
int NETHER_SLAB_METADATA = 6;

View file

@ -18,7 +18,8 @@ public class DDNetherFortressGenerator extends MapGenNetherBridge
MapGenStructureIO.func_143034_b(DDStructureNetherBridgeStart.class, "Fortress");
}
protected StructureStart getStructureStart(int chunkX, int chunkZ)
@Override
protected StructureStart getStructureStart(int chunkX, int chunkZ)
{
return new DDStructureNetherBridgeStart(this.worldObj, this.rand, chunkX, chunkZ, DDProperties.instance());
}

View file

@ -105,7 +105,8 @@ public class DDStructureNetherBridgeStart extends StructureNetherBridgeStart
/**
* Keeps iterating Structure Pieces and spawning them until the checks tell it to stop
*/
public void generateStructure(World world, Random random, StructureBoundingBox generationBounds)
@Override
public void generateStructure(World world, Random random, StructureBoundingBox generationBounds)
{
if (hasGateway)
{

View file

@ -6,10 +6,10 @@
"modid": "dimdoors",
"name": "Dimensional Doors",
"description": "Bend and twist reality itself, creating pocket dimensions, rifts, and much more",
"version": "1.6.4-R2.2.4",
"version": "$version",
"credits": "Created by StevenRS11, Coded by StevenRS11 and SenseiKiwi, Logo and Testing by Jaitsu",
"logoFile": "/dimdoors_logo.png",
"mcversion": "",
"mcversion": "$mcversion",
"url": "http://www.minecraftforum.net/topic/1650007-147smpssplan-dimensional-doors-v110-physics-what-physics-updated-with-fancy-opengl/",
"updateUrl": "",
"authors": [ "StevenRS11", "SenseiKiwi" ],