Mazes #117

Merged
StevenRS11 merged 101 commits from mazes into DevBranch 2013-12-29 07:03:48 +00:00
373 changed files with 4329 additions and 1788 deletions

View File

@@ -1,212 +0,0 @@
package StevenDimDoors.mod_pocketDim;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.Random;
import net.minecraft.inventory.IInventory;
import net.minecraft.item.Item;
import net.minecraft.item.ItemStack;
import net.minecraft.util.WeightedRandom;
import net.minecraft.util.WeightedRandomChestContent;
import net.minecraftforge.common.ChestGenHooks;
/*
* Registers a category of loot chests for Dimensional Doors in Forge.
*/
public class DDLoot {
//These are the categories of loot to be merged into our chests
static final String[] chestSources = new String[] {
ChestGenHooks.MINESHAFT_CORRIDOR,
ChestGenHooks.PYRAMID_DESERT_CHEST,
ChestGenHooks.PYRAMID_JUNGLE_CHEST,
ChestGenHooks.STRONGHOLD_CORRIDOR,
ChestGenHooks.STRONGHOLD_CROSSING,
ChestGenHooks.VILLAGE_BLACKSMITH,
ChestGenHooks.DUNGEON_CHEST
};
public static final String DIMENSIONAL_DUNGEON_CHEST = "dimensionalDungeonChest";
public static ChestGenHooks DungeonChestInfo = null;
private static final int CHEST_SIZE = 5;
private static final int COMMON_LOOT_WEIGHT = 9; //1 less than weight of iron ingots
private static final int UNCOMMON_LOOT_WEIGHT = 4; //1 less than weight of iron armor
private static final int RARE_LOOT_WEIGHT = 1; //Same weight as music discs, golden apple
private static final int DUNGEON_CHEST_WEIGHT_INFLATION = 10; // (weight of iron ingots in dungeon) / (weight of iron ingots in other chests)
private DDLoot() { }
public static void registerInfo()
{
DDProperties properties = DDProperties.instance();
//Register the dimensional dungeon chest with ChestGenHooks. This isn't necessary, but allows
//other mods to add their own loot to our chests if they know our loot category, without having
//to interface with our code.
DungeonChestInfo = ChestGenHooks.getInfo(DIMENSIONAL_DUNGEON_CHEST);
DungeonChestInfo.setMin(CHEST_SIZE);
DungeonChestInfo.setMax(CHEST_SIZE);
//Merge the item lists from source chests
//This means chests will include future loot as Minecraft updates! ^_^
ArrayList<WeightedRandomChestContent> items = mergeCategories(chestSources);
//Add any enabled DD loot to the list of items
addContent(properties.FabricOfRealityLootEnabled, items, mod_pocketDim.blockDimWall.blockID, 8, 32, COMMON_LOOT_WEIGHT);
addContent(properties.DimensionalDoorLootEnabled, items, mod_pocketDim.itemDimDoor.itemID, UNCOMMON_LOOT_WEIGHT);
addContent(properties.WarpDoorLootEnabled, items, mod_pocketDim.itemExitDoor.itemID, UNCOMMON_LOOT_WEIGHT);
addContent(properties.TransTrapdoorLootEnabled, items, mod_pocketDim.transTrapdoor.blockID, UNCOMMON_LOOT_WEIGHT);
addContent(properties.RiftSignatureLootEnabled, items, mod_pocketDim.itemLinkSignature.itemID, UNCOMMON_LOOT_WEIGHT);
addContent(properties.StableFabricLootEnabled, items, mod_pocketDim.itemStableFabric.itemID, UNCOMMON_LOOT_WEIGHT);
addContent(properties.RiftRemoverLootEnabled, items, mod_pocketDim.itemRiftRemover.itemID, UNCOMMON_LOOT_WEIGHT);
addContent(properties.UnstableDoorLootEnabled, items, mod_pocketDim.itemChaosDoor.itemID, RARE_LOOT_WEIGHT);
addContent(properties.StabilizedRiftSignatureLootEnabled, items, mod_pocketDim.itemStabilizedLinkSignature.itemID, RARE_LOOT_WEIGHT);
addContent(properties.RiftBladeLootEnabled, items, mod_pocketDim.itemRiftBlade.itemID, RARE_LOOT_WEIGHT);
//Add all the items to our dungeon chest
addItemsToContainer(DungeonChestInfo, items);
}
private static ArrayList<WeightedRandomChestContent> mergeCategories(String[] categories)
{
//Retrieve the items of each container category and merge the lists together. If two matching items
//are found, choose the item with the minimum weight. Special checks are included for DUNGEON_CHEST
//because the items in that category have strange weights that are incompatible with all other
//chest categories.
Random random = new Random();
HashMap<Integer, WeightedRandomChestContent> container = new HashMap<Integer, WeightedRandomChestContent>();
for (String category : categories)
{
WeightedRandomChestContent[] items = ChestGenHooks.getItems(category, random);
for (WeightedRandomChestContent item : items)
{
ItemStack stack = item.theItemId;
int id = stack.itemID;
int subtype = stack.getItem().getHasSubtypes() ? stack.getItemDamage() : 0;
//Correct the weights of Vanilla dungeon chests (DUNGEON_CHEST)
//Comparing by String references is valid here since they should match!
if (category == ChestGenHooks.DUNGEON_CHEST)
{
//It's okay to modify the weights directly. These are copies of instances,
//not direct references. It won't affect Vanilla chests.
item.itemWeight /= DUNGEON_CHEST_WEIGHT_INFLATION;
if (item.itemWeight == 0)
item.itemWeight = 1;
}
//Generate an identifier for this item using its item ID and damage value,
//if it has subtypes. This solves the issue of matching items that have
//the same item ID but different subtypes (e.g. wood planks, dyes).
int key = ((subtype & 0xFFFF) << 16) + ((id & 0xFFFF) << 16);
WeightedRandomChestContent other = container.get(key);
if (other == null)
{
//This item has not been seen before. Simply add it to the container.
container.put(key, item);
}
else
{
//This item conflicts with an existing entry. Replace that entry
//if our current item has a lower weight.
if (item.itemWeight < other.itemWeight)
{
container.put(key, item);
}
}
}
}
//I've added a minor hack here to make enchanted books more common
//If this is necessary for more items, create an override table and use that
//rather than hardcoding the changes below
final int enchantedBookID = Item.enchantedBook.itemID;
for (WeightedRandomChestContent item : container.values())
{
if (item.theItemId.itemID == enchantedBookID)
{
item.itemWeight = 4;
break;
}
}
//Return merged list
return new ArrayList<WeightedRandomChestContent>( container.values() );
}
private static void addContent(boolean include, ArrayList<WeightedRandomChestContent> items,
int itemID, int weight)
{
if (include)
items.add(new WeightedRandomChestContent(itemID, 0, 1, 1, weight));
}
private static void addContent(boolean include, ArrayList<WeightedRandomChestContent> items,
int itemID, int minAmount, int maxAmount, int weight)
{
if (include)
items.add(new WeightedRandomChestContent(itemID, 0, minAmount, maxAmount, weight));
}
private static void addItemsToContainer(ChestGenHooks container, ArrayList<WeightedRandomChestContent> items)
{
//System.out.println("Preparing Chest Stuff");
for (WeightedRandomChestContent item : items)
{
container.addItem(item);
//Uncomment this code to print out loot and weight pairs
//System.out.println(item.theItemId.getDisplayName() + "\t" + item.itemWeight);
}
}
public static void generateChestContents(ChestGenHooks chestInfo, IInventory inventory, Random random)
{
//This is a custom version of net.minecraft.util.WeightedRandomChestContent.generateChestContents()
//It's designed to avoid the following bugs in MC 1.5:
//1. The randomized filling algorithm will sometimes overwrite item stacks with other stacks
//2. If multiple enchanted books appear, then they will have the same enchantment
//The prime number below is used for choosing chest slots in a seemingly-random pattern. Its value
//was selected specifically to achieve a spread-out distribution for chests with up to 104 slots.
//Choosing a prime number ensures that our increments are relatively-prime to the chest size, which
//means we'll cover all the slots before repeating any. This is mathematically guaranteed.
final int primeOffset = 239333;
int count = chestInfo.getCount(random);
int size = inventory.getSizeInventory();
WeightedRandomChestContent[] content = chestInfo.getItems(random);
for (int k = 0; k < count; k++)
{
WeightedRandomChestContent selection = (WeightedRandomChestContent)WeightedRandom.getRandomItem(random, content);
//Call getChestGenBase() to make sure we generate a different enchantment for books.
//Don't just use a condition to check if the item is an instance of ItemEnchantedBook because
//we don't know if other mods might add items that also need to be regenerated.
selection = selection.theItemId.getItem().getChestGenBase(chestInfo, random, selection);
ItemStack[] stacks = ChestGenHooks.generateStacks(random, selection.theItemId, selection.theMinimumChanceToGenerateItem, selection.theMaximumChanceToGenerateItem);
for (ItemStack item : stacks)
{
int limit = size;
int index = random.nextInt(size);
while (limit > 0 && inventory.getStackInSlot(index) != null)
{
limit--;
index = (index + primeOffset) % size;
}
inventory.setInventorySlotContents(index, item);
}
}
}
}

View File

@@ -1,32 +0,0 @@
package StevenDimDoors.mod_pocketDim.helpers;
import java.util.List;
import net.minecraft.world.World;
import net.minecraftforge.common.ForgeChunkManager;
import net.minecraftforge.common.ForgeChunkManager.LoadingCallback;
import net.minecraftforge.common.ForgeChunkManager.Ticket;
import StevenDimDoors.mod_pocketDim.IChunkLoader;
import StevenDimDoors.mod_pocketDim.mod_pocketDim;
import StevenDimDoors.mod_pocketDim.tileentities.TileEntityDimDoorGold;
import com.google.common.collect.Lists;
public class ChunkLoaderHelper implements LoadingCallback
{
@Override
public void ticketsLoaded(List<Ticket> tickets, World world)
{
for (Ticket ticket : tickets)
{
int goldDimDoorX = ticket.getModData().getInteger("goldDimDoorX");
int goldDimDoorY = ticket.getModData().getInteger("goldDimDoorY");
int goldDimDoorZ = ticket.getModData().getInteger("goldDimDoorZ");
IChunkLoader tile = (IChunkLoader) world.getBlockTileEntity(goldDimDoorX, goldDimDoorY, goldDimDoorZ);
tile.forceChunkLoading(ticket,goldDimDoorX,goldDimDoorZ);
}
}
}

View File

@@ -1,64 +0,0 @@
package StevenDimDoors.mod_pocketDim.items;
import StevenDimDoors.mod_pocketDim.mod_pocketDim;
import net.minecraft.block.Block;
import net.minecraft.block.material.Material;
import net.minecraft.client.renderer.texture.IconRegister;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.item.ItemDoor;
import net.minecraft.item.ItemStack;
import net.minecraft.util.MathHelper;
import net.minecraft.world.World;
public class ItemGoldDoor extends ItemDoor
{
public ItemGoldDoor(int par1, Material par2Material)
{
super(par1, par2Material);
// TODO Auto-generated constructor stub
}
public void registerIcons(IconRegister par1IconRegister)
{
this.itemIcon = par1IconRegister.registerIcon(mod_pocketDim.modid + ":" + this.getUnlocalizedName().replace("item.", ""));
}
public boolean onItemUse(ItemStack par1ItemStack, EntityPlayer par2EntityPlayer, World par3World, int par4, int par5, int par6, int par7, float par8, float par9, float par10)
{
if (par7 != 1)
{
return false;
}
else
{
++par5;
Block block = mod_pocketDim.goldDoor;
if (par2EntityPlayer.canPlayerEdit(par4, par5, par6, par7, par1ItemStack) && par2EntityPlayer.canPlayerEdit(par4, par5 + 1, par6, par7, par1ItemStack))
{
if (!block.canPlaceBlockAt(par3World, par4, par5, par6))
{
return false;
}
else
{
int i1 = MathHelper.floor_double((double)((par2EntityPlayer.rotationYaw + 180.0F) * 4.0F / 360.0F) - 0.5D) & 3;
placeDoorBlock(par3World, par4, par5, par6, i1, block);
--par1ItemStack.stackSize;
return true;
}
}
else
{
return false;
}
}
}
}

View File

@@ -1,78 +0,0 @@
package StevenDimDoors.mod_pocketDim.tileentities;
import StevenDimDoors.mod_pocketDim.mod_pocketDim;
import StevenDimDoors.mod_pocketDim.core.PocketManager;
import net.minecraft.nbt.NBTTagCompound;
import net.minecraft.tileentity.TileEntity;
import net.minecraft.world.World;
public class TileEntityDimDoor extends TileEntity
{
public boolean openOrClosed;
public int orientation;
public boolean hasExit;
public boolean isDungeonChainLink;
public boolean hasGennedPair=false;
public boolean canUpdate()
{
return false;
}
public void updateEntity()
{
}
@Override
public void readFromNBT(NBTTagCompound nbt)
{
super.readFromNBT(nbt);
int i = nbt.getInteger(("Size"));
try
{
this.openOrClosed = nbt.getBoolean("openOrClosed");
this.orientation = nbt.getInteger("orientation");
this.hasExit = nbt.getBoolean("hasExit");
this.isDungeonChainLink = nbt.getBoolean("isDungeonChainLink");
this.hasGennedPair = nbt.getBoolean("hasGennedPair");
}
catch (Exception e)
{
}
}
@Override
public void writeToNBT(NBTTagCompound nbt)
{
int i = 0;
super.writeToNBT(nbt);
nbt.setBoolean("openOrClosed", this.openOrClosed);
nbt.setBoolean("hasExit", this.hasExit);
nbt.setInteger("orientation", this.orientation);
nbt.setBoolean("isDungeonChainLink", isDungeonChainLink);
nbt.setBoolean("hasGennedPair", hasGennedPair);
}
}

View File

@@ -1,110 +0,0 @@
package StevenDimDoors.mod_pocketDim.tileentities;
import StevenDimDoors.mod_pocketDim.IChunkLoader;
import StevenDimDoors.mod_pocketDim.mod_pocketDim;
import StevenDimDoors.mod_pocketDim.core.PocketManager;
import StevenDimDoors.mod_pocketDim.world.PocketBuilder;
import net.minecraft.nbt.NBTTagCompound;
import net.minecraft.world.ChunkCoordIntPair;
import net.minecraftforge.common.ForgeChunkManager;
import net.minecraftforge.common.ForgeChunkManager.Ticket;
import net.minecraftforge.common.ForgeChunkManager.Type;
public class TileEntityDimDoorGold extends TileEntityDimDoor implements IChunkLoader
{
private Ticket chunkTicket;
public boolean canUpdate()
{
return true;
}
public void updateEntity()
{
if(PocketManager.getDimensionData(this.worldObj)!=null&&PocketManager.getDimensionData(this.worldObj).isPocketDimension()&&!this.worldObj.isRemote)
{
if(this.chunkTicket==null)
{
chunkTicket = ForgeChunkManager.requestTicket(mod_pocketDim.instance, worldObj, Type.NORMAL);
}
chunkTicket.getModData().setInteger("goldDimDoorX", xCoord);
chunkTicket.getModData().setInteger("goldDimDoorY", yCoord);
chunkTicket.getModData().setInteger("goldDimDoorZ", zCoord);
ForgeChunkManager.forceChunk(chunkTicket, new ChunkCoordIntPair(xCoord >> 4, zCoord >> 4));
forceChunkLoading(chunkTicket,this.xCoord,this.zCoord);
}
}
public void forceChunkLoading(Ticket chunkTicket,int x,int z)
{
if(PocketManager.getDimensionData(chunkTicket.world)==null)
{
return;
}
if(!PocketManager.getDimensionData(chunkTicket.world).isPocketDimension())
{
return;
}
for(int chunks = (PocketBuilder.DEFAULT_POCKET_SIZE/16)+1;chunks>0;chunks--)
{
ForgeChunkManager.forceChunk(chunkTicket, new ChunkCoordIntPair((xCoord >> 4)+chunks, (zCoord >> 4)+chunks));
}
}
@Override
public void invalidate()
{
ForgeChunkManager.releaseTicket(chunkTicket);
super.invalidate();
}
@Override
public void readFromNBT(NBTTagCompound nbt)
{
super.readFromNBT(nbt);
int i = nbt.getInteger(("Size"));
try
{
this.openOrClosed = nbt.getBoolean("openOrClosed");
this.orientation = nbt.getInteger("orientation");
this.hasExit = nbt.getBoolean("hasExit");
this.isDungeonChainLink = nbt.getBoolean("isDungeonChainLink");
}
catch (Exception e)
{
}
}
@Override
public void writeToNBT(NBTTagCompound nbt)
{
int i = 0;
super.writeToNBT(nbt);
nbt.setBoolean("openOrClosed", this.openOrClosed);
nbt.setBoolean("hasExit", this.hasExit);
nbt.setInteger("orientation", this.orientation);
nbt.setBoolean("isDungeonChainLink", isDungeonChainLink);
}
}

View File

@@ -1,232 +0,0 @@
package StevenDimDoors.mod_pocketDim.world;
import org.lwjgl.opengl.GL11;
import net.minecraft.client.Minecraft;
import net.minecraft.client.multiplayer.WorldClient;
import net.minecraft.client.renderer.GLAllocation;
import net.minecraft.client.renderer.RenderHelper;
import net.minecraft.client.renderer.Tessellator;
import net.minecraft.util.MathHelper;
import net.minecraft.util.Vec3;
import net.minecraftforge.client.IRenderHandler;
public class CustomSkyProvider extends IRenderHandler
{
int starGLCallList;
int glSkyList;
int glSkyList2;
public String getMoonRenderPath()
{
return null;
}
public String getSunRenderPath()
{
return null;
}
@Override
public void render(float par1, WorldClient world, Minecraft mc)
{
starGLCallList = GLAllocation.generateDisplayLists(3);
glSkyList = this.starGLCallList + 1;
glSkyList2 = this.starGLCallList + 2;
GL11.glDisable(GL11.GL_FOG);
GL11.glDisable(GL11.GL_ALPHA_TEST);
GL11.glEnable(GL11.GL_BLEND);
GL11.glBlendFunc(GL11.GL_SRC_ALPHA, GL11.GL_ONE_MINUS_SRC_ALPHA);
RenderHelper.disableStandardItemLighting();
GL11.glDepthMask(false);
mc.renderEngine.bindTexture("/misc/tunnel.png");
Tessellator tessellator = Tessellator.instance;
if (mc.theWorld.provider.isSurfaceWorld())
{
GL11.glDisable(GL11.GL_TEXTURE_2D);
Vec3 vec3 = world.getSkyColor(mc.renderViewEntity, par1);
float f1 = (float)vec3.xCoord;
float f2 = (float)vec3.yCoord;
float f3 = (float)vec3.zCoord;
float f4;
if (mc.gameSettings.anaglyph)
{
float f5 = (f1 * 30.0F + f2 * 59.0F + f3 * 11.0F) / 100.0F;
float f6 = (f1 * 30.0F + f2 * 70.0F) / 100.0F;
f4 = (f1 * 30.0F + f3 * 70.0F) / 100.0F;
f1 = f5;
f2 = f6;
f3 = f4;
}
GL11.glColor3f(f1, f2, f3);
Tessellator tessellator1 = Tessellator.instance;
GL11.glDepthMask(false);
GL11.glEnable(GL11.GL_FOG);
GL11.glColor3f(f1, f2, f3);
GL11.glCallList(this.glSkyList);
GL11.glDisable(GL11.GL_FOG);
GL11.glDisable(GL11.GL_ALPHA_TEST);
GL11.glEnable(GL11.GL_BLEND);
GL11.glBlendFunc(GL11.GL_SRC_ALPHA, GL11.GL_ONE_MINUS_SRC_ALPHA);
RenderHelper.disableStandardItemLighting();
float[] afloat = world.provider.calcSunriseSunsetColors(world.getCelestialAngle(par1), par1);
float f7;
float f8;
float f9;
float f10;
if (afloat != null)
{
GL11.glDisable(GL11.GL_TEXTURE_2D);
GL11.glShadeModel(GL11.GL_SMOOTH);
GL11.glPushMatrix();
GL11.glRotatef(90.0F, 1.0F, 0.0F, 0.0F);
GL11.glRotatef(MathHelper.sin(world.getCelestialAngleRadians(par1)) < 0.0F ? 180.0F : 0.0F, 0.0F, 0.0F, 1.0F);
GL11.glRotatef(90.0F, 0.0F, 0.0F, 1.0F);
f4 = afloat[0];
f7 = afloat[1];
f8 = afloat[2];
float f11;
if (mc.gameSettings.anaglyph)
{
f9 = (f4 * 30.0F + f7 * 59.0F + f8 * 11.0F) / 100.0F;
f10 = (f4 * 30.0F + f7 * 70.0F) / 100.0F;
f11 = (f4 * 30.0F + f8 * 70.0F) / 100.0F;
f4 = f9;
f7 = f10;
f8 = f11;
}
tessellator1.startDrawing(6);
tessellator1.setColorRGBA_F(f4, f7, f8, afloat[3]);
tessellator1.addVertex(0.0D, 100.0D, 0.0D);
byte b0 = 16;
tessellator1.setColorRGBA_F(afloat[0], afloat[1], afloat[2], 0.0F);
for (int j = 0; j <= b0; ++j)
{
f11 = (float)j * (float)Math.PI * 2.0F / (float)b0;
float f12 = MathHelper.sin(f11);
float f13 = MathHelper.cos(f11);
tessellator1.addVertex((double)(f12 * 120.0F), (double)(f13 * 120.0F), (double)(-f13 * 40.0F * afloat[3]));
}
tessellator1.draw();
GL11.glPopMatrix();
GL11.glShadeModel(GL11.GL_FLAT);
}
GL11.glEnable(GL11.GL_TEXTURE_2D);
GL11.glBlendFunc(GL11.GL_SRC_ALPHA, GL11.GL_ONE);
GL11.glPushMatrix();
f4 = 1.0F - world.getRainStrength(par1);
f7 = 0.0F;
f8 = 0.0F;
f9 = 0.0F;
GL11.glColor4f(1.0F, 1.0F, 1.0F, f4);
GL11.glTranslatef(f7, f8, f9);
GL11.glRotatef(-90.0F, 0.0F, 1.0F, 0.0F);
GL11.glRotatef(world.getCelestialAngle(par1) * 360.0F, 1.0F, 0.0F, 0.0F);
f10 = 30.0F;
mc.renderEngine.bindTexture(this.getSunRenderPath());
tessellator1.startDrawingQuads();
tessellator1.addVertexWithUV((double)(-f10), 100.0D, (double)(-f10), 0.0D, 0.0D);
tessellator1.addVertexWithUV((double)f10, 100.0D, (double)(-f10), 1.0D, 0.0D);
tessellator1.addVertexWithUV((double)f10, 100.0D, (double)f10, 1.0D, 1.0D);
tessellator1.addVertexWithUV((double)(-f10), 100.0D, (double)f10, 0.0D, 1.0D);
tessellator1.draw();
f10 = 20.0F;
mc.renderEngine.bindTexture(this.getMoonRenderPath());
int k = world.getMoonPhase();
int l = k % 4;
int i1 = k / 4 % 2;
float f14 = (float)(l + 0) ;
float f15 = (float)(i1 + 0);
float f16 = (float)(l + 1) ;
float f17 = (float)(i1 + 1);
tessellator1.startDrawingQuads();
tessellator1.addVertexWithUV((double)(-f10), -100.0D, (double)f10, (double)f16, (double)f17);
tessellator1.addVertexWithUV((double)f10, -100.0D, (double)f10, (double)f14, (double)f17);
tessellator1.addVertexWithUV((double)f10, -100.0D, (double)(-f10), (double)f14, (double)f15);
tessellator1.addVertexWithUV((double)(-f10), -100.0D, (double)(-f10), (double)f16, (double)f15);
tessellator1.draw();
GL11.glDisable(GL11.GL_TEXTURE_2D);
float f18 = world.getStarBrightness(par1) * f4;
if (f18 > 0.0F)
{
GL11.glColor4f(f18, f18, f18, f18);
GL11.glCallList(this.starGLCallList);
}
GL11.glColor4f(1.0F, 1.0F, 1.0F, 1.0F);
GL11.glDisable(GL11.GL_BLEND);
GL11.glEnable(GL11.GL_ALPHA_TEST);
GL11.glEnable(GL11.GL_FOG);
GL11.glPopMatrix();
GL11.glDisable(GL11.GL_TEXTURE_2D);
GL11.glColor3f(0.0F, 0.0F, 0.0F);
double d0 = mc.thePlayer.getPosition(par1).yCoord - world.getHorizon();
if (d0 < 0.0D)
{
GL11.glPushMatrix();
GL11.glTranslatef(0.0F, 12.0F, 0.0F);
GL11.glCallList(this.glSkyList2);
GL11.glPopMatrix();
f8 = 1.0F;
f9 = -((float)(d0 + 65.0D));
f10 = -f8;
tessellator1.startDrawingQuads();
tessellator1.setColorRGBA_I(0, 255);
tessellator1.addVertex((double)(-f8), (double)f9, (double)f8);
tessellator1.addVertex((double)f8, (double)f9, (double)f8);
tessellator1.addVertex((double)f8, (double)f10, (double)f8);
tessellator1.addVertex((double)(-f8), (double)f10, (double)f8);
tessellator1.addVertex((double)(-f8), (double)f10, (double)(-f8));
tessellator1.addVertex((double)f8, (double)f10, (double)(-f8));
tessellator1.addVertex((double)f8, (double)f9, (double)(-f8));
tessellator1.addVertex((double)(-f8), (double)f9, (double)(-f8));
tessellator1.addVertex((double)f8, (double)f10, (double)(-f8));
tessellator1.addVertex((double)f8, (double)f10, (double)f8);
tessellator1.addVertex((double)f8, (double)f9, (double)f8);
tessellator1.addVertex((double)f8, (double)f9, (double)(-f8));
tessellator1.addVertex((double)(-f8), (double)f9, (double)(-f8));
tessellator1.addVertex((double)(-f8), (double)f9, (double)f8);
tessellator1.addVertex((double)(-f8), (double)f10, (double)f8);
tessellator1.addVertex((double)(-f8), (double)f10, (double)(-f8));
tessellator1.addVertex((double)(-f8), (double)f10, (double)(-f8));
tessellator1.addVertex((double)(-f8), (double)f10, (double)f8);
tessellator1.addVertex((double)f8, (double)f10, (double)f8);
tessellator1.addVertex((double)f8, (double)f10, (double)(-f8));
tessellator1.draw();
}
if (world.provider.isSkyColored())
{
GL11.glColor3f(f1 * 0.2F + 0.04F, f2 * 0.2F + 0.04F, f3 * 0.6F + 0.1F);
}
else
{
GL11.glColor3f(f1, f2, f3);
}
GL11.glPushMatrix();
GL11.glTranslatef(0.0F, -((float)(d0 - 16.0D)), 0.0F);
GL11.glCallList(this.glSkyList2);
GL11.glPopMatrix();
GL11.glEnable(GL11.GL_TEXTURE_2D);
GL11.glDepthMask(true);
}
}
}

View File

@@ -1,27 +0,0 @@
package StevenDimDoors.mod_pocketDim.world;
import org.lwjgl.opengl.GL11;
import net.minecraft.client.Minecraft;
import net.minecraft.client.multiplayer.WorldClient;
import net.minecraft.client.renderer.GLAllocation;
import net.minecraft.client.renderer.RenderHelper;
import net.minecraft.client.renderer.Tessellator;
import net.minecraft.util.MathHelper;
import net.minecraft.util.Vec3;
import net.minecraftforge.client.IRenderHandler;
public class LimboSkyProvider extends CustomSkyProvider
{
@Override
public String getMoonRenderPath()
{
return "/mods/DimDoors/textures/other/limboMoon.png";
}
@Override
public String getSunRenderPath()
{
return "/mods/DimDoors/textures/other/limboSun.png";
}
}

View File

@@ -1,31 +0,0 @@
package StevenDimDoors.mod_pocketDim.world;
import org.lwjgl.opengl.GL11;
import net.minecraft.client.Minecraft;
import net.minecraft.client.multiplayer.WorldClient;
import net.minecraft.client.renderer.GLAllocation;
import net.minecraft.client.renderer.RenderHelper;
import net.minecraft.client.renderer.Tessellator;
import net.minecraft.util.MathHelper;
import net.minecraft.util.Vec3;
import net.minecraftforge.client.IRenderHandler;
public class PocketSkyProvider extends CustomSkyProvider
{
public class LimboSkyProvider extends CustomSkyProvider
{
@Override
public String getMoonRenderPath()
{
return "/mods/DimDoors/textures/other/pocketMoon.png";
}
@Override
public String getSunRenderPath()
{
return "/mods/DimDoors/textures/other/pocketSun.png";
}
}
}

View File

@@ -1,21 +0,0 @@
package StevenDimDoors.mod_pocketDimClient;
import net.minecraft.client.renderer.entity.RenderLiving;
import cpw.mods.fml.relauncher.Side;
import cpw.mods.fml.relauncher.SideOnly;
@SideOnly(Side.CLIENT)
public class RenderMobObelisk extends RenderLiving
{
protected ModelMobObelisk obeliskModel;
public RenderMobObelisk(float f)
{
super(new ModelMobObelisk(), f);
this.obeliskModel = (ModelMobObelisk)this.mainModel;
}
}

48
build.gradle Normal file
View File

@@ -0,0 +1,48 @@
buildscript {
repositories {
mavenCentral()
maven {
name = "forge"
url = "http://files.minecraftforge.net/maven"
}
}
dependencies {
classpath 'net.minecraftforge.gradle:ForgeGradle:1.0-SNAPSHOT'
}
}
apply plugin: 'forge'
version = "2.2.1RC1-" + System.getenv("BUILD_NUMBER")
group= "com.stevenrs11.dimdoors" // http://maven.apache.org/guides/mini/guide-naming-conventions.html
archivesBaseName = "DimensionalDoors"
minecraft {
version = "1.6.4-9.11.1.964"
}
targetCompatibility = '1.6'
sourceCompatibility = '1.6'
processResources
{
// replace stuff in mcmod.info, nothing else
from(sourceSets.main.resources.srcDirs) {
include 'mcmod.info'
// replace version and mcversion
expand 'version':project.version, 'mcversion':project.minecraft.version
}
// copy everything else, thats not the mcmod.info
from(sourceSets.main.resources.srcDirs) {
exclude 'mcmod.info'
}
}
jar
{
destinationDir = new File("build/dist/")
}

View File

@@ -1,62 +1,93 @@
<project name="DimensionalDoors" default="install" basedir=".">
<property environment="env" />
<property name="project.name" value="DimDoors" />
<property name="src.dir" value="StevenDimDoors" />
<property name="resources.dir" value="resources" />
<property name="schematics.dir" value="schematics" />
<property name="versionclass.dir" value="mod_pocketDim" />
<property name="versionclass.file" value="mod_pocketDim.java"/>
<property name="minecraft.version" value="1.6.4" />
<property name="forge.forgeversion" value="9.11.1" />
<property name="forge.buildnum" value="953" />
<property name="build.dir" value="build" />
<property name="classes.dir" value="${build.dir}/packaging" />
<property name="src.dir" value="src" />
<property name="forge.version" value="1.5.2-7.8.0.691" />
<property name="resourcePack.dir" value="${classes.dir}" />
<property name="schematicPack.dir" value="${classes.dir}/schematics/" />
<property name="apiclasses.dir" value="${build.dir}/api-packaging" />
<property name="forge.version" value="${minecraft.version}-${forge.forgeversion}.${forge.buildnum}" />
<property name="forge.url" value="http://files.minecraftforge.net/minecraftforge/minecraftforge-src-${forge.version}.zip" />
<property name="mcp.version" value="751" />
<property name="forge.dir" value="${build.dir}/forge" />
<property name="mcp.dir" value="${forge.dir}/mcp" />
<property name="mcpsrc.dir" value="${mcp.dir}/src/minecraft" />
<property name="resources.dir" value="resources" />
<property name="mcpsrc.dir" value="${mcp.dir}/src/minecraft/StevenDimDoors" />
<property name="package.meta-inf" value="META-INF" />
<property name="build.ver" value="1.5.2" />
<property name="dist.dir" value="${build.dir}/dist" />
<property name="download.dir" value="downloads" />
<property name="download.dir" value="${build.dir}/downloads" />
<property name="lib.dir" value="${mcp.dir}/lib" />
<property file="${forge.dir}/forgeversion.properties" />
<condition property="forge.already.installed">
<equals arg1="${forge.build.number}" arg2="691" />
<equals arg1="${forge.build.number}" arg2="${forge.buildnum}" />
</condition>
<property name="verclass.dir" value="${mcpsrc.dir}/StevenDimDoors/mod_pocketDim/" />
<property name="verclass.name" value="mod_pocketDim.java"/>
<mkdir dir="${download.dir}"/>
<mkdir dir="${build.dir}" />
<target name="get-version" depends="setup-forge">
<mkdir dir="${mcpsrc.dir}/StevenDimDoors" />
<copy todir="${mcpsrc.dir}/StevenDimDoors" overwrite="true">
<fileset dir="StevenDimDoors" />
<!-- Copy source -->
<copy todir="${mcpsrc.dir}" overwrite="true">
<fileset dir="${src.dir}"/>
</copy>
<!-- Get the version from the mcmod.info -->
<script language="javascript">
importClass(java.io.File);
importClass(java.nio.file.Files)
importClass(java.io.FileReader);
importClass(java.io.BufferedReader);
importClass(java.io.FileWriter);
importClass(java.io.BufferedWriter);
echo = project.createTask("echo");
echo.setMessage("Parsing mcmod.info...");
echo.perform();
<exec dir="${verclass.dir}" executable="sh" osfamily="unix" outputproperty="grep.out">
<arg value="-c"/>
<arg value="grep -o -P '[0-9.]+R[0-9.]+(RC[0-9]+)?(B[0-9]+)?' ${verclass.name}"/>
</exec>
<exec executable="python" osfamily="unix">
<arg value="versionscript.py" />
<arg value="${grep.out}" />
</exec>
<echo message="Grepped version: ${grep.out}"/>
<copy todir="${classes.dir}" file="mcmod.info" overwrite="true"/>
var file = new File("./mcmod.info");
fr = new FileReader(file);
br = new BufferedReader(fr);
// Read the file.
// This assumes the file has no line
var line;
var json = "";
while ((line = br.readLine()) != null) {
json += line;
}
var struct = JSON.parse(json);
var version = struct["modlist"][0].version;
echo = project.createTask("echo");
echo.setMessage("Parsed version: " + version);
echo.perform();
project.setProperty("mod.version", version);
</script>
<!-- Replace the version information in the mod class -->
<replace file="${mcpsrc.dir}/${versionclass.dir}/${versionclass.file}">
<replacefilter token="$VERSION$" value="${mod.version}"/>
</replace>
</target>
<available property="forge-exists" file="${download.dir}/minecraftforge-src-${forge.version}.zip" />
<available property="already-compiled" file="${classes.dir}/deathrat" />
<available property="already-compiled" file="${classes.dir}/${src.dir}" />
<condition property="should-download-ant-contrib">
<or>
<available file="${download.dir}/ant-contrib/ant-contrib-1.0b3.jar"/>
@@ -65,14 +96,13 @@
</condition>
<target name="install" depends="build">
<copy todir="${classes.dir}/schematics" overwrite="true">
<fileset dir="schematics" />
</copy>
<zip destfile="${dist.dir}/DimensionalDoors-${grep.out}-${build.number}.zip" basedir="${classes.dir}"/>
<delete dir="${mcpsrc.dir}/${src.dir}" />
<delete dir="${dist.dir}" />
<jar destfile="${dist.dir}/${project.name}-${mod.version}-${build.number}.jar" basedir="${classes.dir}"/>
<delete dir="${classes.dir}" />
<delete dir="${mcp.dir}/reobf"/>
<delete dir="${mcpsrc}/StevenDimDoors" />
<delete dir="${mcpsrc}/Steven" />
<delete dir="{$apiclasses.dir}" />
<delete dir="${mcpsrc.dir}/${src.dir}" />
</target>
<target name="build" depends="get-version" unless="already-compiled">
@@ -87,19 +117,36 @@
<!-- Reobf -->
<exec dir="${mcp.dir}" executable="cmd" osfamily="windows">
<arg line="/c reobfuscate_srg.bat"/>
<arg line="/c reobfuscate.bat --srgnames"/>
</exec>
<exec dir="${mcp.dir}" executable="sh" osfamily="unix">
<arg value="reobfuscate_srg.sh" />
<arg value="reobfuscate.sh" />
</exec>
<copy todir="${classes.dir}">
<fileset dir="${mcp.dir}/reobf/minecraft"/>
</copy>
<copy todir="${classes.dir}">
<fileset dir="${resources.dir}"/>
<copy todir="${resourcePack.dir}">
<fileset dir="${resources.dir}" />
</copy>
<copy todir="${schematicPack.dir}">
<fileset dir="${schematics.dir}" />
</copy>
<copy todir="${classes.dir}">
<fileset file="mcmod.info" />
</copy>
<copy todir="${classes.dir}">
<fileset file="${resources.dir}/pack.mcmeta" />
</copy>
<delete file="${resourcePack.dir}/mcmod.info" />
<delete file="${resourcePack.dir}/pack.mcmeta" />
</target>
<target name="build-number-there" if="env.BUILD_NUMBER" >
@@ -109,7 +156,7 @@
<target name="build-number-not-there" unless="env.BUILD_NUMBER" >
<echo message="!! No build number set !!" />
<property name="build.number" value="CUSTOM_BUILD" />
<property name="build.number" value="0" />
</target>
<target name="setup-forge" depends="download-forge,build-number-there,build-number-not-there" unless="forge.already.installed">
@@ -121,15 +168,9 @@
</fileset>
</unzip>
<!-- Change executables' permitions -->
<chmod file="${forge.dir}/install.sh" perm="+x"/>
<!-- if your building on OSX these 2 should be executable -->
<!-- Install forge -->
<delete dir="${mcp.dir}" failonerror="no"/>
<exec dir="${forge.dir}" executable="cmd" osfamily="windows" inputstring="Yes\n">
@@ -138,38 +179,29 @@
<exec dir="${forge.dir}" executable="sh" osfamily="unix" inputstring="Yes\n">
<arg value="install.sh" />
</exec>
<chmod file="${mcp.dir}/updatemd5.sh" perm="+x"/>
<chmod file="${mcp.dir}/recompile.sh" perm="+x"/>
<chmod file="${mcp.dir}/reobfuscate_srg.sh" perm="+x"/>
<chmod file="${mcp.dir}/reobfuscate.sh" perm="+x"/>
<chmod file="${mcp.dir}/runtime/bin/astyle-osx" perm="+x" />
<chmod file="${mcp.dir}/runtime/bin/jad-osx" perm="+x" />
<!-- Copy libraries -->
<!-- <copy todir="${mcp.dir}/lib" >
<fileset dir="lib" >
<patternset includes="*.jar" />
</fileset>
</copy> -->
</target>
<target name="download-forge" depends="download-ant-contrib" unless="forge-exists">
<taskdef resource="net/sf/antcontrib/antlib.xml">
<classpath>
<pathelement location="${download.dir}/ant-contrib/ant-contrib-1.0b3.jar"/>
<fileset dir="${download.dir}/ant-contrib/lib">
<include name="*.jar"/>
</fileset>
</classpath>
</taskdef>
<echo message="Downloading forge... " />
<get src="${forge.url}" dest="${download.dir}/minecraftforge-src-${forge.version}.zip" />
<target name="download-forge" depends="download-ant-contrib" unless="forge-exists">
<taskdef resource="net/sf/antcontrib/antlib.xml">
<classpath>
<pathelement location="${download.dir}/ant-contrib/ant-contrib-1.0b3.jar"/>
<fileset dir="${download.dir}/ant-contrib/lib">
<include name="*.jar"/>
</fileset>
</classpath>
</taskdef>
<echo message="Downloading forge... " />
<get src="http://files.minecraftforge.net/minecraftforge-src-${forge.version}.zip"
dest="${download.dir}/minecraftforge-src-${forge.version}.zip" />
</target>
<target name="download-ant-contrib" unless="should-download-ant-contrib">
<echo message="Getting: ant-contrib"/>
<mkdir dir="${download.dir}/tmp"/>
@@ -196,4 +228,3 @@
</project>

BIN
gradle/wrapper/gradle-wrapper.jar vendored Normal file

Binary file not shown.

View File

@@ -0,0 +1,6 @@
#Tue Oct 29 18:00:54 CDT 2013
distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists
zipStoreBase=GRADLE_USER_HOME
zipStorePath=wrapper/dists
distributionUrl=http\://services.gradle.org/distributions/gradle-1.8-bin.zip

164
gradlew vendored Executable file
View File

@@ -0,0 +1,164 @@
#!/usr/bin/env bash
##############################################################################
##
## Gradle start up script for UN*X
##
##############################################################################
# Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script.
DEFAULT_JVM_OPTS=""
APP_NAME="Gradle"
APP_BASE_NAME=`basename "$0"`
# Use the maximum available, or set MAX_FD != -1 to use that value.
MAX_FD="maximum"
warn ( ) {
echo "$*"
}
die ( ) {
echo
echo "$*"
echo
exit 1
}
# OS specific support (must be 'true' or 'false').
cygwin=false
msys=false
darwin=false
case "`uname`" in
CYGWIN* )
cygwin=true
;;
Darwin* )
darwin=true
;;
MINGW* )
msys=true
;;
esac
# For Cygwin, ensure paths are in UNIX format before anything is touched.
if $cygwin ; then
[ -n "$JAVA_HOME" ] && JAVA_HOME=`cygpath --unix "$JAVA_HOME"`
fi
# Attempt to set APP_HOME
# Resolve links: $0 may be a link
PRG="$0"
# Need this for relative symlinks.
while [ -h "$PRG" ] ; do
ls=`ls -ld "$PRG"`
link=`expr "$ls" : '.*-> \(.*\)$'`
if expr "$link" : '/.*' > /dev/null; then
PRG="$link"
else
PRG=`dirname "$PRG"`"/$link"
fi
done
SAVED="`pwd`"
cd "`dirname \"$PRG\"`/" >&-
APP_HOME="`pwd -P`"
cd "$SAVED" >&-
CLASSPATH=$APP_HOME/gradle/wrapper/gradle-wrapper.jar
# Determine the Java command to use to start the JVM.
if [ -n "$JAVA_HOME" ] ; then
if [ -x "$JAVA_HOME/jre/sh/java" ] ; then
# IBM's JDK on AIX uses strange locations for the executables
JAVACMD="$JAVA_HOME/jre/sh/java"
else
JAVACMD="$JAVA_HOME/bin/java"
fi
if [ ! -x "$JAVACMD" ] ; then
die "ERROR: JAVA_HOME is set to an invalid directory: $JAVA_HOME
Please set the JAVA_HOME variable in your environment to match the
location of your Java installation."
fi
else
JAVACMD="java"
which java >/dev/null 2>&1 || die "ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH.
Please set the JAVA_HOME variable in your environment to match the
location of your Java installation."
fi
# Increase the maximum file descriptors if we can.
if [ "$cygwin" = "false" -a "$darwin" = "false" ] ; then
MAX_FD_LIMIT=`ulimit -H -n`
if [ $? -eq 0 ] ; then
if [ "$MAX_FD" = "maximum" -o "$MAX_FD" = "max" ] ; then
MAX_FD="$MAX_FD_LIMIT"
fi
ulimit -n $MAX_FD
if [ $? -ne 0 ] ; then
warn "Could not set maximum file descriptor limit: $MAX_FD"
fi
else
warn "Could not query maximum file descriptor limit: $MAX_FD_LIMIT"
fi
fi
# For Darwin, add options to specify how the application appears in the dock
if $darwin; then
GRADLE_OPTS="$GRADLE_OPTS \"-Xdock:name=$APP_NAME\" \"-Xdock:icon=$APP_HOME/media/gradle.icns\""
fi
# For Cygwin, switch paths to Windows format before running java
if $cygwin ; then
APP_HOME=`cygpath --path --mixed "$APP_HOME"`
CLASSPATH=`cygpath --path --mixed "$CLASSPATH"`
# We build the pattern for arguments to be converted via cygpath
ROOTDIRSRAW=`find -L / -maxdepth 1 -mindepth 1 -type d 2>/dev/null`
SEP=""
for dir in $ROOTDIRSRAW ; do
ROOTDIRS="$ROOTDIRS$SEP$dir"
SEP="|"
done
OURCYGPATTERN="(^($ROOTDIRS))"
# Add a user-defined pattern to the cygpath arguments
if [ "$GRADLE_CYGPATTERN" != "" ] ; then
OURCYGPATTERN="$OURCYGPATTERN|($GRADLE_CYGPATTERN)"
fi
# Now convert the arguments - kludge to limit ourselves to /bin/sh
i=0
for arg in "$@" ; do
CHECK=`echo "$arg"|egrep -c "$OURCYGPATTERN" -`
CHECK2=`echo "$arg"|egrep -c "^-"` ### Determine if an option
if [ $CHECK -ne 0 ] && [ $CHECK2 -eq 0 ] ; then ### Added a condition
eval `echo args$i`=`cygpath --path --ignore --mixed "$arg"`
else
eval `echo args$i`="\"$arg\""
fi
i=$((i+1))
done
case $i in
(0) set -- ;;
(1) set -- "$args0" ;;
(2) set -- "$args0" "$args1" ;;
(3) set -- "$args0" "$args1" "$args2" ;;
(4) set -- "$args0" "$args1" "$args2" "$args3" ;;
(5) set -- "$args0" "$args1" "$args2" "$args3" "$args4" ;;
(6) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" ;;
(7) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" ;;
(8) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" ;;
(9) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" "$args8" ;;
esac
fi
# Split up the JVM_OPTS And GRADLE_OPTS values into an array, following the shell quoting and substitution rules
function splitJvmOpts() {
JVM_OPTS=("$@")
}
eval splitJvmOpts $DEFAULT_JVM_OPTS $JAVA_OPTS $GRADLE_OPTS
JVM_OPTS[${#JVM_OPTS[*]}]="-Dorg.gradle.appname=$APP_BASE_NAME"
exec "$JAVACMD" "${JVM_OPTS[@]}" -classpath "$CLASSPATH" org.gradle.wrapper.GradleWrapperMain "$@"

90
gradlew.bat vendored Normal file
View File

@@ -0,0 +1,90 @@
@if "%DEBUG%" == "" @echo off
@rem ##########################################################################
@rem
@rem Gradle startup script for Windows
@rem
@rem ##########################################################################
@rem Set local scope for the variables with windows NT shell
if "%OS%"=="Windows_NT" setlocal
@rem Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script.
set DEFAULT_JVM_OPTS=
set DIRNAME=%~dp0
if "%DIRNAME%" == "" set DIRNAME=.
set APP_BASE_NAME=%~n0
set APP_HOME=%DIRNAME%
@rem Find java.exe
if defined JAVA_HOME goto findJavaFromJavaHome
set JAVA_EXE=java.exe
%JAVA_EXE% -version >NUL 2>&1
if "%ERRORLEVEL%" == "0" goto init
echo.
echo ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH.
echo.
echo Please set the JAVA_HOME variable in your environment to match the
echo location of your Java installation.
goto fail
:findJavaFromJavaHome
set JAVA_HOME=%JAVA_HOME:"=%
set JAVA_EXE=%JAVA_HOME%/bin/java.exe
if exist "%JAVA_EXE%" goto init
echo.
echo ERROR: JAVA_HOME is set to an invalid directory: %JAVA_HOME%
echo.
echo Please set the JAVA_HOME variable in your environment to match the
echo location of your Java installation.
goto fail
:init
@rem Get command-line arguments, handling Windowz variants
if not "%OS%" == "Windows_NT" goto win9xME_args
if "%@eval[2+2]" == "4" goto 4NT_args
:win9xME_args
@rem Slurp the command line arguments.
set CMD_LINE_ARGS=
set _SKIP=2
:win9xME_args_slurp
if "x%~1" == "x" goto execute
set CMD_LINE_ARGS=%*
goto execute
:4NT_args
@rem Get arguments from the 4NT Shell from JP Software
set CMD_LINE_ARGS=%$
:execute
@rem Setup the command line
set CLASSPATH=%APP_HOME%\gradle\wrapper\gradle-wrapper.jar
@rem Execute Gradle
"%JAVA_EXE%" %DEFAULT_JVM_OPTS% %JAVA_OPTS% %GRADLE_OPTS% "-Dorg.gradle.appname=%APP_BASE_NAME%" -classpath "%CLASSPATH%" org.gradle.wrapper.GradleWrapperMain %CMD_LINE_ARGS%
:end
@rem End local scope for the variables with windows NT shell
if "%ERRORLEVEL%"=="0" goto mainEnd
:fail
rem Set variable GRADLE_EXIT_CONSOLE if you need the _script_ return code instead of
rem the _cmd.exe /c_ return code!
if not "" == "%GRADLE_EXIT_CONSOLE%" exit 1
exit /b 1
:mainEnd
if "%OS%"=="Windows_NT" endlocal
:omega

Binary file not shown.

Before

Width:  |  Height:  |  Size: 1.0 KiB

View File

@@ -1 +0,0 @@
0*7,1*7,2*7,3*7,4*7,5*7,6*7,5*7,4*7,3*7,2*7,1*7

View File

@@ -0,0 +1,225 @@
package StevenDimDoors.experimental;
/**
* Provides a complete implementation of a directed graph.
* @author SenseiKiwi
*
* @param <U> The type of data to store in the graph's nodes
* @param <V> The type of data to store in the graph's edges
*/
public class DirectedGraph<U, V>
{
private static class GraphNode<P, Q> implements IGraphNode<P, Q>
{
private LinkedList<Edge<P, Q>> inbound;
private LinkedList<Edge<P, Q>> outbound;
private ILinkedListNode<GraphNode<P, Q>> graphEntry;
private P data;
public GraphNode(P data, LinkedList<GraphNode<P, Q>> graphList)
{
this.data = data;
this.inbound = new LinkedList<Edge<P, Q>>();
this.outbound = new LinkedList<Edge<P, Q>>();
this.graphEntry = graphList.addLast(this);
}
public int indegree()
{
return inbound.size();
}
public int outdegree()
{
return outbound.size();
}
public Iterable<Edge<P, Q>> inbound()
{
return inbound;
}
public Iterable<Edge<P, Q>> outbound()
{
return outbound;
}
public P data()
{
return data;
}
public void remove()
{
graphEntry.remove();
graphEntry = null;
for (Edge<P, Q> edge : inbound)
edge.remove();
for (Edge<P, Q> edge : outbound)
edge.remove();
inbound = null;
outbound = null;
data = null;
}
}
private static class Edge<P, Q> implements IEdge<P, Q>
{
private GraphNode<P, Q> head;
private GraphNode<P, Q> tail;
private ILinkedListNode<Edge<P, Q>> headEntry;
private ILinkedListNode<Edge<P, Q>> tailEntry;
private ILinkedListNode<Edge<P, Q>> graphEntry;
private Q data;
public Edge(GraphNode<P, Q> head, GraphNode<P, Q> tail, Q data, LinkedList<Edge<P, Q>> graphList)
{
this.head = head;
this.tail = tail;
this.data = data;
this.graphEntry = graphList.addLast(this);
this.headEntry = head.outbound.addLast(this);
this.tailEntry = tail.inbound.addLast(this);
}
public IGraphNode<P, Q> head()
{
return head;
}
public IGraphNode<P, Q> tail()
{
return tail;
}
public Q data()
{
return data;
}
public void remove()
{
headEntry.remove();
tailEntry.remove();
graphEntry.remove();
headEntry = null;
tailEntry = null;
graphEntry = null;
head = null;
tail = null;
data = null;
}
}
private LinkedList<GraphNode<U, V>> nodes;
private LinkedList<Edge<U, V>> edges;
public DirectedGraph()
{
nodes = new LinkedList<GraphNode<U, V>>();
edges = new LinkedList<Edge<U, V>>();
}
public int nodeCount()
{
return nodes.size();
}
public int edgeCount()
{
return edges.size();
}
public boolean isEmpty()
{
return nodes.isEmpty();
}
public Iterable<? extends IGraphNode<U, V>> nodes()
{
return nodes;
}
public Iterable<? extends IEdge<U, V>> edges()
{
return edges;
}
private GraphNode<U, V> checkNode(IGraphNode<U, V> node)
{
GraphNode<U, V> innerNode = (GraphNode<U, V>) node;
// Check that this node actually belongs to this graph instance.
// Accepting foreign nodes could corrupt the graph's internal state.
if (innerNode.graphEntry.owner() != nodes)
{
throw new IllegalArgumentException("The specified node does not belong to this graph.");
}
return innerNode;
}
private Edge<U, V> checkEdge(IEdge<U, V> edge)
{
Edge<U, V> innerEdge = (Edge<U, V>) edge;
// Check that this node actually belongs to this graph instance.
// Accepting foreign nodes could corrupt the graph's internal state.
if (innerEdge.graphEntry.owner() != edges)
{
throw new IllegalArgumentException("The specified edge does not belong to this graph.");
}
return innerEdge;
}
public IGraphNode<U, V> addNode(U data)
{
return new GraphNode<U, V>(data, nodes);
}
public IEdge<U, V> addEdge(IGraphNode<U, V> head, IGraphNode<U, V> tail, V data)
{
GraphNode<U, V> innerHead = checkNode(head);
GraphNode<U, V> innerTail = checkNode(tail);
return new Edge<U, V>(innerHead, innerTail, data, edges);
}
public U removeNode(IGraphNode<U, V> node)
{
GraphNode<U, V> innerNode = checkNode(node);
U data = innerNode.data();
innerNode.remove();
return data;
}
public V removeEdge(IEdge<U, V> edge)
{
Edge<U, V> innerEdge = checkEdge(edge);
V data = innerEdge.data();
innerEdge.remove();
return data;
}
public IEdge<U, V> findEdge(IGraphNode<U, V> head, IGraphNode<U, V> tail)
{
for (IEdge<U, V> edge : head.outbound())
{
if (edge.tail() == tail)
return edge;
}
return null;
}
public void clear()
{
// Remove each node individually to guarantee that all external
// references are invalidated. That'll prevent memory leaks and
// keep external code from using removed nodes or edges.
for (GraphNode<U, V> node : nodes)
{
node.remove();
}
}
}

View File

@@ -0,0 +1,36 @@
package StevenDimDoors.experimental;
import StevenDimDoors.mod_pocketDim.Point3D;
public class DoorwayData
{
public static final char X_AXIS = 'X';
public static final char Y_AXIS = 'Y';
public static final char Z_AXIS = 'Z';
private Point3D minCorner;
private Point3D maxCorner;
private char axis;
public DoorwayData(Point3D minCorner, Point3D maxCorner, char axis)
{
this.minCorner = minCorner;
this.maxCorner = maxCorner;
this.axis = axis;
}
public Point3D minCorner()
{
return minCorner;
}
public Point3D maxCorner()
{
return maxCorner;
}
public char axis()
{
return axis;
}
}

View File

@@ -0,0 +1,8 @@
package StevenDimDoors.experimental;
public interface IEdge<U, V>
{
public IGraphNode<U, V> head();
public IGraphNode<U, V> tail();
public V data();
}

View File

@@ -0,0 +1,10 @@
package StevenDimDoors.experimental;
public interface IGraphNode<U, V>
{
public Iterable<? extends IEdge<U, V>> inbound();
public Iterable<? extends IEdge<U, V>> outbound();
public int indegree();
public int outdegree();
public U data();
}

View File

@@ -0,0 +1,11 @@
package StevenDimDoors.experimental;
public interface ILinkedListNode<T>
{
public ILinkedListNode<T> next();
public ILinkedListNode<T> prev();
public T data();
public void setData(T data);
public LinkedList<T> owner();
public T remove();
}

View File

@@ -0,0 +1,236 @@
package StevenDimDoors.experimental;
import java.util.Iterator;
import java.util.NoSuchElementException;
/**
* Provides an implementation of a linked list that exposes its internal nodes.
* This differs from Java's implementation, which does not expose nodes. Access
* to the nodes allows certain operations to be implemented more efficiently.
* Not all operations are supported, but we can add them as the need arises.
* @author SenseiKiwi
*
* @param <T> The type of data to be stored in the LinkedList
*/
public class LinkedList<T> implements Iterable<T>
{
private static class Node<P> implements ILinkedListNode<P>
{
private Node<P> next;
private Node<P> prev;
private P data;
private LinkedList<P> owner;
public Node(Node<P> prev, Node<P> next, P data, LinkedList<P> owner)
{
this.prev = prev;
this.next = next;
this.data = data;
this.owner = owner;
}
@Override
public ILinkedListNode<P> next()
{
return next;
}
@Override
public ILinkedListNode<P> prev()
{
return prev;
}
@Override
public P data()
{
return data;
}
@Override
public void setData(P data)
{
if (this == owner.header || this == owner.trailer)
{
throw new IllegalStateException("Cannot set data for the header and trailer nodes of a list.");
}
this.data = data;
}
@Override
public LinkedList<P> owner()
{
return owner;
}
@Override
public P remove()
{
if (this == owner.header || this == owner.trailer)
{
throw new IllegalStateException("Cannot remove the header and trailer nodes of a list.");
}
P data = this.data;
this.prev.next = this.next;
this.next.prev = this.prev;
this.owner.size--;
this.clear();
return data;
}
public void clear()
{
this.data = null;
this.prev = null;
this.next = null;
this.owner = null;
}
}
private static class LinkedListIterator<P> implements Iterator<P>
{
private Node<P> current;
private Node<P> trailer;
public LinkedListIterator(LinkedList<P> list)
{
current = list.header.next;
trailer = list.trailer;
}
@Override
public boolean hasNext()
{
return (current != trailer);
}
@Override
public P next()
{
if (current == trailer)
{
throw new NoSuchElementException();
}
else
{
P result = current.data;
current = current.next;
return result;
}
}
@Override
public void remove()
{
throw new UnsupportedOperationException();
}
}
private Node<T> header; // Sentinel node
private Node<T> trailer; // Sentinel node
private int size;
public LinkedList()
{
size = 0;
header = new Node<T>(null, null, null, this);
trailer = new Node<T>(null, null, null, this);
header.next = trailer;
trailer.prev = header;
}
public ILinkedListNode<T> header()
{
return header;
}
public ILinkedListNode<T> trailer()
{
return trailer;
}
public int size()
{
return size;
}
public boolean isEmpty()
{
return (size == 0);
}
public void clear()
{
// Go through the list and wipe everything out
Node<T> current;
Node<T> next;
size = 0;
current = header.next;
while (current != trailer)
{
next = current.next;
current.clear();
current = next;
}
header.next = trailer;
trailer.prev = header;
}
private Node<T> checkNode(ILinkedListNode<T> node)
{
Node<T> innerNode = (Node<T>) node;
// Check that this node actually belongs to this list instance.
// Accepting foreign nodes could corrupt the list's internal state.
if (innerNode.owner() != this)
{
throw new IllegalArgumentException("The specified node does not belong to this list.");
}
return innerNode;
}
public ILinkedListNode<T> addFirst(T data)
{
return addAfter(header, data);
}
public ILinkedListNode<T> addLast(T data)
{
return addBefore(trailer, data);
}
public ILinkedListNode<T> addBefore(ILinkedListNode<T> node, T data)
{
if (node == header)
{
throw new IllegalArgumentException("Cannot add a node before the header node.");
}
return addAfter( checkNode(node).prev, data );
}
public ILinkedListNode<T> addAfter(ILinkedListNode<T> node, T data)
{
if (node == trailer)
{
throw new IllegalArgumentException("Cannot add a node after the trailer node.");
}
return addAfter( checkNode(node), data );
}
private Node<T> addAfter(Node<T> node, T data)
{
Node<T> addition = new Node(node, node.next, data, this);
node.next = addition;
addition.next.prev = addition;
return addition;
}
public Iterator<T> iterator()
{
return new LinkedListIterator<T>(this);
}
}

View File

@@ -0,0 +1,561 @@
package StevenDimDoors.experimental;
import java.util.ArrayList;
import java.util.Collections;
import java.util.HashMap;
import java.util.LinkedList;
import java.util.Queue;
import java.util.Random;
import net.minecraft.block.Block;
import net.minecraft.util.MathHelper;
import net.minecraft.world.World;
import net.minecraft.world.chunk.Chunk;
import net.minecraft.world.chunk.storage.ExtendedBlockStorage;
import StevenDimDoors.mod_pocketDim.Point3D;
public class MazeGenerator
{
public static final int ROOT_WIDTH = 40;
public static final int ROOT_LENGTH = 40;
public static final int ROOT_HEIGHT = 20;
private static final int MIN_HEIGHT = 4;
private static final int MIN_SIDE = 3;
private static final int SPLIT_COUNT = 9;
private MazeGenerator() { }
public static void generate(World world, int x, int y, int z, Random random)
{
// Construct a random binary space partitioning of our maze volume
PartitionNode root = partitionRooms(ROOT_WIDTH, ROOT_HEIGHT, ROOT_LENGTH, SPLIT_COUNT, random);
// List all the leaf nodes of the partition tree, which denote individual rooms
ArrayList<PartitionNode> partitions = new ArrayList<PartitionNode>(1 << SPLIT_COUNT);
listRoomPartitions(root, partitions);
// Construct an adjacency graph of the rooms we've carved out. Two rooms are
// considered adjacent if and only if a doorway could connect them. Their
// common boundary must be large enough for a doorway.
DirectedGraph<PartitionNode, DoorwayData> rooms = createRoomGraph(root, partitions, random);
// Cut out random subgraphs from the adjacency graph
ArrayList<IGraphNode<PartitionNode, DoorwayData>> cores = createMazeSections(rooms, random);
buildRooms(rooms, world, new Point3D(x - ROOT_WIDTH / 2, y - ROOT_HEIGHT - 1, z - ROOT_WIDTH / 2));
}
private static void listRoomPartitions(PartitionNode node, ArrayList<PartitionNode> partitions)
{
if (node.isLeaf())
{
partitions.add(node);
}
else
{
listRoomPartitions(node.leftChild(), partitions);
listRoomPartitions(node.rightChild(), partitions);
}
}
private static void removeRandomRooms(ArrayList<PartitionNode> rooms, Random random)
{
// Randomly remove a fraction of the rooms
Collections.shuffle(rooms, random);
int remaining = rooms.size() / 2;
for (int k = rooms.size() - 1; k >= remaining; k--)
{
removeRoom(rooms.remove(k));
}
}
private static void removeRoom(PartitionNode node)
{
// Remove a node and any of its ancestors that become leaf nodes
PartitionNode parent;
PartitionNode current;
current = node;
while (current != null && current.isLeaf())
{
parent = current.parent();
current.remove();
current = parent;
}
}
private static PartitionNode partitionRooms(int width, int height, int length, int maxLevels, Random random)
{
PartitionNode root = new PartitionNode(width, height, length);
splitByRandomX(root, maxLevels, random);
return root;
}
private static void splitByRandomX(PartitionNode node, int levels, Random random)
{
if (node.width() >= 2 * MIN_SIDE)
{
node.splitByX(MathHelper.getRandomIntegerInRange(random,
node.minCorner().getX() + MIN_SIDE, node.maxCorner().getX() - MIN_SIDE + 1));
if (levels > 1)
{
splitByRandomZ(node.leftChild(), levels - 1, random);
splitByRandomZ(node.rightChild(), levels - 1, random);
}
}
else if (levels > 1)
{
splitByRandomZ(node, levels - 1, random);
}
}
private static void splitByRandomZ(PartitionNode node, int levels, Random random)
{
if (node.length() >= 2 * MIN_SIDE)
{
node.splitByZ(MathHelper.getRandomIntegerInRange(random,
node.minCorner().getZ() + MIN_SIDE, node.maxCorner().getZ() - MIN_SIDE + 1));
if (levels > 1)
{
splitByRandomY(node.leftChild(), levels - 1, random);
splitByRandomY(node.rightChild(), levels - 1, random);
}
}
else if (levels > 1)
{
splitByRandomY(node, levels - 1, random);
}
}
private static void splitByRandomY(PartitionNode node, int levels, Random random)
{
if (node.height() >= 2 * MIN_HEIGHT)
{
node.splitByY(MathHelper.getRandomIntegerInRange(random,
node.minCorner().getY() + MIN_HEIGHT, node.maxCorner().getY() - MIN_HEIGHT + 1));
if (levels > 1)
{
splitByRandomX(node.leftChild(), levels - 1, random);
splitByRandomX(node.rightChild(), levels - 1, random);
}
}
else if (levels > 1)
{
splitByRandomX(node, levels - 1, random);
}
}
private static DirectedGraph<PartitionNode, DoorwayData> createRoomGraph(PartitionNode root, ArrayList<PartitionNode> partitions, Random random)
{
DirectedGraph<PartitionNode, DoorwayData> roomGraph = new DirectedGraph<PartitionNode, DoorwayData>();
HashMap<PartitionNode, IGraphNode<PartitionNode, DoorwayData>> roomsToGraph = new HashMap<PartitionNode, IGraphNode<PartitionNode, DoorwayData>>(2 * partitions.size());
// Shuffle the list of rooms so that they're not listed in any ordered way in the room graph
// This is the only convenient way of randomizing the maze sections generated later
Collections.shuffle(partitions, random);
// Add all rooms to a graph
// Also add them to a map so we can associate rooms with their graph nodes
// The map is needed for linking graph nodes based on adjacent partitions
for (PartitionNode partition : partitions)
{
roomsToGraph.put(partition, roomGraph.addNode(partition));
}
// Add edges for each room
for (IGraphNode<PartitionNode, DoorwayData> node : roomGraph.nodes())
{
findDoorways(node, root, roomsToGraph, roomGraph);
}
return roomGraph;
}
private static void findDoorways(IGraphNode<PartitionNode, DoorwayData> roomNode, PartitionNode root,
HashMap<PartitionNode, IGraphNode<PartitionNode, DoorwayData>> roomsToGraph,
DirectedGraph<PartitionNode, DoorwayData> roomGraph)
{
// This function finds rooms adjacent to a specified room that could be connected
// to it through a doorway. Edges are added to the room graph to denote rooms that
// could be connected. The areas of their common bounds that could be carved
// out for a passage are stored in the edges.
// Three directions have to be checked: up, forward, and right. The other three
// directions (down, back, left) aren't checked because other nodes will cover them.
// That is, down for this room is up for some other room, if it exists. Also, rooms
// are guaranteed to have at least one doorway to another room, because the minimum
// dimensions to which a room can be partitioned still allow passages along all
// its sides. A room's sibling in the partition tree is guaranteed to share a side
// through which a doorway could exist. Similar arguments guarantee the existence
// of passages such that the whole set of rooms is a connected graph - in other words,
// there will always be a way to walk from any room to any other room.
boolean[][] detected;
PartitionNode adjacent;
int a, b, c;
int p, q, r;
int minXI, minYI, minZI;
int maxXI, maxYI, maxZI;
Point3D otherMin;
Point3D otherMax;
DoorwayData doorway;
IGraphNode<PartitionNode, DoorwayData> adjacentNode;
PartitionNode room = roomNode.data();
Point3D minCorner = room.minCorner();
Point3D maxCorner = room.maxCorner();
int minX = minCorner.getX();
int minY = minCorner.getY();
int minZ = minCorner.getZ();
int maxX = maxCorner.getX();
int maxY = maxCorner.getY();
int maxZ = maxCorner.getZ();
int width = room.width();
int height = room.height();
int length = room.length();
if (maxZ < root.maxCorner().getZ())
{
// Check for adjacent rooms along the XY plane
detected = new boolean[width][height];
for (a = 0; a < width; a++)
{
for (b = 0; b < height; b++)
{
if (!detected[a][b])
{
adjacent = root.findPoint(minX + a, minY + b, maxZ + 1);
if (adjacent != null)
{
// Compute the dimensions available for a doorway
otherMin = adjacent.minCorner();
otherMax = adjacent.maxCorner();
minXI = Math.max(minX, otherMin.getX());
maxXI = Math.min(maxX, otherMax.getX());
minYI = Math.max(minY, otherMin.getY());
maxYI = Math.min(maxY, otherMax.getY());
for (p = a; p <= maxXI - minXI; p++)
{
for (q = b; q <= maxYI - minYI; q++)
{
detected[p][q] = true;
}
}
// Check if we meet the minimum dimensions needed for a doorway
if (maxXI - minXI + 1 >= MIN_SIDE && maxYI - minYI + 1 >= MIN_HEIGHT)
{
otherMin = new Point3D(minXI, minYI, maxZ);
otherMax = new Point3D(maxXI, maxYI, maxZ + 1);
doorway = new DoorwayData(otherMin, otherMax, DoorwayData.Z_AXIS);
adjacentNode = roomsToGraph.get(adjacent);
roomGraph.addEdge(roomNode, adjacentNode, doorway);
}
}
else
{
detected[a][b] = true;
}
}
}
}
}
if (maxX < root.maxCorner().getX())
{
// Check for adjacent rooms along the YZ plane
detected = new boolean[height][length];
for (b = 0; b < height; b++)
{
for (c = 0; c < length; c++)
{
if (!detected[b][c])
{
adjacent = root.findPoint(maxX + 1, minY + b, minZ + c);
if (adjacent != null)
{
// Compute the dimensions available for a doorway
otherMin = adjacent.minCorner();
otherMax = adjacent.maxCorner();
minYI = Math.max(minY, otherMin.getY());
maxYI = Math.min(maxY, otherMax.getY());
minZI = Math.max(minZ, otherMin.getZ());
maxZI = Math.min(maxZ, otherMax.getZ());
for (q = b; q <= maxYI - minYI; q++)
{
for (r = c; r <= maxZI - minZI; r++)
{
detected[q][r] = true;
}
}
// Check if we meet the minimum dimensions needed for a doorway
if (maxYI - minYI + 1 >= MIN_HEIGHT && maxZI - minZI + 1 >= MIN_SIDE)
{
otherMin = new Point3D(maxX, minYI, minZI);
otherMax = new Point3D(maxX + 1, maxYI, maxZI);
doorway = new DoorwayData(otherMin, otherMax, DoorwayData.X_AXIS);
adjacentNode = roomsToGraph.get(adjacent);
roomGraph.addEdge(roomNode, adjacentNode, doorway);
}
}
else
{
detected[b][c] = true;
}
}
}
}
}
if (maxY < root.maxCorner().getY())
{
// Check for adjacent rooms along the XZ plane
detected = new boolean[width][length];
for (a = 0; a < width; a++)
{
for (c = 0; c < length; c++)
{
if (!detected[a][c])
{
adjacent = root.findPoint(minX + a, maxY + 1, minZ + c);
if (adjacent != null)
{
// Compute the dimensions available for a doorway
otherMin = adjacent.minCorner();
otherMax = adjacent.maxCorner();
minXI = Math.max(minX, otherMin.getX());
maxXI = Math.min(maxX, otherMax.getX());
minZI = Math.max(minZ, otherMin.getZ());
maxZI = Math.min(maxZ, otherMax.getZ());
for (p = a; p <= maxXI - minXI; p++)
{
for (r = c; r <= maxZI - minZI; r++)
{
detected[p][r] = true;
}
}
// Check if we meet the minimum dimensions needed for a doorway
if (maxXI - minXI + 1 >= MIN_SIDE && maxZI - minZI + 1 >= MIN_SIDE)
{
otherMin = new Point3D(minXI, maxY, minZI);
otherMax = new Point3D(maxXI, maxY + 1, maxZI);
doorway = new DoorwayData(otherMin, otherMax, DoorwayData.Y_AXIS);
adjacentNode = roomsToGraph.get(adjacent);
roomGraph.addEdge(roomNode, adjacentNode, doorway);
}
}
else
{
detected[a][c] = true;
}
}
}
}
}
//Done!
}
private static ArrayList<IGraphNode<PartitionNode, DoorwayData>> createMazeSections(DirectedGraph<PartitionNode, DoorwayData> roomGraph, Random random)
{
// The randomness of the sections generated here hinges on
// the nodes in the graph being in a random order. We assume
// that was handled in a previous step!
final int MAX_DISTANCE = 2;
int distance;
IGraphNode<PartitionNode, DoorwayData> current;
IGraphNode<PartitionNode, DoorwayData> neighbor;
ArrayList<IGraphNode<PartitionNode, DoorwayData>> cores = new ArrayList<IGraphNode<PartitionNode, DoorwayData>>();
Queue<IGraphNode<PartitionNode, DoorwayData>> ordering = new LinkedList<IGraphNode<PartitionNode, DoorwayData>>();
HashMap<IGraphNode<PartitionNode, DoorwayData>, Integer> distances = new HashMap<IGraphNode<PartitionNode, DoorwayData>, Integer>();
// Repeatedly generate sections until all nodes have been visited
for (IGraphNode<PartitionNode, DoorwayData> node : roomGraph.nodes())
{
// If this node has an indegree and outdegree of 0, then it has no neighbors,
// which means it could not have been visited. This could happen if its neighbors
// were pruned away before. Single rooms look weird, so remove it.
if (node.indegree() == 0 && node.outdegree() == 0)
{
roomGraph.removeNode(node);
}
// If this node hasn't been visited, then use it as the core of a new section
// Otherwise, ignore it, since it already belongs to a section
else if (!distances.containsKey(node))
{
cores.add(node);
// Perform a breadth-first search to tag surrounding nodes with distances
distances.put(node, 0);
ordering.add(node);
while (!ordering.isEmpty())
{
current = ordering.remove();
distance = distances.get(current) + 1;
if (distance <= MAX_DISTANCE + 1)
{
// Visit neighboring nodes and assign them distances, if they don't
// have a distance assigned already
for (IEdge<PartitionNode, DoorwayData> edge : current.inbound())
{
neighbor = edge.head();
if (!distances.containsKey(neighbor))
{
distances.put(neighbor, distance);
ordering.add(neighbor);
}
}
for (IEdge<PartitionNode, DoorwayData> edge : current.outbound())
{
neighbor = edge.tail();
if (!distances.containsKey(neighbor))
{
distances.put(neighbor, distance);
ordering.add(neighbor);
}
}
}
else
{
roomGraph.removeNode(current);
break;
}
}
// Remove all nodes that have a distance of exactly MAX_DISTANCE + 1
// Those are precisely the nodes that remain in the queue
while (!ordering.isEmpty())
{
roomGraph.removeNode( ordering.remove() );
}
}
}
return cores;
}
private static void buildRooms(DirectedGraph<PartitionNode, DoorwayData> roomGraph, World world, Point3D offset)
{
for (IGraphNode<PartitionNode, DoorwayData> node : roomGraph.nodes())
{
PartitionNode room = node.data();
buildBox(world, offset, room.minCorner(), room.maxCorner(), Block.stoneBrick.blockID, 0);
}
// TESTING!!!
// This code carves out cheap doorways
// The final system will be better
// This has to happen after all the rooms have been built or the passages will be overwritten sometimes
for (IGraphNode<PartitionNode, DoorwayData> node : roomGraph.nodes())
{
for (IEdge<PartitionNode, DoorwayData> doorway : node.outbound())
{
char axis = doorway.data().axis();
Point3D lower = doorway.data().minCorner();
if (axis == DoorwayData.Z_AXIS)
{
setBlockDirectly(world, offset.getX() + lower.getX() + 1, offset.getY() + lower.getY() + 1, offset.getZ() + lower.getZ(), 0, 0);
setBlockDirectly(world, offset.getX() + lower.getX() + 1, offset.getY() + lower.getY() + 2, offset.getZ() + lower.getZ(), 0, 0);
setBlockDirectly(world, offset.getX() + lower.getX() + 1, offset.getY() + lower.getY() + 1, offset.getZ() + lower.getZ() + 1, 0, 0);
setBlockDirectly(world, offset.getX() + lower.getX() + 1, offset.getY() + lower.getY() + 2, offset.getZ() + lower.getZ() + 1, 0, 0);
}
else if (axis == DoorwayData.X_AXIS)
{
setBlockDirectly(world, offset.getX() + lower.getX(), offset.getY() + lower.getY() + 1, offset.getZ() + lower.getZ() + 1, 0, 0);
setBlockDirectly(world, offset.getX() + lower.getX(), offset.getY() + lower.getY() + 2, offset.getZ() + lower.getZ() + 1, 0, 0);
setBlockDirectly(world, offset.getX() + lower.getX() + 1, offset.getY() + lower.getY() + 1, offset.getZ() + lower.getZ() + 1, 0, 0);
setBlockDirectly(world, offset.getX() + lower.getX() + 1, offset.getY() + lower.getY() + 2, offset.getZ() + lower.getZ() + 1, 0, 0);
}
else
{
setBlockDirectly(world, offset.getX() + lower.getX() + 1, offset.getY() + lower.getY(), offset.getZ() + lower.getZ() + 1, 0, 0);
setBlockDirectly(world, offset.getX() + lower.getX() + 1, offset.getY() + lower.getY(), offset.getZ() + lower.getZ() + 1, 0, 0);
setBlockDirectly(world, offset.getX() + lower.getX() + 1, offset.getY() + lower.getY() + 1, offset.getZ() + lower.getZ() + 1, 0, 0);
setBlockDirectly(world, offset.getX() + lower.getX() + 1, offset.getY() + lower.getY() + 1, offset.getZ() + lower.getZ() + 1, 0, 0);
}
}
}
}
private static void buildBox(World world, Point3D offset, Point3D minCorner, Point3D maxCorner, int blockID, int metadata)
{
int minX = minCorner.getX() + offset.getX();
int minY = minCorner.getY() + offset.getY();
int minZ = minCorner.getZ() + offset.getZ();
int maxX = maxCorner.getX() + offset.getX();
int maxY = maxCorner.getY() + offset.getY();
int maxZ = maxCorner.getZ() + offset.getZ();
int x, y, z;
for (x = minX; x <= maxX; x++)
{
for (z = minZ; z <= maxZ; z++)
{
setBlockDirectly(world, x, minY, z, blockID, metadata);
setBlockDirectly(world, x, maxY, z, blockID, metadata);
}
}
for (x = minX; x <= maxX; x++)
{
for (y = minY; y <= maxY; y++)
{
setBlockDirectly(world, x, y, minZ, blockID, metadata);
setBlockDirectly(world, x, y, maxZ, blockID, metadata);
}
}
for (z = minZ; z <= maxZ; z++)
{
for (y = minY; y <= maxY; y++)
{
setBlockDirectly(world, minX, y, z, blockID, metadata);
setBlockDirectly(world, maxX, y, z, blockID, metadata);
}
}
}
private static void setBlockDirectly(World world, int x, int y, int z, int blockID, int metadata)
{
if (blockID != 0 && Block.blocksList[blockID] == null)
{
return;
}
int cX = x >> 4;
int cZ = z >> 4;
int cY = y >> 4;
Chunk chunk;
int localX = (x % 16) < 0 ? (x % 16) + 16 : (x % 16);
int localZ = (z % 16) < 0 ? (z % 16) + 16 : (z % 16);
ExtendedBlockStorage extBlockStorage;
chunk = world.getChunkFromChunkCoords(cX, cZ);
extBlockStorage = chunk.getBlockStorageArray()[cY];
if (extBlockStorage == null)
{
extBlockStorage = new ExtendedBlockStorage(cY << 4, !world.provider.hasNoSky);
chunk.getBlockStorageArray()[cY] = extBlockStorage;
}
extBlockStorage.setExtBlockID(localX, y & 15, localZ, blockID);
extBlockStorage.setExtBlockMetadata(localX, y & 15, localZ, metadata);
}
}

View File

@@ -0,0 +1,161 @@
package StevenDimDoors.experimental;
import StevenDimDoors.mod_pocketDim.Point3D;
public class PartitionNode
{
private Point3D minCorner;
private Point3D maxCorner;
private PartitionNode parent;
private PartitionNode leftChild = null;
private PartitionNode rightChild = null;
public PartitionNode(int width, int height, int length)
{
parent = null;
minCorner = new Point3D(0, 0, 0);
maxCorner = new Point3D(width - 1, height - 1, length - 1);
}
private PartitionNode(PartitionNode parent, Point3D minCorner, Point3D maxCorner)
{
this.parent = parent;
this.minCorner = minCorner;
this.maxCorner = maxCorner;
}
public int width()
{
return (maxCorner.getX() - minCorner.getX() + 1);
}
public int height()
{
return (maxCorner.getY() - minCorner.getY() + 1);
}
public int length()
{
return (maxCorner.getZ() - minCorner.getZ() + 1);
}
public boolean isLeaf()
{
return (leftChild == null && rightChild == null);
}
public PartitionNode leftChild()
{
return leftChild;
}
public PartitionNode rightChild()
{
return rightChild;
}
public Point3D minCorner()
{
return minCorner;
}
public Point3D maxCorner()
{
return maxCorner;
}
public PartitionNode parent()
{
return parent;
}
public void splitByX(int rightStart)
{
if (!this.isLeaf())
{
throw new IllegalStateException("This node has already been split.");
}
if (rightStart <= minCorner.getX() || rightStart > maxCorner.getX())
{
throw new IllegalArgumentException("The specified cutting plane is invalid.");
}
leftChild = new PartitionNode(this, minCorner, new Point3D(rightStart - 1, maxCorner.getY(), maxCorner.getZ()));
rightChild = new PartitionNode(this, new Point3D(rightStart, minCorner.getY(), minCorner.getZ()), maxCorner);
}
public void splitByY(int rightStart)
{
if (!this.isLeaf())
{
throw new IllegalStateException("This node has already been split.");
}
if (rightStart <= minCorner.getY() || rightStart > maxCorner.getY())
{
throw new IllegalArgumentException("The specified cutting plane is invalid.");
}
leftChild = new PartitionNode(this, minCorner, new Point3D(maxCorner.getX(), rightStart - 1, maxCorner.getZ()));
rightChild = new PartitionNode(this, new Point3D(minCorner.getX(), rightStart, minCorner.getZ()), maxCorner);
}
public void splitByZ(int rightStart)
{
if (!this.isLeaf())
{
throw new IllegalStateException("This node has already been split.");
}
if (rightStart <= minCorner.getZ() || rightStart > maxCorner.getZ())
{
throw new IllegalArgumentException("The specified cutting plane is invalid.");
}
leftChild = new PartitionNode(this, minCorner, new Point3D(maxCorner.getX(), maxCorner.getY(), rightStart - 1));
rightChild = new PartitionNode(this, new Point3D(minCorner.getX(), minCorner.getY(), rightStart), maxCorner);
}
public void remove()
{
if (parent != null)
{
if (parent.leftChild == this)
parent.leftChild = null;
else
parent.rightChild = null;
parent = null;
}
}
public boolean contains(int x, int y, int z)
{
return ((minCorner.getX() <= x && x <= maxCorner.getX()) &&
(minCorner.getY() <= y && y <= maxCorner.getY()) &&
(minCorner.getZ() <= z && z <= maxCorner.getZ()));
}
public PartitionNode findPoint(int x, int y, int z)
{
// Find the lowest node that contains the specified point or return null
if (this.contains(x, y, z))
{
return this.findPointInternal(x, y, z);
}
else
{
return null;
}
}
private PartitionNode findPointInternal(int x, int y, int z)
{
if (leftChild != null && leftChild.contains(x, y, z))
{
return leftChild.findPointInternal(x, y, z);
}
else if (rightChild != null && rightChild.contains(x, y, z))
{
return rightChild.findPointInternal(x, y, z);
}
else
{
return this;
}
}
}

View File

@@ -29,7 +29,7 @@ public class BlankTeleporter extends Teleporter
public void setEntityPosition(Entity entity, double x, double y, double z)
{
entity.lastTickPosX = entity.prevPosX = entity.posX = x;
entity.lastTickPosY = entity.prevPosY = entity.posY = y + (double)entity.yOffset;
entity.lastTickPosY = entity.prevPosY = entity.posY = y + entity.yOffset;
entity.lastTickPosZ = entity.prevPosZ = entity.posZ = z;
entity.setPosition(x, y, z);
}

View File

@@ -8,7 +8,8 @@ import cpw.mods.fml.relauncher.SideOnly;
public class CloudRenderBlank extends IRenderHandler
{
@SideOnly(Side.CLIENT)
@Override
@SideOnly(Side.CLIENT)
public void render(float partialTicks, WorldClient world, Minecraft mc)
{

View File

@@ -4,12 +4,18 @@ import java.io.ByteArrayOutputStream;
import java.io.DataOutputStream;
import java.io.IOException;
import net.minecraft.entity.player.EntityPlayerMP;
import net.minecraft.network.INetworkManager;
import net.minecraft.network.NetLoginHandler;
import net.minecraft.network.packet.NetHandler;
import net.minecraft.network.packet.Packet1Login;
import net.minecraft.network.packet.Packet250CustomPayload;
import net.minecraft.server.MinecraftServer;
import net.minecraft.server.integrated.IntegratedServer;
import net.minecraftforge.common.DimensionManager;
import net.minecraftforge.common.network.ForgePacket;
import net.minecraftforge.common.network.packet.DimensionRegisterPacket;
import StevenDimDoors.mod_pocketDim.core.NewDimData;
import StevenDimDoors.mod_pocketDim.core.PocketManager;
import cpw.mods.fml.common.network.IConnectionHandler;
import cpw.mods.fml.common.network.Player;
@@ -19,7 +25,22 @@ public class ConnectionHandler implements IConnectionHandler
@Override
public String connectionReceived(NetLoginHandler netHandler, INetworkManager manager)
{
for(NewDimData data : PocketManager.getDimensions())
{
try
{
Packet250CustomPayload[] pkt = ForgePacket.makePacketSet(new DimensionRegisterPacket(data.id(), DimensionManager.getProviderType(data.id())));
manager.addToSendQueue(pkt[0]);
}
catch(Exception E)
{
}
}
return null;
}
@Override
@@ -29,7 +50,13 @@ public class ConnectionHandler implements IConnectionHandler
public void connectionOpened(NetHandler netClientHandler,MinecraftServer server, INetworkManager manager) { }
@Override
public void connectionClosed(INetworkManager manager) { }
public void connectionClosed(INetworkManager manager)
{
if(PocketManager.isConnected)
{
PocketManager.unload();
}
}
@Override
public void clientLoggedIn(NetHandler clientHandler, INetworkManager manager, Packet1Login login) { }
@@ -38,23 +65,6 @@ public class ConnectionHandler implements IConnectionHandler
public void playerLoggedIn(Player player, NetHandler netHandler, INetworkManager manager)
{
//Send information about all the registered dimensions and links to the client
try
{
Packet250CustomPayload packet = new Packet250CustomPayload();
ByteArrayOutputStream buffer = new ByteArrayOutputStream();
DataOutputStream writer = new DataOutputStream(buffer);
writer.writeByte(PacketConstants.CLIENT_JOIN_PACKET_ID);
PocketManager.writePacket(writer);
writer.close();
packet.channel = PacketConstants.CHANNEL_NAME;
packet.data = buffer.toByteArray();
packet.length = packet.data.length;
manager.addToSendQueue(packet);
}
catch (IOException e)
{
//This shouldn't happen...
e.printStackTrace();
}
}
}

View File

@@ -0,0 +1,135 @@
package StevenDimDoors.mod_pocketDim;
import net.minecraft.block.Block;
import net.minecraft.item.Item;
import net.minecraft.item.ItemStack;
import cpw.mods.fml.common.registry.GameRegistry;
import static StevenDimDoors.mod_pocketDim.mod_pocketDim.*;
public class CraftingManager
{
public static void registerRecipies()
{
Item coreCraftingItem = Item.enderPearl;
if(properties.enableServerMode)
{
coreCraftingItem = itemWorldThread;
}
if (properties.CraftingDimensionalDoorAllowed)
{
GameRegistry.addRecipe(new ItemStack(itemDimDoor, 1), new Object[]
{
" ", "yxy", " ", 'x', coreCraftingItem, 'y', Item.doorIron
});
GameRegistry.addRecipe(new ItemStack(itemDimDoor, 1), new Object[]
{
" ", "yxy", " ", 'x', mod_pocketDim.itemStableFabric, 'y', Item.doorIron
});
}
if(properties.CraftingUnstableDoorAllowed)
{
GameRegistry.addRecipe(new ItemStack(itemChaosDoor, 1), new Object[]
{
" ", "yxy", " ", 'x', Item.eyeOfEnder, 'y', mod_pocketDim.itemDimDoor
});
}
if(properties.CraftingWarpDoorAllowed)
{
GameRegistry.addRecipe(new ItemStack(itemExitDoor, 1), new Object[]
{
" ", "yxy", " ", 'x', coreCraftingItem, 'y', Item.doorWood
});
GameRegistry.addRecipe(new ItemStack(itemExitDoor, 1), new Object[]
{
" ", "yxy", " ", 'x', mod_pocketDim.itemStableFabric, 'y', Item.doorWood
});
}
if(properties.CraftingTransTrapdoorAllowed)
{
GameRegistry.addRecipe(new ItemStack(transTrapdoor, 1), new Object[]
{
" y ", " x ", " y ", 'x', coreCraftingItem, 'y', Block.trapdoor
});
GameRegistry.addRecipe(new ItemStack(transTrapdoor, 1), new Object[]
{
" y ", " x ", " y ", 'x', mod_pocketDim.itemStableFabric, 'y', Block.trapdoor
});
}
if(properties.CraftingRiftSignatureAllowed)
{
GameRegistry.addRecipe(new ItemStack(itemLinkSignature, 1), new Object[]
{
" y ", "yxy", " y ", 'x', coreCraftingItem, 'y', Item.ingotIron
});
GameRegistry.addRecipe(new ItemStack(itemLinkSignature, 1), new Object[]
{
" y ", "yxy", " y ", 'x', mod_pocketDim.itemStableFabric, 'y', Item.ingotIron
});
}
if(properties.CraftingRiftRemoverAllowed)
{
GameRegistry.addRecipe(new ItemStack(itemRiftRemover, 1), new Object[]
{
" y ", "yxy", " y ", 'x', coreCraftingItem, 'y', Item.ingotGold
});
GameRegistry.addRecipe(new ItemStack(itemRiftRemover, 1), new Object[]
{
"yyy", "yxy", "yyy", 'x', mod_pocketDim.itemStableFabric, 'y', Item.ingotGold
});
}
if (properties.CraftingRiftBladeAllowed)
{
GameRegistry.addRecipe(new ItemStack(itemRiftBlade, 1), new Object[]
{
" x ", " x ", " y ", 'x', coreCraftingItem, 'y',mod_pocketDim.itemRiftRemover
});
}
if (properties.CraftingStableFabricAllowed)
{
GameRegistry.addRecipe(new ItemStack(itemStableFabric, 1), new Object[]
{
"yyy", "yxy", "yyy", 'x', coreCraftingItem, 'y', mod_pocketDim.itemWorldThread
});
}
if (properties.CraftingStabilizedRiftSignatureAllowed)
{
GameRegistry.addRecipe(new ItemStack(mod_pocketDim.itemStabilizedLinkSignature,1), new Object[]
{
" y ", "yxy", " y ", 'x', mod_pocketDim.itemLinkSignature, 'y', mod_pocketDim.itemStableFabric
});
}
if (properties.CraftingGoldDimDoorAllowed)
{
GameRegistry.addRecipe(new ItemStack(mod_pocketDim.itemGoldDimDoor,1), new Object[]
{
" x ", " y ", " x ", 'x', mod_pocketDim.itemGoldDoor, 'y', Item.eyeOfEnder
});
}
if (properties.CraftingGoldDoorAllowed)
{
GameRegistry.addRecipe(new ItemStack(mod_pocketDim.itemGoldDoor,1), new Object[]
{
"yy ", "yy ", "yy ", 'y', Item.ingotGold
});
GameRegistry.addRecipe(new ItemStack(mod_pocketDim.itemGoldDoor,1), new Object[]
{
" yy", " yy", " yy", 'y', Item.ingotGold
});
}
}
}

View File

@@ -0,0 +1,262 @@
package StevenDimDoors.mod_pocketDim;
import java.util.ArrayList;
import java.util.Random;
import net.minecraft.enchantment.Enchantment;
import net.minecraft.inventory.IInventory;
import net.minecraft.item.Item;
import net.minecraft.item.ItemStack;
import net.minecraft.util.MathHelper;
import net.minecraft.util.WeightedRandom;
import net.minecraft.util.WeightedRandomChestContent;
import net.minecraftforge.common.ChestGenHooks;
import StevenDimDoors.mod_pocketDim.util.WeightedContainer;
/*
* Registers a category of loot chests for Dimensional Doors in Forge.
*/
public class DDLoot {
private static final double MIN_ITEM_DAMAGE = 0.3;
private static final double MAX_ITEM_DAMAGE = 0.9;
private static final int ITEM_ENCHANTMENT_CHANCE = 50;
private static final int MAX_ITEM_ENCHANTMENT_CHANCE = 100;
public static final String DIMENSIONAL_DUNGEON_CHEST = "dimensionalDungeonChest";
public static ChestGenHooks DungeonChestInfo = null;
private static final int CHEST_SIZE = 5;
private DDLoot() { }
public static void registerInfo(DDProperties properties)
{
// Register the dimensional dungeon chest with ChestGenHooks. This isn't necessary, but allows
// other mods to add their own loot to our chests if they know our loot category, without having
// to interface with our code.
DungeonChestInfo = ChestGenHooks.getInfo(DIMENSIONAL_DUNGEON_CHEST);
DungeonChestInfo.setMin(CHEST_SIZE);
DungeonChestInfo.setMax(CHEST_SIZE);
ArrayList<WeightedRandomChestContent> items = new ArrayList<WeightedRandomChestContent>();
addContent(true, items, Item.ingotIron.itemID, 160, 1, 3);
addContent(true, items, Item.coal.itemID, 120, 1, 3);
addContent(true, items, Item.netherQuartz.itemID, 120, 1, 3);
addContent(true, items, Item.enchantedBook.itemID, 100);
addContent(true, items, Item.ingotGold.itemID, 80, 1, 3);
addContent(true, items, Item.diamond.itemID, 40, 1, 2);
addContent(true, items, Item.emerald.itemID, 20, 1, 2);
addContent(true, items, Item.appleGold.itemID, 10);
addContent(properties.FabricOfRealityLootEnabled, items, mod_pocketDim.blockDimWall.blockID, 80, 4, 16);
addContent(properties.StableFabricLootEnabled, items, mod_pocketDim.itemStableFabric.itemID, 40);
// Add all the items to our dungeon chest
addItemsToContainer(DungeonChestInfo, items);
}
private static void addContent(boolean include, ArrayList<WeightedRandomChestContent> items,
int itemID, int weight)
{
if (include)
items.add(new WeightedRandomChestContent(itemID, 0, 1, 1, weight));
}
private static void addContent(boolean include, ArrayList<WeightedRandomChestContent> items,
int itemID, int weight, int minAmount, int maxAmount)
{
if (include)
items.add(new WeightedRandomChestContent(itemID, 0, minAmount, maxAmount, weight));
}
private static void addItemsToContainer(ChestGenHooks container, ArrayList<WeightedRandomChestContent> items)
{
for (WeightedRandomChestContent item : items)
{
container.addItem(item);
}
}
private static void fillChest(ArrayList<ItemStack> stacks, IInventory inventory, Random random)
{
// This custom chest-filling function avoids overwriting item stacks
// The prime number below is used for choosing chest slots in a seemingly-random pattern. Its value
// was selected specifically to achieve a spread-out distribution for chests with up to 104 slots.
// Choosing a prime number ensures that our increments are relatively-prime to the chest size, which
// means we'll cover all the slots before repeating any. This is mathematically guaranteed.
final int primeOffset = 239333;
int size = inventory.getSizeInventory();
for (ItemStack item : stacks)
{
int limit = size;
int index = random.nextInt(size);
while (limit > 0 && inventory.getStackInSlot(index) != null)
{
limit--;
index = (index + primeOffset) % size;
}
inventory.setInventorySlotContents(index, item);
}
}
public static void generateChestContents(ChestGenHooks chestInfo, IInventory inventory, Random random)
{
// This is a custom version of net.minecraft.util.WeightedRandomChestContent.generateChestContents()
// It's designed to avoid the following bugs in MC 1.5:
// 1. If multiple enchanted books appear, then they will have the same enchantment
// 2. The randomized filling algorithm will sometimes overwrite item stacks with other stacks
int count = chestInfo.getCount(random);
WeightedRandomChestContent[] content = chestInfo.getItems(random);
ArrayList<ItemStack> allStacks = new ArrayList<ItemStack>();
for (int k = 0; k < count; k++)
{
WeightedRandomChestContent selection = (WeightedRandomChestContent)WeightedRandom.getRandomItem(random, content);
// Call getChestGenBase() to make sure we generate a different enchantment for books.
// Don't just use a condition to check if the item is an instance of ItemEnchantedBook because
// we don't know if other mods might add items that also need to be regenerated.
selection = selection.theItemId.getItem().getChestGenBase(chestInfo, random, selection);
ItemStack[] stacks = ChestGenHooks.generateStacks(random, selection.theItemId, selection.theMinimumChanceToGenerateItem, selection.theMaximumChanceToGenerateItem);
for (int h = 0; h < stacks.length; h++)
{
allStacks.add(stacks[h]);
}
}
fillChest(allStacks, inventory, random);
}
public static void fillGraveChest(IInventory inventory, Random random, DDProperties properties)
{
// This function fills "grave chests", which are chests for dungeons that
// look like a player died in the area and his remains were gathered in
// a chest. Doing this properly requires fine control of loot generation,
// so we use our own function rather than Minecraft's functions.
int k;
int count;
ArrayList<ItemStack> stacks = new ArrayList<ItemStack>();
ArrayList<WeightedContainer<Item>> selection = new ArrayList<WeightedContainer<Item>>();
// Insert bones and rotten flesh
// Make stacks of single items to spread them out
count = MathHelper.getRandomIntegerInRange(random, 2, 5);
for (k = 0; k < count; k++)
{
stacks.add( new ItemStack(Item.bone, 1) );
}
count = MathHelper.getRandomIntegerInRange(random, 2, 4);
for (k = 0; k < count; k++)
{
stacks.add( new ItemStack(Item.rottenFlesh, 1) );
}
// Insert tools
// 30% chance of adding a pickaxe
if (random.nextInt(100) < 30)
{
addModifiedTool(Item.pickaxeIron, stacks, random);
}
// 30% chance of adding a bow and some arrows
if (random.nextInt(100) < 30)
{
addModifiedBow(stacks, random);
stacks.add( new ItemStack(Item.arrow, MathHelper.getRandomIntegerInRange(random, 8, 32)) );
}
// 10% chance of adding a Rift Blade (no enchants)
if (properties.RiftBladeLootEnabled && random.nextInt(100) < 10)
{
stacks.add( new ItemStack(mod_pocketDim.itemRiftBlade, 1) );
}
else
{
// 20% of adding an iron sword, 10% of adding a stone sword
addModifiedSword( getRandomItem(Item.swordIron, Item.swordStone, null, 20, 10, random) , stacks, random);
}
// Insert equipment
// For each piece, 25% of an iron piece, 10% of a chainmail piece
addModifiedEquipment( getRandomItem(Item.helmetIron, Item.helmetChain, null, 25, 10, random) , stacks, random);
addModifiedEquipment( getRandomItem(Item.plateIron, Item.plateChain, null, 25, 10, random) , stacks, random);
addModifiedEquipment( getRandomItem(Item.legsIron, Item.legsChain, null, 25, 10, random) , stacks, random);
addModifiedEquipment( getRandomItem(Item.bootsIron, Item.bootsChain, null, 25, 10, random) , stacks, random);
// Insert other random stuff
// 40% chance for a name tag, 35% chance for a glass bottle, and 5% chance for record 11
addItemWithChance(stacks, random, 40, Item.nameTag, 1);
addItemWithChance(stacks, random, 35, Item.glassBottle, 1);
addItemWithChance(stacks, random, 5, Item.record11, 1);
fillChest(stacks, inventory, random);
}
private static void addModifiedEquipment(Item item, ArrayList<ItemStack> stacks, Random random)
{
if (item == null)
return;
stacks.add( getModifiedItem(item, random, new Enchantment[] { Enchantment.blastProtection, Enchantment.fireProtection, Enchantment.protection, Enchantment.projectileProtection }) );
}
private static void addModifiedSword(Item item, ArrayList<ItemStack> stacks, Random random)
{
if (item == null)
return;
stacks.add( getModifiedItem(item, random, new Enchantment[] { Enchantment.fireAspect, Enchantment.knockback, Enchantment.sharpness }) );
}
private static void addModifiedTool(Item tool, ArrayList<ItemStack> stacks, Random random)
{
if (tool == null)
return;
stacks.add( getModifiedItem(tool, random, new Enchantment[] { Enchantment.efficiency, Enchantment.unbreaking }) );
}
private static void addModifiedBow(ArrayList<ItemStack> stacks, Random random)
{
stacks.add( getModifiedItem(Item.bow, random, new Enchantment[] { Enchantment.flame, Enchantment.power, Enchantment.punch }) );
}
private static ItemStack getModifiedItem(Item item, Random random, Enchantment[] enchantments)
{
ItemStack result = applyRandomDamage(item, random);
if (enchantments.length > 0 && random.nextInt(MAX_ITEM_ENCHANTMENT_CHANCE) < ITEM_ENCHANTMENT_CHANCE)
{
result.addEnchantment(enchantments[ random.nextInt(enchantments.length) ], 1);
}
return result;
}
private static Item getRandomItem(Item a, Item b, Item c, int weightA, int weightB, Random random)
{
int roll = random.nextInt(100);
if (roll < weightA)
return a;
if (roll < weightA + weightB)
return b;
return c;
}
private static void addItemWithChance(ArrayList<ItemStack> stacks, Random random, int chance, Item item, int count)
{
if (random.nextInt(100) < chance)
{
stacks.add(new ItemStack(item, count));
}
}
private static ItemStack applyRandomDamage(Item item, Random random)
{
int damage = (int) (item.getMaxDamage() * MathHelper.getRandomDoubleInRange(random, MIN_ITEM_DAMAGE, MAX_ITEM_DAMAGE));
return new ItemStack(item, 1, damage);
}
}

View File

@@ -43,6 +43,8 @@ public class DDProperties
public final int DimensionalDoorItemID;
public final int UnstableDoorItemID;
public final int WarpDoorItemID;
public final int ItemWorldThreadID;
/**
* Other IDs
@@ -91,6 +93,7 @@ public class DDProperties
* Other Flags
*/
public final boolean enableServerMode;
public final boolean WorldRiftGenerationEnabled;
public final boolean RiftSpreadEnabled;
public final boolean RiftGriefingEnabled;
@@ -101,6 +104,7 @@ public class DDProperties
public final boolean DoorRenderingEnabled;
public final boolean TNFREAKINGT_Enabled;
/**
* Other
*/
@@ -112,11 +116,13 @@ public class DDProperties
public final int LimboReturnRange;
public final String CustomSchematicDirectory;
//Singleton instance
private static DDProperties instance = null;
//Path for custom dungeons within configuration directory
private final String CUSTOM_SCHEMATIC_SUBDIRECTORY = "/DimDoors_Custom_schematics";
//Names of categories
private final String CATEGORY_SERVERMODE = "server mode";
private final String CATEGORY_CRAFTING = "crafting";
private final String CATEGORY_ENTITY = "entity";
private final String CATEGORY_DIMENSION = "dimension";
@@ -178,6 +184,11 @@ public class DDProperties
"Weighs the chance that a block will not be TNT. Must be greater than or equal to 0. " +
"EXPLOSIONS must be set to true for this to have any effect.").getInt();
enableServerMode = config.get(CATEGORY_SERVERMODE, "Server Mode", false,
"Enables servermode, changing all crafting recipies to require stabilized fabric. " +
"Stabilized fabric, in turn, requires the item World Thread, which is not craftable or obtainable at all. "+
"It is up to the server manager on how to distribute it.").getBoolean(false);
DoorRenderEntityID=config.get(CATEGORY_ENTITY, "Door Render Entity ID", 89).getInt();
MonolithEntityID = config.get(CATEGORY_ENTITY, "Monolith Entity ID", 125).getInt();
@@ -201,6 +212,7 @@ public class DDProperties
StabilizedRiftSignatureItemID = config.getItem("Stabilized Rift Signature Item ID", 5677).getInt();
GoldDoorItemID = config.getItem("Gold Door Item ID", 5678).getInt();
GoldDimDoorItemID = config.getItem("Gold Dim Door Item ID", 5679).getInt();
ItemWorldThreadID = config.getItem("World Thread Item ID", 5680).getInt();
LimboBlockID = config.getTerrainBlock("World Generation Block IDs - must be less than 256", "Limbo Block ID", 217,
"Blocks used for the terrain in Limbo").getInt();
@@ -218,13 +230,13 @@ public class DDProperties
"Sets the chance (out of " + MonolithSpawner.MAX_MONOLITH_SPAWNING_CHANCE + ") that Monoliths will " +
"spawn in a given Limbo chunk. The default chance is 28.").getInt();
ClusterGenerationChance = config.get(Configuration.CATEGORY_GENERAL, "Cluster Generation Chance", 3,
ClusterGenerationChance = config.get(Configuration.CATEGORY_GENERAL, "Cluster Generation Chance", 2,
"Sets the chance (out of " + GatewayGenerator.MAX_CLUSTER_GENERATION_CHANCE + ") that a cluster of rifts will " +
"generate in a given chunk. The default chance is 3.").getInt();
"generate in a given chunk. The default chance is 2.").getInt();
GatewayGenerationChance = config.get(Configuration.CATEGORY_GENERAL, "Gateway Generation Chance", 10,
GatewayGenerationChance = config.get(Configuration.CATEGORY_GENERAL, "Gateway Generation Chance", 15,
"Sets the chance (out of " + GatewayGenerator.MAX_GATEWAY_GENERATION_CHANCE + ") that a Rift Gateway will " +
"generate in a given chunk. The default chance is 10.").getInt();
"generate in a given chunk. The default chance is 15.").getInt();
LimboBiomeID = config.get(CATEGORY_BIOME, "Limbo Biome ID", 251).getInt();
PocketBiomeID = config.get(CATEGORY_BIOME, "Pocket Biome ID", 250).getInt();

View File

@@ -10,7 +10,7 @@ import java.util.Iterator;
import net.minecraft.util.MathHelper;
import net.minecraft.world.World;
@Deprecated
public class DimData implements Serializable
{
public int dimID;

View File

@@ -9,6 +9,7 @@ import StevenDimDoors.mod_pocketDim.dungeon.pack.DungeonPack;
import StevenDimDoors.mod_pocketDim.dungeon.pack.DungeonType;
import StevenDimDoors.mod_pocketDim.helpers.DungeonHelper;
@Deprecated
public class DungeonGenerator implements Serializable
{
//This static field is hax so that I don't have to add an instance field to DungeonGenerator to support DungeonType.

View File

@@ -1,6 +1,7 @@
package StevenDimDoors.mod_pocketDim;
import paulscode.sound.SoundSystem;
import net.minecraft.client.audio.SoundManager;
import net.minecraft.client.audio.SoundPool;
import net.minecraft.client.audio.SoundPoolEntry;
import net.minecraft.entity.Entity;
@@ -8,7 +9,6 @@ import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.util.ChunkCoordinates;
import net.minecraft.world.World;
import net.minecraftforge.client.event.sound.PlayBackgroundMusicEvent;
import net.minecraftforge.client.event.sound.PlaySoundEffectEvent;
import net.minecraftforge.client.event.sound.SoundLoadEvent;
import net.minecraftforge.event.EventPriority;
import net.minecraftforge.event.ForgeSubscribe;
@@ -38,15 +38,15 @@ public class EventHookContainer
@ForgeSubscribe
public void onSoundLoad(SoundLoadEvent event)
{
event.manager.soundPoolSounds.addSound("mods/DimDoors/sfx/monk.ogg", (mod_pocketDim.class.getResource("/mods/DimDoors/sfx/monk.ogg")));
event.manager.soundPoolSounds.addSound("mods/DimDoors/sfx/crack.ogg", (mod_pocketDim.class.getResource("/mods/DimDoors/sfx/crack.ogg")));
event.manager.soundPoolSounds.addSound("mods/DimDoors/sfx/tearing.ogg", (mod_pocketDim.class.getResource("/mods/DimDoors/sfx/tearing.ogg")));
event.manager.soundPoolSounds.addSound("mods/DimDoors/sfx/rift.ogg", (mod_pocketDim.class.getResource("/mods/DimDoors/sfx/rift.ogg")));
event.manager.soundPoolSounds.addSound("mods/DimDoors/sfx/riftStart.ogg", (mod_pocketDim.class.getResource("/mods/DimDoors/sfx/riftStart.ogg")));
event.manager.soundPoolSounds.addSound("mods/DimDoors/sfx/riftEnd.ogg", (mod_pocketDim.class.getResource("/mods/DimDoors/sfx/riftEnd.ogg")));
event.manager.soundPoolSounds.addSound("mods/DimDoors/sfx/riftClose.ogg", (mod_pocketDim.class.getResource("/mods/DimDoors/sfx/riftClose.ogg")));
event.manager.soundPoolSounds.addSound("mods/DimDoors/sfx/riftDoor.ogg", (mod_pocketDim.class.getResource("/mods/DimDoors/sfx/riftDoor.ogg")));
event.manager.soundPoolMusic.addSound("mods/DimDoors/sfx/creepy.ogg", (mod_pocketDim.class.getResource("/mods/DimDoors/sfx/creepy.ogg")));
event.manager.addSound(mod_pocketDim.modid+":monk.ogg");
event.manager.addSound(mod_pocketDim.modid+":crack.ogg");
event.manager.addSound(mod_pocketDim.modid+":tearing.ogg");
event.manager.addSound(mod_pocketDim.modid+":rift.ogg");
event.manager.addSound(mod_pocketDim.modid+":riftStart.ogg");
event.manager.addSound(mod_pocketDim.modid+":riftEnd.ogg");
event.manager.addSound(mod_pocketDim.modid+":riftClose.ogg");
event.manager.addSound(mod_pocketDim.modid+":riftDoor.ogg");
event.manager.addMusic(mod_pocketDim.modid+":creepy.ogg");
}
@SideOnly(Side.CLIENT)
@@ -95,10 +95,11 @@ public class EventHookContainer
{
player.inventory.clearInventory(-1, -1);
}
ChunkCoordinates coords = LimboProvider.getLimboSkySpawn(player.worldObj.rand);
Point4D destination = new Point4D((int) (coords.posX+entity.posX), coords.posY, (int) (coords.posZ+entity.posZ ), mod_pocketDim.properties.LimboDimensionID);
DDTeleporter.teleportEntity(player, destination, false);
player.setEntityHealth(player.getMaxHealth());
player.setHealth(player.getMaxHealth());
event.setCanceled(true);
return false;
}
@@ -116,17 +117,24 @@ public class EventHookContainer
public void playMusicForDim(World world)
{
if(world.isRemote&&world.provider instanceof LimboProvider)
if(world.isRemote)
{
SoundSystem sndSystem = FMLClientHandler.instance().getClient().sndManager.sndSystem;
sndSystem.stop("BgMusic");
SoundPoolEntry soundPoolEntry = FMLClientHandler.instance().getClient().sndManager.soundPoolMusic.getRandomSoundFromSoundPool("mods.DimDoors.sfx.creepy");
sndSystem.backgroundMusic("LimboMusic", soundPoolEntry.soundUrl, soundPoolEntry.soundName, false);
sndSystem.play("LimboMusic");
}
else if(world.isRemote && !(world.provider instanceof LimboProvider))
{
FMLClientHandler.instance().getClient().sndManager.sndSystem.stop("LimboMusic");
SoundManager sndManager = FMLClientHandler.instance().getClient().sndManager;
if(world.provider instanceof LimboProvider)
{
sndManager.sndSystem.stop("BgMusic");
SoundPoolEntry soundPoolEntry = sndManager.soundPoolMusic.getRandomSoundFromSoundPool(mod_pocketDim.modid+":creepy");
if(soundPoolEntry!=null)
{
sndManager.sndSystem.backgroundMusic("LimboMusic", soundPoolEntry.getSoundUrl(), soundPoolEntry.getSoundName(), false);
sndManager.sndSystem.play("LimboMusic");
}
}
else if(!(world.provider instanceof LimboProvider))
{
sndManager.sndSystem.stop("LimboMusic");
}
}
}
}

View File

@@ -1,7 +1,7 @@
package StevenDimDoors.mod_pocketDim;
import java.io.Serializable;
@Deprecated
public class LinkData implements Serializable
{

View File

@@ -1,4 +1,5 @@
package StevenDimDoors.mod_pocketDim;
import java.io.IOException;
import java.io.InputStream;
import java.io.InvalidClassException;
@@ -6,7 +7,7 @@ import java.io.ObjectInputStream;
import java.io.ObjectStreamClass;
import java.util.logging.Logger;
@SuppressWarnings("unused")
public class ObjectSaveInputStream extends ObjectInputStream {
// private static Logger logger = LoggerFactory.getLogger(ObjectSaveInputStream.class);
@@ -18,7 +19,7 @@ public class ObjectSaveInputStream extends ObjectInputStream {
@Override
protected ObjectStreamClass readClassDescriptor() throws IOException, ClassNotFoundException {
ObjectStreamClass resultClassDescriptor = super.readClassDescriptor(); // initially streams descriptor
Class localClass; // the class in the local JVM that this descriptor represents.
Class<?> localClass; // the class in the local JVM that this descriptor represents.
try {
localClass = Class.forName(resultClassDescriptor.getName());
} catch (ClassNotFoundException e) {
@@ -33,7 +34,7 @@ public class ObjectSaveInputStream extends ObjectInputStream {
final StringBuffer s = new StringBuffer("Overriding serialized class version mismatch: ");
s.append("local serialVersionUID = ").append(localSUID);
s.append(" stream serialVersionUID = ").append(streamSUID);
Exception e = new InvalidClassException(s.toString());
Exception e = new InvalidClassException(s.toString());
// logger.error("Potentially Fatal Deserialization Operation.", e);
resultClassDescriptor = localClassDescriptor; // Use local class descriptor for deserialization
}

View File

@@ -11,4 +11,6 @@ public class PacketConstants
public static final byte DELETE_DIM_PACKET_ID = 3;
public static final byte CREATE_LINK_PACKET_ID = 4;
public static final byte DELETE_LINK_PACKET_ID = 5;
public static final byte CLIENT_LOGIN_DIM_REGISTER = 6;
}

View File

@@ -0,0 +1,39 @@
package StevenDimDoors.mod_pocketDim;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.entity.player.EntityPlayerMP;
import net.minecraft.network.packet.Packet250CustomPayload;
import net.minecraftforge.common.DimensionManager;
import net.minecraftforge.common.network.ForgePacket;
import net.minecraftforge.common.network.packet.DimensionRegisterPacket;
import cpw.mods.fml.common.IPlayerTracker;
public class PlayerTracker implements IPlayerTracker
{
@Override
public void onPlayerLogin(EntityPlayer player)
{
}
@Override
public void onPlayerLogout(EntityPlayer player) {
// TODO Auto-generated method stub
}
@Override
public void onPlayerChangedDimension(EntityPlayer player) {
// TODO Auto-generated method stub
}
@Override
public void onPlayerRespawn(EntityPlayer player)
{
}
}

View File

@@ -56,14 +56,17 @@ public class Point3D implements Serializable {
return this.z = z;
}
@Override
public Point3D clone()
{
return new Point3D(x, y, z);
}
public int[] toIntArray()
{
return new int[]{x,y,z};
}
public boolean equals(Point3D other)
{
if (other == null)
@@ -75,6 +78,7 @@ public class Point3D implements Serializable {
return (this.x == other.x && this.y == other.y && this.z == other.z);
}
@Override
public boolean equals(Object other)
{
return equals((Point3D) other);

View File

@@ -4,6 +4,7 @@ import java.io.ByteArrayOutputStream;
import java.io.DataOutputStream;
import java.io.IOException;
import StevenDimDoors.mod_pocketDim.watcher.ClientLinkData;
import net.minecraft.network.INetworkManager;
import net.minecraft.network.packet.Packet250CustomPayload;
import StevenDimDoors.mod_pocketDim.core.PocketManager;
@@ -40,21 +41,47 @@ public class ServerPacketHandler implements IPacketHandler
}
}
private static class LinkWatcher implements IUpdateWatcher<Point4D>
private static class LinkWatcher implements IUpdateWatcher<ClientLinkData>
{
@Override
public void onCreated(Point4D message)
public void onCreated(ClientLinkData message)
{
sendLinkPacket(PacketConstants.CREATE_LINK_PACKET_ID, message);
}
@Override
public void onDeleted(Point4D message)
public void onDeleted(ClientLinkData message)
{
sendLinkPacket(PacketConstants.DELETE_LINK_PACKET_ID, message);
}
}
public static Packet250CustomPayload createLinkPacket(ClientLinkData data)
{
try
{
Packet250CustomPayload packet = new Packet250CustomPayload();
ByteArrayOutputStream buffer = new ByteArrayOutputStream();
DataOutputStream writer = new DataOutputStream(buffer);
writer.writeByte(PacketConstants.CREATE_LINK_PACKET_ID);
data.write(writer);
writer.close();
packet.channel = PacketConstants.CHANNEL_NAME;
packet.data = buffer.toByteArray();
packet.length = packet.data.length;
return packet;
}
catch (IOException e)
{
//This shouldn't happen...
e.printStackTrace();
return null;
}
}
private static void sendDimPacket(byte id, ClientDimData data)
{
try
@@ -77,7 +104,7 @@ public class ServerPacketHandler implements IPacketHandler
}
}
private static void sendLinkPacket(byte id, Point4D data)
private static void sendLinkPacket(byte id, ClientLinkData message)
{
try
{
@@ -85,7 +112,7 @@ public class ServerPacketHandler implements IPacketHandler
ByteArrayOutputStream buffer = new ByteArrayOutputStream();
DataOutputStream writer = new DataOutputStream(buffer);
writer.writeByte(id);
Point4D.write(data, writer);
message.write(writer);
writer.close();
packet.channel = PacketConstants.CHANNEL_NAME;
packet.data = buffer.toByteArray();

View File

@@ -6,12 +6,10 @@ import net.minecraft.block.Block;
import net.minecraft.block.BlockDoor;
import net.minecraft.block.ITileEntityProvider;
import net.minecraft.block.material.Material;
import net.minecraft.client.particle.EntityFX;
import net.minecraft.client.renderer.texture.IconRegister;
import net.minecraft.entity.Entity;
import net.minecraft.entity.EntityLiving;
import net.minecraft.entity.EntityLivingBase;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.item.ItemDoor;
import net.minecraft.tileentity.TileEntity;
import net.minecraft.util.Icon;
import net.minecraft.util.MathHelper;
@@ -22,12 +20,12 @@ import StevenDimDoors.mod_pocketDim.mod_pocketDim;
import StevenDimDoors.mod_pocketDim.core.DDTeleporter;
import StevenDimDoors.mod_pocketDim.core.DimLink;
import StevenDimDoors.mod_pocketDim.core.PocketManager;
import StevenDimDoors.mod_pocketDim.items.BaseItemDoor;
import StevenDimDoors.mod_pocketDim.schematic.BlockRotator;
import StevenDimDoors.mod_pocketDim.tileentities.TileEntityDimDoor;
import cpw.mods.fml.relauncher.Side;
import cpw.mods.fml.relauncher.SideOnly;
@SuppressWarnings("deprecation")
public abstract class BaseDimDoor extends BlockDoor implements IDimDoor, ITileEntityProvider
{
protected final DDProperties properties;
@@ -40,13 +38,15 @@ public abstract class BaseDimDoor extends BlockDoor implements IDimDoor, ITileEn
this.properties = properties;
}
@Override
public void registerIcons(IconRegister par1IconRegister)
{
this.blockIcon = par1IconRegister.registerIcon(mod_pocketDim.modid + ":" + this.getUnlocalizedName2()+"_top");
this.blockIconBottom = par1IconRegister.registerIcon(mod_pocketDim.modid + ":" + this.getUnlocalizedName2()+"_bottom");
this.blockIcon = par1IconRegister.registerIcon(mod_pocketDim.modid + ":" + this.getUnlocalizedName()+"_top");
this.blockIconBottom = par1IconRegister.registerIcon(mod_pocketDim.modid + ":" + this.getUnlocalizedName()+"_bottom");
}
@SideOnly(Side.CLIENT)
@Override
@SideOnly(Side.CLIENT)
/**
* From the specified side and block metadata retrieves the blocks texture. Args: side, metadata
@@ -64,6 +64,7 @@ public abstract class BaseDimDoor extends BlockDoor implements IDimDoor, ITileEn
this.enterDimDoor(world, x, y, z, entity);
}
@Override
public boolean onBlockActivated(World world, int x, int y, int z, EntityPlayer player, int side, float hitX, float hitY, float hitZ)
{
@@ -77,7 +78,7 @@ public abstract class BaseDimDoor extends BlockDoor implements IDimDoor, ITileEn
shouldOpen = false;
if (!world.isRemote && world.getBlockId(x, y-1, z) == this.blockID)
{
int var12 = (int) (MathHelper.floor_double((double)((player.rotationYaw+90) * 4.0F / 360.0F) + 0.5D) & 3);
int var12 = MathHelper.floor_double((player.rotationYaw+90) * 4.0F / 360.0F + 0.5D) & 3;
if (world.getBlockMetadata(x, y-1, z) == var12)
{
@@ -87,7 +88,7 @@ public abstract class BaseDimDoor extends BlockDoor implements IDimDoor, ITileEn
}
if (!world.isRemote && world.getBlockId(x, y+1, z) == this.blockID)
{
int var12 = (int) (MathHelper.floor_double((double)((player.rotationYaw+90) * 4.0F / 360.0F) + 0.5D) & 3);
int var12 = MathHelper.floor_double((player.rotationYaw+90) * 4.0F / 360.0F + 0.5D) & 3;
if(world.getBlockMetadata(x, y, z)==var12)
{
var12 = BlockRotator.transformMetadata(var12, 1, this.blockID);
@@ -144,6 +145,7 @@ public abstract class BaseDimDoor extends BlockDoor implements IDimDoor, ITileEn
/**
* Retrieves the block texture to use based on the display side. Args: iBlockAccess, x, y, z, side
*/
@Override
@SideOnly(Side.CLIENT)
public Icon getBlockTexture(IBlockAccess par1IBlockAccess, int par2, int par3, int par4, int par5)
{
@@ -175,6 +177,7 @@ public abstract class BaseDimDoor extends BlockDoor implements IDimDoor, ITileEn
* Is this block (a) opaque and (b) a full 1m cube? This determines whether or not to render the shared face of two
* adjacent blocks and also whether the player can attach torches, redstone wire, etc to this block.
*/
@Override
public void updateTick(World par1World, int par2, int par3, int par4, Random par5Random)
{
TileEntityDimDoor tile = (TileEntityDimDoor) par1World.getBlockTileEntity(par2, par3, par4);
@@ -386,7 +389,7 @@ public abstract class BaseDimDoor extends BlockDoor implements IDimDoor, ITileEn
if (canUse && entity instanceof EntityPlayer)
{
// Dont check for non-player entites
canUse = isEntityFacingDoor(metadata, (EntityLiving) entity);
canUse = isEntityFacingDoor(metadata, (EntityLivingBase) entity);
}
if (canUse)
{
@@ -418,12 +421,12 @@ public abstract class BaseDimDoor extends BlockDoor implements IDimDoor, ITileEn
return (metadata & 4) != 0;
}
protected static boolean isEntityFacingDoor(int metadata, EntityLiving entity)
protected static boolean isEntityFacingDoor(int metadata, 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.
int direction = (int) (MathHelper.floor_double((double) ((entity.rotationYaw + 90) * 4.0F / 360.0F) + 0.5D) & 3);
int direction = MathHelper.floor_double((entity.rotationYaw + 90) * 4.0F / 360.0F + 0.5D) & 3;
return ((metadata & 3) == direction);
}
}

View File

@@ -57,10 +57,11 @@ public class BlockDimWall extends Block
}
}
@Override
public void registerIcons(IconRegister par1IconRegister)
{
this.blockIcon[0] = par1IconRegister.registerIcon(mod_pocketDim.modid + ":" + this.getUnlocalizedName2());
this.blockIcon[1] = par1IconRegister.registerIcon(mod_pocketDim.modid + ":" + this.getUnlocalizedName2() + "Perm");
this.blockIcon[0] = par1IconRegister.registerIcon(mod_pocketDim.modid + ":" + this.getUnlocalizedName());
this.blockIcon[1] = par1IconRegister.registerIcon(mod_pocketDim.modid + ":" + this.getUnlocalizedName() + "Perm");
}
@SideOnly(Side.CLIENT)
@@ -77,6 +78,7 @@ public class BlockDimWall extends Block
return 0;
}
@Override
@SuppressWarnings({ "rawtypes", "unchecked" })
@SideOnly(Side.CLIENT)
public void getSubBlocks(int unknown, CreativeTabs tab, List subItems)
@@ -86,14 +88,17 @@ public class BlockDimWall extends Block
subItems.add(new ItemStack(this, 1, ix));
}
}
public void onBlockDestroyedByPlayer(World par1World, int par2, int par3, int par4, int par5) {}
@Override
public void onBlockDestroyedByPlayer(World par1World, int par2, int par3, int par4, int par5) {}
protected boolean canSilkHarvest()
@Override
protected boolean canSilkHarvest()
{
return true;
}
public int quantityDropped(Random par1Random)
@Override
public int quantityDropped(Random par1Random)
{
return 0;
}
@@ -101,7 +106,8 @@ public class BlockDimWall extends Block
/**
* replaces the block clicked with the held block, instead of placing the block on top of it. Shift click to disable.
*/
public boolean onBlockActivated(World world, int x, int y, int z, EntityPlayer entityPlayer, int par6, float par7, float par8, float par9)
@Override
public boolean onBlockActivated(World world, int x, int y, int z, EntityPlayer entityPlayer, int par6, float par7, float par8, float par9)
{
//Check if the metadata value is 0 -- we don't want the user to replace Ancient Fabric
if (entityPlayer.getCurrentEquippedItem() != null && world.getBlockMetadata(x, y, z) == 0)

View File

@@ -30,21 +30,25 @@ public class BlockDimWallPerm extends Block
properties = DDProperties.instance();
}
@Override
public void registerIcons(IconRegister par1IconRegister)
{
this.blockIcon = par1IconRegister.registerIcon(mod_pocketDim.modid + ":" + this.getUnlocalizedName2());
this.blockIcon = par1IconRegister.registerIcon(mod_pocketDim.modid + ":" + this.getUnlocalizedName());
}
@Override
public int quantityDropped(Random par1Random)
{
return 0;
}
@Override
public void onBlockDestroyedByPlayer(World par1World, int par2, int par3, int par4, int par5) {}
/**
* Only matters if the player is in limbo, acts to teleport the player from limbo back to dim 0
*/
@Override
public void onEntityWalking(World world, int x, int y, int z, Entity entity)
{
if (!world.isRemote && world.provider.dimensionId == properties.LimboDimensionID)

View File

@@ -1,5 +1,7 @@
package StevenDimDoors.mod_pocketDim.blocks;
import java.util.Random;
import cpw.mods.fml.relauncher.Side;
import cpw.mods.fml.relauncher.SideOnly;
import StevenDimDoors.mod_pocketDim.DDProperties;
@@ -7,6 +9,7 @@ import StevenDimDoors.mod_pocketDim.mod_pocketDim;
import net.minecraft.block.BlockDoor;
import net.minecraft.block.material.Material;
import net.minecraft.client.renderer.texture.IconRegister;
import net.minecraft.item.Item;
import net.minecraft.util.Icon;
import net.minecraft.world.IBlockAccess;
@@ -14,6 +17,7 @@ public class BlockDoorGold extends BlockDoor
{
private Icon blockIconBottom;
@SuppressWarnings("unused") // ??
private DDProperties properties;
public BlockDoorGold(int par1, Material par2Material,DDProperties properties)
@@ -23,17 +27,25 @@ public class BlockDoorGold extends BlockDoor
}
@Override
public void registerIcons(IconRegister par1IconRegister)
{
this.blockIcon = par1IconRegister.registerIcon(mod_pocketDim.modid + ":" + this.getUnlocalizedName2()+"_top");
this.blockIconBottom = par1IconRegister.registerIcon(mod_pocketDim.modid + ":" + this.getUnlocalizedName2()+"_bottom");
this.blockIcon = par1IconRegister.registerIcon(mod_pocketDim.modid + ":" + this.getUnlocalizedName()+"_top");
this.blockIconBottom = par1IconRegister.registerIcon(mod_pocketDim.modid + ":" + this.getUnlocalizedName()+"_bottom");
}
public int idDropped(int par1, Random par2Random, int par3)
{
return mod_pocketDim.itemGoldDoor.itemID;
}
@Override
public Icon getIcon(int par1, int par2)
{
return this.blockIcon;
}
@Override
@SideOnly(Side.CLIENT)
public Icon getBlockTexture(IBlockAccess par1IBlockAccess, int par2, int par3, int par4, int par5)
{

View File

@@ -1,24 +1,24 @@
package StevenDimDoors.mod_pocketDim.blocks;
import net.minecraft.block.material.Material;
import net.minecraft.item.Item;
import net.minecraft.tileentity.TileEntity;
import net.minecraft.world.World;
import StevenDimDoors.mod_pocketDim.DDProperties;
import StevenDimDoors.mod_pocketDim.mod_pocketDim;
import StevenDimDoors.mod_pocketDim.core.DimLink;
import StevenDimDoors.mod_pocketDim.core.LinkTypes;
import StevenDimDoors.mod_pocketDim.core.NewDimData;
import StevenDimDoors.mod_pocketDim.core.PocketManager;
import StevenDimDoors.mod_pocketDim.tileentities.TileEntityDimDoor;
import StevenDimDoors.mod_pocketDim.tileentities.TileEntityDimDoorGold;
public class BlockGoldDimDoor extends BaseDimDoor implements IDimDoor
import net.minecraft.block.material.Material;
import net.minecraft.tileentity.TileEntity;
import net.minecraft.world.World;
@SuppressWarnings("deprecation")
public class BlockGoldDimDoor extends BaseDimDoor
{
public BlockGoldDimDoor(int blockID, Material material,
DDProperties properties) {
super(blockID, material, properties);
// TODO Auto-generated constructor stub
}
@Override
@@ -38,7 +38,7 @@ public class BlockGoldDimDoor extends BaseDimDoor implements IDimDoor
@Override
public int getDrops()
{
return this.properties.GoldDoorItemID;
return mod_pocketDim.itemGoldDoor.itemID;
}
@Override

View File

@@ -40,7 +40,7 @@ public class BlockLimbo extends Block
@Override
public void registerIcons(IconRegister iconRegister)
{
this.blockIcon = iconRegister.registerIcon(mod_pocketDim.modid + ":" + this.getUnlocalizedName2());
this.blockIcon = iconRegister.registerIcon(mod_pocketDim.modid + ":" + this.getUnlocalizedName());
}
@Override

View File

@@ -17,6 +17,8 @@ import net.minecraft.world.World;
import StevenDimDoors.mod_pocketDim.DDProperties;
import StevenDimDoors.mod_pocketDim.Point3D;
import StevenDimDoors.mod_pocketDim.mod_pocketDim;
import StevenDimDoors.mod_pocketDim.core.DimLink;
import StevenDimDoors.mod_pocketDim.core.NewDimData;
import StevenDimDoors.mod_pocketDim.core.PocketManager;
import StevenDimDoors.mod_pocketDim.tileentities.TileEntityRift;
import StevenDimDoors.mod_pocketDimClient.ClosingRiftFX;
@@ -66,7 +68,7 @@ public class BlockRift extends BlockContainer
@Override
public void registerIcons(IconRegister par1IconRegister)
{
this.blockIcon = par1IconRegister.registerIcon(mod_pocketDim.modid + ":" + this.getUnlocalizedName2());
this.blockIcon = par1IconRegister.registerIcon(mod_pocketDim.modid + ":" + this.getUnlocalizedName());
}
//sends a packet informing the client that there is a link present so it renders properly. (when placed)
@@ -152,6 +154,8 @@ public class BlockRift extends BlockContainer
return null;
}
//function that regulates how many blocks it eats/ how fast it eats them.
@Override
public void updateTick(World world, int x, int y, int z, Random random)
@@ -162,11 +166,12 @@ public class BlockRift extends BlockContainer
//Randomly decide whether to search for blocks to destroy. This reduces the frequency of search operations,
//moderates performance impact, and controls the apparent speed of block destruction.
if (random.nextInt(MAX_BLOCK_SEARCH_CHANCE) < BLOCK_SEARCH_CHANCE &&
((TileEntityRift) world.getBlockTileEntity(x, y, z)).isNearRift )
((TileEntityRift) world.getBlockTileEntity(x, y, z)).isNearRift() )
{
destroyNearbyBlocks(world, x, y, z, random);
}
}
}
private void destroyNearbyBlocks(World world, int x, int y, int z, Random random)
@@ -313,10 +318,10 @@ public class BlockRift extends BlockContainer
yChange=(float) ((yGrowth+yGrowthn)+rand.nextGaussian()*.05F);
zChange=(float) ((zGrowth+zGrowthn)+rand.nextGaussian()*.05F);
Xoffset= (float) ((0.25F/(1+Math.abs(xChange))));
Xoffset= ((0.25F/(1+Math.abs(xChange))));
Yoffset= (float) ((0.25F/(1+Math.abs(yChange))));
Zoffset= (float) ((0.25F/(1+Math.abs(zChange))));
Yoffset= ((0.25F/(1+Math.abs(yChange))));
Zoffset= ((0.25F/(1+Math.abs(zChange))));

View File

@@ -9,6 +9,7 @@ import StevenDimDoors.mod_pocketDim.core.LinkTypes;
import StevenDimDoors.mod_pocketDim.core.NewDimData;
import StevenDimDoors.mod_pocketDim.core.PocketManager;
@SuppressWarnings("deprecation")
public class DimensionalDoor extends BaseDimDoor
{

View File

@@ -8,7 +8,6 @@ import net.minecraft.block.ITileEntityProvider;
import net.minecraft.block.material.Material;
import net.minecraft.client.renderer.texture.IconRegister;
import net.minecraft.entity.Entity;
import net.minecraft.item.ItemDoor;
import net.minecraft.tileentity.TileEntity;
import net.minecraft.world.World;
import StevenDimDoors.mod_pocketDim.mod_pocketDim;
@@ -17,9 +16,9 @@ import StevenDimDoors.mod_pocketDim.core.DimLink;
import StevenDimDoors.mod_pocketDim.core.LinkTypes;
import StevenDimDoors.mod_pocketDim.core.NewDimData;
import StevenDimDoors.mod_pocketDim.core.PocketManager;
import StevenDimDoors.mod_pocketDim.items.BaseItemDoor;
import StevenDimDoors.mod_pocketDim.tileentities.TileEntityTransTrapdoor;
@SuppressWarnings("deprecation")
public class TransTrapdoor extends BlockTrapDoor implements IDimDoor, ITileEntityProvider
{
@@ -32,7 +31,7 @@ public class TransTrapdoor extends BlockTrapDoor implements IDimDoor, ITileEntit
@Override
public void registerIcons(IconRegister par1IconRegister)
{
this.blockIcon = par1IconRegister.registerIcon(mod_pocketDim.modid + ":" + this.getUnlocalizedName2());
this.blockIcon = par1IconRegister.registerIcon(mod_pocketDim.modid + ":" + this.getUnlocalizedName());
}
//Teleports the player to the exit link of that dimension, assuming it is a pocket
@@ -65,6 +64,7 @@ public class TransTrapdoor extends BlockTrapDoor implements IDimDoor, ITileEntit
this.updateAttachedTile(world, x, y, z);
}
@Override
public void updateTick(World world, int x, int y, int z, Random random)
{
TileEntityTransTrapdoor tile = (TileEntityTransTrapdoor) world.getBlockTileEntity(x, y, z);
@@ -96,7 +96,7 @@ public class TransTrapdoor extends BlockTrapDoor implements IDimDoor, ITileEntit
DimLink link = dimension.getLink(x, y, z);
if (link == null && dimension.isPocketDimension())
{
dimension.createLink(x, y, z, LinkTypes.UNSAFE_EXIT);
dimension.createLink(x, y, z, LinkTypes.UNSAFE_EXIT,0);
}
}
}

View File

@@ -1,21 +1,21 @@
package StevenDimDoors.mod_pocketDim.blocks;
import net.minecraft.block.material.Material;
import net.minecraft.client.particle.EntityFX;
import net.minecraft.entity.Entity;
import net.minecraft.entity.EntityLiving;
import net.minecraft.item.ItemDoor;
import net.minecraft.util.AxisAlignedBB;
import net.minecraft.world.World;
import StevenDimDoors.mod_pocketDim.DDProperties;
import StevenDimDoors.mod_pocketDim.mod_pocketDim;
import StevenDimDoors.mod_pocketDim.core.DDTeleporter;
import StevenDimDoors.mod_pocketDim.core.DimLink;
import StevenDimDoors.mod_pocketDim.core.LinkTypes;
import StevenDimDoors.mod_pocketDim.core.NewDimData;
import StevenDimDoors.mod_pocketDim.core.PocketManager;
import StevenDimDoors.mod_pocketDim.items.BaseItemDoor;
import net.minecraft.block.material.Material;
import net.minecraft.client.particle.EntityFX;
import net.minecraft.entity.Entity;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.entity.EntityLivingBase;
import net.minecraft.util.AxisAlignedBB;
import net.minecraft.world.World;
@SuppressWarnings("deprecation")
public class TransientDoor extends BaseDimDoor
{
public TransientDoor(int blockID, Material material, DDProperties properties)
@@ -27,7 +27,7 @@ public class TransientDoor extends BaseDimDoor
public void enterDimDoor(World world, int x, int y, int z, Entity entity)
{
// We need to ignore particle entities
if (world.isRemote || entity instanceof EntityFX)
if (world.isRemote)
{
return;
}
@@ -37,10 +37,10 @@ public class TransientDoor extends BaseDimDoor
{
boolean canUse = true;
int metadata = world.getBlockMetadata(x, y - 1, z);
if (canUse && entity instanceof EntityLiving)
if (canUse && entity instanceof EntityPlayer)
{
// Don't check for non-living entities since it might not work right
canUse = BaseDimDoor.isEntityFacingDoor(metadata, (EntityLiving) entity);
canUse = BaseDimDoor.isEntityFacingDoor(metadata, (EntityLivingBase) entity);
}
if (canUse)
{

View File

@@ -9,6 +9,7 @@ import StevenDimDoors.mod_pocketDim.core.LinkTypes;
import StevenDimDoors.mod_pocketDim.core.NewDimData;
import StevenDimDoors.mod_pocketDim.core.PocketManager;
@SuppressWarnings("deprecation")
public class WarpDoor extends BaseDimDoor
{
public WarpDoor(int blockID, Material material, DDProperties properties)

View File

@@ -1,9 +1,5 @@
package StevenDimDoors.mod_pocketDim.commands;
import java.util.Collection;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.util.MathHelper;
import StevenDimDoors.mod_pocketDim.mod_pocketDim;
import StevenDimDoors.mod_pocketDim.core.DimLink;
import StevenDimDoors.mod_pocketDim.core.LinkTypes;
@@ -11,7 +7,15 @@ import StevenDimDoors.mod_pocketDim.core.NewDimData;
import StevenDimDoors.mod_pocketDim.core.PocketManager;
import StevenDimDoors.mod_pocketDim.dungeon.DungeonData;
import StevenDimDoors.mod_pocketDim.helpers.DungeonHelper;
import StevenDimDoors.mod_pocketDim.world.PocketBuilder;
import java.util.Collection;
import net.minecraft.command.ICommandSender;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.util.MathHelper;
@SuppressWarnings("deprecation")
public class CommandCreateDungeonRift extends DDCommandBase
{
private static CommandCreateDungeonRift instance = null;
@@ -29,6 +33,13 @@ public class CommandCreateDungeonRift extends DDCommandBase
return instance;
}
@Override
public String getCommandUsage(ICommandSender sender) {
return "Usage: /dd-rift <dungeon name>\r\n" +
" /dd-rift list\r\n" +
" /dd-rift random";
}
@Override
protected DDCommandResult processCommand(EntityPlayer sender, String[] command)
{
@@ -53,9 +64,9 @@ public class CommandCreateDungeonRift extends DDCommandBase
Collection<String> dungeonNames = dungeonHelper.getDungeonNames();
for (String name : dungeonNames)
{
sender.sendChatToPlayer(name);
sendChat(sender,(name));
}
sender.sendChatToPlayer("");
sendChat(sender,(""));
}
else
{
@@ -64,16 +75,16 @@ public class CommandCreateDungeonRift extends DDCommandBase
int x = MathHelper.floor_double(sender.posX);
int y = MathHelper.floor_double(sender.posY);
int z = MathHelper.floor_double (sender.posZ);
int orientation = MathHelper.floor_double((double) ((sender.rotationYaw + 180.0F) * 4.0F / 360.0F) - 0.5D) & 3;
int orientation = MathHelper.floor_double((sender.rotationYaw + 180.0F) * 4.0F / 360.0F - 0.5D) & 3;
if (command[0].equals("random"))
{
dimension = PocketManager.getDimensionData(sender.worldObj);
link = dimension.createLink(x, y + 1, z, LinkTypes.DUNGEON);
link = dimension.createLink(x, y + 1, z, LinkTypes.DUNGEON,orientation);
sender.worldObj.setBlock(x, y + 1, z,mod_pocketDim.blockRift.blockID,0,3);
sender.sendChatToPlayer("Created a rift to a random dungeon.");
sendChat(sender,("Created a rift to a random dungeon."));
}
else
{
@@ -83,16 +94,17 @@ public class CommandCreateDungeonRift extends DDCommandBase
result = findDungeonByPartialName(command[0], dungeonHelper.getUntaggedDungeons());
}
//Check if we found any matches
if (result != null)
{
//Create a rift to our selected dungeon and notify the player
//TODO currently crashes, need to create the dimension first
dimension = PocketManager.getDimensionData(sender.worldObj);
link = dimension.createLink(x, y + 1, z, LinkTypes.DUNGEON);
PocketManager.getDimensionData(link.destination().getDimension()).initializeDungeon(x, y + 1, z, orientation,link, result);
sender.worldObj.setBlock(x, y + 1, z,mod_pocketDim.blockRift.blockID,0,3);
sender.sendChatToPlayer("Created a rift to \"" + result.schematicName() + "\" dungeon (Dimension ID = " + link.destination().getDimension() + ").");
}
if (result != null)
{
//Create a rift to our selected dungeon and notify the player
//TODO currently crashes, need to create the dimension first
dimension = PocketManager.getDimensionData(sender.worldObj);
link = dimension.createLink(x, y + 1, z, LinkTypes.DUNGEON,orientation);
PocketBuilder.generateSelectedDungeonPocket(link, mod_pocketDim.properties, result);
sender.worldObj.setBlock(x, y + 1, z,mod_pocketDim.blockRift.blockID,0,3);
sendChat(sender,("Created a rift to \"" + result.schematicName() + "\" dungeon (Dimension ID = " + link.destination().getDimension() + ")."));
}
else
{
//No matches!

View File

@@ -1,5 +1,6 @@
package StevenDimDoors.mod_pocketDim.commands;
import net.minecraft.command.ICommandSender;
import net.minecraft.entity.player.EntityPlayer;
import StevenDimDoors.mod_pocketDim.helpers.DungeonHelper;
@@ -20,6 +21,11 @@ public class CommandCreatePocket extends DDCommandBase
return instance;
}
@Override
public String getCommandUsage(ICommandSender sender) {
return "Usage: /dd-create";
}
@Override
protected DDCommandResult processCommand(EntityPlayer sender, String[] command)
{
@@ -41,7 +47,7 @@ public class CommandCreatePocket extends DDCommandBase
DungeonHelper.instance().createCustomDungeonDoor(sender.worldObj, x, y, z);
//Notify the player
sender.sendChatToPlayer("Created a door to a pocket dimension. Please build your dungeon there.");
sendChat(sender,("Created a door to a pocket dimension. Please build your dungeon there."));
}
return DDCommandResult.SUCCESS;
}

View File

@@ -1,14 +1,16 @@
package StevenDimDoors.mod_pocketDim.commands;
import java.util.ArrayList;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.world.World;
import net.minecraftforge.common.DimensionManager;
import StevenDimDoors.mod_pocketDim.core.DimLink;
import StevenDimDoors.mod_pocketDim.core.NewDimData;
import StevenDimDoors.mod_pocketDim.core.PocketManager;
import java.util.ArrayList;
import net.minecraft.command.ICommandSender;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.world.World;
@SuppressWarnings("deprecation")
public class CommandDeleteAllLinks extends DDCommandBase
{
private static CommandDeleteAllLinks instance = null;
@@ -26,6 +28,11 @@ public class CommandDeleteAllLinks extends DDCommandBase
return instance;
}
@Override
public String getCommandUsage(ICommandSender sender) {
return "Usage: /dd-deletelinks <targetDimensionID>";
}
@Override
protected DDCommandResult processCommand(EntityPlayer sender, String[] command)
{
@@ -41,7 +48,7 @@ public class CommandDeleteAllLinks extends DDCommandBase
{
targetDim=0;
shouldGo=false;
sender.sendChatToPlayer("Error-Invalid argument, delete_all_links <targetDimID>");
sendChat(sender, ("Error-Invalid argument, delete_all_links <targetDimID>"));
}
if(shouldGo)
@@ -59,7 +66,7 @@ public class CommandDeleteAllLinks extends DDCommandBase
linksRemoved++;
}
sender.sendChatToPlayer("Removed " + linksRemoved + " links.");
sendChat(sender,("Removed " + linksRemoved + " links."));
}
return DDCommandResult.SUCCESS; //TEMPORARY HACK

View File

@@ -2,6 +2,7 @@ package StevenDimDoors.mod_pocketDim.commands;
import java.util.ArrayList;
import net.minecraft.command.ICommandSender;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.world.World;
import StevenDimDoors.mod_pocketDim.mod_pocketDim;
@@ -9,6 +10,7 @@ import StevenDimDoors.mod_pocketDim.core.DimLink;
import StevenDimDoors.mod_pocketDim.core.NewDimData;
import StevenDimDoors.mod_pocketDim.core.PocketManager;
@SuppressWarnings("deprecation")
public class CommandDeleteRifts extends DDCommandBase
{
private static CommandDeleteRifts instance = null;
@@ -26,6 +28,11 @@ public class CommandDeleteRifts extends DDCommandBase
return instance;
}
@Override
public String getCommandUsage(ICommandSender sender) {
return "Usage: /dd-??? <dimension ID>";
}
@Override
protected DDCommandResult processCommand(EntityPlayer sender, String[] command)
{
@@ -41,7 +48,7 @@ public class CommandDeleteRifts extends DDCommandBase
{
targetDim=0;
shouldGo=false;
sender.sendChatToPlayer("Error-Invalid argument, delete_all_links <targetDimID>");
sendChat(sender,("Error-Invalid argument, delete_all_links <targetDimID>"));
}
if(shouldGo)
@@ -54,14 +61,20 @@ public class CommandDeleteRifts extends DDCommandBase
{
World targetWorld = PocketManager.loadDimension(targetDim);
if(sender.worldObj.getBlockId(link.source().getX(), link.source().getY(), link.source().getZ())==mod_pocketDim.blockRift.blockID)
if(!mod_pocketDim.blockRift.isBlockImmune(sender.worldObj,link.source().getX(), link.source().getY(), link.source().getZ())||
(targetWorld.getBlockId(link.source().getX(), link.source().getY(), link.source().getZ())==mod_pocketDim.blockRift.blockID))
{
targetWorld.setBlock(link.source().getX(), link.source().getY(), link.source().getZ(), 0);
linksRemoved++;
targetWorld.setBlock(link.source().getX(), link.source().getY(), link.source().getZ(), 0);
dim.deleteLink(link);
}
//TODO Probably should check what the block is, but thats annoying so Ill do it later.
}
sender.sendChatToPlayer("Removed " + linksRemoved + " rifts.");
sendChat(sender,("Removed " + linksRemoved + " links."));
}
return DDCommandResult.SUCCESS; //TEMPORARY HACK

View File

@@ -2,6 +2,7 @@ package StevenDimDoors.mod_pocketDim.commands;
import java.io.File;
import net.minecraft.command.ICommandSender;
import net.minecraft.entity.player.EntityPlayer;
import StevenDimDoors.mod_pocketDim.DDProperties;
import StevenDimDoors.mod_pocketDim.helpers.DungeonHelper;
@@ -25,6 +26,13 @@ public class CommandExportDungeon extends DDCommandBase
return instance;
}
@Override
public String getCommandUsage(ICommandSender sender) {
return "Usage: /dd-export <dungeon type> <dungeon name> open <weight>\r\n" +
" /dd-export <dungeon type> <dungeon name> closed <weight>\r\n" +
" /dd-export <schematic name> override";
}
@Override
protected DDCommandResult processCommand(EntityPlayer sender, String[] command)
{
@@ -132,7 +140,7 @@ public class CommandExportDungeon extends DDCommandBase
String exportPath = properties.CustomSchematicDirectory + File.separator + name + ".schematic";
if (dungeonHelper.exportDungeon(player.worldObj, x, y, z, exportPath))
{
player.sendChatToPlayer("Saved dungeon schematic in " + exportPath);
sendChat(player,("Saved dungeon schematic in " + exportPath));
dungeonHelper.registerDungeon(exportPath, dungeonHelper.getDungeonPack("ruins"), false, true);
return DDCommandResult.SUCCESS;
}

View File

@@ -2,6 +2,7 @@ package StevenDimDoors.mod_pocketDim.commands;
import java.util.ArrayList;
import net.minecraft.command.ICommandSender;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraftforge.common.DimensionManager;
import StevenDimDoors.mod_pocketDim.core.DimLink;
@@ -9,6 +10,7 @@ import StevenDimDoors.mod_pocketDim.core.LinkTypes;
import StevenDimDoors.mod_pocketDim.core.NewDimData;
import StevenDimDoors.mod_pocketDim.core.PocketManager;
@SuppressWarnings("deprecation")
public class CommandResetDungeons extends DDCommandBase
{
private static CommandResetDungeons instance = null;
@@ -26,6 +28,11 @@ public class CommandResetDungeons extends DDCommandBase
return instance;
}
@Override
public String getCommandUsage(ICommandSender sender) {
return "/dd-resetdungeons";
}
@Override
protected DDCommandResult processCommand(EntityPlayer sender, String[] command)
{
@@ -84,7 +91,7 @@ public class CommandResetDungeons extends DDCommandBase
//TODO- for some reason the parent field of loaded dimenions get reset to null if I call .setParentToRoot() before I delete the pockets.
//TODO implement blackList
//Notify the user of the results
sender.sendChatToPlayer("Reset complete. " + resetCount + " out of " + dungeonCount + " dungeons were reset.");
sendChat(sender,("Reset complete. " + resetCount + " out of " + dungeonCount + " dungeons were reset."));
return DDCommandResult.SUCCESS;
}
}

View File

@@ -1,30 +1,23 @@
package StevenDimDoors.mod_pocketDim.commands;
import java.util.ArrayList;
import StevenDimDoors.mod_pocketDim.core.DDTeleporter;
import StevenDimDoors.mod_pocketDim.core.PocketManager;
import StevenDimDoors.mod_pocketDim.util.Point4D;
import java.util.Arrays;
import java.util.List;
import cpw.mods.fml.common.FMLCommonHandler;
import StevenDimDoors.mod_pocketDim.BlankTeleporter;
import StevenDimDoors.mod_pocketDim.core.DDTeleporter;
import StevenDimDoors.mod_pocketDim.core.PocketManager;
import StevenDimDoors.mod_pocketDim.helpers.yCoordHelper;
import StevenDimDoors.mod_pocketDim.util.Point4D;
import net.minecraft.command.ICommandSender;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.entity.player.EntityPlayerMP;
import net.minecraft.world.World;
import net.minecraft.world.WorldServer;
import net.minecraftforge.common.DimensionManager;
public class CommandTeleportPlayer extends DDCommandBase
{
private static CommandTeleportPlayer instance = null;
private CommandTeleportPlayer()
{
super("dd-tp", new String[] {"<Player Name> <Dimension ID> <X Coord> <Y Coord> <Z Coord>"} );
super("dd-tp", new String[] {"<Player Name> <Dimension ID> <X Coord> <Y Coord> <Z Coord>","<Player Name> <Dimension ID>"} );
}
public static CommandTeleportPlayer instance()
@@ -36,13 +29,17 @@ public class CommandTeleportPlayer extends DDCommandBase
return instance;
}
@Override
public String getCommandUsage(ICommandSender sender) {
return "Usage: /dd-tp <player name> <dimension id> <x> <y> <z>";
}
/**
* TODO- Change to accept variety of input, like just coords, just dim ID, or two player names.
*/
@Override
protected DDCommandResult processCommand(EntityPlayer sender, String[] command)
{
List dimensionIDs = Arrays.asList(DimensionManager.getStaticDimensionIDs()); //Gets list of all registered dimensions, regardless if loaded or not
EntityPlayer targetPlayer = sender;
int dimDestinationID = sender.worldObj.provider.dimensionId;
@@ -65,7 +62,7 @@ public class CommandTeleportPlayer extends DDCommandBase
}
dimDestinationID=Integer.parseInt(command[1]);//gets the target dim ID from the command string
if(!dimensionIDs.contains(dimDestinationID))
if(!DimensionManager.isDimensionRegistered(dimDestinationID))
{
return DDCommandResult.INVALID_DIMENSION_ID;
}
@@ -74,6 +71,55 @@ public class CommandTeleportPlayer extends DDCommandBase
Point4D destination = new Point4D(Integer.parseInt(command[2]),Integer.parseInt(command[3]),Integer.parseInt(command[4]),dimDestinationID);
DDTeleporter.teleportEntity(targetPlayer, destination, false);
}
else if(command.length == 2 && isInteger(command[1]))
{
if(sender.worldObj.getPlayerEntityByName(command[0])!=null) //Gets the targeted player
{
targetPlayer = sender.worldObj.getPlayerEntityByName(command[0]);
}
else
{
return DDCommandResult.INVALID_ARGUMENTS;
}
dimDestinationID=Integer.parseInt(command[1]);//gets the target dim ID from the command string
if(!DimensionManager.isDimensionRegistered(dimDestinationID))
{
return DDCommandResult.INVALID_DIMENSION_ID;
}
Point4D destination = PocketManager.getDimensionData(dimDestinationID).origin();
if(!PocketManager.getDimensionData(dimDestinationID).isPocketDimension())
{
destination = new Point4D(destination.getX(),PocketManager.loadDimension(dimDestinationID).getTopSolidOrLiquidBlock(
destination.getX(), destination.getZ()),
destination.getZ(),destination.getDimension());
}
DDTeleporter.teleportEntity(targetPlayer, destination, false);
}
else if(command.length == 1 && isInteger(command[0]))
{
targetPlayer = sender;
dimDestinationID=Integer.parseInt(command[0]);//gets the target dim ID from the command string
if(!DimensionManager.isDimensionRegistered(dimDestinationID))
{
return DDCommandResult.INVALID_DIMENSION_ID;
}
Point4D destination = PocketManager.getDimensionData(dimDestinationID).origin();
if(!PocketManager.getDimensionData(dimDestinationID).isPocketDimension())
{
destination = new Point4D(destination.getX(),PocketManager.loadDimension(dimDestinationID).getTopSolidOrLiquidBlock(
destination.getX(), destination.getZ()),
destination.getZ(),destination.getDimension());
}
DDTeleporter.teleportEntity(targetPlayer, destination, false);
}
else
{
return DDCommandResult.INVALID_ARGUMENTS;

View File

@@ -3,6 +3,7 @@ package StevenDimDoors.mod_pocketDim.commands;
import net.minecraft.command.CommandBase;
import net.minecraft.command.ICommandSender;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.util.ChatMessageComponent;
import cpw.mods.fml.common.event.FMLServerStartingEvent;
/*
@@ -32,6 +33,7 @@ public abstract class DDCommandBase extends CommandBase
*/
protected abstract DDCommandResult processCommand(EntityPlayer sender, String[] command);
@Override
public final String getCommandName()
{
return name;
@@ -49,6 +51,7 @@ public abstract class DDCommandBase extends CommandBase
* Method invoked by the server to execute a command. The call is forwarded to a derived class
* to provide the sending player directly.
*/
@Override
public final void processCommand(ICommandSender sender, String[] command)
{
//Forward the command
@@ -63,10 +66,24 @@ public abstract class DDCommandBase extends CommandBase
//Send the argument formats for this command
for (String format : formats)
{
player.sendChatToPlayer("Usage: " + name + " " + format);
sendChat(player,("Usage: " + name + " " + format));
}
}
player.sendChatToPlayer(result.getMessage());
sendChat(player,(result.getMessage()));
}
}
public static void sendChat(EntityPlayer player, String message)
{
ChatMessageComponent cmp = new ChatMessageComponent();
cmp.addText(message);
player.sendChatToPlayer(cmp);
}
@Override
public int compareTo(Object par1Obj)
{
return this.getCommandName().compareTo(((CommandBase)par1Obj).getCommandName());
}
}

View File

@@ -9,8 +9,8 @@ import net.minecraft.entity.EntityList;
import net.minecraft.entity.item.EntityMinecart;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.entity.player.EntityPlayerMP;
import net.minecraft.item.ItemDoor;
import net.minecraft.nbt.NBTTagCompound;
import net.minecraft.network.packet.Packet250CustomPayload;
import net.minecraft.network.packet.Packet41EntityEffect;
import net.minecraft.network.packet.Packet43Experience;
import net.minecraft.network.packet.Packet9Respawn;
@@ -20,20 +20,22 @@ import net.minecraft.util.MathHelper;
import net.minecraft.world.World;
import net.minecraft.world.WorldServer;
import net.minecraftforge.common.DimensionManager;
import net.minecraftforge.common.network.ForgePacket;
import net.minecraftforge.common.network.packet.DimensionRegisterPacket;
import StevenDimDoors.mod_pocketDim.DDProperties;
import StevenDimDoors.mod_pocketDim.Point3D;
import StevenDimDoors.mod_pocketDim.mod_pocketDim;
import StevenDimDoors.mod_pocketDim.blocks.BlockRift;
import StevenDimDoors.mod_pocketDim.blocks.IDimDoor;
import StevenDimDoors.mod_pocketDim.helpers.yCoordHelper;
import StevenDimDoors.mod_pocketDim.items.BaseItemDoor;
import StevenDimDoors.mod_pocketDim.items.ItemDimensionalDoor;
import StevenDimDoors.mod_pocketDim.schematic.BlockRotator;
import StevenDimDoors.mod_pocketDim.tileentities.TileEntityDimDoor;
import StevenDimDoors.mod_pocketDim.util.Point4D;
import StevenDimDoors.mod_pocketDim.watcher.ClientDimData;
import StevenDimDoors.mod_pocketDim.world.PocketBuilder;
import cpw.mods.fml.common.registry.GameRegistry;
@SuppressWarnings("deprecation")
public class DDTeleporter
{
private static final Random random = new Random();
@@ -235,7 +237,7 @@ public class DDTeleporter
private static void setEntityPosition(Entity entity, double x, double y, double z)
{
entity.lastTickPosX = entity.prevPosX = entity.posX = x;
entity.lastTickPosY = entity.prevPosY = entity.posY = y + (double)entity.yOffset;
entity.lastTickPosY = entity.prevPosY = entity.posY = y + entity.yOffset;
entity.lastTickPosZ = entity.prevPosZ = entity.posZ = z;
entity.setPosition(x, y, z);
}
@@ -273,6 +275,7 @@ public class DDTeleporter
throw new IllegalArgumentException("destination cannot be null.");
}
//This beautiful teleport method is based off of xCompWiz's teleport function.
WorldServer oldWorld = (WorldServer) entity.worldObj;
@@ -304,7 +307,7 @@ public class DDTeleporter
}
else
{
newWorld = (WorldServer) oldWorld;
newWorld = oldWorld;
}
@@ -317,6 +320,10 @@ public class DDTeleporter
if(player != null) // Are we working with a player?
{
// We need to do all this special stuff to move a player between dimensions.
//Give the client the dimensionData for the destination
PocketManager.dimWatcher.onCreated(new ClientDimData(PocketManager.getDimensionData(destination.getDimension())));
// Set the new dimension and inform the client that it's moving to a new world.
player.dimension = destination.getDimension();
@@ -327,6 +334,7 @@ public class DDTeleporter
// the last non-sleeping player leaves the Overworld
// for a pocket dimension, causing all sleeping players
// to remain asleep instead of progressing to day.
((WorldServer)entity.worldObj).getPlayerManager().removePlayer(player);
oldWorld.removePlayerEntityDangerously(player);
player.isDead = false;
@@ -357,13 +365,13 @@ public class DDTeleporter
oldWorld.getChunkFromChunkCoords(entX, entZ).isModified = true;
}
// Memory concerns.
oldWorld.releaseEntitySkin(entity);
oldWorld.onEntityRemoved(entity);
if (player == null) // Are we NOT working with a player?
{
NBTTagCompound entityNBT = new NBTTagCompound();
entity.isDead = false;
entity.addEntityID(entityNBT);
entity.writeMountToNBT(entityNBT);
entity.isDead = true;
entity = EntityList.createEntityFromNBT(entityNBT, newWorld);
@@ -399,7 +407,6 @@ public class DDTeleporter
if (player != null)
{
newWorld.getChunkProvider().loadChunk(MathHelper.floor_double(entity.posX) >> 4, MathHelper.floor_double(entity.posZ) >> 4);
// Tell Forge we're moving its players so everyone else knows.
// Let's try doing this down here in case this is what's killing NEI.
GameRegistry.onPlayerChangedDimension((EntityPlayer)entity);
@@ -471,7 +478,7 @@ public class DDTeleporter
{
if(PocketManager.isBlackListed(link.destination().getDimension()))
{
link=PocketManager.getDimensionData(link.source().getDimension()).createLink(link.source,LinkTypes.SAFE_EXIT,link.orientation);
link=PocketManager.getDimensionData(link.source().getDimension()).createLink(link.link.point,LinkTypes.SAFE_EXIT,link.link.orientation);
}
else
{
@@ -547,7 +554,7 @@ public class DDTeleporter
// To avoid loops, don't generate a destination if the player is
// already in a non-pocket dimension.
NewDimData current = PocketManager.getDimensionData(link.source.getDimension());
NewDimData current = PocketManager.getDimensionData(link.link.point.getDimension());
if (current.isPocketDimension())
{
Point4D source = link.source();
@@ -571,7 +578,7 @@ public class DDTeleporter
{
World startWorld = PocketManager.loadDimension(link.source().getDimension());
World destWorld = PocketManager.loadDimension(link.destination().getDimension());
TileEntity doorTE = startWorld.getBlockTileEntity(link.source().getX(), link.source().getY(), link.source.getZ());
TileEntity doorTE = startWorld.getBlockTileEntity(link.source().getX(), link.source().getY(), link.link.point.getZ());
if(doorTE instanceof TileEntityDimDoor)
{
if((TileEntityDimDoor.class.cast(doorTE).hasGennedPair))
@@ -601,7 +608,7 @@ public class DDTeleporter
}
private static boolean generateSafeExit(DimLink link, DDProperties properties)
{
NewDimData current = PocketManager.getDimensionData(link.source.getDimension());
NewDimData current = PocketManager.getDimensionData(link.link.point.getDimension());
return generateSafeExit(current.root(), link, properties);
}
@@ -610,7 +617,7 @@ public class DDTeleporter
// A dungeon exit acts the same as a safe exit, but has the chance of
// taking the user to any non-pocket dimension, excluding Limbo and The End.
NewDimData current = PocketManager.getDimensionData(link.source.getDimension());
NewDimData current = PocketManager.getDimensionData(link.link.point.getDimension());
ArrayList<NewDimData> roots = PocketManager.getRootDimensions();
int shiftChance = START_ROOT_SHIFT_CHANCE + ROOT_SHIFT_CHANCE_PER_LEVEL * (current.packDepth() - 1);

View File

@@ -4,47 +4,56 @@ import java.util.LinkedList;
import java.util.List;
import StevenDimDoors.mod_pocketDim.util.Point4D;
import StevenDimDoors.mod_pocketDim.watcher.ClientLinkData;
public abstract class DimLink
{
protected Point4D source;
protected ClientLinkData link;
protected DimLink parent;
protected LinkTail tail;
protected int orientation;
protected List<DimLink> children;
protected DimLink(Point4D source, DimLink parent, int orientation)
protected DimLink(ClientLinkData link, DimLink parent)
{
if (parent.source.getDimension() != source.getDimension())
if (parent.link.point.getDimension() != link.point.getDimension())
{
// Ban having children in other dimensions to avoid serialization issues with cross-dimensional tails
throw new IllegalArgumentException("source and parent.source must have the same dimension.");
}
this.orientation=orientation;
this.parent = parent;
this.source = source;
this.link = link;
this.tail = parent.tail;
this.children = new LinkedList<DimLink>();
parent.children.add(this);
}
protected DimLink(Point4D source, int linkType, int orientation)
protected DimLink(ClientLinkData link, int linkType)
{
if ((linkType < LinkTypes.ENUM_MIN || linkType > LinkTypes.ENUM_MAX) && linkType != LinkTypes.CLIENT_SIDE)
{
throw new IllegalArgumentException("The specified link type is invalid.");
}
this.orientation = orientation;
this.parent = null;
this.source = source;
this.link = link;
this.tail = new LinkTail(linkType, null);
this.children = new LinkedList<DimLink>();
}
public Point4D source()
{
return source;
return link.point;
}
public int orientation()
{
return link.orientation;
}
public ClientLinkData link()
{
return link;
}
public Point4D destination()
@@ -53,7 +62,7 @@ public abstract class DimLink
}
public int getDestinationOrientation()
{
return PocketManager.getLink(source.getX(), source.getY(), source.getZ(), source.getDimension()).orientation();
return PocketManager.getLink(link.point.getX(), link.point.getY(), link.point.getZ(), link.point.getDimension()).link().orientation;
}
public boolean hasDestination()
{
@@ -79,13 +88,9 @@ public abstract class DimLink
{
return tail.getLinkType();
}
public int orientation()
{
return orientation;
}
public String toString()
{
return source + " -> " + (hasDestination() ? destination() : "");
return link.point + " -> " + (hasDestination() ? destination() : "");
}
}

View File

@@ -6,6 +6,7 @@ import java.util.Map;
import java.util.Random;
import java.util.TreeMap;
import StevenDimDoors.mod_pocketDim.watcher.ClientLinkData;
import net.minecraft.world.World;
import StevenDimDoors.mod_pocketDim.DDProperties;
import StevenDimDoors.mod_pocketDim.Point3D;
@@ -14,18 +15,19 @@ import StevenDimDoors.mod_pocketDim.dungeon.pack.DungeonPack;
import StevenDimDoors.mod_pocketDim.util.Point4D;
import StevenDimDoors.mod_pocketDim.watcher.IUpdateWatcher;
@SuppressWarnings("deprecation")
public abstract class NewDimData
{
private static class InnerDimLink extends DimLink
{
public InnerDimLink(Point4D source, DimLink parent,int orientation)
{
super(source, parent,orientation);
super(new ClientLinkData(source, orientation), parent);
}
public InnerDimLink(Point4D source, int linkType, int orientation)
{
super(source, linkType,orientation);
super(new ClientLinkData(source, orientation), linkType);
}
public void setDestination(int x, int y, int z, NewDimData dimension)
@@ -49,7 +51,7 @@ public abstract class NewDimData
}
parent = null;
source = null;
link = null;
tail = new LinkTail(0, null);
}
@@ -64,7 +66,7 @@ public abstract class NewDimData
//Ignore this request silently
return false;
}
if (nextParent.source.getDimension() != source.getDimension())
if (nextParent.link.point.getDimension() != link.point.getDimension())
{
// Ban having children in other dimensions to avoid serialization issues with cross-dimensional tails
throw new IllegalArgumentException("source and parent.source must have the same dimension.");
@@ -87,7 +89,7 @@ public abstract class NewDimData
parent = nextParent;
tail = nextParent.tail;
nextParent.children.add(this);
this.orientation=orientation;
this.link.orientation=orientation;
return true;
}
@@ -110,7 +112,7 @@ public abstract class NewDimData
parent = null;
tail = new LinkTail(linkType, null);
//Set new orientation
this.orientation=orientation;
this.link.orientation=orientation;
}
}
@@ -129,10 +131,10 @@ public abstract class NewDimData
protected Point4D origin;
protected int orientation;
protected DungeonData dungeon;
protected IUpdateWatcher<Point4D> linkWatcher;
public IUpdateWatcher<ClientLinkData> linkWatcher;
protected NewDimData(int id, NewDimData parent, boolean isPocket, boolean isDungeon,
IUpdateWatcher<Point4D> linkWatcher)
IUpdateWatcher<ClientLinkData> linkWatcher)
{
// The isPocket flag is redundant. It's meant as an integrity safeguard.
if (isPocket && (parent == null))
@@ -196,6 +198,7 @@ public abstract class NewDimData
this.root = root;
}
public DimLink findNearestRift(World world, int range, int x, int y, int z)
{
//TODO: Rewrite this later to use an octtree
@@ -224,7 +227,7 @@ public abstract class NewDimData
for (k = -range; k <= range; k++)
{
distance = getAbsoluteSum(i, j, k);
if (distance > 1 && distance < minDistance && world.getBlockId(x + i, y + j, z + k) == properties.RiftBlockID)
if (distance > 0 && distance < minDistance && world.getBlockId(x + i, y + j, z + k) == properties.RiftBlockID)
{
link = getLink(x+i, y+j, z+k);
if (link != null)
@@ -240,14 +243,52 @@ public abstract class NewDimData
return nearest;
}
public ArrayList<DimLink> findRiftsInRange(World world, int range, int x, int y, int z)
{
ArrayList<DimLink> links = new ArrayList<DimLink>();
//TODO: Rewrite this later to use an octtree
//Sanity check...
if (world.provider.dimensionId != id)
{
throw new IllegalArgumentException("Attempted to search for links in a World instance for a different dimension!");
}
//Note: Only detect rifts at a distance > 1, so we ignore the rift
//that called this function and any adjacent rifts.
DimLink link;
int distance;
int i, j, k;
DDProperties properties = DDProperties.instance();
for (i = -range; i <= range; i++)
{
for (j = -range; j <= range; j++)
{
for (k = -range; k <= range; k++)
{
distance = getAbsoluteSum(i, j, k);
if (distance > 0 && world.getBlockId(x + i, y + j, z + k) == properties.RiftBlockID)
{
link = getLink(x+i, y+j, z+k);
if (link != null)
{
links.add(link);
}
}
}
}
}
return links;
}
private static int getAbsoluteSum(int i, int j, int k)
{
return Math.abs(i) + Math.abs(j) + Math.abs(k);
}
public DimLink createLink(int x, int y, int z, int linkType)
{
return createLink(new Point4D(x, y, z, id), linkType,0);
}
public DimLink createLink(int x, int y, int z, int linkType,int orientation)
{
return createLink(new Point4D(x, y, z, id), linkType,orientation);
@@ -270,7 +311,7 @@ public abstract class NewDimData
//Link created!
if(linkType!=LinkTypes.CLIENT_SIDE)
{
linkWatcher.onCreated(link.source);
linkWatcher.onCreated(link.link);
}
return link;
}
@@ -293,19 +334,19 @@ public abstract class NewDimData
InnerDimLink link = linkMapping.get(source);
if (link == null)
{
link = new InnerDimLink(source, parent, parent.orientation);
link = new InnerDimLink(source, parent, parent.link.orientation);
linkMapping.put(source, link);
linkList.add(link);
//Link created!
linkWatcher.onCreated(link.source);
linkWatcher.onCreated(link.link);
}
else
{
if (link.overwrite(parent, parent.orientation))
if (link.overwrite(parent, parent.link.orientation))
{
//Link created!
linkWatcher.onCreated(link.source);
linkWatcher.onCreated(link.link);
}
}
return link;
@@ -322,7 +363,7 @@ public abstract class NewDimData
{
linkList.remove(target);
//Raise deletion event
linkWatcher.onDeleted(target.source);
linkWatcher.onDeleted(target.link);
target.clear();
}
return (target != null);
@@ -336,7 +377,11 @@ public abstract class NewDimData
{
linkList.remove(target);
//Raise deletion event
linkWatcher.onDeleted(target.source);
//TODO why is source null here?
if(target.link!=null)
{
linkWatcher.onDeleted(target.link);
}
target.clear();
}
return (target != null);

View File

@@ -9,6 +9,8 @@ import java.util.HashMap;
import java.util.List;
import cpw.mods.fml.common.FMLCommonHandler;
import cpw.mods.fml.relauncher.Side;
import cpw.mods.fml.relauncher.SideOnly;
import net.minecraft.world.World;
import net.minecraft.world.WorldServer;
@@ -27,6 +29,7 @@ import StevenDimDoors.mod_pocketDim.saving.PackedLinkData;
import StevenDimDoors.mod_pocketDim.saving.PackedLinkTail;
import StevenDimDoors.mod_pocketDim.util.Point4D;
import StevenDimDoors.mod_pocketDim.watcher.ClientDimData;
import StevenDimDoors.mod_pocketDim.watcher.ClientLinkData;
import StevenDimDoors.mod_pocketDim.watcher.IUpdateSource;
import StevenDimDoors.mod_pocketDim.watcher.IUpdateWatcher;
import StevenDimDoors.mod_pocketDim.watcher.UpdateWatcherProxy;
@@ -35,6 +38,7 @@ import StevenDimDoors.mod_pocketDim.watcher.UpdateWatcherProxy;
* This class regulates all the operations involving the storage and manipulation of dimensions. It handles saving dim data, teleporting the player, and
* creating/registering new dimensions as well as loading old dimensions on startup
*/
@SuppressWarnings("deprecation")
public class PocketManager
{
private static class InnerDimData extends NewDimData implements IPackable<PackedDimData>
@@ -45,7 +49,7 @@ public class PocketManager
// that any link destinations must be real dimensions controlled by PocketManager.
public InnerDimData(int id, InnerDimData parent, boolean isPocket, boolean isDungeon,
IUpdateWatcher<Point4D> linkWatcher)
IUpdateWatcher<ClientLinkData> linkWatcher)
{
super(id, parent, isPocket, isDungeon, linkWatcher);
}
@@ -117,7 +121,7 @@ public class PocketManager
Point3D parentPoint = new Point3D(-1,-1,-1);
if(link.parent!=null)
{
parentPoint=link.parent.source.toPoint3D();
parentPoint=link.parent.link.point.toPoint3D();
}
for(DimLink childLink : link.children)
@@ -125,7 +129,7 @@ public class PocketManager
children.add(childLink.source().toPoint3D());
}
PackedLinkTail tail = new PackedLinkTail(link.tail.getDestination(),link.tail.getLinkType());
Links.add(new PackedLinkData(link.source,parentPoint,tail,link.orientation,children));
Links.add(new PackedLinkData(link.link.point,parentPoint,tail,link.link.orientation,children));
PackedLinkTail tempTail = new PackedLinkTail(link.tail.getDestination(),link.tail.getLinkType());
if(Tails.contains(tempTail))
@@ -153,22 +157,24 @@ public class PocketManager
}
}
private static class ClientLinkWatcher implements IUpdateWatcher<Point4D>
{
@Override
public void onCreated(Point4D source)
{
NewDimData dimension = getDimensionData(source.getDimension());
dimension.createLink(source.getX(), source.getY(), source.getZ(), LinkTypes.CLIENT_SIDE);
}
private static class ClientLinkWatcher implements IUpdateWatcher<ClientLinkData>
{
@Override
public void onCreated(ClientLinkData link)
{
Point4D source = link.point;
NewDimData dimension = getDimensionData(source.getDimension());
dimension.createLink(source.getX(), source.getY(), source.getZ(), LinkTypes.CLIENT_SIDE,link.orientation);
}
@Override
public void onDeleted(Point4D source)
{
NewDimData dimension = getDimensionData(source.getDimension());
dimension.deleteLink(source.getX(), source.getY(), source.getZ());
}
}
@Override
public void onDeleted(ClientLinkData link)
{
Point4D source = link.point;
NewDimData dimension = getDimensionData(source.getDimension());
dimension.deleteLink(source.getX(), source.getY(), source.getZ());
}
}
private static class ClientDimWatcher implements IUpdateWatcher<ClientDimData>
{
@@ -204,8 +210,12 @@ public class PocketManager
private static volatile boolean isLoading = false;
private static volatile boolean isLoaded = false;
private static volatile boolean isSaving = false;
private static final UpdateWatcherProxy<Point4D> linkWatcher = new UpdateWatcherProxy<Point4D>();
private static final UpdateWatcherProxy<ClientDimData> dimWatcher = new UpdateWatcherProxy<ClientDimData>();
/**
* Set as true if we are a client that has connected to a dedicated server
*/
public static volatile boolean isConnected = false;
public static final UpdateWatcherProxy<ClientLinkData> linkWatcher = new UpdateWatcherProxy<ClientLinkData>();
static final UpdateWatcherProxy<ClientDimData> dimWatcher = new UpdateWatcherProxy<ClientDimData>();
private static ArrayList<NewDimData> rootDimensions = null;
//HashMap that maps all the dimension IDs registered with DimDoors to their DD data.
@@ -268,6 +278,7 @@ public class PocketManager
dimData.root=dimData;
dimData.parent=dimData;
dimData.isFilled=packedData.IsFilled;
dimData.origin = new Point4D(packedData.Origin.getX(),packedData.Origin.getY(),packedData.Origin.getZ(),packedData.ID);
PocketManager.rootDimensions.add(dimData);
}
@@ -276,6 +287,7 @@ public class PocketManager
InnerDimData test = PocketManager.dimensionData.get(packedData.ParentID);
dimData = new InnerDimData(packedData.ID, test,true, packedData.IsDungeon, linkWatcher);
dimData.isFilled=packedData.IsFilled;
dimData.origin = new Point4D(packedData.Origin.getX(),packedData.Origin.getY(),packedData.Origin.getZ(),packedData.ID);
dimData.root=PocketManager.getDimensionData(packedData.RootID);
@@ -372,6 +384,18 @@ public class PocketManager
}
}
}
for(Integer dimID : dimensionIDBlackList)
{
try
{
DimensionManager.unregisterDimension(dimID);
}
catch (Exception e)
{
System.err.println("An unexpected error occurred while unregistering blacklisted dim #" + dimID + ":");
e.printStackTrace();
}
}
}
/**
@@ -384,7 +408,8 @@ public class PocketManager
File saveDir = DimensionManager.getCurrentSaveRootDirectory();
if (saveDir != null)
{
// Load and register blacklisted dimension IDs
//Try to import data from old DD versions
//TODO - remove this code in a few versions
File oldSaveData = new File(saveDir+"/DimensionalDoorsData");
if(oldSaveData.exists())
{
@@ -395,7 +420,6 @@ public class PocketManager
oldSaveData.delete();
System.out.println("Import Succesful!");
}
catch (Exception e)
{
@@ -435,11 +459,7 @@ public class PocketManager
try
{
System.out.println("Writing Dimensional Doors save data...");
if ( DDSaveHandler.saveAll(dimensionData.values()) )
{
System.out.println("Saved successfully!");
}
DDSaveHandler.saveAll(dimensionData.values(), dimensionIDBlackList);
}
catch (Exception e)
{
@@ -506,6 +526,7 @@ public class PocketManager
return dimension;
}
@SideOnly(Side.CLIENT)
private static NewDimData registerClientDimension(int dimensionID, int rootID)
{
// No need to raise events heres since this code should only run on the client side
@@ -530,10 +551,13 @@ public class PocketManager
{
dimension = root;
}
if(dimension.isPocketDimension())
if(dimension.isPocketDimension()&&!DimensionManager.isDimensionRegistered(dimension.id()))
{
//Im registering pocket dims here. I *think* we can assume that if its a pocket and we are
//registering its dim data, we also need to register it with forge.
//New packet stuff prevents this from always being true, unfortuantly. I send the dimdata to the client when they teleport.
//Steven
DimensionManager.registerDimension(dimensionID, mod_pocketDim.properties.PocketProviderID);
}
return dimension;
@@ -552,6 +576,10 @@ public class PocketManager
//Any pocket dimension must be listed with PocketManager to have a dimension ID
//assigned, so it's safe to assume that any unknown dimensions don't belong to us.
if(PocketManager.dimensionData == null)
{
System.out.println("Something odd happend during shutdown");
}
NewDimData dimension = PocketManager.dimensionData.get(dimensionID);
if (dimension == null)
{
@@ -573,6 +601,7 @@ public class PocketManager
public static void unload()
{
System.out.println("Unloading Pocket Dimensions...");
if (!isLoaded)
{
throw new IllegalStateException("Pocket dimensions have already been unloaded!");
@@ -583,6 +612,7 @@ public class PocketManager
dimensionData = null;
rootDimensions = null;
isLoaded = false;
isConnected = false;
}
public static DimLink getLink(int x, int y, int z, World world)
@@ -622,12 +652,12 @@ public class PocketManager
return dimWatcher.unregisterReceiver(watcher);
}
public static void registerLinkWatcher(IUpdateWatcher<Point4D> watcher)
public static void registerLinkWatcher(IUpdateWatcher<ClientLinkData> watcher)
{
linkWatcher.registerReceiver(watcher);
}
public static boolean unregisterLinkWatcher(IUpdateWatcher<Point4D> watcher)
public static boolean unregisterLinkWatcher(IUpdateWatcher<ClientLinkData> watcher)
{
return linkWatcher.unregisterReceiver(watcher);
}
@@ -648,24 +678,35 @@ public class PocketManager
return dimensionData.containsKey(dimensionID);
}
public static void createAndRegisterBlacklist(List<Integer> blacklist)
{
//TODO - create a special blacklist provider
for(Integer dimID : blacklist)
{
PocketManager.dimensionIDBlackList.add(dimID);
DimensionManager.registerDimension(dimID, DDProperties.instance().PocketProviderID);
}
}
public static void readPacket(DataInputStream input) throws IOException
{
//TODO- figure out why this is getting called so frequently
if (isLoaded)
{
throw new IllegalStateException("Pocket dimensions have already been loaded!");
return;
}
if (isLoading)
{
throw new IllegalStateException("Pocket dimensions are already loading!");
}
// Load compacted client-side dimension data
load();
Compactor.readDimensions(input, new DimRegistrationCallback());
// Register pocket dimensions
DDProperties properties = DDProperties.instance();
registerPockets(properties);
isLoaded = true;
isLoading = false;
isConnected = true;
}
}

View File

@@ -81,6 +81,7 @@ public class DungeonSchematic extends Schematic {
public static DungeonSchematic readFromFile(File schematicFile) throws FileNotFoundException, InvalidSchematicException
{
// TODO: fix resource leak
return readFromStream(new FileInputStream(schematicFile));
}
@@ -169,7 +170,7 @@ public class DungeonSchematic extends Schematic {
return new DungeonSchematic(Schematic.copyFromWorld(world, x, y, z, width, height, length, doCompactBounds));
}
public void copyToWorld(World world, Point3D pocketCenter, int targetOrientation, DimLink entryLink, Random random)
public void copyToWorld(World world, Point3D pocketCenter, int targetOrientation, DimLink entryLink, Random random, DDProperties properties)
{
//TODO: This function is an improvised solution so we can get the release moving. In the future,
//we should generalize block transformations and implement support for them at the level of Schematic,
@@ -223,10 +224,10 @@ public class DungeonSchematic extends Schematic {
world.setBlockTileEntity(pocketPoint.getX(), pocketPoint.getY(), pocketPoint.getZ(), TileEntity.createAndLoadEntity(tileTag));
}
setUpDungeon(PocketManager.getDimensionData(world), world, pocketCenter, turnAngle, entryLink, random);
setUpDungeon(PocketManager.getDimensionData(world), world, pocketCenter, turnAngle, entryLink, random, properties);
}
private void setUpDungeon(NewDimData dimension, World world, Point3D pocketCenter, int turnAngle, DimLink entryLink, Random random)
private void setUpDungeon(NewDimData dimension, World world, Point3D pocketCenter, int turnAngle, DimLink entryLink, Random random, DDProperties properties)
{
//Transform dungeon corners
Point3D minCorner = new Point3D(0, 0, 0);
@@ -234,7 +235,7 @@ public class DungeonSchematic extends Schematic {
transformCorners(entranceDoorLocation, pocketCenter, turnAngle, minCorner, maxCorner);
//Fill empty chests and dispensers
FillContainersOperation filler = new FillContainersOperation(random);
FillContainersOperation filler = new FillContainersOperation(random, properties);
filler.apply(world, minCorner, maxCorner);
//Set up entrance door rift
@@ -301,7 +302,7 @@ public class DungeonSchematic extends Schematic {
Point3D location = point.clone();
BlockRotator.transformPoint(location, entrance, rotation, pocketCenter);
int orientation = world.getBlockMetadata(location.getX(), location.getY()-1, location.getZ());
dimension.createLink(location.getX(), location.getY(), location.getZ(), LinkTypes.DUNGEON_EXIT,orientation);
dimension.createLink(location.getX(), location.getY(), location.getZ(), LinkTypes.DUNGEON_EXIT, orientation);
//Replace the sandstone block under the exit door with the same block as the one underneath it
int x = location.getX();
int y = location.getY() - 3;
@@ -321,7 +322,7 @@ public class DungeonSchematic extends Schematic {
BlockRotator.transformPoint(location, entrance, rotation, pocketCenter);
int orientation = world.getBlockMetadata(location.getX(), location.getY()-1, location.getZ());
dimension.createLink(location.getX(), location.getY(), location.getZ(), LinkTypes.DUNGEON,orientation);
dimension.createLink(location.getX(), location.getY(), location.getZ(), LinkTypes.DUNGEON, orientation);
}
private static void spawnMonolith(World world, Point3D point, Point3D entrance, int rotation, Point3D pocketCenter, boolean canSpawn)

View File

@@ -12,16 +12,22 @@ import net.minecraft.tileentity.TileEntityChest;
import net.minecraft.tileentity.TileEntityDispenser;
import net.minecraft.world.World;
import StevenDimDoors.mod_pocketDim.DDLoot;
import StevenDimDoors.mod_pocketDim.DDProperties;
import StevenDimDoors.mod_pocketDim.schematic.WorldOperation;
public class FillContainersOperation extends WorldOperation
{
private Random random;
private DDProperties properties;
public FillContainersOperation(Random random)
private static final int GRAVE_CHEST_CHANCE = 100;
private static final int MAX_GRAVE_CHEST_CHANCE = 700;
public FillContainersOperation(Random random, DDProperties properties)
{
super("FillContainersOperation");
this.random = random;
this.properties = properties;
}
@Override
@@ -29,22 +35,30 @@ public class FillContainersOperation extends WorldOperation
{
int blockID = world.getBlockId(x, y, z);
//Fill empty chests and dispensers
// Fill empty chests and dispensers
if (Block.blocksList[blockID] instanceof BlockContainer)
{
TileEntity tileEntity = world.getBlockTileEntity(x, y, z);
//Fill chests
// Fill chests
if (tileEntity instanceof TileEntityChest)
{
TileEntityChest chest = (TileEntityChest) tileEntity;
if (isInventoryEmpty(chest))
{
DDLoot.generateChestContents(DDLoot.DungeonChestInfo, chest, random);
// Randomly choose whether this will be a regular dungeon chest or a grave chest
if (random.nextInt(MAX_GRAVE_CHEST_CHANCE) < GRAVE_CHEST_CHANCE)
{
DDLoot.fillGraveChest(chest, random, properties);
}
else
{
DDLoot.generateChestContents(DDLoot.DungeonChestInfo, chest, random);
}
}
}
//Fill dispensers
// Fill dispensers
if (tileEntity instanceof TileEntityDispenser)
{
TileEntityDispenser dispenser = (TileEntityDispenser) tileEntity;

View File

@@ -191,7 +191,14 @@ public class DungeonPack
return getRandomDungeon(random, candidates);
}
//If we've reached this point, then a dungeon was not selected. Discard the type and try again.
products.remove(nextType);
for (index = 0; index < products.size(); index++)
{
if (products.get(index).getData().equals(nextType))
{
products.remove(index);
break;
}
}
}
}
while (nextType != null);

View File

@@ -206,6 +206,7 @@ public class DungeonPackConfigReader extends BaseConfigurationProcessor<DungeonP
private class DungeonTypeProcessor implements ILineProcessor
{
@Override
public void process(String line, DungeonPackConfig config) throws ConfigurationProcessingException
{
List<String> typeNames = config.getTypeNames();
@@ -229,6 +230,7 @@ public class DungeonPackConfigReader extends BaseConfigurationProcessor<DungeonP
private class DungeonSettingsParser implements ILineProcessor
{
@Override
public void process(String line, DungeonPackConfig config) throws ConfigurationProcessingException
{
//The various settings that we support will be hardcoded here.
@@ -295,6 +297,7 @@ public class DungeonPackConfigReader extends BaseConfigurationProcessor<DungeonP
private class RuleDefinitionParser implements ILineProcessor
{
@Override
public void process(String definition, DungeonPackConfig config) throws ConfigurationProcessingException
{
String[] ruleParts;

View File

@@ -17,7 +17,7 @@ public class BlockRotationHelper
{
HashMap<Integer,HashMap<Integer, Integer>> orientation0 = new HashMap<Integer,HashMap<Integer, Integer>>();
HashMap<Integer,Integer> stairs0 = new HashMap();
HashMap<Integer,Integer> stairs0 = new HashMap<Integer,Integer>();
stairs0.put(0, 2);
stairs0.put(1, 3);

View File

@@ -0,0 +1,62 @@
package StevenDimDoors.mod_pocketDim.helpers;
import StevenDimDoors.mod_pocketDim.IChunkLoader;
import StevenDimDoors.mod_pocketDim.mod_pocketDim;
import StevenDimDoors.mod_pocketDim.core.NewDimData;
import StevenDimDoors.mod_pocketDim.core.PocketManager;
import cpw.mods.fml.common.event.FMLServerStartingEvent;
import java.io.File;
import java.util.List;
import net.minecraft.world.World;
import net.minecraftforge.common.DimensionManager;
import net.minecraftforge.common.ForgeChunkManager;
import net.minecraftforge.common.ForgeChunkManager.LoadingCallback;
import net.minecraftforge.common.ForgeChunkManager.Ticket;
public class ChunkLoaderHelper implements LoadingCallback
{
@Override
public void ticketsLoaded(List<Ticket> tickets, World world)
{
for (Ticket ticket : tickets)
{
int goldDimDoorX = ticket.getModData().getInteger("goldDimDoorX");
int goldDimDoorY = ticket.getModData().getInteger("goldDimDoorY");
int goldDimDoorZ = ticket.getModData().getInteger("goldDimDoorZ");
if(world.getBlockId(goldDimDoorX, goldDimDoorY, goldDimDoorZ)!=mod_pocketDim.properties.GoldDimDoorID)
{
ForgeChunkManager.releaseTicket(ticket);
}
else
{
IChunkLoader tile = (IChunkLoader) world.getBlockTileEntity(goldDimDoorX, goldDimDoorY, goldDimDoorZ);
tile.forceChunkLoading(ticket,goldDimDoorX,goldDimDoorZ);
}
}
}
public static void loadChunkForcedWorlds(FMLServerStartingEvent event)
{
for(NewDimData data : PocketManager.getDimensions())
{
if(data.isPocketDimension())
{
String chunkDir = DimensionManager.getCurrentSaveRootDirectory()+"/DimensionalDoors/pocketDimID" + data.id();
File file = new File(chunkDir);
if(file.exists())
{
if(ForgeChunkManager.savedWorldHasForcedChunkTickets(file))
{
PocketManager.loadDimension(data.id());
}
}
}
}
}
}

View File

@@ -12,10 +12,12 @@ import StevenDimDoors.mod_pocketDim.core.IDimRegistrationCallback;
import StevenDimDoors.mod_pocketDim.core.LinkTypes;
import StevenDimDoors.mod_pocketDim.core.NewDimData;
import StevenDimDoors.mod_pocketDim.util.Point4D;
import StevenDimDoors.mod_pocketDim.watcher.ClientLinkData;
public class Compactor
{
@SuppressWarnings("unused") // ?
private static class DimComparator implements Comparator<NewDimData>
{
@Override
@@ -37,6 +39,7 @@ public class Compactor
for (DimLink link : dimension.links())
{
Point4D.write(link.source(), output);
output.writeInt(link.orientation());
}
}
@@ -75,8 +78,9 @@ public class Compactor
int linkCount = input.readInt();
for (int h = 0; h < linkCount; h++)
{
Point4D source = Point4D.read(input);
dimension.createLink(source.getX(), source.getY(), source.getZ(), LinkTypes.CLIENT_SIDE);
ClientLinkData link = ClientLinkData.read(input);
Point4D source = link.point;
dimension.createLink(source.getX(), source.getY(), source.getZ(), LinkTypes.CLIENT_SIDE,link.orientation);
}
}
}

View File

@@ -140,7 +140,11 @@ public class DungeonHelper
config.setName(name);
return config;
}
catch (ConfigurationProcessingException e)
catch (FileNotFoundException e)
{
System.err.println("Could not find a dungeon pack config file: " + configPath);
}
catch (Exception e) // handles IOException and ConfigurationProcessingException
{
System.err.println(e.getMessage());
if (e.getCause() != null)
@@ -148,10 +152,6 @@ public class DungeonHelper
System.err.println(e.getCause());
}
}
catch (FileNotFoundException e)
{
System.err.println("Could not find a dungeon pack config file: " + configPath);
}
return null;
}
@@ -442,6 +442,7 @@ public class DungeonHelper
System.out.println("Registering bundled dungeon pack: " + name);
InputStream listStream = this.getClass().getResourceAsStream(listPath);
// chance of leak?
if (listStream == null)
{
System.err.println("Unable to open list of bundled dungeon schematics for " + name);

View File

@@ -29,6 +29,7 @@ public abstract class BaseItemDoor extends ItemDoor
properties = DDProperties.instance();
}
@Override
public void registerIcons(IconRegister par1IconRegister)
{
this.itemIcon = par1IconRegister.registerIcon(mod_pocketDim.modid + ":" + this.getUnlocalizedName().replace("item.", ""));
@@ -59,7 +60,7 @@ public abstract class BaseItemDoor extends ItemDoor
player.canPlayerEdit(x, y, z, side, stack) && player.canPlayerEdit(x, y + 1, z, side, stack) &&
(!requireLink || PocketManager.getLink(x, y + 1, z, world) != null)&&stack.stackSize>0)
{
int orientation = MathHelper.floor_double((double) ((player.rotationYaw + 180.0F) * 4.0F / 360.0F) - 0.5D) & 3;
int orientation = MathHelper.floor_double((player.rotationYaw + 180.0F) * 4.0F / 360.0F - 0.5D) & 3;
placeDoorBlock(world, x, y, z, orientation, doorBlock);
if (!player.capabilities.isCreativeMode && reduceStack)

View File

@@ -15,7 +15,8 @@ public class ItemBlockDimWall extends ItemBlock
this.setCreativeTab(mod_pocketDim.dimDoorsCreativeTab);
setHasSubtypes(true);
}
public void registerIcons(IconRegister par1IconRegister)
@Override
public void registerIcons(IconRegister par1IconRegister)
{
this.itemIcon = par1IconRegister.registerIcon(mod_pocketDim.modid + ":" + this.getUnlocalizedName().replace("tile.", ""));
}
@@ -28,6 +29,6 @@ public class ItemBlockDimWall extends ItemBlock
public String getUnlocalizedName(ItemStack par1ItemStack)
{
return subNames[getItemDamageFromStack(par1ItemStack)];
return subNames[this.getDamage(par1ItemStack)];
}
}

View File

@@ -2,7 +2,6 @@ package StevenDimDoors.mod_pocketDim.items;
import java.util.List;
import net.minecraft.block.Block;
import net.minecraft.block.material.Material;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.item.ItemStack;

View File

@@ -0,0 +1,58 @@
package StevenDimDoors.mod_pocketDim.items;
import StevenDimDoors.mod_pocketDim.mod_pocketDim;
import net.minecraft.block.Block;
import net.minecraft.block.material.Material;
import net.minecraft.client.renderer.texture.IconRegister;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.item.ItemDoor;
import net.minecraft.item.ItemStack;
import net.minecraft.util.MathHelper;
import net.minecraft.world.World;
public class ItemGoldDoor extends ItemDoor
{
public ItemGoldDoor(int par1, Material par2Material)
{
super(par1, par2Material);
}
@Override
public void registerIcons(IconRegister par1IconRegister)
{
this.itemIcon = par1IconRegister.registerIcon(mod_pocketDim.modid + ":" + this.getUnlocalizedName().replace("item.", ""));
}
@Override
public boolean onItemUse(ItemStack par1ItemStack, EntityPlayer par2EntityPlayer, World par3World, int par4, int par5, int par6, int par7, float par8, float par9, float par10)
{
if (par7 != 1)
{
return false;
}
else
{
++par5;
Block block = mod_pocketDim.goldDoor;
if (par2EntityPlayer.canPlayerEdit(par4, par5, par6, par7, par1ItemStack) && par2EntityPlayer.canPlayerEdit(par4, par5 + 1, par6, par7, par1ItemStack))
{
if (!block.canPlaceBlockAt(par3World, par4, par5, par6))
{
return false;
}
else
{
int i1 = MathHelper.floor_double((par2EntityPlayer.rotationYaw + 180.0F) * 4.0F / 360.0F - 0.5D) & 3;
placeDoorBlock(par3World, par4, par5, par6, i1, block);
--par1ItemStack.stackSize;
return true;
}
}
else
{
return false;
}
}
}
}

View File

@@ -7,6 +7,9 @@ import net.minecraft.block.material.Material;
import net.minecraft.client.renderer.texture.IconRegister;
import net.minecraft.entity.Entity;
import net.minecraft.entity.EntityLiving;
import net.minecraft.entity.EntityLivingBase;
import net.minecraft.entity.SharedMonsterAttributes;
import net.minecraft.entity.ai.attributes.AttributeModifier;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.entity.player.EntityPlayerMP;
import net.minecraft.item.EnumToolMaterial;
@@ -20,6 +23,7 @@ import net.minecraft.world.World;
import StevenDimDoors.mod_pocketDim.DDProperties;
import StevenDimDoors.mod_pocketDim.mod_pocketDim;
import StevenDimDoors.mod_pocketDim.core.PocketManager;
import com.google.common.collect.Multimap;
import cpw.mods.fml.relauncher.Side;
import cpw.mods.fml.relauncher.SideOnly;
@@ -60,10 +64,12 @@ public class ItemRiftBlade extends ItemSword
}
@Override
public int getDamageVsEntity(Entity par1Entity)
{
return 7;
}
public Multimap getItemAttributeModifiers()
{
Multimap multimap = super.getItemAttributeModifiers();
multimap.put(SharedMonsterAttributes.attackDamage.getAttributeUnlocalizedName(), new AttributeModifier(field_111210_e, "Weapon modifier", (double)7, 0));
return multimap;
}
@Override
@SideOnly(Side.CLIENT)
@@ -73,7 +79,7 @@ public class ItemRiftBlade extends ItemSword
}
@Override
public boolean hitEntity(ItemStack par1ItemStack, EntityLiving par2EntityLiving, EntityLiving par3EntityLiving)
public boolean hitEntity(ItemStack par1ItemStack, EntityLivingBase par2EntityLiving, EntityLivingBase par3EntityLiving)
{
par1ItemStack.damageItem(1, par3EntityLiving);
return true;
@@ -85,9 +91,9 @@ public class ItemRiftBlade extends ItemSword
float var4 = 1.0F;
float var5 = par2EntityPlayer.prevRotationPitch + (par2EntityPlayer.rotationPitch - par2EntityPlayer.prevRotationPitch) * var4;
float var6 = par2EntityPlayer.prevRotationYaw + (par2EntityPlayer.rotationYaw - par2EntityPlayer.prevRotationYaw) * var4;
double var7 = par2EntityPlayer.prevPosX + (par2EntityPlayer.posX - par2EntityPlayer.prevPosX) * (double)var4;
double var9 = par2EntityPlayer.prevPosY + (par2EntityPlayer.posY - par2EntityPlayer.prevPosY) * (double)var4 + 1.62D - (double)par2EntityPlayer.yOffset;
double var11 = par2EntityPlayer.prevPosZ + (par2EntityPlayer.posZ - par2EntityPlayer.prevPosZ) * (double)var4;
double var7 = par2EntityPlayer.prevPosX + (par2EntityPlayer.posX - par2EntityPlayer.prevPosX) * var4;
double var9 = par2EntityPlayer.prevPosY + (par2EntityPlayer.posY - par2EntityPlayer.prevPosY) * var4 + 1.62D - par2EntityPlayer.yOffset;
double var11 = par2EntityPlayer.prevPosZ + (par2EntityPlayer.posZ - par2EntityPlayer.prevPosZ) * var4;
Vec3 var13 = par1World.getWorldVec3Pool().getVecFromPool(var7, var9, var11);
float var14 = MathHelper.cos(-var6 * 0.017453292F - (float)Math.PI);
float var15 = MathHelper.sin(-var6 * 0.017453292F - (float)Math.PI);
@@ -100,13 +106,13 @@ public class ItemRiftBlade extends ItemSword
{
var21 = 7;
}
Vec3 var23 = var13.addVector((double)var18 * var21, (double)var17 * var21, (double)var20 * var21);
Vec3 var23 = var13.addVector(var18 * var21, var17 * var21, var20 * var21);
return par1World.rayTraceBlocks_do_do(var13, var23, true, false);
}
private boolean teleportToEntity(ItemStack item, Entity par1Entity, EntityPlayer holder)
{
Vec3 var2 = holder.worldObj.getWorldVec3Pool().getVecFromPool(holder.posX - par1Entity.posX, holder.boundingBox.minY + (double)(holder.height / 2.0F) - par1Entity.posY + (double)par1Entity.getEyeHeight(), holder.posZ - par1Entity.posZ);
Vec3 var2 = holder.worldObj.getWorldVec3Pool().getVecFromPool(holder.posX - par1Entity.posX, holder.boundingBox.minY + holder.height / 2.0F - par1Entity.posY + par1Entity.getEyeHeight(), holder.posZ - par1Entity.posZ);
double cooef =( var2.lengthVector()-2.5)/var2.lengthVector();
var2.xCoord*=cooef;
@@ -141,13 +147,13 @@ public class ItemRiftBlade extends ItemSword
if (!world.isRemote)
{
@SuppressWarnings("unchecked")
List<EntityLiving> list = (List<EntityLiving>) world.getEntitiesWithinAABB(EntityLiving.class, AxisAlignedBB.getBoundingBox(player.posX-8,player.posY-8, player.posZ-8, player.posX+8,player.posY+8, player.posZ+8));
List<EntityLiving> list = world.getEntitiesWithinAABB(EntityLiving.class, AxisAlignedBB.getBoundingBox(player.posX-8,player.posY-8, player.posZ-8, player.posX+8,player.posY+8, player.posZ+8));
list.remove(player);
for (EntityLiving ent : list)
{
Vec3 var3 = player.getLook(1.0F).normalize();
Vec3 var4 = player.worldObj.getWorldVec3Pool().getVecFromPool(ent.posX - player.posX, ent.boundingBox.minY + (double)((ent.height) / 2.0F) - ( player.posY + (double) player.getEyeHeight()), ent.posZ - player.posZ);
Vec3 var4 = player.worldObj.getWorldVec3Pool().getVecFromPool(ent.posX - player.posX, ent.boundingBox.minY + (ent.height) / 2.0F - ( player.posY + player.getEyeHeight()), ent.posZ - player.posZ);
double var5 = var4.lengthVector();
var4 = var4.normalize();
double var7 = var3.dotProduct(var4);
@@ -172,13 +178,13 @@ public class ItemRiftBlade extends ItemSword
if (player.canPlayerEdit(x, y, z, hit.sideHit, stack) &&
player.canPlayerEdit(x, y + 1, z, hit.sideHit, stack))
{
int orientation = MathHelper.floor_double((double)((player.rotationYaw + 180.0F) * 4.0F / 360.0F) - 0.5D) & 3;
int orientation = MathHelper.floor_double((player.rotationYaw + 180.0F) * 4.0F / 360.0F - 0.5D) & 3;
if (BaseItemDoor.canPlace(world, x, y, z) &&
BaseItemDoor.canPlace(world, x, y - 1, z))
{
ItemDimensionalDoor.placeDoorBlock(world, x, y - 1, z, orientation, mod_pocketDim.transientDoor);
player.worldObj.playSoundAtEntity(player,"mods.DimDoors.sfx.riftDoor", 0.6f, 1);
player.worldObj.playSoundAtEntity(player,mod_pocketDim.modid+":riftDoor", 0.6f, 1);
stack.damageItem(3, player);
return stack;
}
@@ -212,6 +218,7 @@ public class ItemRiftBlade extends ItemSword
/**
* allows items to add custom lines of information to the mouseover description
*/
@Override
@SuppressWarnings({ "unchecked", "rawtypes" })
@SideOnly(Side.CLIENT)
public void addInformation(ItemStack par1ItemStack, EntityPlayer par2EntityPlayer, List par3List, boolean par4)

Some files were not shown because too many files have changed in this diff Show More