Main mod file and CommonProxy finished, ClientProxy almost done.

Need to research mob rendering to finish.
This commit is contained in:
zangamj 2016-06-16 14:05:30 -04:00
parent 45d6de97d3
commit 88a5f573a0
6 changed files with 83 additions and 111 deletions

View file

@ -1,20 +1,22 @@
package com.zixiken.dimdoors;
import java.io.File;
import java.io.FileInputStream;
import java.io.FileOutputStream;
import java.io.IOException;
import com.zixiken.dimdoors.blocks.BaseDimDoor;
import com.zixiken.dimdoors.config.DDProperties;
import com.zixiken.dimdoors.tileentities.TileEntityDimDoor;
import net.minecraft.entity.Entity;
import net.minecraft.block.BlockDoor;
import net.minecraft.block.state.IBlockState;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.nbt.CompressedStreamTools;
import net.minecraft.nbt.NBTTagCompound;
import net.minecraft.tileentity.TileEntity;
import net.minecraft.util.BlockPos;
import net.minecraft.world.World;
import net.minecraftforge.fml.common.network.IGuiHandler;
import net.minecraftforge.fml.common.network.simpleimpl.MessageContext;
public class CommonProxy {
public static String BLOCK_PNG = "/PocketBlockTextures.png";
@ -23,6 +25,8 @@ public class CommonProxy {
public static String RIFT2_PNG = "/RIFT2.png";
public static String WARP_PNG = "/WARP.png";
public void registerRenderers() {}
public void writeNBTToFile(World world) {
try {
String dirFolder = world.getSaveHandler().getMapFileFromName("idcounts")
@ -42,7 +46,7 @@ public class CommonProxy {
}
}
public void readNBTFromFile(World world) {
public NBTTagCompound readNBTFromFile(World world) {
try {
String dirFolder = world.getSaveHandler().getMapFileFromName("idcounts")
.getCanonicalPath().replace("idcounts.dat", "");
@ -58,29 +62,29 @@ public class CommonProxy {
fileoutputstream.close();
}
/*FileInputStream fileinputstream = new FileInputStream(file);
FileInputStream fileinputstream = new FileInputStream(file);
NBTTagCompound nbttagcompound = CompressedStreamTools.readCompressed(fileinputstream);
fileinputstream.close();*/
fileinputstream.close();
return nbttagcompound;
} catch (IOException e) {
System.err.println("Could not read NBT data from file:\n" + e);
return null;
}
}
public void printStringClient(String string) {}
public void updateDoorTE(BaseDimDoor door, World world, int x, int y, int z) {
TileEntity tile = world.getTileEntity(x, y, z);
public void updateDoorTE(BaseDimDoor door, World world, BlockPos pos) {
TileEntity tile = world.getTileEntity(pos);
if (tile instanceof TileEntityDimDoor)
{
int metadata = world.getBlockMetadata(x, y, z);
IBlockState state = world.getBlockState(pos);
TileEntityDimDoor dimTile = (TileEntityDimDoor) tile;
dimTile.openOrClosed = door.isDoorOnRift(world, x, y, z)&&door.isUpperDoorBlock(metadata);
dimTile.orientation = door.func_150012_g(world, x,y,z) & 7;
dimTile.lockStatus = door.getLockStatus(world, x, y, z);
dimTile.openOrClosed = door.isDoorOnRift(world, pos) && door.isUpperDoorBlock(state);
dimTile.orientation = state.getValue(BlockDoor.FACING).rotateY().getHorizontalIndex();
dimTile.lockStatus = door.getLockStatus(world, pos);
}
}
public void registerSidedHooks(DDProperties properties) {
public void registerSidedHooks() {
new ServerPacketHandler();
}

View file

@ -3,6 +3,7 @@ package com.zixiken.dimdoors;
import java.io.File;
import java.util.List;
import com.zixiken.dimdoors.items.*;
import com.zixiken.dimdoors.network.DimDoorsNetwork;
import com.zixiken.dimdoors.schematic.BlockRotator;
import com.zixiken.dimdoors.blocks.TransientDoor;
@ -34,21 +35,7 @@ import com.zixiken.dimdoors.config.DDWorldProperties;
import com.zixiken.dimdoors.core.PocketManager;
import com.zixiken.dimdoors.helpers.ChunkLoaderHelper;
import com.zixiken.dimdoors.helpers.DungeonHelper;
import com.zixiken.dimdoors.items.ItemBlockDimWall;
import com.zixiken.dimdoors.items.ItemDDKey;
import com.zixiken.dimdoors.items.ItemDimensionalDoor;
import com.zixiken.dimdoors.items.ItemGoldDimDoor;
import com.zixiken.dimdoors.items.ItemGoldDoor;
import com.zixiken.dimdoors.items.ItemPersonalDoor;
import com.zixiken.dimdoors.items.ItemQuartzDoor;
import com.zixiken.dimdoors.items.ItemRiftBlade;
import com.zixiken.dimdoors.items.ItemRiftSignature;
import com.zixiken.dimdoors.items.ItemStabilizedRiftSignature;
import com.zixiken.dimdoors.items.ItemStableFabric;
import com.zixiken.dimdoors.items.ItemUnstableDoor;
import com.zixiken.dimdoors.items.ItemWarpDoor;
import com.zixiken.dimdoors.items.ItemWorldThread;
import com.zixiken.dimdoors.items.itemRiftRemover;
import com.zixiken.dimdoors.items.ItemRiftRemover;
import com.zixiken.dimdoors.ticking.CustomLimboPopulator;
import com.zixiken.dimdoors.ticking.LimboDecayScheduler;
import com.zixiken.dimdoors.ticking.RiftRegenerator;
@ -164,7 +151,7 @@ public class DimDoors {
MinecraftForge.EVENT_BUS.register(hooks);
MinecraftForge.TERRAIN_GEN_BUS.register(hooks);
proxy.registerSidedHooks(properties);
proxy.registerSidedHooks();
DimDoorsNetwork.init();
}
@ -203,7 +190,7 @@ public class DimDoors {
itemDimensionalDoor = new ItemDimensionalDoor();
itemWarpDoor = new ItemWarpDoor();
itemRiftSignature = new ItemRiftSignature();
itemRiftRemover = new itemRiftRemover();
itemRiftRemover = new ItemRiftRemover();
itemStableFabric = new ItemStableFabric();
itemUnstableDoor = new ItemUnstableDoor();
itemRiftBlade = new ItemRiftBlade();
@ -218,34 +205,33 @@ public class DimDoors {
DimDoors.limboBiome = (new BiomeGenLimbo(properties.LimboBiomeID));
DimDoors.pocketBiome = (new BiomeGenPocket(properties.PocketBiomeID));
GameRegistry.registerBlock(quartzDoor, null, "Quartz Door");
GameRegistry.registerBlock(personalDimDoor, null, "Personal Dimensional Door");
GameRegistry.registerBlock(goldenDoor, null, "Golden Door");
GameRegistry.registerBlock(goldenDimensionalDoor, null, "Golden Dimensional Door");
GameRegistry.registerBlock(unstableDoor, null, "Unstable Door");
GameRegistry.registerBlock(warpDoor, null, "Warp Door");
GameRegistry.registerBlock(blockRift, "Rift");
GameRegistry.registerBlock(blockLimbo, "Unraveled Fabric");
GameRegistry.registerBlock(dimensionalDoor, null, "Dimensional Door");
GameRegistry.registerBlock(transTrapdoor,"Transdimensional Trapdoor");
GameRegistry.registerBlock(blockDimWallPerm, "Fabric of RealityPerm");
GameRegistry.registerBlock(transientDoor, "transientDoor");
GameRegistry.registerItem(itemDDKey, "Rift Key");
GameRegistry.registerItem(itemQuartzDoor, "Quartz Door Item");
GameRegistry.registerItem(itemPersonalDoor, "Personal Dimensional Door Item");
GameRegistry.registerItem(itemGoldenDoor, "Golden Door Item");
GameRegistry.registerItem(itemGoldenDimensionalDoor, "Golden Dimensional Door Item");
GameRegistry.registerItem(itemDimensionalDoor, "Dimensional Door Item");
GameRegistry.registerItem(itemWarpDoor, "Warp Door Item");
GameRegistry.registerItem(itemRiftSignature, "Rift Signature");
GameRegistry.registerItem(itemRiftRemover, "Rift Remover");
GameRegistry.registerItem(itemStableFabric, "Stable Fabric Item");
GameRegistry.registerItem(itemUnstableDoor, "Unstable Door Item");
GameRegistry.registerItem(itemRiftBlade, "Rift Blade");
GameRegistry.registerItem(itemStabilizedRiftSignature, "Stabilized Rift Signature");
GameRegistry.registerItem(itemWorldThread, "World Thread");
GameRegistry.registerBlock(blockDimWall, ItemBlockDimWall.class, "Fabric of Reality");
GameRegistry.registerBlock(quartzDoor, null, BlockDoorQuartz.ID);
GameRegistry.registerBlock(personalDimDoor, null, PersonalDimDoor.ID);
GameRegistry.registerBlock(goldenDoor, null, BlockDoorGold.ID);
GameRegistry.registerBlock(goldenDimensionalDoor, null, BlockGoldDimDoor.ID);
GameRegistry.registerBlock(unstableDoor, null, UnstableDoor.ID);
GameRegistry.registerBlock(warpDoor, null, WarpDoor.ID);
GameRegistry.registerBlock(blockRift, BlockRift.ID);
GameRegistry.registerBlock(blockLimbo, BlockLimbo.ID);
GameRegistry.registerBlock(dimensionalDoor, null, DimensionalDoor.ID);
GameRegistry.registerBlock(transTrapdoor, TransTrapdoor.ID);
GameRegistry.registerBlock(blockDimWall, ItemBlockDimWall.class, BlockDimWall.ID);
GameRegistry.registerBlock(blockDimWallPerm, BlockDimWallPerm.ID);
GameRegistry.registerBlock(transientDoor, TransientDoor.ID);
GameRegistry.registerItem(itemDDKey, ItemDDKey.ID);
GameRegistry.registerItem(itemQuartzDoor, ItemQuartzDoor.ID);
GameRegistry.registerItem(itemPersonalDoor, ItemPersonalDoor.ID);
GameRegistry.registerItem(itemGoldenDoor, ItemGoldDoor.ID);
GameRegistry.registerItem(itemGoldenDimensionalDoor, ItemGoldDimDoor.ID);
GameRegistry.registerItem(itemDimensionalDoor, ItemDimensionalDoor.ID);
GameRegistry.registerItem(itemWarpDoor, ItemWarpDoor.ID);
GameRegistry.registerItem(itemRiftSignature, ItemRiftSignature.ID);
GameRegistry.registerItem(itemRiftRemover, ItemRiftRemover.ID);
GameRegistry.registerItem(itemStableFabric, ItemStableFabric.ID);
GameRegistry.registerItem(itemUnstableDoor, ItemUnstableDoor.ID);
GameRegistry.registerItem(itemRiftBlade, ItemRiftBlade.ID);
GameRegistry.registerItem(itemStabilizedRiftSignature, ItemStabilizedRiftSignature.ID);
GameRegistry.registerItem(itemWorldThread, ItemWorldThread.ID);
BlockRotator.setupOrientations();

View file

@ -9,6 +9,7 @@ import net.minecraft.block.Block;
import net.minecraft.block.BlockDoor;
import net.minecraft.block.ITileEntityProvider;
import net.minecraft.block.material.Material;
import net.minecraft.block.state.IBlockState;
import net.minecraft.client.renderer.IconFlipped;
import net.minecraft.client.renderer.texture.IIconRegister;
import net.minecraft.entity.Entity;
@ -17,6 +18,7 @@ import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.item.Item;
import net.minecraft.item.ItemStack;
import net.minecraft.tileentity.TileEntity;
import net.minecraft.util.BlockPos;
import net.minecraft.util.IIcon;
import net.minecraft.util.MathHelper;
import net.minecraft.util.MovingObjectPosition;
@ -192,22 +194,22 @@ public abstract class BaseDimDoor extends BlockDoor implements IDimDoor, ITileEn
return this;
}
public boolean isDoorOnRift(World world, int x, int y, int z)
public boolean isDoorOnRift(World world, BlockPos pos)
{
return this.getLink(world, x, y, z) != null;
return this.getLink(world, pos) != null;
}
public DimLink getLink(World world, int x, int y, int z)
public DimLink getLink(World world, BlockPos pos)
{
DimLink link= PocketManager.getLink(x, y, z, world.provider.dimensionId);
DimLink link= PocketManager.getLink(pos, world.provider.getDimensionId());
if(link!=null)
{
return link;
}
if(isUpperDoorBlock( world.getBlockMetadata(x, y, z)))
if(isUpperDoorBlock(world.getBlockState(pos)))
{
link = PocketManager.getLink(x, y-1, z, world.provider.dimensionId);
link = PocketManager.getLink(pos.down(), world.provider.getDimensionId());
if(link!=null)
{
return link;
@ -215,7 +217,7 @@ public abstract class BaseDimDoor extends BlockDoor implements IDimDoor, ITileEn
}
else
{
link = PocketManager.getLink(x, y+1, z, world.provider.dimensionId);
link = PocketManager.getLink(pos.up(), world.provider.getDimensionId());
if(link != null)
{
return link;
@ -443,9 +445,9 @@ public abstract class BaseDimDoor extends BlockDoor implements IDimDoor, ITileEn
}
}
public boolean isUpperDoorBlock(int metadata)
public boolean isUpperDoorBlock(IBlockState state)
{
return (metadata & 8) != 0;
return state.getValue(BlockDoor.HALF) == EnumDoorHalf.UPPER;
}
public boolean isDoorOpen(int metadata)
@ -463,10 +465,10 @@ public abstract class BaseDimDoor extends BlockDoor implements IDimDoor, ITileEn
* @param z
* @return
*/
public byte getLockStatus(World world, int x, int y, int z)
public byte getLockStatus(World world, BlockPos pos)
{
byte status = 0;
DimLink link = getLink(world, x, y, z);
DimLink link = getLink(world, pos);
if(link!=null&&link.hasLock())
{
status++;

View file

@ -1,28 +1,23 @@
package com.zixiken.dimdoors.client;
import com.zixiken.dimdoors.CommonProxy;
import com.zixiken.dimdoors.config.DDProperties;
import com.zixiken.dimdoors.blocks.BaseDimDoor;
import com.zixiken.dimdoors.core.DimLink;
import com.zixiken.dimdoors.core.PocketManager;
import com.zixiken.dimdoors.ticking.MobMonolith;
import com.zixiken.dimdoors.tileentities.TileEntityDimDoor;
import com.zixiken.dimdoors.tileentities.TileEntityTransTrapdoor;
import cpw.mods.fml.common.network.simpleimpl.MessageContext;
import net.minecraft.client.Minecraft;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.tileentity.TileEntity;
import net.minecraft.world.World;
import com.zixiken.dimdoors.CommonProxy;
import com.zixiken.dimdoors.tileentities.TileEntityDimDoor;
import cpw.mods.fml.client.registry.ClientRegistry;
import cpw.mods.fml.client.registry.RenderingRegistry;
import net.minecraftforge.common.MinecraftForge;
import net.minecraftforge.fml.client.registry.ClientRegistry;
import net.minecraftforge.fml.client.registry.RenderingRegistry;
import net.minecraftforge.fml.common.network.simpleimpl.MessageContext;
public class ClientProxy extends CommonProxy
{
@Override
public void registerRenderers()
{
public class ClientProxy extends CommonProxy {
public void registerRenderers() {
//MinecraftForgeClient.preloadTexture(BLOCK_PNG);
ClientRegistry.bindTileEntitySpecialRenderer(TileEntityDimDoor.class, new RenderDimDoor());
ClientRegistry.bindTileEntitySpecialRenderer(TileEntityTransTrapdoor.class, new RenderTransTrapdoor());
@ -32,30 +27,10 @@ public class ClientProxy extends CommonProxy
RenderingRegistry.registerBlockHandler(new PrivatePocketRender(RenderingRegistry.getNextAvailableRenderId()));
}
@Override
public void updateDoorTE(BaseDimDoor door, World world, int x, int y, int z)
{
TileEntity tile = world.getTileEntity(x, y, z);
if (tile instanceof TileEntityDimDoor)
{
DimLink link = PocketManager.getLink(x, y, z, world);
int metadata = world.getBlockMetadata(x, y, z);
TileEntityDimDoor dimTile = (TileEntityDimDoor) tile;
dimTile.openOrClosed = door.isDoorOnRift(world, x, y, z)&&door.isUpperDoorBlock(metadata);
dimTile.orientation = door.func_150012_g(world, x, y, z) & 7;
dimTile.lockStatus = door.getLockStatus(world, x, y, z);
}
}
@Override
public void printStringClient(String string)
{
}
@Override
public void registerSidedHooks(DDProperties properties) {
ClientOnlyHooks hooks = new ClientOnlyHooks(properties);
public void registerSidedHooks() {
ClientOnlyHooks hooks = new ClientOnlyHooks(DDProperties.instance());
MinecraftForge.EVENT_BUS.register(hooks);
MinecraftForge.TERRAIN_GEN_BUS.register(hooks);
PocketManager.getDimwatcher().registerReceiver (new PocketManager.ClientDimWatcher());

View file

@ -8,6 +8,7 @@ import java.util.List;
import com.zixiken.dimdoors.DimDoors;
import com.zixiken.dimdoors.watcher.IUpdateWatcher;
import io.netty.buffer.ByteBuf;
import net.minecraft.util.BlockPos;
import net.minecraft.world.World;
import net.minecraft.world.WorldServer;
import net.minecraftforge.common.DimensionManager;
@ -678,6 +679,10 @@ public class PocketManager
return null;
}
public static DimLink getLink(BlockPos pos, int dimensionId) {
return getLink(pos.getX(), pos.getY(), pos.getZ(), dimensionId);
}
public static boolean isBlackListed(int dimensionID)
{
return PocketManager.dimensionIDBlackList.contains(dimensionID);

View file

@ -19,10 +19,10 @@ import cpw.mods.fml.client.FMLClientHandler;
import cpw.mods.fml.relauncher.Side;
import cpw.mods.fml.relauncher.SideOnly;
public class itemRiftRemover extends Item {
public static final String ID = "itemRiftRemover";
public class ItemRiftRemover extends Item {
public static final String ID = "ItemRiftRemover";
public itemRiftRemover() {
public ItemRiftRemover() {
super();
setMaxStackSize(1);
setCreativeTab(DimDoors.dimDoorsCreativeTab);