Auto indented all code

No actual functionality was changed
This commit is contained in:
Mathijs Riezebos 2017-01-13 03:13:49 +01:00
parent c741d5cd35
commit b61aff025c
48 changed files with 1267 additions and 1121 deletions

View file

@ -9,32 +9,33 @@ import net.minecraftforge.fml.common.registry.GameRegistry;
import net.minecraftforge.oredict.ShapedOreRecipe;
public class CraftingManager {
public static void registerRecipes() {
GameRegistry.addRecipe(new ItemStack(ModItems.itemStableFabric, 1),
"yxy", 'x', Items.ENDER_PEARL, 'y', ModItems.itemWorldThread);
GameRegistry.addRecipe(new ItemStack(ModItems.itemDimDoor, 1),
"yxy", 'x', ModItems.itemStableFabric, 'y', Items.IRON_DOOR);
public static void registerRecipes() {
GameRegistry.addRecipe(new ItemStack(ModItems.itemStableFabric, 1),
"yxy", 'x', Items.ENDER_PEARL, 'y', ModItems.itemWorldThread);
GameRegistry.addRecipe(new ItemStack(ModItems.itemDimDoorChaos, 1),
"yxy", 'x', Items.ENDER_EYE, 'y', ModItems.itemDimDoor);
GameRegistry.addRecipe(new ItemStack(ModItems.itemDimDoor, 1),
"yxy", 'x', ModItems.itemStableFabric, 'y', Items.IRON_DOOR);
GameRegistry.addRecipe(new ItemStack(ModItems.itemDimDoorWarp, 1),
"yxy", 'x', Items.ENDER_PEARL, 'y', Items.OAK_DOOR);
GameRegistry.addRecipe(new ItemStack(ModItems.itemDimDoorChaos, 1),
"yxy", 'x', Items.ENDER_EYE, 'y', ModItems.itemDimDoor);
GameRegistry.addRecipe(new ItemStack(ModBlocks.blockDimHatch, 1),
"y", "x", "y", 'x', Items.ENDER_PEARL, 'y', Blocks.TRAPDOOR);
GameRegistry.addRecipe(new ItemStack(ModItems.itemDimDoorWarp, 1),
"yxy", 'x', Items.ENDER_PEARL, 'y', Items.OAK_DOOR);
GameRegistry.addRecipe(new ItemStack(ModItems.itemDimDoorGold, 1),
"yxy", 'x', ModItems.itemStableFabric, 'y', ModItems.itemDoorGold);
GameRegistry.addRecipe(new ItemStack(ModBlocks.blockDimHatch, 1),
"y", "x", "y", 'x', Items.ENDER_PEARL, 'y', Blocks.TRAPDOOR);
GameRegistry.addRecipe(new ItemStack(ModItems.itemDoorGold, 1),
"yy", "yy", "yy", 'y', Items.GOLD_INGOT);
GameRegistry.addRecipe(new ItemStack(ModItems.itemDimDoorGold, 1),
"yxy", 'x', ModItems.itemStableFabric, 'y', ModItems.itemDoorGold);
GameRegistry.addRecipe(new ItemStack(ModItems.itemDimDoorPersonal,1),
"yxy", 'y', ModItems.itemDoorQuartz, 'x', ModItems.itemStableFabric);
GameRegistry.addRecipe(new ItemStack(ModItems.itemDoorGold, 1),
"yy", "yy", "yy", 'y', Items.GOLD_INGOT);
GameRegistry.addRecipe(new ShapedOreRecipe(ModItems.itemDoorQuartz,
"yy", "yy", "yy", 'y', "oreQuartz"));
}
GameRegistry.addRecipe(new ItemStack(ModItems.itemDimDoorPersonal, 1),
"yxy", 'y', ModItems.itemDoorQuartz, 'x', ModItems.itemStableFabric);
GameRegistry.addRecipe(new ShapedOreRecipe(ModItems.itemDoorQuartz,
"yy", "yy", "yy", 'y', "oreQuartz"));
}
}

View file

@ -41,18 +41,18 @@ public abstract class DDProxyCommon implements IDDProxy {
ModelManager.registerModels();
}
public void updateDoorTE(BlockDimDoorBase door, World world, BlockPos pos) {
TileEntity tile = world.getTileEntity(pos);
if (tile instanceof TileEntityDimDoor) {
TileEntityDimDoor dimTile = (TileEntityDimDoor) tile;
public void updateDoorTE(BlockDimDoorBase door, World world, BlockPos pos) {
TileEntity tile = world.getTileEntity(pos);
if (tile instanceof TileEntityDimDoor) {
TileEntityDimDoor dimTile = (TileEntityDimDoor) tile;
IBlockState state = world.getBlockState(pos.down());
dimTile.orientation = state.getBlock() instanceof BlockDimDoorBase ?
state.getValue(BlockDoor.FACING).rotateY() :
ModBlocks.blockDimDoor.getDefaultState().getValue(BlockDoor.FACING);
dimTile.openOrClosed = door.isDoorOnRift(world, pos) && door.isUpperDoorBlock(world.getBlockState(pos));
dimTile.lockStatus = 0;
}
}
dimTile.orientation = state.getBlock() instanceof BlockDimDoorBase
? state.getValue(BlockDoor.FACING).rotateY()
: ModBlocks.blockDimDoor.getDefaultState().getValue(BlockDoor.FACING);
dimTile.openOrClosed = door.isDoorOnRift(world, pos) && door.isUpperDoorBlock(world.getBlockState(pos));
dimTile.lockStatus = 0;
}
}
@Override
public abstract boolean isClient();

View file

@ -15,52 +15,55 @@ import net.minecraftforge.fml.relauncher.SideOnly;
@Mod(modid = DimDoors.MODID, name = "Dimensional Doors", version = DimDoors.VERSION)
public class DimDoors {
public static final String VERSION = "3.0.0-a1";
public static final String MODID = "dimdoors";
@SidedProxy(clientSide = "com.zixiken.dimdoors.client.DDProxyClient",
public static final String VERSION = "3.0.0-a1";
public static final String MODID = "dimdoors";
@SidedProxy(clientSide = "com.zixiken.dimdoors.client.DDProxyClient",
serverSide = "com.zixiken.dimdoors.server.DDProxyServer")
public static DDProxyCommon proxy;
public static DDProxyCommon proxy;
@Mod.Instance(DimDoors.MODID)
public static DimDoors instance;
@Mod.Instance(DimDoors.MODID)
public static DimDoors instance;
public static CreativeTabs dimDoorsCreativeTab = new CreativeTabs("dimDoorsCreativeTab") {
@Override
@SideOnly(Side.CLIENT)
public Item getTabIconItem() {return ModItems.itemDimDoor;}
};
public static CreativeTabs dimDoorsCreativeTab = new CreativeTabs("dimDoorsCreativeTab") {
@Override
@SideOnly(Side.CLIENT)
public Item getTabIconItem() {
return ModItems.itemDimDoor;
}
};
@Mod.EventHandler
public void onPreInitialization(FMLPreInitializationEvent event) {
proxy.onPreInitialization(event);
}
@Mod.EventHandler
public void onPreInitialization(FMLPreInitializationEvent event) {
proxy.onPreInitialization(event);
}
@Mod.EventHandler
public void onInitialization(FMLInitializationEvent event) {
@Mod.EventHandler
public void onInitialization(FMLInitializationEvent event) {
proxy.onInitialization(event);
}
}
@Mod.EventHandler
public void serverLoad( FMLServerStartingEvent event ) {
//@todo event.registerServerCommand( new DDCommand() ); //to register commands that this mod offers?
PocketSavedData.get(getDefWorld());
RiftSavedData.get(getDefWorld());
}
@Mod.EventHandler
public void serverLoad(FMLServerStartingEvent event) {
//@todo event.registerServerCommand( new DDCommand() ); //to register commands that this mod offers?
PocketSavedData.get(getDefWorld());
RiftSavedData.get(getDefWorld());
}
public static boolean isClient() {
return proxy.isClient();
}
public static boolean isClient() {
return proxy.isClient();
}
public static boolean isServer() {
return !isClient();
}
public static boolean isServer() {
return !isClient();
}
public static World getDefWorld() {
return proxy.getDefWorld(); //gets the server or client world dim 0 handler
}
public static World getDefWorld() {
return proxy.getDefWorld(); //gets the server or client world dim 0 handler
}
public static void log( String text ) {
FMLLog.info("[DimDoors] " + text, 0);
}
public static void log(String text) {
FMLLog.info("[DimDoors] " + text, 0);
}
}

View file

@ -7,14 +7,16 @@ import net.minecraftforge.event.entity.player.PlayerInteractEvent;
import net.minecraftforge.fml.common.eventhandler.SubscribeEvent;
public class EventHookContainer {
@SubscribeEvent
public void onPlayerEvent(PlayerInteractEvent event) {
// Handle all door placement here
World world = event.getEntity().world;
ItemStack stack = event.getEntityPlayer().inventory.getCurrentItem();
if (stack != null && ItemDoorBase.tryToPlaceDoor(stack, event.getEntityPlayer(), world, event.getPos(), event.getFace()))
// Cancel the event so that we don't get two doors from vanilla doors
event.setCanceled(true);
}
@SubscribeEvent
public void onPlayerEvent(PlayerInteractEvent event) {
// Handle all door placement here
World world = event.getEntity().world;
ItemStack stack = event.getEntityPlayer().inventory.getCurrentItem();
if (stack != null && ItemDoorBase.tryToPlaceDoor(stack, event.getEntityPlayer(), world, event.getPos(), event.getFace())) // Cancel the event so that we don't get two doors from vanilla doors
{
event.setCanceled(true);
}
}
}

View file

@ -3,6 +3,8 @@ package com.zixiken.dimdoors;
import net.minecraftforge.common.ForgeChunkManager.Ticket;
public interface IChunkLoader {
boolean isInitialized();
void initialize(Ticket ticket);
boolean isInitialized();
void initialize(Ticket ticket);
}

View file

@ -14,10 +14,12 @@ import net.minecraftforge.fml.common.event.FMLPreInitializationEvent;
*
* @author Robijnvogel
*/
public interface IDDProxy
{
public interface IDDProxy {
public boolean isClient();
public void onPreInitialization(FMLPreInitializationEvent event);
public void onInitialization(FMLInitializationEvent event);
public EntityPlayer getLocalPlayer();

View file

@ -15,6 +15,7 @@ import static net.minecraft.item.Item.getItemFromBlock;
@SuppressWarnings({"MethodCallSideOnly", "NewExpressionSideOnly"})
public class ModelManager {
public static void registerModels() {
//ItemBlock registration
register(getItemFromBlock(ModBlocks.blockDimWall));

View file

@ -7,20 +7,23 @@ import net.minecraft.util.math.BlockPos;
import net.minecraft.world.World;
public class BlockDimDoor extends BlockDimDoorBase {
public static final String ID = "blockDimDoor";
public BlockDimDoor() {
super(Material.IRON);
public static final String ID = "blockDimDoor";
public BlockDimDoor() {
super(Material.IRON);
setHardness(1.0F);
setResistance(2000.0F);
setUnlocalizedName(ID);
setRegistryName(ID);
}
}
@Override
public void placeLink(World world, BlockPos pos) {
}
@Override
public void placeLink(World world, BlockPos pos) {
}
@Override
public Item getItemDoor() {return ModItems.itemDimDoor;}
@Override
public Item getItemDoor() {
return ModItems.itemDimDoor;
}
}

View file

@ -28,115 +28,134 @@ import javax.annotation.Nullable;
public abstract class BlockDimDoorBase extends BlockDoor implements IDimDoor, ITileEntityProvider {
public BlockDimDoorBase(Material material) {super(material);}
public BlockDimDoorBase(Material material) {
super(material);
}
@Override
public void onEntityCollidedWithBlock(World world, BlockPos pos, IBlockState state, Entity entity) {
enterDimDoor(world, pos, entity);
}
@Override
public void onEntityCollidedWithBlock(World world, BlockPos pos, IBlockState state, Entity entity) {
enterDimDoor(world, pos, entity);
}
@Override
@Override
public boolean onBlockActivated(World world, BlockPos pos, IBlockState state, EntityPlayer player, EnumHand hand, @Nullable ItemStack heldItem, EnumFacing side, float hitX, float hitY, float hitZ) {
if(!checkCanOpen(world, pos, player)) {return false;}
if (!checkCanOpen(world, pos, player)) {
return false;
}
if(state.getValue(BlockDoor.HALF) == EnumDoorHalf.UPPER) {
if (state.getValue(BlockDoor.HALF) == EnumDoorHalf.UPPER) {
pos = pos.down();
state = world.getBlockState(pos);
}
if(state.getBlock() != this) return false;
else {
if (state.getBlock() != this) {
return false;
} else {
state = state.cycleProperty(BlockDoor.OPEN);
world.setBlockState(pos, state, 2);
world.markBlockRangeForRenderUpdate(pos, pos.up());
return true;
}
}
}
@Override
public boolean hasTileEntity(IBlockState state) {return state.getValue(BlockDoor.HALF) == EnumDoorHalf.UPPER;}
public boolean hasTileEntity(IBlockState state) {
return state.getValue(BlockDoor.HALF) == EnumDoorHalf.UPPER;
}
@Override
public void onBlockAdded(World world, BlockPos pos, IBlockState state) {
if(state.getValue(BlockDoor.HALF) == EnumDoorHalf.UPPER) {
world.setTileEntity(pos, createNewTileEntity(world, 0));
updateAttachedTile(world, pos);
}
}
public void onBlockAdded(World world, BlockPos pos, IBlockState state) {
if (state.getValue(BlockDoor.HALF) == EnumDoorHalf.UPPER) {
world.setTileEntity(pos, createNewTileEntity(world, 0));
updateAttachedTile(world, pos);
}
}
//Called to update the render information on the tile entity. Could probably implement a data watcher,
//but this works fine and is more versatile I think.
public BlockDimDoorBase updateAttachedTile(World world, BlockPos pos) {
DimDoors.proxy.updateDoorTE(this, world, pos);
return this;
}
//Called to update the render information on the tile entity. Could probably implement a data watcher,
//but this works fine and is more versatile I think.
public BlockDimDoorBase updateAttachedTile(World world, BlockPos pos) {
DimDoors.proxy.updateDoorTE(this, world, pos);
return this;
}
public boolean isDoorOnRift(World world, BlockPos pos) {return true;}
public boolean isDoorOnRift(World world, BlockPos pos) {
return true;
}
@Override
public void updateTick(World par1World, BlockPos pos, IBlockState state, Random rand) {
updateAttachedTile(par1World, pos);
}
@Override
public void updateTick(World par1World, BlockPos pos, IBlockState state, Random rand) {
updateAttachedTile(par1World, pos);
}
/**
* only called by clickMiddleMouseButton , and passed to inventory.setCurrentItem (along with isCreative)
*/
@Override
@SideOnly(Side.CLIENT)
/**
* only called by clickMiddleMouseButton , and passed to
* inventory.setCurrentItem (along with isCreative)
*/
@Override
@SideOnly(Side.CLIENT)
public ItemStack getPickBlock(IBlockState state, RayTraceResult target, World world, BlockPos pos, EntityPlayer player) {
return new ItemStack(this.getItemDoor(), 1, 0);
}
return new ItemStack(this.getItemDoor(), 1, 0);
}
/**
* Returns the ID of the items to drop on destruction.
*/
@Override
public Item getItemDropped(IBlockState state, Random random, int fortune) {
public Item getItemDropped(IBlockState state, Random random, int fortune) {
return isUpperDoorBlock(state) ? null : this.getItemDoor();
}
@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();}
@Override
public TileEntity createNewTileEntity(World world, int metadata) {
return new TileEntityDimDoor(world);
}
@Override
public void enterDimDoor(World world, BlockPos pos, Entity entity) {
// Check that this is the top block of the door
IBlockState state = world.getBlockState(pos.down());
if (!world.isRemote && state.getBlock() == this) {
if(state.getValue(BlockDoor.OPEN)
&& entity instanceof EntityPlayer
@Override
public void enterDimDoor(World world, BlockPos pos, Entity entity) {
// Check that this is the top block of the door
IBlockState state = world.getBlockState(pos.down());
if (!world.isRemote && state.getBlock() == this) {
if (state.getValue(BlockDoor.OPEN)
&& entity instanceof EntityPlayer
&& isEntityFacingDoor(state, (EntityLivingBase) entity)) {
this.toggleDoor(world, pos, false);
}
} else {
this.toggleDoor(world, pos, false);
}
} else {
BlockPos up = pos.up();
if (world.getBlockState(up).getBlock() == this) enterDimDoor(world, up, entity);
if (world.getBlockState(up).getBlock() == this) {
enterDimDoor(world, up, entity);
}
}
}
}
public boolean isUpperDoorBlock(IBlockState state) {return state.getValue(BlockDoor.HALF) == EnumDoorHalf.UPPER;}
public boolean isUpperDoorBlock(IBlockState state) {
return state.getValue(BlockDoor.HALF) == EnumDoorHalf.UPPER;
}
public boolean checkCanOpen(World world, BlockPos pos, EntityPlayer player) {
return true;
}
public boolean checkCanOpen(World world, BlockPos pos, EntityPlayer player) {
return true;
}
protected static boolean isEntityFacingDoor(IBlockState state, EntityLivingBase entity) {
// Although any entity has the proper fields for this check,
// we should only apply it to living entities since things
// like Minecarts might come in backwards.
return (state.getValue(BlockDoor.FACING) == EnumFacing.fromAngle(entity.rotationYaw));
}
protected static boolean isEntityFacingDoor(IBlockState state, EntityLivingBase entity) {
// Although any entity has the proper fields for this check,
// we should only apply it to living entities since things
// like Minecarts might come in backwards.
return (state.getValue(BlockDoor.FACING) == EnumFacing.fromAngle(entity.rotationYaw));
}
@Override
public void breakBlock(World world, BlockPos pos, IBlockState state) {
// This function runs on the server side after a block is replaced
// We MUST call super.breakBlock() since it involves removing tile entities
if(state.getValue(BlockDoor.HALF) == EnumDoorHalf.LOWER) world.setBlockToAir(pos.up());
@Override
public void breakBlock(World world, BlockPos pos, IBlockState state) {
// This function runs on the server side after a block is replaced
// We MUST call super.breakBlock() since it involves removing tile entities
if (state.getValue(BlockDoor.HALF) == EnumDoorHalf.LOWER) {
world.setBlockToAir(pos.up());
}
super.breakBlock(world, pos, state);
}
}

View file

@ -10,23 +10,28 @@ import net.minecraft.util.math.BlockPos;
import net.minecraft.world.World;
public class BlockDimDoorGold extends BlockDimDoorBase {
public static final String ID = "blockDimDoorGold";
public BlockDimDoorGold() {
super(Material.IRON);
public BlockDimDoorGold() {
super(Material.IRON);
setHardness(1.0F);
setUnlocalizedName(ID);
setRegistryName(ID);
}
}
@Override
public void placeLink(World world, BlockPos pos) {
}
@Override
public void placeLink(World world, BlockPos pos) {
}
@Override
public Item getItemDoor() {return ModItems.itemDimDoorGold;}
@Override
public Item getItemDoor() {
return ModItems.itemDimDoorGold;
}
@Override
public TileEntity createNewTileEntity(World world, int metadata) {return new TileEntityDimDoorGold(world);}
@Override
public TileEntity createNewTileEntity(World world, int metadata) {
return new TileEntityDimDoorGold(world);
}
}

View file

@ -7,20 +7,23 @@ import net.minecraft.util.math.BlockPos;
import net.minecraft.world.World;
public class BlockDimDoorPersonal extends BlockDimDoorBase {
public static final String ID = "blockDimDoorPersonal";
public BlockDimDoorPersonal() {
super(Material.ROCK);
public static final String ID = "blockDimDoorPersonal";
public BlockDimDoorPersonal() {
super(Material.ROCK);
setHardness(0.1F);
setUnlocalizedName(ID);
setRegistryName(ID);
}
}
@Override
public void placeLink(World world, BlockPos pos) {
}
@Override
public void placeLink(World world, BlockPos pos) {
}
@Override
public Item getItemDoor() {return ModItems.itemDimDoorPersonal;}
@Override
public Item getItemDoor() {
return ModItems.itemDimDoorPersonal;
}
}

View file

@ -11,39 +11,46 @@ import net.minecraft.util.math.BlockPos;
import net.minecraft.world.World;
public class BlockDimDoorTransient extends BlockDimDoorBase {
public static final String ID = "blockDimDoorTransient";
public BlockDimDoorTransient() {
super(Material.IRON);
setHardness(1.0F);
setUnlocalizedName(ID);
setRegistryName(ID);
}
public static final String ID = "blockDimDoorTransient";
@Override
public void enterDimDoor(World world, BlockPos pos, Entity entity) {
// Check that this is the top block of the door
IBlockState state = world.getBlockState(pos.down());
if (!world.isRemote && state.getBlock() == this) {
if (entity instanceof EntityPlayer && isEntityFacingDoor(state, (EntityLivingBase) entity)) {
// Turn the door into a rift AFTER teleporting the player.
// The door's orientation may be necessary for the teleport.
world.setBlockState(pos, ModBlocks.blockRift.getDefaultState());
world.setBlockToAir(pos.down());
}
} else {
public BlockDimDoorTransient() {
super(Material.IRON);
setHardness(1.0F);
setUnlocalizedName(ID);
setRegistryName(ID);
}
@Override
public void enterDimDoor(World world, BlockPos pos, Entity entity) {
// Check that this is the top block of the door
IBlockState state = world.getBlockState(pos.down());
if (!world.isRemote && state.getBlock() == this) {
if (entity instanceof EntityPlayer && isEntityFacingDoor(state, (EntityLivingBase) entity)) {
// Turn the door into a rift AFTER teleporting the player.
// The door's orientation may be necessary for the teleport.
world.setBlockState(pos, ModBlocks.blockRift.getDefaultState());
world.setBlockToAir(pos.down());
}
} else {
BlockPos up = pos.up();
if (world.getBlockState(up).getBlock() == this) enterDimDoor(world, up, entity);
if (world.getBlockState(up).getBlock() == this) {
enterDimDoor(world, up, entity);
}
}
}
}
@Override
public void placeLink(World world, BlockPos pos) {
}
@Override
public void placeLink(World world, BlockPos pos) {
}
@Override
public Item getItemDoor() {return null;}
@Override
public Item getItemDoor() {
return null;
}
@Override
public boolean isCollidable() {return false;}
@Override
public boolean isCollidable() {
return false;
}
}

View file

@ -11,23 +11,28 @@ import net.minecraft.world.World;
import java.util.Random;
public class BlockDimDoorUnstable extends BlockDimDoorBase {
public static final String ID = "blockDimDoorChaos";
public BlockDimDoorUnstable() {
super(Material.IRON);
public static final String ID = "blockDimDoorChaos";
public BlockDimDoorUnstable() {
super(Material.IRON);
setHardness(.2F);
setUnlocalizedName(ID);
setRegistryName(ID);
setLightLevel(.0F);
}
@Override
public void placeLink(World world, BlockPos pos) {
}
@Override
public Item getItemDoor() {return ModItems.itemDimDoorChaos;}
}
@Override
public Item getItemDropped(IBlockState state, Random random, int fortune) {return Items.IRON_DOOR;}
public void placeLink(World world, BlockPos pos) {
}
@Override
public Item getItemDoor() {
return ModItems.itemDimDoorChaos;
}
@Override
public Item getItemDropped(IBlockState state, Random random, int fortune) {
return Items.IRON_DOOR;
}
}

View file

@ -7,19 +7,22 @@ import net.minecraft.util.math.BlockPos;
import net.minecraft.world.World;
public class BlockDimDoorWarp extends BlockDimDoorBase {
public static final String ID = "blockDimDoorWarp";
public BlockDimDoorWarp() {
super(Material.WOOD);
public BlockDimDoorWarp() {
super(Material.WOOD);
setHardness(1.0F);
setUnlocalizedName(ID);
setRegistryName(ID);
}
}
@Override
public void placeLink(World world, BlockPos pos) {
}
@Override
public void placeLink(World world, BlockPos pos) {
}
@Override
public Item getItemDoor() {return ModItems.itemDimDoorWarp;}
@Override
public Item getItemDoor() {
return ModItems.itemDimDoorWarp;
}
}

View file

@ -31,82 +31,96 @@ import javax.annotation.Nullable;
@SuppressWarnings("deprecation")
public class BlockDimWall extends Block {
public static final String ID = "blockDimWall";
public static final PropertyInteger TYPE = PropertyInteger.create("type", 0, 2);
private static final float SUPER_HIGH_HARDNESS = 10000000000000F;
private static final float SUPER_EXPLOSION_RESISTANCE = 18000000F;
private static final float SUPER_HIGH_HARDNESS = 10000000000000F;
private static final float SUPER_EXPLOSION_RESISTANCE = 18000000F;
public BlockDimWall() {
super(Material.IRON);
this.setCreativeTab(DimDoors.dimDoorsCreativeTab);
setLightLevel(1.0F);
public BlockDimWall() {
super(Material.IRON);
this.setCreativeTab(DimDoors.dimDoorsCreativeTab);
setLightLevel(1.0F);
setHardness(0.1F);
setUnlocalizedName(ID);
setRegistryName(ID);
setDefaultState(blockState.getBaseState().withProperty(TYPE, 0));
setSoundType(SoundType.STONE);
}
@Override
public IBlockState getStateFromMeta(int meta) {
if(meta >= 0 && meta <= 2) return getDefaultState().withProperty(TYPE, meta);
else return getDefaultState();
setSoundType(SoundType.STONE);
}
@Override
public boolean isReplaceable(IBlockAccess world, BlockPos pos) {
if(world.getBlockState(pos).getValue(TYPE) == 1) return false;
return true;
}
@Override
public int getMetaFromState(IBlockState state) {return state.getValue(TYPE);}
@Override
protected BlockStateContainer createBlockState() {return new BlockStateContainer(this, TYPE);}
@Override
public float getBlockHardness(IBlockState state, World world, BlockPos pos) {
if (state.getValue(TYPE) != 1) return this.blockHardness;
else return SUPER_HIGH_HARDNESS;
}
@Override
public float getExplosionResistance(World world, BlockPos pos, Entity exploder, Explosion explosion) {
if(world.getBlockState(pos).getValue(TYPE) != 1)
return super.getExplosionResistance(world, pos, exploder, explosion);
else return SUPER_EXPLOSION_RESISTANCE;
}
@Override
public int damageDropped(IBlockState state) {
int metadata = state.getValue(TYPE);
//Return 0 to avoid dropping Ancient Fabric even if the player somehow manages to break it
return metadata == 1 ? 0 : metadata;
}
@Override
@SideOnly(Side.CLIENT)
public void getSubBlocks(Item itemIn, CreativeTabs tab, List<ItemStack> subItems) {
for (int ix = 0; ix < 3; ix++)
subItems.add(new ItemStack(itemIn, 1, ix));
}
public IBlockState getStateFromMeta(int meta) {
if (meta >= 0 && meta <= 2) {
return getDefaultState().withProperty(TYPE, meta);
} else {
return getDefaultState();
}
}
@Override
public boolean canSilkHarvest(World world, BlockPos pos, IBlockState state, EntityPlayer player)
{
public boolean isReplaceable(IBlockAccess world, BlockPos pos) {
if (world.getBlockState(pos).getValue(TYPE) == 1) {
return false;
}
return true;
}
@Override
public ItemStack getPickBlock(IBlockState state, RayTraceResult target, World world, BlockPos pos, EntityPlayer player) {
public int getMetaFromState(IBlockState state) {
return state.getValue(TYPE);
}
@Override
protected BlockStateContainer createBlockState() {
return new BlockStateContainer(this, TYPE);
}
@Override
public float getBlockHardness(IBlockState state, World world, BlockPos pos) {
if (state.getValue(TYPE) != 1) {
return this.blockHardness;
} else {
return SUPER_HIGH_HARDNESS;
}
}
@Override
public float getExplosionResistance(World world, BlockPos pos, Entity exploder, Explosion explosion) {
if (world.getBlockState(pos).getValue(TYPE) != 1) {
return super.getExplosionResistance(world, pos, exploder, explosion);
} else {
return SUPER_EXPLOSION_RESISTANCE;
}
}
@Override
public int damageDropped(IBlockState state) {
int metadata = state.getValue(TYPE);
//Return 0 to avoid dropping Ancient Fabric even if the player somehow manages to break it
return metadata == 1 ? 0 : metadata;
}
@Override
@SideOnly(Side.CLIENT)
public void getSubBlocks(Item itemIn, CreativeTabs tab, List<ItemStack> subItems) {
for (int ix = 0; ix < 3; ix++) {
subItems.add(new ItemStack(itemIn, 1, ix));
}
}
@Override
public boolean canSilkHarvest(World world, BlockPos pos, IBlockState state, EntityPlayer player) {
return true;
}
@Override
public ItemStack getPickBlock(IBlockState state, RayTraceResult target, World world, BlockPos pos, EntityPlayer player) {
return new ItemStack(Item.getItemFromBlock(this), 1, getMetaFromState(world.getBlockState(pos)));
}
@Override
public int quantityDropped(Random par1Random)
{
public int quantityDropped(Random par1Random) {
return 0;
}
}

View file

@ -14,14 +14,15 @@ import net.minecraftforge.fml.relauncher.Side;
import net.minecraftforge.fml.relauncher.SideOnly;
public class BlockDoorGold extends BlockDoor {
public static final String ID = "blockDoorGold";
public BlockDoorGold() {
super(Material.IRON);
public BlockDoorGold() {
super(Material.IRON);
setHardness(0.1F);
setUnlocalizedName(ID);
setRegistryName(ID);
}
}
@Override
public Item getItemDropped(IBlockState state, Random rand, int fortune) {

View file

@ -14,14 +14,15 @@ import net.minecraftforge.fml.relauncher.Side;
import net.minecraftforge.fml.relauncher.SideOnly;
public class BlockDoorQuartz extends BlockDoor {
public static final String ID = "blockDoorQuartz";
public BlockDoorQuartz() {
super(Material.ROCK);
public BlockDoorQuartz() {
super(Material.ROCK);
setHardness(0.1F);
setUnlocalizedName(ID);
setRegistryName(ID);
}
}
@Override
public Item getItemDropped(IBlockState state, Random rand, int fortune) {

View file

@ -32,159 +32,167 @@ import net.minecraftforge.fml.relauncher.SideOnly;
@SuppressWarnings("deprecation")
public class BlockRift extends Block implements ITileEntityProvider {
private static final float MIN_IMMUNE_RESISTANCE = 5000.0F;
private static final float MIN_IMMUNE_RESISTANCE = 5000.0F;
public static final String ID = "blockRift";
private final ArrayList<Block> blocksImmuneToRift; // List of Vanilla blocks immune to rifts
private final ArrayList<Block> modBlocksImmuneToRift; // List of DD blocks immune to rifts
private final ArrayList<Block> blocksImmuneToRift; // List of Vanilla blocks immune to rifts
private final ArrayList<Block> modBlocksImmuneToRift; // List of DD blocks immune to rifts
public BlockRift() {
super(Material.FIRE);
setTickRandomly(true);
public BlockRift() {
super(Material.FIRE);
setTickRandomly(true);
setHardness(1.0F);
setUnlocalizedName(ID);
setRegistryName(ID);
modBlocksImmuneToRift = new ArrayList<Block>();
modBlocksImmuneToRift.add(ModBlocks.blockDimWall);
modBlocksImmuneToRift.add(ModBlocks.blockDimDoor);
modBlocksImmuneToRift.add(ModBlocks.blockDimDoorWarp);
modBlocksImmuneToRift.add(ModBlocks.blockDimHatch);
modBlocksImmuneToRift.add(ModBlocks.blockDimDoorChaos);
modBlocksImmuneToRift.add(ModBlocks.blockRift);
modBlocksImmuneToRift.add(ModBlocks.blockDimDoorTransient);
modBlocksImmuneToRift.add(ModBlocks.blockDimDoorGold);
modBlocksImmuneToRift.add(ModBlocks.blockDoorGold);
modBlocksImmuneToRift.add(ModBlocks.blockDimDoorPersonal);
modBlocksImmuneToRift.add(ModBlocks.blockDoorQuartz);
modBlocksImmuneToRift = new ArrayList<Block>();
modBlocksImmuneToRift.add(ModBlocks.blockDimWall);
modBlocksImmuneToRift.add(ModBlocks.blockDimDoor);
modBlocksImmuneToRift.add(ModBlocks.blockDimDoorWarp);
modBlocksImmuneToRift.add(ModBlocks.blockDimHatch);
modBlocksImmuneToRift.add(ModBlocks.blockDimDoorChaos);
modBlocksImmuneToRift.add(ModBlocks.blockRift);
modBlocksImmuneToRift.add(ModBlocks.blockDimDoorTransient);
modBlocksImmuneToRift.add(ModBlocks.blockDimDoorGold);
modBlocksImmuneToRift.add(ModBlocks.blockDoorGold);
modBlocksImmuneToRift.add(ModBlocks.blockDimDoorPersonal);
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 = 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);
}
@Override
public boolean isCollidable() {return false;}
@Override
public boolean isCollidable() {
return false;
}
@Override
public boolean isOpaqueCube(IBlockState state) {return false;}
@Override
public boolean isOpaqueCube(IBlockState state) {
return false;
}
@Override
public AxisAlignedBB getCollisionBoundingBox(IBlockState state, World world, BlockPos pos) {
return null;
}
@Override
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
*/
@Override
public boolean canCollideCheck(IBlockState state, boolean hitIfLiquid)
{
return hitIfLiquid;
}
/**
* Returns whether this block is collideable based on the arguments passed
* in Args: blockMetaData, unknownFlag
*/
@Override
public boolean canCollideCheck(IBlockState state, boolean hitIfLiquid) {
return hitIfLiquid;
}
/**
* Returns Returns true if the given side of this block type should be rendered (if it's solid or not), if the
* adjacent block is at the given coordinates. Args: blockAccess, x, y, z, side
*/
@Override
public boolean isBlockSolid(IBlockAccess worldIn, BlockPos pos, EnumFacing side)
{
return true;
}
/**
* Returns Returns true if the given side of this block type should be
* rendered (if it's solid or not), if the adjacent block is at the given
* coordinates. Args: blockAccess, x, y, z, side
*/
@Override
public boolean isBlockSolid(IBlockAccess worldIn, BlockPos pos, EnumFacing side) {
return true;
}
@Override
public EnumBlockRenderType getRenderType(IBlockState state) {
@Override
public EnumBlockRenderType getRenderType(IBlockState state) {
return EnumBlockRenderType.INVISIBLE; //Tile Entity Special Renderer
}
public void dropWorldThread(World world, BlockPos pos, Random random) {
public void dropWorldThread(World world, BlockPos pos, Random random) {
Block block = world.getBlockState(pos).getBlock();
if (!world.getBlockState(pos).equals(Blocks.AIR) && !(block instanceof BlockLiquid || block instanceof IFluidBlock)) {
ItemStack thread = new ItemStack(ModItems.itemWorldThread, 1);
world.spawnEntity(new EntityItem(world, pos.getX(), pos.getY(), pos.getZ(), thread));
}
}
if (!world.getBlockState(pos).equals(Blocks.AIR) && !(block instanceof BlockLiquid || block instanceof IFluidBlock)) {
ItemStack thread = new ItemStack(ModItems.itemWorldThread, 1);
world.spawnEntity(new EntityItem(world, pos.getX(), pos.getY(), pos.getZ(), thread));
}
}
/**
* Lets pistons push through rifts, destroying them
*/
@Override
public EnumPushReaction getMobilityFlag(IBlockState state) {
return EnumPushReaction.NORMAL;
}
/**
* Lets pistons push through rifts, destroying them
*/
@Override
public EnumPushReaction getMobilityFlag(IBlockState state) {
return EnumPushReaction.NORMAL;
}
/**
* regulates the render effect, especially when multiple rifts start to link up.
* Has 3 main parts- Grows toward and away from nearest rift, bends toward it, and a randomization function
*/
@Override
@SideOnly(Side.CLIENT)
public void randomDisplayTick(IBlockState state, World worldIn, BlockPos pos, Random rand) {
/**
* regulates the render effect, especially when multiple rifts start to link
* up. Has 3 main parts- Grows toward and away from nearest rift, bends
* toward it, and a randomization function
*/
@Override
@SideOnly(Side.CLIENT)
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();
TileEntityRift tile = (TileEntityRift)worldIn.getTileEntity(pos);
TileEntityRift tile = (TileEntityRift) worldIn.getTileEntity(pos);
//renders an extra little blob on top of the actual rift location so its easier to find.
// Eventually will only render if the player has the goggles.
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));
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
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));
}
x + .5, y + .5, z + .5,
rand.nextGaussian() * 0.01D, rand.nextGaussian() * 0.01D, rand.nextGaussian() * 0.01D));
}
}
public boolean tryPlacingRift(World world, BlockPos pos) {
return world != null && !isBlockImmune(world, pos) && world.setBlockState(pos, getDefaultState());
}
public boolean tryPlacingRift(World world, BlockPos pos) {
return world != null && !isBlockImmune(world, pos) && world.setBlockState(pos, getDefaultState());
}
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 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);
}
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
public ItemStack getPickBlock(IBlockState state, RayTraceResult target, World world, BlockPos pos, EntityPlayer player) {
@Override
public ItemStack getPickBlock(IBlockState state, RayTraceResult target, World world, BlockPos pos, EntityPlayer player) {
return null;
}
@Override
public Item getItemDropped(IBlockState state, Random rand, int fortune) {return null;}
public Item getItemDropped(IBlockState state, Random rand, int fortune) {
return null;
}
@Override
public TileEntity createNewTileEntity(World world, int metadata)
{
return new TileEntityRift(world);
}
public TileEntity createNewTileEntity(World world, int metadata) {
return new TileEntityRift(world);
}
@Override
public void breakBlock(World world, BlockPos pos, IBlockState state) {
world.removeTileEntity(pos);
@Override
public void breakBlock(World world, BlockPos pos, IBlockState state) {
world.removeTileEntity(pos);
}
}

View file

@ -25,87 +25,100 @@ import net.minecraftforge.fml.relauncher.Side;
import net.minecraftforge.fml.relauncher.SideOnly;
public class BlockTransTrapdoor extends BlockTrapDoor implements IDimDoor, ITileEntityProvider {
public static final String ID = "blockDimHatch";
public BlockTransTrapdoor() {
super(Material.WOOD);
this.setCreativeTab(DimDoors.dimDoorsCreativeTab);
public static final String ID = "blockDimHatch";
public BlockTransTrapdoor() {
super(Material.WOOD);
this.setCreativeTab(DimDoors.dimDoorsCreativeTab);
setHardness(1.0F);
setUnlocalizedName(ID);
setRegistryName(ID);
setSoundType(SoundType.WOOD);
}
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, IBlockState state, Entity entity) {
enterDimDoor(world, pos, entity);
}
//Teleports the player to the exit link of that dimension, assuming it is a pocket
@Override
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);}
public boolean checkCanOpen(World world, BlockPos pos) {
return this.checkCanOpen(world, pos, null);
}
public boolean checkCanOpen(World world, BlockPos pos, EntityPlayer player) {return true;}
public boolean checkCanOpen(World world, BlockPos pos, EntityPlayer player) {
return true;
}
@Override
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, hand, heldItem, side, hitX, hitY, hitZ);
return checkCanOpen(worldIn, pos, playerIn)
&& super.onBlockActivated(worldIn, pos, state, playerIn, hand, heldItem, side, hitX, hitY, hitZ);
}
@Override
public void neighborChanged(IBlockState state, World worldIn, BlockPos pos, Block neighborBlock) {
if(checkCanOpen(worldIn, pos)) super.neighborChanged(state, worldIn, pos, neighborBlock);
if (checkCanOpen(worldIn, pos)) {
super.neighborChanged(state, worldIn, pos, neighborBlock);
}
}
@Override
public void enterDimDoor(World world, BlockPos pos, Entity entity) {
public void enterDimDoor(World world, BlockPos pos, Entity entity) {
IBlockState state = world.getBlockState(pos);
if (!world.isRemote && state.getValue(BlockTrapDoor.OPEN)) {
if (entity instanceof EntityPlayer) {
if (!world.isRemote && state.getValue(BlockTrapDoor.OPEN)) {
if (entity instanceof EntityPlayer) {
state.cycleProperty(BlockTrapDoor.OPEN);
world.markBlockRangeForRenderUpdate(pos, pos);
}
}
}
}
}
@Override
public void onBlockAdded(World world, BlockPos pos, IBlockState state) {
this.placeLink(world, pos);
world.setTileEntity(pos, createNewTileEntity(world, getMetaFromState(state)));
}
@Override
public void onBlockAdded(World world, BlockPos pos, IBlockState state) {
this.placeLink(world, pos);
world.setTileEntity(pos, createNewTileEntity(world, getMetaFromState(state)));
}
@Override
public TileEntity createNewTileEntity(World world, int metadata) {return new TileEntityTransTrapdoor(world);}
@Override
public TileEntity createNewTileEntity(World world, int metadata) {
return new TileEntityTransTrapdoor(world);
}
@Override
public void placeLink(World world, BlockPos pos) {
}
@Override
public void placeLink(World world, BlockPos pos) {
}
@Override
@SideOnly(Side.CLIENT)
public ItemStack getPickBlock(IBlockState state, RayTraceResult target, World world, BlockPos pos, EntityPlayer player) {
return new ItemStack(this.getItemDoor(), 1, 0);
}
@Override
@SideOnly(Side.CLIENT)
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) {
@Override
public Item getItemDropped(IBlockState state, Random random, int fortuneLevel) {
return Item.getItemFromBlock(Blocks.TRAPDOOR);
}
@Override
public Item getItemDoor() {return Item.getItemFromBlock(ModBlocks.blockDimHatch);}
@Override
public Item getItemDoor() {
return Item.getItemFromBlock(ModBlocks.blockDimHatch);
}
public static boolean isTrapdoorSetLow(IBlockState state) {
public static boolean isTrapdoorSetLow(IBlockState state) {
return state.getValue(BlockTrapDoor.HALF) == DoorHalf.BOTTOM;
}
@Override
public boolean isDoorOnRift(World world, BlockPos pos) {return true;}
@Override
public boolean isDoorOnRift(World world, BlockPos pos) {
return true;
}
@Override
public void breakBlock(World world, BlockPos pos, IBlockState state) {
// This function runs on the server side after a block is replaced
// We MUST call super.breakBlock() since it involves removing tile entities
@Override
public void breakBlock(World world, BlockPos pos, IBlockState state) {
// This function runs on the server side after a block is replaced
// We MUST call super.breakBlock() since it involves removing tile entities
super.breakBlock(world, pos, state);
}
}

View file

@ -6,37 +6,41 @@ import net.minecraft.tileentity.TileEntity;
import net.minecraft.util.math.BlockPos;
import net.minecraft.world.World;
public interface IDimDoor
{
/**
* A function to enter a dim door and traverse its link, called when a player collides with an open door
* @param world
* @param x
* @param y
* @param z
* @param entity
*/
public void enterDimDoor(World world, BlockPos pos, Entity entity);
public interface IDimDoor {
/**
* called when a door is placed to determine how it will place a link
* @param world
* @param x
* @param y
* @param z
*/
public void placeLink(World world, BlockPos pos);
/**
* A function to enter a dim door and traverse its link, called when a
* player collides with an open door
*
* @param world
* @param x
* @param y
* @param z
* @param entity
*/
public void enterDimDoor(World world, BlockPos pos, Entity entity);
public Item getItemDoor();
/**
* called when a door is placed to determine how it will place a link
*
* @param world
* @param x
* @param y
* @param z
*/
public void placeLink(World world, BlockPos pos);
/**
* checks if any of this doors blocks are overlapping with a rift
* @param world
* @param x
* @param y
* @param z
* @return
*/
public boolean isDoorOnRift(World world, BlockPos pos);
public Item getItemDoor();
/**
* checks if any of this doors blocks are overlapping with a rift
*
* @param world
* @param x
* @param y
* @param z
* @return
*/
public boolean isDoorOnRift(World world, BlockPos pos);
}

View file

@ -3,6 +3,7 @@ package com.zixiken.dimdoors.blocks;
import net.minecraftforge.fml.common.registry.GameRegistry;
public class ModBlocks {
public static BlockDoorQuartz blockDoorQuartz;
public static BlockDoorGold blockDoorGold;
public static BlockDimDoorPersonal blockDimDoorPersonal;

View file

@ -10,49 +10,50 @@ import net.minecraftforge.fml.relauncher.Side;
import net.minecraftforge.fml.relauncher.SideOnly;
@SideOnly(Side.CLIENT)
public class ClosingRiftFX extends Particle
{
private int baseTextureIndex = 160;
private boolean trail;
private boolean twinkle;
private float fadeColourRed;
private float fadeColourGreen;
private float fadeColourBlue;
private boolean hasFadeColour;
public class ClosingRiftFX extends Particle {
public ClosingRiftFX(World world, double x, double y, double z, double motionX, double motionY, double motionZ) {
private int baseTextureIndex = 160;
private boolean trail;
private boolean twinkle;
private float fadeColourRed;
private float fadeColourGreen;
private float fadeColourBlue;
private boolean hasFadeColour;
super(world, x, y, z);
this.motionX = motionX;
this.motionY = motionY;
this.motionZ = motionZ;
this.particleScale *= .55F;
this.particleMaxAge = 30 + this.rand.nextInt(16);
}
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.particleScale *= .55F;
this.particleMaxAge = 30 + this.rand.nextInt(16);
}
@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
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)
this.doRenderParticle(worldRenderer, partialTicks, p_180434_4_,
p_180434_5_, p_180434_6_, p_180434_7_, p_180434_8_);
}
|| (this.particleAge + this.particleMaxAge) / 3 % 2 == 0) {
this.doRenderParticle(worldRenderer, partialTicks, p_180434_4_,
p_180434_5_, p_180434_6_, p_180434_7_, p_180434_8_);
}
}
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;
float var10 = this.particleTextureIndexX / 16 / 16.0F;
float var11 = var10 + 0.0624375F;
float var12 = 0.1F * this.particleScale;
float var13 = (float)(this.prevPosX + (this.posX - this.prevPosX) * par2 - interpPosX);
float var14 = (float)(this.prevPosY + (this.posY - this.prevPosY) * par2 - interpPosY);
float var15 = (float)(this.prevPosZ + (this.posZ - this.prevPosZ) * par2 - interpPosZ);
float var16 = 0.8F;
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;
float var10 = this.particleTextureIndexX / 16 / 16.0F;
float var11 = var10 + 0.0624375F;
float var12 = 0.1F * this.particleScale;
float var13 = (float) (this.prevPosX + (this.posX - this.prevPosX) * par2 - interpPosX);
float var14 = (float) (this.prevPosY + (this.posY - this.prevPosY) * par2 - interpPosY);
float var15 = (float) (this.prevPosZ + (this.posZ - this.prevPosZ) * par2 - interpPosZ);
float var16 = 0.8F;
worldRenderer.pos(var13 - par3 * var12 - par6 * var12, var14 - par4 * var12, var15 - par5 * var12 - par7 * var12)
worldRenderer.pos(var13 - par3 * var12 - par6 * var12, var14 - par4 * var12, var15 - par5 * var12 - par7 * var12)
.tex(var9, var11)
.color(this.particleRed * var16, this.particleGreen * var16, this.particleBlue * var16, (float) .7)
.endVertex();
@ -68,54 +69,55 @@ public class ClosingRiftFX extends Particle
.tex(var8, var11)
.color(this.particleRed * var16, this.particleGreen * var16, this.particleBlue * var16, (float) .7)
.endVertex();
}
}
/**
* Called to update the entity's position/logic.
*/
@Override
public void onUpdate() {
this.prevPosX = this.posX;
this.prevPosY = this.posY;
this.prevPosZ = this.posZ;
/**
* Called to update the entity's position/logic.
*/
@Override
public void onUpdate() {
this.prevPosX = this.posX;
this.prevPosY = this.posY;
this.prevPosZ = this.posZ;
if (this.particleAge++ >= this.particleMaxAge) {
this.setExpired();
} if (this.particleAge > this.particleMaxAge / 2) {
this.setAlphaF(1.0F - ((float)this.particleAge - (float)(this.particleMaxAge / 2)) / this.particleMaxAge);
if (this.particleAge++ >= this.particleMaxAge) {
this.setExpired();
}
if (this.particleAge > this.particleMaxAge / 2) {
this.setAlphaF(1.0F - ((float) this.particleAge - (float) (this.particleMaxAge / 2)) / this.particleMaxAge);
if (this.hasFadeColour) {
if (this.hasFadeColour) {
this.particleRed += (this.fadeColourRed - this.particleRed) * 0.2F;
this.particleGreen += (this.fadeColourGreen - this.particleGreen) * 0.2F;
this.particleBlue += (this.fadeColourBlue - this.particleBlue) * 0.2F;
this.particleBlue += (this.fadeColourBlue - this.particleBlue) * 0.2F;
}
}
this.setParticleTextureIndex(this.baseTextureIndex + (7 - this.particleAge * 8 / this.particleMaxAge));
// this.motionY -= 0.004D;
this.move(this.motionX, this.motionY, this.motionZ);
this.motionX *= 0.9100000262260437D;
this.motionY *= 0.9100000262260437D;
this.motionZ *= 0.9100000262260437D;
this.setParticleTextureIndex(this.baseTextureIndex + (7 - this.particleAge * 8 / this.particleMaxAge));
// this.motionY -= 0.004D;
this.move(this.motionX, this.motionY, this.motionZ);
this.motionX *= 0.9100000262260437D;
this.motionY *= 0.9100000262260437D;
this.motionZ *= 0.9100000262260437D;
if (this.trail && this.particleAge < this.particleMaxAge / 2 && (this.particleAge + this.particleMaxAge) % 2 == 0) {
ClosingRiftFX var1 = new ClosingRiftFX(this.world, 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;
if (this.trail && this.particleAge < this.particleMaxAge / 2 && (this.particleAge + this.particleMaxAge) % 2 == 0) {
ClosingRiftFX var1 = new ClosingRiftFX(this.world, 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;
if (this.hasFadeColour) {
var1.hasFadeColour = true;
var1.fadeColourRed = this.fadeColourRed;
var1.fadeColourGreen = this.fadeColourGreen;
var1.fadeColourBlue = this.fadeColourBlue;
if (this.hasFadeColour) {
var1.hasFadeColour = true;
var1.fadeColourRed = this.fadeColourRed;
var1.fadeColourGreen = this.fadeColourGreen;
var1.fadeColourBlue = this.fadeColourBlue;
}
var1.twinkle = this.twinkle;
var1.twinkle = this.twinkle;
}
}
@Override
public int getBrightnessForRender(float par1) {
return 15728880;
@Override
public int getBrightnessForRender(float par1) {
return 15728880;
}
}

View file

@ -10,7 +10,6 @@ import net.minecraft.world.World;
import net.minecraftforge.fml.client.registry.ClientRegistry;
import net.minecraftforge.fml.common.event.FMLPreInitializationEvent;
public class DDProxyClient extends DDProxyCommon {
@Override

View file

@ -8,8 +8,9 @@ import net.minecraftforge.fml.relauncher.SideOnly;
@SideOnly(Side.CLIENT)
public class GoggleRiftFX extends ParticleCloud {
public GoggleRiftFX(World par1World, double par2, double par4, double par6,
double par8, double par10, double par12) {
double par8, double par10, double par12) {
super(par1World, par2, par4, par6, par12, par12, par12);
this.particleMaxAge = 40 + this.rand.nextInt(26);
}

View file

@ -26,129 +26,130 @@ import static org.lwjgl.opengl.GL11.*;
@SideOnly(Side.CLIENT)
public class RenderDimDoor extends TileEntitySpecialRenderer<TileEntityDimDoor> {
private FloatBuffer buffer = GLAllocation.createDirectFloatBuffer(16);
private ResourceLocation warpPath= new ResourceLocation(DimDoors.MODID + ":textures/other/WARP.png");
private ResourceLocation keyPath= new ResourceLocation(DimDoors.MODID + ":textures/other/keyhole.png");
private ResourceLocation KeyholeLight= new ResourceLocation(DimDoors.MODID + ":textures/other/keyholeLight.png");
/**
* Renders the dimdoor.
*/
public void renderDimDoorTileEntity(TileEntityDimDoor tile, double x, double y, double z) {
GL11.glDisable(GL11.GL_LIGHTING);
Random rand = new Random(31100L);
private FloatBuffer buffer = GLAllocation.createDirectFloatBuffer(16);
private ResourceLocation warpPath = new ResourceLocation(DimDoors.MODID + ":textures/other/WARP.png");
private ResourceLocation keyPath = new ResourceLocation(DimDoors.MODID + ":textures/other/keyhole.png");
private ResourceLocation KeyholeLight = new ResourceLocation(DimDoors.MODID + ":textures/other/keyholeLight.png");
for (int count = 0; count < 16; ++count) {
GlStateManager.pushMatrix();
/**
* Renders the dimdoor.
*/
public void renderDimDoorTileEntity(TileEntityDimDoor tile, double x, double y, double z) {
GL11.glDisable(GL11.GL_LIGHTING);
Random rand = new Random(31100L);
float var15 = 16 - count;
float var16 = 0.2625F;
float var17 = 1.0F / (var15 + .80F);
for (int count = 0; count < 16; ++count) {
GlStateManager.pushMatrix();
this.bindTexture(warpPath);
GlStateManager.enableBlend();
float var15 = 16 - count;
float var16 = 0.2625F;
float var17 = 1.0F / (var15 + .80F);
if (count == 0) {
var17 = 0.1F;
var15 = 25.0F;
var16 = 0.125F;
this.bindTexture(warpPath);
GlStateManager.enableBlend();
GlStateManager.blendFunc(GL11.GL_SRC_ALPHA, GL11.GL_ONE_MINUS_SRC_ALPHA);
}
if (count == 0) {
var17 = 0.1F;
var15 = 25.0F;
var16 = 0.125F;
if (count == 1) {
var16 = .5F;
GlStateManager.blendFunc(GL11.GL_SRC_ALPHA, GL11.GL_ONE_MINUS_SRC_ALPHA);
}
GlStateManager.blendFunc(GL11.GL_ONE, GL11.GL_ONE);
}
if (count == 1) {
var16 = .5F;
GlStateManager.translate(Minecraft.getSystemTime() % 200000L / 200000.0F, 0, 0.0F);
GlStateManager.translate(0, Minecraft.getSystemTime() % 200000L / 200000.0F, 0.0F);
GlStateManager.translate(0, 0, Minecraft.getSystemTime() % 200000L / 200000.0F);
GlStateManager.blendFunc(GL11.GL_ONE, GL11.GL_ONE);
}
GlStateManager.texGen(GlStateManager.TexGen.S, GL11.GL_OBJECT_LINEAR);
GlStateManager.texGen(GlStateManager.TexGen.T, GL11.GL_OBJECT_LINEAR);
GlStateManager.texGen(GlStateManager.TexGen.R, GL11.GL_OBJECT_LINEAR);
GlStateManager.texGen(GlStateManager.TexGen.Q, GL11.GL_OBJECT_LINEAR);
GlStateManager.translate(Minecraft.getSystemTime() % 200000L / 200000.0F, 0, 0.0F);
GlStateManager.translate(0, Minecraft.getSystemTime() % 200000L / 200000.0F, 0.0F);
GlStateManager.translate(0, 0, Minecraft.getSystemTime() % 200000L / 200000.0F);
EnumFacing orientation = EnumFacing.getHorizontal((tile.orientation.getHorizontalIndex() % 4) + 4);
GlStateManager.texGen(GlStateManager.TexGen.S, GL11.GL_OBJECT_LINEAR);
GlStateManager.texGen(GlStateManager.TexGen.T, GL11.GL_OBJECT_LINEAR);
GlStateManager.texGen(GlStateManager.TexGen.R, GL11.GL_OBJECT_LINEAR);
GlStateManager.texGen(GlStateManager.TexGen.Q, GL11.GL_OBJECT_LINEAR);
switch (orientation) {
case SOUTH:
GlStateManager.texGen(GlStateManager.TexGen.S, GL11.GL_OBJECT_PLANE, this.getFloatBuffer(0.0F, 1.0F, 0.0F, 0.0F));
EnumFacing orientation = EnumFacing.getHorizontal((tile.orientation.getHorizontalIndex() % 4) + 4);
switch (orientation) {
case SOUTH:
GlStateManager.texGen(GlStateManager.TexGen.S, GL11.GL_OBJECT_PLANE, this.getFloatBuffer(0.0F, 1.0F, 0.0F, 0.0F));
GlStateManager.texGen(GlStateManager.TexGen.T, GL11.GL_OBJECT_PLANE, this.getFloatBuffer(0.0F, 0.0F, 1.0F, 0.0F));
GlStateManager.texGen(GlStateManager.TexGen.R, GL11.GL_OBJECT_PLANE, this.getFloatBuffer(0.0F, 0.0F, 0.0F, 1.0F));
GlStateManager.texGen(GlStateManager.TexGen.Q, GL11.GL_OBJECT_PLANE, this.getFloatBuffer(1.0F, 0.0F, 0.0F, 0.15F));
break;
case WEST:
break;
case WEST:
GlStateManager.texGen(GlStateManager.TexGen.S, GL11.GL_OBJECT_PLANE, this.getFloatBuffer(0.0F, 1.0F, 0.0F, 0.0F));
GlStateManager.texGen(GlStateManager.TexGen.T, GL11.GL_OBJECT_PLANE, this.getFloatBuffer(1.0F, 0.0F, 0.0F, 0.0F));
GlStateManager.texGen(GlStateManager.TexGen.R, GL11.GL_OBJECT_PLANE, this.getFloatBuffer(0.0F, 0.0F, 0.0F, 1.0F));
GlStateManager.texGen(GlStateManager.TexGen.Q, GL11.GL_OBJECT_PLANE, this.getFloatBuffer(0.0F, 0.0F, 1.0F, 0.15F));
break;
case NORTH:
break;
case NORTH:
GlStateManager.texGen(GlStateManager.TexGen.S, GL11.GL_OBJECT_PLANE, this.getFloatBuffer(0.0F, 1.0F, 0.0F, 0.0F));
GlStateManager.texGen(GlStateManager.TexGen.T, GL11.GL_OBJECT_PLANE, this.getFloatBuffer(0.0F, 0.0F, 1.0F, 0.0F));
GlStateManager.texGen(GlStateManager.TexGen.T, GL11.GL_OBJECT_PLANE, this.getFloatBuffer(0.0F, 0.0F, 1.0F, 0.0F));
GlStateManager.texGen(GlStateManager.TexGen.R, GL11.GL_OBJECT_PLANE, this.getFloatBuffer(0.0F, 0.0F, 0.0F, 1.0F));
GlStateManager.texGen(GlStateManager.TexGen.Q, GL11.GL_OBJECT_PLANE, this.getFloatBuffer(1.0F, 0.0F, 0.0F, -0.15F));
break;
case EAST:
GlStateManager.texGen(GlStateManager.TexGen.S, GL11.GL_OBJECT_PLANE, this.getFloatBuffer(0.0F, 1.0F, 0.0F, 0.0F));
break;
case EAST:
GlStateManager.texGen(GlStateManager.TexGen.S, GL11.GL_OBJECT_PLANE, this.getFloatBuffer(0.0F, 1.0F, 0.0F, 0.0F));
GlStateManager.texGen(GlStateManager.TexGen.T, GL11.GL_OBJECT_PLANE, this.getFloatBuffer(1.0F, 0.0F, 0.0F, 0.0F));
GlStateManager.texGen(GlStateManager.TexGen.R, GL11.GL_OBJECT_PLANE, this.getFloatBuffer(0.0F, 0.0F, 0.0F, 1.0F));
GlStateManager.texGen(GlStateManager.TexGen.Q, GL11.GL_OBJECT_PLANE, this.getFloatBuffer(0.0F, 0.0F, 1.0F, -0.15F));
break;
}
break;
}
GlStateManager.enableTexGenCoord(GlStateManager.TexGen.S);
GlStateManager.enableTexGenCoord(GlStateManager.TexGen.S);
GlStateManager.enableTexGenCoord(GlStateManager.TexGen.T);
GlStateManager.enableTexGenCoord(GlStateManager.TexGen.R);
GlStateManager.enableTexGenCoord(GlStateManager.TexGen.Q);
GlStateManager.popMatrix();
GlStateManager.popMatrix();
GlStateManager.matrixMode(GL11.GL_TEXTURE);
GlStateManager.pushMatrix();
GlStateManager.loadIdentity();
GlStateManager.translate(0.0F, Minecraft.getSystemTime() % 200000L / 200000.0F * var15, 0.0F);
GlStateManager.scale(var16, var16, var16);
GlStateManager.translate(0.5F, 0.5F, 0.5F);
GlStateManager.rotate((count * count * 4321 + count * 9) * 2.0F, 0.0F, 0.0F, 1.0F);
GlStateManager.translate(0.5F, 0.5F, 0.5F);
GlStateManager.pushMatrix();
GlStateManager.loadIdentity();
GlStateManager.translate(0.0F, Minecraft.getSystemTime() % 200000L / 200000.0F * var15, 0.0F);
GlStateManager.scale(var16, var16, var16);
GlStateManager.translate(0.5F, 0.5F, 0.5F);
GlStateManager.rotate((count * count * 4321 + count * 9) * 2.0F, 0.0F, 0.0F, 1.0F);
GlStateManager.translate(0.5F, 0.5F, 0.5F);
Tessellator tessellator = Tessellator.getInstance();
VertexBuffer worldRenderer = tessellator.getBuffer();
worldRenderer.begin(GL11.GL_QUADS, DefaultVertexFormats.POSITION);
float[] color = tile.getRenderColor(rand);
GlStateManager.color(color[0] * var17, color[1] * var17, color[2] * var17, color[3]);
float[] color = tile.getRenderColor(rand);
GlStateManager.color(color[0] * var17, color[1] * var17, color[2] * var17, color[3]);
switch (tile.orientation) {
switch (tile.orientation) {
case SOUTH:
worldRenderer.pos(x + .01, y - 1, z).endVertex();
worldRenderer.pos(x + .01, y - 1, z + 1.0D).endVertex();
worldRenderer.pos(x + .01, y + 1, z + 1.0D).endVertex();
worldRenderer.pos(x + .01, y + 1, z).endVertex();
break;
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;
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;
worldRenderer.pos(x + .99, y + 1, z).endVertex();
worldRenderer.pos(x + .99, y + 1, z + 1.0D).endVertex();
worldRenderer.pos(x + .99, y - 1, z + 1.0D).endVertex();
worldRenderer.pos(x + .99, y - 1, z).endVertex();
break;
case EAST:
worldRenderer.pos(x, y -1, z + .99).endVertex();
worldRenderer.pos(x + 1, y -1, z + .99).endVertex();
worldRenderer.pos(x + 1, y + 1, z + .99).endVertex();
worldRenderer.pos(x, y + 1, z + .99).endVertex();
break;
/*case 4:
worldRenderer.pos(x, y - 1, z + .99).endVertex();
worldRenderer.pos(x + 1, y - 1, z + .99).endVertex();
worldRenderer.pos(x + 1, y + 1, z + .99).endVertex();
worldRenderer.pos(x, y + 1, z + .99).endVertex();
break;
/*case 4:
GL11.glVertex3d(x + .15F, y - 1 , z);
GL11.glVertex3d(x + .15, y - 1, z + 1.0D);
GL11.glVertex3d(x + .15, y + 1, z + 1.0D);
@ -172,40 +173,40 @@ public class RenderDimDoor extends TileEntitySpecialRenderer<TileEntityDimDoor>
GL11.glVertex3d(x + 1, y + 1, z + .85);
GL11.glVertex3d(x, y + 1, z + .85);
break;*/
}
}
tessellator.draw();
GlStateManager.popMatrix();
GlStateManager.matrixMode(GL11.GL_MODELVIEW);
}
GlStateManager.popMatrix();
GlStateManager.matrixMode(GL11.GL_MODELVIEW);
}
GlStateManager.disableBlend();
GlStateManager.disableTexGenCoord(GlStateManager.TexGen.S);
GlStateManager.disableBlend();
GlStateManager.disableTexGenCoord(GlStateManager.TexGen.S);
GlStateManager.disableTexGenCoord(GlStateManager.TexGen.T);
GlStateManager.disableTexGenCoord(GlStateManager.TexGen.R);
GlStateManager.disableTexGenCoord(GlStateManager.TexGen.Q);
GlStateManager.enableLighting();
}
GlStateManager.enableLighting();
}
private FloatBuffer getFloatBuffer(float par1, float par2, float par3, float par4) {
buffer.clear();
buffer.put(par1).put(par2).put(par3).put(par4);
buffer.flip();
return buffer;
}
private FloatBuffer getFloatBuffer(float par1, float par2, float par3, float par4) {
buffer.clear();
buffer.put(par1).put(par2).put(par3).put(par4);
buffer.flip();
return buffer;
}
private void renderKeyHole(TileEntityDimDoor tile, double x, double y, double z, int i) {
EnumFacing rotation = EnumFacing.getHorizontal((tile.orientation.getHorizontalIndex()+3)%4);
private void renderKeyHole(TileEntityDimDoor tile, double x, double y, double z, int i) {
EnumFacing rotation = EnumFacing.getHorizontal((tile.orientation.getHorizontalIndex() + 3) % 4);
GlStateManager.pushMatrix();
GlStateManager.translate(x,y,z);
GlStateManager.translate(x, y, z);
x = ActiveRenderInfo.getPosition().xCoord;
y = ActiveRenderInfo.getPosition().yCoord;
z = ActiveRenderInfo.getPosition().zCoord;
GlStateManager.rotate(180.0F - 90*rotation.getHorizontalIndex(), 0.0F, 1.0F, 0.0F);
GlStateManager.rotate(180.0F - 90 * rotation.getHorizontalIndex(), 0.0F, 1.0F, 0.0F);
//GL11.glRotatef((float)(-90 * rotation), 0.0F, 0.0F, 1.0F);
GlStateManager.translate(0.007F, .25F, 0F);
@ -213,7 +214,7 @@ public class RenderDimDoor extends TileEntitySpecialRenderer<TileEntityDimDoor>
switch (rotation) {
case SOUTH:
GL11.glTranslatef(-0.5F, 0, -0.03F);
break;
break;
case WEST:
GL11.glTranslatef(-.5F, 0F, .97F);
break;
@ -224,53 +225,54 @@ public class RenderDimDoor extends TileEntitySpecialRenderer<TileEntityDimDoor>
GL11.glTranslatef(0.5F, 0F, -0.03F);
}
GL11.glDisable(GL_LIGHTING);
GL11.glDisable(GL_LIGHTING);
GL11.glEnable(GL11.GL_BLEND);
GL11.glEnable(GL11.GL_BLEND);
if(i==1) {
bindTexture(KeyholeLight);
GlStateManager.color(1, 1, 1, .7f);
GlStateManager.blendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_DST_COLOR);
} else {
bindTexture(keyPath);
GlStateManager.blendFunc(GL_ONE_MINUS_SRC_ALPHA, GL_SRC_ALPHA);
if (i == 1) {
bindTexture(KeyholeLight);
GlStateManager.color(1, 1, 1, .7f);
GlStateManager.blendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_DST_COLOR);
} else {
bindTexture(keyPath);
GlStateManager.blendFunc(GL_ONE_MINUS_SRC_ALPHA, GL_SRC_ALPHA);
}
GlStateManager.rotate(180.0F, 0.0F, 1.0F, 0.0F);
GlStateManager.rotate(180.0F, 0.0F, 1.0F, 0.0F);
GlStateManager.rotate(180.0F, 0.0F, 0.0F, 1.0F);
GlStateManager.scale(0.00860625F, 0.00730625F, 0.0086625F);
GlStateManager.translate(-65.0F, -107.0F, -3.0F);
Tessellator tessellator = Tessellator.getInstance();
VertexBuffer worldRenderer = tessellator.getBuffer();
worldRenderer.begin(GL11.GL_QUADS, DefaultVertexFormats.POSITION_TEX_NORMAL);
worldRenderer.begin(GL11.GL_QUADS, DefaultVertexFormats.POSITION_TEX_NORMAL);
byte b0 = 7;
worldRenderer.pos((double)(0 - b0), (double)(128 + b0), 0.0D).tex(0.0D, 1.0D).normal(0.0F, 0.0F, -1.0F).endVertex();
worldRenderer.pos((double)(128 + b0), (double)(128 + b0), 0.0D).tex(1.0D, 1.0D).normal(0.0F, 0.0F, -1.0F).endVertex();
worldRenderer.pos((double)(128 + b0), (double)(0 - b0), 0.0D).tex(1.0D, 0.0D).normal(0.0F, 0.0F, -1.0F).endVertex();
worldRenderer.pos((double)(0 - b0), (double)(0 - b0), 0.0D).tex(0.0D, 0.0D).normal(0.0F, 0.0F, -1.0F).endVertex();
worldRenderer.pos((double) (0 - b0), (double) (128 + b0), 0.0D).tex(0.0D, 1.0D).normal(0.0F, 0.0F, -1.0F).endVertex();
worldRenderer.pos((double) (128 + b0), (double) (128 + b0), 0.0D).tex(1.0D, 1.0D).normal(0.0F, 0.0F, -1.0F).endVertex();
worldRenderer.pos((double) (128 + b0), (double) (0 - b0), 0.0D).tex(1.0D, 0.0D).normal(0.0F, 0.0F, -1.0F).endVertex();
worldRenderer.pos((double) (0 - b0), (double) (0 - b0), 0.0D).tex(0.0D, 0.0D).normal(0.0F, 0.0F, -1.0F).endVertex();
tessellator.draw();
GlStateManager.translate(0.0F, 0.0F, -1.0F);
GlStateManager.disableBlend();
GlStateManager.disableBlend();
GlStateManager.popMatrix();
}
}
@Override
public void renderTileEntityAt(TileEntityDimDoor te, double x, double y, double z, float partialTicks, int destroyStage) {
@Override
public void renderTileEntityAt(TileEntityDimDoor te, double x, double y, double z, float partialTicks, int destroyStage) {
World world = te.getWorld();
BlockPos pos = te.getPos();
((BlockDimDoorBase)world.getBlockState(pos).getBlock()).updateAttachedTile(world, pos);
if (te.openOrClosed) {
renderDimDoorTileEntity(te, x, y, z);
if(te.lockStatus >= 1)
for(int i = 0; i < 1+te.lockStatus; i++ ) this.renderKeyHole(te, x, y, z, i);
((BlockDimDoorBase) world.getBlockState(pos).getBlock()).updateAttachedTile(world, pos);
if (te.openOrClosed) {
renderDimDoorTileEntity(te, x, y, z);
if (te.lockStatus >= 1) {
for (int i = 0; i < 1 + te.lockStatus; i++) {
this.renderKeyHole(te, x, y, z, i);
}
}
}
}
}
}
}

View file

@ -23,9 +23,10 @@ import org.lwjgl.opengl.GL11;
@SideOnly(Side.CLIENT)
public class RenderTransTrapdoor extends TileEntitySpecialRenderer<TileEntityTransTrapdoor> {
private FloatBuffer buffer = GLAllocation.createDirectFloatBuffer(16);
private ResourceLocation riftPath= new ResourceLocation(DimDoors.MODID+":textures/other/RIFT.png");
private ResourceLocation warpPath= new ResourceLocation(DimDoors.MODID+":textures/other/WARP.png");
private ResourceLocation riftPath = new ResourceLocation(DimDoors.MODID + ":textures/other/RIFT.png");
private ResourceLocation warpPath = new ResourceLocation(DimDoors.MODID + ":textures/other/WARP.png");
/**
* Renders the dimdoor.
@ -58,10 +59,10 @@ public class RenderTransTrapdoor extends TileEntitySpecialRenderer<TileEntityTra
var16 = .5F;
}
GlStateManager.translate(Minecraft.getSystemTime() % 200000L / 200000.0F,0, 0.0F);
GlStateManager.translate(Minecraft.getSystemTime() % 200000L / 200000.0F, 0, 0.0F);
GlStateManager.translate(0, Minecraft.getSystemTime() % 200000L / 200000.0F, 0.0F);
GlStateManager.translate(0,0, Minecraft.getSystemTime() % 200000L / 200000.0F);
GlStateManager.translate(0, 0, Minecraft.getSystemTime() % 200000L / 200000.0F);
GlStateManager.texGen(GlStateManager.TexGen.S, GL11.GL_OBJECT_LINEAR);
GlStateManager.texGen(GlStateManager.TexGen.T, GL11.GL_OBJECT_LINEAR);
@ -83,7 +84,7 @@ public class RenderTransTrapdoor extends TileEntitySpecialRenderer<TileEntityTra
GlStateManager.matrixMode(GL11.GL_TEXTURE);
GlStateManager.pushMatrix();
GlStateManager.loadIdentity();
GlStateManager.translate(0.0F, Minecraft.getSystemTime() % 200000L / 200000.0F*var15, 0.0F);
GlStateManager.translate(0.0F, Minecraft.getSystemTime() % 200000L / 200000.0F * var15, 0.0F);
GlStateManager.scale(var16, var16, var16);
GlStateManager.translate(0.5F, 0.5F, 0.5F);
GlStateManager.rotate((count * count * 4321 + count * 9) * 2.0F, 0.0F, 0.0F, 1.0F);
@ -103,29 +104,29 @@ public class RenderTransTrapdoor extends TileEntitySpecialRenderer<TileEntityTra
worldrenderer.begin(GL11.GL_QUADS, DefaultVertexFormats.POSITION_COLOR);
if (BlockTransTrapdoor.isTrapdoorSetLow(state)) {
if (state.getValue(BlockTrapDoor.OPEN)) {
worldrenderer.pos(x, y+0.2, z).color(r, g, b, 1.0F).endVertex();
worldrenderer.pos(x, y+0.2, z+1).color(r, g, b, 1.0F).endVertex();
worldrenderer.pos(x+1, y+0.2, z+1).color(r, g, b, 1.0F).endVertex();
worldrenderer.pos(x+1, y+0.2, z).color(r, g, b, 1.0F).endVertex();
} else {
worldrenderer.pos(x, y+0.15, z).color(r, g, b, 1.0F).endVertex();
worldrenderer.pos(x, y+0.15, z+1).color(r, g, b, 1.0F).endVertex();
worldrenderer.pos(x+1, y+0.15, z+1).color(r, g, b, 1.0F).endVertex();
worldrenderer.pos(x+1, y+0.15, z).color(r, g, b, 1.0F).endVertex();
}
if (state.getValue(BlockTrapDoor.OPEN)) {
worldrenderer.pos(x, y + 0.2, z).color(r, g, b, 1.0F).endVertex();
worldrenderer.pos(x, y + 0.2, z + 1).color(r, g, b, 1.0F).endVertex();
worldrenderer.pos(x + 1, y + 0.2, z + 1).color(r, g, b, 1.0F).endVertex();
worldrenderer.pos(x + 1, y + 0.2, z).color(r, g, b, 1.0F).endVertex();
} else {
worldrenderer.pos(x, y + 0.15, z).color(r, g, b, 1.0F).endVertex();
worldrenderer.pos(x, y + 0.15, z + 1).color(r, g, b, 1.0F).endVertex();
worldrenderer.pos(x + 1, y + 0.15, z + 1).color(r, g, b, 1.0F).endVertex();
worldrenderer.pos(x + 1, y + 0.15, z).color(r, g, b, 1.0F).endVertex();
}
} else {
if (state.getValue(BlockTrapDoor.OPEN)) {
worldrenderer.pos(x, y+0.95, z).color(r, g, b, 1.0F).endVertex();
worldrenderer.pos(x, y+0.95, z+1).color(r, g, b, 1.0F).endVertex();
worldrenderer.pos(x+1, y+0.95, z+1).color(r, g, b, 1.0F).endVertex();
worldrenderer.pos(x+1, y+0.95, z).color(r, g, b, 1.0F).endVertex();
} else {
worldrenderer.pos(x, y+0.85, z).color(r, g, b, 1.0F).endVertex();
worldrenderer.pos(x, y+0.85, z+1).color(r, g, b, 1.0F).endVertex();
worldrenderer.pos(x+1, y+0.85, z+1).color(r, g, b, 1.0F).endVertex();
worldrenderer.pos(x+1, y+0.85, z).color(r, g, b, 1.0F).endVertex();
}
if (state.getValue(BlockTrapDoor.OPEN)) {
worldrenderer.pos(x, y + 0.95, z).color(r, g, b, 1.0F).endVertex();
worldrenderer.pos(x, y + 0.95, z + 1).color(r, g, b, 1.0F).endVertex();
worldrenderer.pos(x + 1, y + 0.95, z + 1).color(r, g, b, 1.0F).endVertex();
worldrenderer.pos(x + 1, y + 0.95, z).color(r, g, b, 1.0F).endVertex();
} else {
worldrenderer.pos(x, y + 0.85, z).color(r, g, b, 1.0F).endVertex();
worldrenderer.pos(x, y + 0.85, z + 1).color(r, g, b, 1.0F).endVertex();
worldrenderer.pos(x + 1, y + 0.85, z + 1).color(r, g, b, 1.0F).endVertex();
worldrenderer.pos(x + 1, y + 0.85, z).color(r, g, b, 1.0F).endVertex();
}
}
tessellator.draw();
@ -150,6 +151,6 @@ public class RenderTransTrapdoor extends TileEntitySpecialRenderer<TileEntityTra
@Override
public void renderTileEntityAt(TileEntityTransTrapdoor te, double x, double y, double z, float partialTicks, int destroyStage) {
this.renderTransTrapdoorTileEntity(te, x, y, z, partialTicks);
this.renderTransTrapdoorTileEntity(te, x, y, z, partialTicks);
}
}

View file

@ -8,7 +8,8 @@ import net.minecraft.item.ItemBlock;
import net.minecraft.item.ItemStack;
public class ItemBlockDimWall extends ItemBlock {
private final static String[] subNames = {"", "Ancient" , "Altered"};
private final static String[] subNames = {"", "Ancient", "Altered"};
public ItemBlockDimWall() {
super(ModBlocks.blockDimWall);
@ -19,10 +20,9 @@ public class ItemBlockDimWall extends ItemBlock {
}
@Override
public int getMetadata (int damageValue)
{
return damageValue;
}
public int getMetadata(int damageValue) {
return damageValue;
}
public String getUnlocalizedName(ItemStack stack) {
return super.getUnlocalizedName() + subNames[this.getDamage(stack)];

View file

@ -10,19 +10,22 @@ import net.minecraft.item.ItemDoor;
import net.minecraft.item.ItemStack;
public class ItemDimDoor extends ItemDoorBase {
public static final String ID = "itemDimDoor";
public ItemDimDoor() {
super(ModBlocks.blockDimDoor, (ItemDoor)Items.IRON_DOOR);
public static final String ID = "itemDimDoor";
public ItemDimDoor() {
super(ModBlocks.blockDimDoor, (ItemDoor) Items.IRON_DOOR);
setUnlocalizedName(ID);
setRegistryName(ID);
}
@Override
public void addInformation(ItemStack stack, EntityPlayer playerIn, List<String> tooltip, boolean advanced) {
@Override
public void addInformation(ItemStack stack, EntityPlayer playerIn, List<String> tooltip, boolean advanced) {
translateAndAdd("info.dimDoor", tooltip);
}
}
@Override
protected BlockDimDoorBase getDoorBlock() {return ModBlocks.blockDimDoor;}
@Override
protected BlockDimDoorBase getDoorBlock() {
return ModBlocks.blockDimDoor;
}
}

View file

@ -8,18 +8,22 @@ import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.item.ItemStack;
public class ItemDimDoorGold extends ItemDoorBase {
public static final String ID = "itemDimDoorGold";
public ItemDimDoorGold() {
super(ModBlocks.blockDimDoorGold, ModItems.itemDoorGold);
public static final String ID = "itemDimDoorGold";
public ItemDimDoorGold() {
super(ModBlocks.blockDimDoorGold, ModItems.itemDoorGold);
setUnlocalizedName(ID);
setRegistryName(ID);
}
@Override
public void addInformation(ItemStack stack, EntityPlayer playerIn, List<String> tooltip, boolean advanced) {
translateAndAdd("info.goldDimDoor", tooltip);
}
@Override
protected BlockDimDoorBase getDoorBlock() {return ModBlocks.blockDimDoorGold;}
@Override
public void addInformation(ItemStack stack, EntityPlayer playerIn, List<String> tooltip, boolean advanced) {
translateAndAdd("info.goldDimDoor", tooltip);
}
@Override
protected BlockDimDoorBase getDoorBlock() {
return ModBlocks.blockDimDoorGold;
}
}

View file

@ -8,19 +8,22 @@ import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.item.ItemStack;
public class ItemDimDoorPersonal extends ItemDoorBase {
public static final String ID = "itemDimDoorQuartz";
public ItemDimDoorPersonal() {
super(ModBlocks.blockDimDoorPersonal, ModItems.itemDoorQuartz);
public static final String ID = "itemDimDoorQuartz";
public ItemDimDoorPersonal() {
super(ModBlocks.blockDimDoorPersonal, ModItems.itemDoorQuartz);
setUnlocalizedName(ID);
setRegistryName(ID);
}
@Override
public void addInformation(ItemStack stack, EntityPlayer playerIn, List<String> tooltip, boolean advanced) {
translateAndAdd("info.personalDimDoor", tooltip);
}
@Override
public void addInformation(ItemStack stack, EntityPlayer playerIn, List<String> tooltip, boolean advanced) {
translateAndAdd("info.personalDimDoor", tooltip);
}
@Override
protected BlockDimDoorBase getDoorBlock() {return ModBlocks.blockDimDoorPersonal;}
@Override
protected BlockDimDoorBase getDoorBlock() {
return ModBlocks.blockDimDoorPersonal;
}
}

View file

@ -8,6 +8,7 @@ import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.item.ItemStack;
public class ItemDimDoorUnstable extends ItemDoorBase {
public static final String ID = "itemDimDoorChaos";
public ItemDimDoorUnstable() {
@ -16,11 +17,13 @@ public class ItemDimDoorUnstable extends ItemDoorBase {
setRegistryName(ID);
}
@Override
@Override
public void addInformation(ItemStack stack, EntityPlayer playerIn, List<String> tooltip, boolean advanced) {
//tooltip.add(StatCollector.translateToLocal("info.chaosDoor"));
//tooltip.add(StatCollector.translateToLocal("info.chaosDoor"));
}
@Override
protected BlockDimDoorBase getDoorBlock() {return ModBlocks.blockDimDoorChaos;}
protected BlockDimDoorBase getDoorBlock() {
return ModBlocks.blockDimDoorChaos;
}
}

View file

@ -11,19 +11,22 @@ import net.minecraft.item.ItemDoor;
import net.minecraft.item.ItemStack;
public class ItemDimDoorWarp extends ItemDoorBase {
public static final String ID = "itemDimDoorWarp";
public ItemDimDoorWarp() {
super(ModBlocks.blockDimDoorWarp, (ItemDoor)Items.OAK_DOOR );
public static final String ID = "itemDimDoorWarp";
public ItemDimDoorWarp() {
super(ModBlocks.blockDimDoorWarp, (ItemDoor) Items.OAK_DOOR);
setUnlocalizedName(ID);
setRegistryName(ID);
}
}
@Override
public void addInformation(ItemStack stack, EntityPlayer playerIn, List<String> tooltip, boolean advanced) {
translateAndAdd("info.warpDoor",tooltip);
}
@Override
public void addInformation(ItemStack stack, EntityPlayer playerIn, List<String> tooltip, boolean advanced) {
translateAndAdd("info.warpDoor", tooltip);
}
@Override
protected BlockDimDoorBase getDoorBlock() {return ModBlocks.blockDimDoorWarp;}
@Override
protected BlockDimDoorBase getDoorBlock() {
return ModBlocks.blockDimDoorWarp;
}
}

View file

@ -22,168 +22,190 @@ import net.minecraft.world.World;
import com.zixiken.dimdoors.tileentities.TileEntityDimDoor;
public abstract class ItemDoorBase extends ItemDoor {
// Maps non-dimensional door items to their corresponding dimensional door item
// Also maps dimensional door items to themselves for simplicity
private static HashMap<ItemDoor, ItemDoorBase> doorItemMapping = new HashMap<ItemDoor, ItemDoorBase>();
// Maps non-dimensional door items to their corresponding dimensional door item
// Also maps dimensional door items to themselves for simplicity
/**
* door represents the non-dimensional door this item is associated with. Leave null for none.
* @param vanillaDoor
*/
public ItemDoorBase(Block block, ItemDoor vanillaDoor) {
super(block);
this.setMaxStackSize(64);
this.setCreativeTab(DimDoors.dimDoorsCreativeTab);
doorItemMapping.put(this, this);
if (vanillaDoor != null)
doorItemMapping.put(vanillaDoor, this);
}
@Override
public abstract void addInformation(ItemStack stack, EntityPlayer playerIn, List<String> tooltip, boolean advanced);
/**
* Overriden in subclasses to specify which door block that door item will
* place
*
* @return
*/
protected abstract BlockDimDoorBase getDoorBlock();
private static HashMap<ItemDoor, ItemDoorBase> doorItemMapping = new HashMap<ItemDoor, ItemDoorBase>();
/**
* Overriden here to remove vanilla block placement functionality from
* dimensional doors, we handle this in the EventHookContainer
*/
@Override
public EnumActionResult onItemUse(ItemStack stack, EntityPlayer playerIn, World worldIn, BlockPos pos, EnumHand hand, EnumFacing side, float hitX, float hitY, float hitZ) {return EnumActionResult.FAIL;}
* door represents the non-dimensional door this item is associated with.
* Leave null for none.
*
* @param vanillaDoor
*/
public ItemDoorBase(Block block, ItemDoor vanillaDoor) {
super(block);
this.setMaxStackSize(64);
this.setCreativeTab(DimDoors.dimDoorsCreativeTab);
/**
* Tries to place a door as a dimensional door
*
* @param stack
* @param player
* @param world
* @param side
* @return
*/
public static boolean tryToPlaceDoor(ItemStack stack, EntityPlayer player, World world, BlockPos pos, EnumFacing side) {
if (world.isRemote) return false;
doorItemMapping.put(this, this);
if (vanillaDoor != null) {
doorItemMapping.put(vanillaDoor, this);
}
}
// Retrieve the actual door type that we want to use here.
// It's okay if stack isn't an ItemDoor. In that case, the lookup will
// 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();
return ItemDoorBase.placeDoorOnBlock(doorBlock, stack, player, world, pos, side) ||
ItemDoorBase.placeDoorOnRift(doorBlock, world, player, stack);
}
@Override
public abstract void addInformation(ItemStack stack, EntityPlayer playerIn, List<String> tooltip, boolean advanced);
/**
* try to place a door block on a block
* @param doorBlock
* @param stack
* @param player
* @param world
* @param pos
* @param side
* @return
*/
public static boolean placeDoorOnBlock(Block doorBlock, ItemStack stack, EntityPlayer player,
World world, BlockPos pos, EnumFacing side) {
if (world.isRemote) return false;
/**
* Overriden in subclasses to specify which door block that door item will
* place
*
* @return
*/
protected abstract BlockDimDoorBase getDoorBlock();
// Only place doors on top of blocks - check if we're targeting the top
// side
if (side == EnumFacing.UP) {
Block block = world.getBlockState(pos).getBlock();
if (!world.getBlockState(pos).equals(Blocks.AIR) && !block.isReplaceable(world, pos)) pos = pos.up();
/**
* Overriden here to remove vanilla block placement functionality from
* dimensional doors, we handle this in the EventHookContainer
*/
@Override
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
*
* @param stack
* @param player
* @param world
* @param side
* @return
*/
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.
// It's okay if stack isn't an ItemDoor. In that case, the lookup will
// 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();
return ItemDoorBase.placeDoorOnBlock(doorBlock, stack, player, world, pos, side)
|| ItemDoorBase.placeDoorOnRift(doorBlock, world, player, stack);
}
/**
* try to place a door block on a block
*
* @param doorBlock
* @param stack
* @param player
* @param world
* @param pos
* @param side
* @return
*/
public static boolean placeDoorOnBlock(Block doorBlock, ItemStack stack, EntityPlayer player,
World world, BlockPos pos, EnumFacing side) {
if (world.isRemote) {
return false;
}
// Only place doors on top of blocks - check if we're targeting the top
// side
if (side == EnumFacing.UP) {
Block block = world.getBlockState(pos).getBlock();
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, true);
if (!player.capabilities.isCreativeMode) stack.stackSize--;
return true;
}
}
return false;
}
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, true);
if (!player.capabilities.isCreativeMode) {
stack.stackSize--;
}
return true;
}
}
return false;
}
/**
* uses a raytrace to try and place a door on a rift
*
* @param doorBlock
* @param world
* @param player
* @param stack
* @return
*/
public static boolean placeDoorOnRift(Block doorBlock, World world, EntityPlayer player, ItemStack stack) {
if (world.isRemote) return false;
/**
* uses a raytrace to try and place a door on a rift
*
* @param doorBlock
* @param world
* @param player
* @param stack
* @return
*/
public static boolean placeDoorOnRift(Block doorBlock, World world, EntityPlayer player, ItemStack stack) {
if (world.isRemote) {
return false;
}
RayTraceResult hit = ItemDoorBase.doRayTrace(world, player, true);
if (hit != null) {
RayTraceResult hit = ItemDoorBase.doRayTrace(world, player, true);
if (hit != null) {
BlockPos pos = hit.getBlockPos();
if (world.getBlockState(pos).getBlock() == ModBlocks.blockRift) {
if (world.getBlockState(pos).getBlock() == ModBlocks.blockRift) {
BlockPos downPos = pos.down();
if (player.canPlayerEdit(pos, hit.sideHit, stack) &&
player.canPlayerEdit(downPos, hit.sideHit, stack) &&
canPlace(world, pos) && canPlace(world, downPos)) {
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, true);
if (!(stack.getItem() instanceof ItemDoorBase))
if (!(stack.getItem() instanceof ItemDoorBase)) {
((TileEntityDimDoor) world.getTileEntity(pos)).hasGennedPair = true;
if (!player.capabilities.isCreativeMode) stack.stackSize--;
}
if (!player.capabilities.isCreativeMode) {
stack.stackSize--;
}
return true;
}
}
}
return false;
}
}
}
return false;
}
public static boolean canPlace(World world, BlockPos pos) {
IBlockState state = world.getBlockState(pos);
public static boolean canPlace(World world, BlockPos pos) {
IBlockState state = world.getBlockState(pos);
return (state.getBlock() == ModBlocks.blockRift || state.equals(Blocks.AIR) || state.getMaterial().isReplaceable());
}
return (state.getBlock() == ModBlocks.blockRift || state.equals(Blocks.AIR) || state.getMaterial().isReplaceable());
}
/**
* Copied from minecraft Item.class
* TODO we probably can improve this
*
* @param world
* @param player
* @param useLiquids
* @return
*/
/**
* Copied from minecraft Item.class TODO we probably can improve this
*
* @param world
* @param player
* @param useLiquids
* @return
*/
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 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 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);
float f5 = MathHelper.sin(-f * 0.017453292F);
float f6 = f3 * f4;
float f7 = f2 * f4;
double d3 = 5.0D;
if (player instanceof EntityPlayerMP)
d3 = ((EntityPlayerMP)player).interactionManager.getBlockReachDistance();
Vec3d vec31 = vec3.addVector((double)f6 * d3, (double)f5 * d3, (double)f7 * d3);
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))) {
public void translateAndAdd(String key, List<String> list) {
for (int i = 0; i < 10; i++) {
/*if(StatCollector.canTranslate(key+Integer.toString(i))) {
String line = StatCollector.translateToLocal(key + Integer.toString(i));
list.add(line);
} else */ break;
}
}
}
}
}

View file

@ -4,12 +4,13 @@ import com.zixiken.dimdoors.blocks.ModBlocks;
import net.minecraft.item.ItemDoor;
public class ItemDoorGold extends ItemDoor {
public static final String ID = "itemDoorGold";
public ItemDoorGold() {
super(ModBlocks.blockDoorGold);
setMaxStackSize(16);
public static final String ID = "itemDoorGold";
public ItemDoorGold() {
super(ModBlocks.blockDoorGold);
setMaxStackSize(16);
setUnlocalizedName(ID);
setRegistryName(ID);
}
}
}

View file

@ -4,11 +4,12 @@ import com.zixiken.dimdoors.blocks.ModBlocks;
import net.minecraft.item.ItemDoor;
public class ItemDoorQuartz extends ItemDoor {
public static final String ID = "itemDoorQuartz";
public ItemDoorQuartz() {
super(ModBlocks.blockDoorQuartz);
setUnlocalizedName(ID);
setRegistryName(ID);
}
public ItemDoorQuartz() {
super(ModBlocks.blockDoorQuartz);
setUnlocalizedName(ID);
setRegistryName(ID);
}
}

View file

@ -4,12 +4,13 @@ import com.zixiken.dimdoors.DimDoors;
import net.minecraft.item.Item;
public class ItemStableFabric extends Item {
public static final String ID = "itemStableFabric";
public ItemStableFabric() {
super();
public static final String ID = "itemStableFabric";
public ItemStableFabric() {
super();
setCreativeTab(DimDoors.dimDoorsCreativeTab);
setUnlocalizedName(ID);
setRegistryName(ID);
}
}
}

View file

@ -4,12 +4,13 @@ import com.zixiken.dimdoors.DimDoors;
import net.minecraft.item.Item;
public class ItemWorldThread extends Item {
public static final String ID = "itemWorldThread";
public ItemWorldThread() {
super();
public static final String ID = "itemWorldThread";
public ItemWorldThread() {
super();
setCreativeTab(DimDoors.dimDoorsCreativeTab);
setUnlocalizedName(ID);
setRegistryName(ID);
}
}
}

View file

@ -5,6 +5,7 @@ import net.minecraftforge.fml.common.registry.GameRegistry;
import com.zixiken.dimdoors.blocks.ModBlocks;
public class ModItems {
public static ItemDimDoorGold itemDimDoorGold;
public static ItemDoorGold itemDoorGold;
public static ItemWorldThread itemWorldThread;

View file

@ -14,7 +14,7 @@ import net.minecraftforge.common.DimensionManager;
*
* @author Robijnvogel
*/
public class DDProxyServer extends DDProxyCommon{
public class DDProxyServer extends DDProxyCommon {
@Override
public boolean isClient() {

View file

@ -48,7 +48,6 @@ class Pocket {
NBTTagCompound pocketNBT = new NBTTagCompound();
//@todo implement shit;
return pocketNBT;
}

View file

@ -64,7 +64,7 @@ public class PocketRegistry {
nextUnusedID++;
PocketSavedData.get(world).markDirty(); //Notify that this needs to be saved on world save
return nextUnusedID -1;
return nextUnusedID - 1;
}
public void removePocket(int pocketID, World world) {

View file

@ -67,7 +67,7 @@ public class RiftRegistry {
nextRiftID++;
RiftSavedData.get(DimDoors.getDefWorld()).markDirty(); //Notify that this needs to be saved on world save
return nextRiftID -1;
return nextRiftID - 1;
}
public void removeRift(int riftID, World world) {

View file

@ -8,76 +8,75 @@ import net.minecraft.tileentity.TileEntity;
import net.minecraft.util.math.BlockPos;
import net.minecraft.world.World;
public abstract class DDTileEntityBase extends TileEntity
{
public abstract class DDTileEntityBase extends TileEntity {
public boolean isPaired = false;
public int riftID;
public int pairedRiftID;
/**
*
* @return an array of floats representing RGBA color where 1.0 = 255.
*/
public abstract float[] getRenderColor(Random rand);
/**
*
* @return an array of floats representing RGBA color where 1.0 = 255.
*/
public abstract float[] getRenderColor(Random rand);
DDTileEntityBase(World world) { //@todo what is the difference between a TileEntity instance being created on Block placement and on world-load?
super();
this.setWorld(world);
register();
}
DDTileEntityBase(World world) { //@todo what is the difference between a TileEntity instance being created on Block placement and on world-load?
super();
this.setWorld(world);
register();
}
@Override
public boolean shouldRefresh(World world, BlockPos pos, IBlockState oldState, IBlockState newSate) {
return oldState.getBlock() != newSate.getBlock();
}
@Override
public boolean shouldRefresh(World world, BlockPos pos, IBlockState oldState, IBlockState newSate) {
return oldState.getBlock() != newSate.getBlock();
}
public void pair(int otherRiftID) {
if (isPaired) {
if (otherRiftID == pairedRiftID) {
return;
}
else {
RiftRegistry.Instance.unpair(pairedRiftID);
}
}
pairedRiftID = otherRiftID;
RiftRegistry.Instance.pair(pairedRiftID, riftID);
isPaired = true;
this.markDirty();
}
public void unpair() {
if (!isPaired) {
public void pair(int otherRiftID) {
if (isPaired) {
if (otherRiftID == pairedRiftID) {
return;
}
else {
isPaired = false;
} else {
RiftRegistry.Instance.unpair(pairedRiftID);
}
this.markDirty();
}
pairedRiftID = otherRiftID;
RiftRegistry.Instance.pair(pairedRiftID, riftID);
isPaired = true;
this.markDirty();
}
private void register() {
riftID = RiftRegistry.Instance.registerNewRift(this);
this.markDirty();
public void unpair() {
if (!isPaired) {
return;
} else {
isPaired = false;
RiftRegistry.Instance.unpair(pairedRiftID);
}
this.markDirty();
}
@Override
public void readFromNBT(NBTTagCompound nbt) {
super.readFromNBT(nbt);
try {
this.isPaired = nbt.getBoolean("isPaired");
this.riftID = nbt.getInteger("riftID");
this.pairedRiftID = nbt.getInteger("pairedRiftID");
} catch (Exception e) {}
}
private void register() {
riftID = RiftRegistry.Instance.registerNewRift(this);
this.markDirty();
}
@Override
public NBTTagCompound writeToNBT(NBTTagCompound nbt) {
super.writeToNBT(nbt);
nbt.setBoolean("isPaired", this.isPaired);
nbt.setInteger("riftID", this.riftID);
nbt.setInteger("pairedRiftID", this.pairedRiftID);
return nbt;
}
@Override
public void readFromNBT(NBTTagCompound nbt) {
super.readFromNBT(nbt);
try {
this.isPaired = nbt.getBoolean("isPaired");
this.riftID = nbt.getInteger("riftID");
this.pairedRiftID = nbt.getInteger("pairedRiftID");
} catch (Exception e) {
}
}
@Override
public NBTTagCompound writeToNBT(NBTTagCompound nbt) {
super.writeToNBT(nbt);
nbt.setBoolean("isPaired", this.isPaired);
nbt.setInteger("riftID", this.riftID);
nbt.setInteger("pairedRiftID", this.pairedRiftID);
return nbt;
}
}

View file

@ -6,58 +6,58 @@ import net.minecraft.nbt.NBTTagCompound;
import net.minecraft.util.EnumFacing;
import net.minecraft.world.World;
public class TileEntityDimDoor extends DDTileEntityBase {
public class TileEntityDimDoor extends DDTileEntityBase
{
public boolean openOrClosed;
public EnumFacing orientation;
public boolean hasExit;
public byte lockStatus;
public boolean isDungeonChainLink;
public boolean hasGennedPair=false;
public boolean openOrClosed;
public EnumFacing orientation;
public boolean hasExit;
public byte lockStatus;
public boolean isDungeonChainLink;
public boolean hasGennedPair = false;
public TileEntityDimDoor(World world) {
super(world);
}
@Override
public void readFromNBT(NBTTagCompound nbt) {
super.readFromNBT(nbt);
@Override
public void readFromNBT(NBTTagCompound nbt) {
super.readFromNBT(nbt);
try {
this.openOrClosed = nbt.getBoolean("openOrClosed");
this.orientation = EnumFacing.getFront(nbt.getInteger("orientation"));
this.hasExit = nbt.getBoolean("hasExit");
this.isDungeonChainLink = nbt.getBoolean("isDungeonChainLink");
this.hasGennedPair = nbt.getBoolean("hasGennedPair");
} catch (Exception e) {}
}
try {
this.openOrClosed = nbt.getBoolean("openOrClosed");
this.orientation = EnumFacing.getFront(nbt.getInteger("orientation"));
this.hasExit = nbt.getBoolean("hasExit");
this.isDungeonChainLink = nbt.getBoolean("isDungeonChainLink");
this.hasGennedPair = nbt.getBoolean("hasGennedPair");
} catch (Exception e) {
}
}
@Override
public NBTTagCompound writeToNBT(NBTTagCompound nbt) {
super.writeToNBT(nbt);
@Override
public NBTTagCompound writeToNBT(NBTTagCompound nbt) {
super.writeToNBT(nbt);
nbt.setBoolean("openOrClosed", this.openOrClosed);
nbt.setBoolean("hasExit", this.hasExit);
nbt.setInteger("orientation", this.orientation.getIndex());
nbt.setBoolean("isDungeonChainLink", isDungeonChainLink);
nbt.setBoolean("hasGennedPair", hasGennedPair);
return nbt;
}
nbt.setBoolean("openOrClosed", this.openOrClosed);
nbt.setBoolean("hasExit", this.hasExit);
nbt.setInteger("orientation", this.orientation.getIndex());
nbt.setBoolean("isDungeonChainLink", isDungeonChainLink);
nbt.setBoolean("hasGennedPair", hasGennedPair);
return nbt;
}
@Override
public float[] getRenderColor(Random rand) {
float[] rgbaColor = {1,1,1,1};
if (this.world.provider.getDimension() == -1) {
rgbaColor[0] = rand.nextFloat() * 0.5F + 0.4F;
rgbaColor[1] = rand.nextFloat() * 0.05F;
rgbaColor[2] = rand.nextFloat() * 0.05F;
} else {
rgbaColor[0] = rand.nextFloat() * 0.5F + 0.1F;
rgbaColor[1] = rand.nextFloat() * 0.4F + 0.4F;
rgbaColor[2] = rand.nextFloat() * 0.6F + 0.5F;
}
@Override
public float[] getRenderColor(Random rand) {
float[] rgbaColor = {1, 1, 1, 1};
if (this.world.provider.getDimension() == -1) {
rgbaColor[0] = rand.nextFloat() * 0.5F + 0.4F;
rgbaColor[1] = rand.nextFloat() * 0.05F;
rgbaColor[2] = rand.nextFloat() * 0.05F;
} else {
rgbaColor[0] = rand.nextFloat() * 0.5F + 0.1F;
rgbaColor[1] = rand.nextFloat() * 0.4F + 0.4F;
rgbaColor[2] = rand.nextFloat() * 0.6F + 0.5F;
}
return rgbaColor;
}
return rgbaColor;
}
}

View file

@ -6,24 +6,25 @@ import net.minecraftforge.common.ForgeChunkManager;
import net.minecraftforge.common.ForgeChunkManager.Ticket;
public class TileEntityDimDoorGold extends TileEntityDimDoor implements IChunkLoader {
private Ticket chunkTicket;
private boolean initialized = false;
private Ticket chunkTicket;
private boolean initialized = false;
public TileEntityDimDoorGold(World world) {
super(world);
}
@Override
public boolean isInitialized() {
return initialized;
}
@Override
public boolean isInitialized() {
return initialized;
}
@Override
public void initialize(Ticket ticket) {
initialized = true;
chunkTicket = ticket;
@Override
public void initialize(Ticket ticket) {
initialized = true;
chunkTicket = ticket;
/*
/*
// Only do anything if this function is running on the server side
// NOTE: We don't have to check whether this block is the upper door
// block or the lower one because only one of them should have a
@ -53,12 +54,12 @@ public class TileEntityDimDoorGold extends TileEntityDimDoor implements IChunkLo
ChunkLoaderHelper.forcePocketChunks(dimension, chunkTicket);
}
}
*/
}
*/
}
@Override
public void invalidate() {
ForgeChunkManager.releaseTicket(chunkTicket);
super.invalidate();
}
@Override
public void invalidate() {
ForgeChunkManager.releaseTicket(chunkTicket);
super.invalidate();
}
}

View file

@ -31,7 +31,7 @@ public class TileEntityRift extends DDTileEntityBase implements ITickable {
public float growth = 0;
public TileEntityRift(World world) {
super(world);
super(world);
// Vary the update times of rifts to prevent all the rifts in a cluster
// from updating at the same time.
updateTimer = random.nextInt(UPDATE_PERIOD);

View file

@ -9,18 +9,18 @@ public class TileEntityTransTrapdoor extends DDTileEntityBase {
super(world);
}
@Override
public float[] getRenderColor(Random rand) {
float[] rgbaColor = {1,1,1,1};
if (this.world.provider.getDimension() == -1) {
rgbaColor[0] = world.rand.nextFloat() * 0.5F + 0.4F;
rgbaColor[1] = world.rand.nextFloat() * 0.05F;
rgbaColor[2] = world.rand.nextFloat() * 0.05F;
} else {
rgbaColor[0] = world.rand.nextFloat() * 0.5F + 0.1F;
rgbaColor[1] = world.rand.nextFloat() * 0.4F + 0.4F;
rgbaColor[2] = world.rand.nextFloat() * 0.6F + 0.5F;
}
return rgbaColor;
}
@Override
public float[] getRenderColor(Random rand) {
float[] rgbaColor = {1, 1, 1, 1};
if (this.world.provider.getDimension() == -1) {
rgbaColor[0] = world.rand.nextFloat() * 0.5F + 0.4F;
rgbaColor[1] = world.rand.nextFloat() * 0.05F;
rgbaColor[2] = world.rand.nextFloat() * 0.05F;
} else {
rgbaColor[0] = world.rand.nextFloat() * 0.5F + 0.1F;
rgbaColor[1] = world.rand.nextFloat() * 0.4F + 0.4F;
rgbaColor[2] = world.rand.nextFloat() * 0.6F + 0.5F;
}
return rgbaColor;
}
}

View file

@ -4,6 +4,7 @@ import net.minecraft.world.DimensionType;
import net.minecraft.world.WorldProvider;
public class PocketProvider extends WorldProvider {
/*@Override
public String getDimensionName() {
return "Pocket Dimension";