Merge remote-tracking branch 'origin/master' into StevenRS
Conflicts: src/main/java/StevenDimDoors/mod_pocketDim/CraftingManager.java src/main/java/StevenDimDoors/mod_pocketDim/EventHookContainer.java src/main/java/StevenDimDoors/mod_pocketDim/core/DDTeleporter.java src/main/java/StevenDimDoors/mod_pocketDim/core/DimLink.java src/main/java/StevenDimDoors/mod_pocketDim/items/ItemRiftSignature.java src/main/java/StevenDimDoors/mod_pocketDim/items/ItemStabilizedRiftSignature.java src/main/java/StevenDimDoors/mod_pocketDim/mod_pocketDim.java src/main/java/StevenDimDoors/mod_pocketDim/world/PocketBuilder.java src/main/java/StevenDimDoors/mod_pocketDimClient/RenderRift.java
This commit is contained in:
commit
5ba58dc91b
22 changed files with 324 additions and 299 deletions
|
@ -1,14 +1,8 @@
|
||||||
package StevenDimDoors.mod_pocketDim;
|
package StevenDimDoors.mod_pocketDim;
|
||||||
|
|
||||||
import static StevenDimDoors.mod_pocketDim.mod_pocketDim.itemDimensionalDoor;
|
|
||||||
import static StevenDimDoors.mod_pocketDim.mod_pocketDim.itemRiftBlade;
|
|
||||||
import static StevenDimDoors.mod_pocketDim.mod_pocketDim.itemRiftRemover;
|
|
||||||
import static StevenDimDoors.mod_pocketDim.mod_pocketDim.itemRiftSignature;
|
|
||||||
import static StevenDimDoors.mod_pocketDim.mod_pocketDim.itemStableFabric;
|
|
||||||
import static StevenDimDoors.mod_pocketDim.mod_pocketDim.itemUnstableDoor;
|
|
||||||
import static StevenDimDoors.mod_pocketDim.mod_pocketDim.itemWarpDoor;
|
|
||||||
import static StevenDimDoors.mod_pocketDim.mod_pocketDim.transTrapdoor;
|
|
||||||
import net.minecraft.block.Block;
|
import net.minecraft.block.Block;
|
||||||
|
import net.minecraft.block.BlockDispenser;
|
||||||
import net.minecraft.entity.player.EntityPlayer;
|
import net.minecraft.entity.player.EntityPlayer;
|
||||||
import net.minecraft.inventory.IInventory;
|
import net.minecraft.inventory.IInventory;
|
||||||
import net.minecraft.item.Item;
|
import net.minecraft.item.Item;
|
||||||
|
@ -17,6 +11,7 @@ import net.minecraftforge.oredict.ShapedOreRecipe;
|
||||||
import StevenDimDoors.mod_pocketDim.config.DDProperties;
|
import StevenDimDoors.mod_pocketDim.config.DDProperties;
|
||||||
import StevenDimDoors.mod_pocketDim.core.DDLock;
|
import StevenDimDoors.mod_pocketDim.core.DDLock;
|
||||||
import StevenDimDoors.mod_pocketDim.items.ItemDDKey;
|
import StevenDimDoors.mod_pocketDim.items.ItemDDKey;
|
||||||
|
import StevenDimDoors.mod_pocketDim.items.behaviors.DispenserBehaviorStabilizedRS;
|
||||||
import cpw.mods.fml.common.ICraftingHandler;
|
import cpw.mods.fml.common.ICraftingHandler;
|
||||||
import cpw.mods.fml.common.registry.GameRegistry;
|
import cpw.mods.fml.common.registry.GameRegistry;
|
||||||
|
|
||||||
|
@ -31,19 +26,19 @@ public class CraftingManager implements ICraftingHandler
|
||||||
switch (properties.WorldThreadRequirementLevel)
|
switch (properties.WorldThreadRequirementLevel)
|
||||||
{
|
{
|
||||||
case 1:
|
case 1:
|
||||||
GameRegistry.addShapelessRecipe(new ItemStack(itemStableFabric, 1),
|
GameRegistry.addShapelessRecipe(new ItemStack(mod_pocketDim.itemStableFabric, 1),
|
||||||
Item.enderPearl, mod_pocketDim.itemWorldThread);
|
Item.enderPearl, mod_pocketDim.itemWorldThread);
|
||||||
break;
|
break;
|
||||||
case 2:
|
case 2:
|
||||||
GameRegistry.addRecipe(new ItemStack(itemStableFabric, 1),
|
GameRegistry.addRecipe(new ItemStack(mod_pocketDim.itemStableFabric, 1),
|
||||||
"yxy", 'x', Item.enderPearl, 'y', mod_pocketDim.itemWorldThread);
|
"yxy", 'x', Item.enderPearl, 'y', mod_pocketDim.itemWorldThread);
|
||||||
break;
|
break;
|
||||||
case 3:
|
case 3:
|
||||||
GameRegistry.addRecipe(new ItemStack(itemStableFabric, 1),
|
GameRegistry.addRecipe(new ItemStack(mod_pocketDim.itemStableFabric, 1),
|
||||||
" y ", "yxy", " y ", 'x', Item.enderPearl, 'y', mod_pocketDim.itemWorldThread);
|
" y ", "yxy", " y ", 'x', Item.enderPearl, 'y', mod_pocketDim.itemWorldThread);
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
GameRegistry.addRecipe(new ItemStack(itemStableFabric, 1),
|
GameRegistry.addRecipe(new ItemStack(mod_pocketDim.itemStableFabric, 1),
|
||||||
"yyy", "yxy", "yyy", 'x', Item.enderPearl, 'y', mod_pocketDim.itemWorldThread);
|
"yyy", "yxy", "yyy", 'x', Item.enderPearl, 'y', mod_pocketDim.itemWorldThread);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
@ -51,48 +46,53 @@ public class CraftingManager implements ICraftingHandler
|
||||||
|
|
||||||
if (properties.CraftingDimensionalDoorAllowed)
|
if (properties.CraftingDimensionalDoorAllowed)
|
||||||
{
|
{
|
||||||
GameRegistry.addRecipe(new ItemStack(itemDimensionalDoor, 1),
|
GameRegistry.addRecipe(new ItemStack(mod_pocketDim.itemDimensionalDoor, 1),
|
||||||
"yxy", 'x', mod_pocketDim.itemStableFabric, 'y', Item.doorIron);
|
"yxy", 'x', mod_pocketDim.itemStableFabric, 'y', Item.doorIron);
|
||||||
}
|
}
|
||||||
if (properties.CraftingUnstableDoorAllowed)
|
if (properties.CraftingUnstableDoorAllowed)
|
||||||
{
|
{
|
||||||
GameRegistry.addRecipe(new ItemStack(itemUnstableDoor, 1),
|
GameRegistry.addRecipe(new ItemStack(mod_pocketDim.itemUnstableDoor, 1),
|
||||||
"yxy", 'x', Item.eyeOfEnder, 'y', mod_pocketDim.itemDimensionalDoor);
|
"yxy", 'x', Item.eyeOfEnder, 'y', mod_pocketDim.itemDimensionalDoor);
|
||||||
}
|
}
|
||||||
if (properties.CraftingWarpDoorAllowed)
|
if (properties.CraftingWarpDoorAllowed)
|
||||||
{
|
{
|
||||||
GameRegistry.addRecipe(new ItemStack(itemWarpDoor, 1),
|
|
||||||
|
GameRegistry.addRecipe(new ItemStack(mod_pocketDim.itemWarpDoor, 1),
|
||||||
"yxy", 'x', Item.enderPearl, 'y', Item.doorWood);
|
"yxy", 'x', Item.enderPearl, 'y', Item.doorWood);
|
||||||
}
|
}
|
||||||
if (properties.CraftingTransTrapdoorAllowed)
|
if (properties.CraftingTransTrapdoorAllowed)
|
||||||
{
|
{
|
||||||
GameRegistry.addRecipe(new ItemStack(transTrapdoor, 1),
|
|
||||||
|
GameRegistry.addRecipe(new ItemStack(mod_pocketDim.transTrapdoor, 1),
|
||||||
"y", "x", "y", 'x', Item.enderPearl, 'y', Block.trapdoor);
|
"y", "x", "y", 'x', Item.enderPearl, 'y', Block.trapdoor);
|
||||||
}
|
}
|
||||||
if (properties.CraftingRiftSignatureAllowed)
|
if (properties.CraftingRiftSignatureAllowed)
|
||||||
{
|
{
|
||||||
GameRegistry.addRecipe(new ItemStack(itemRiftSignature, 1),
|
|
||||||
|
GameRegistry.addRecipe(new ItemStack(mod_pocketDim.itemRiftSignature, 1),
|
||||||
" y ", "yxy", " y ", 'x', Item.enderPearl, 'y', Item.ingotIron);
|
" y ", "yxy", " y ", 'x', Item.enderPearl, 'y', Item.ingotIron);
|
||||||
}
|
}
|
||||||
if (properties.CraftingRiftRemoverAllowed)
|
if (properties.CraftingRiftRemoverAllowed)
|
||||||
{
|
{
|
||||||
GameRegistry.addRecipe(new ItemStack(itemRiftRemover, 1),
|
|
||||||
|
GameRegistry.addRecipe(new ItemStack(mod_pocketDim.itemRiftRemover, 1),
|
||||||
"yyy", "yxy", "yyy", 'x', Item.enderPearl, 'y', Item.ingotGold);
|
"yyy", "yxy", "yyy", 'x', Item.enderPearl, 'y', Item.ingotGold);
|
||||||
}
|
}
|
||||||
if (properties.CraftingRiftBladeAllowed)
|
if (properties.CraftingRiftBladeAllowed)
|
||||||
{
|
{
|
||||||
GameRegistry.addRecipe(new ItemStack(itemRiftBlade, 1),
|
GameRegistry.addRecipe(new ItemStack(mod_pocketDim.itemRiftBlade, 1),
|
||||||
"x", "x", "y", 'x', mod_pocketDim.itemStableFabric, 'y', Item.blazeRod);
|
"x", "x", "y", 'x', mod_pocketDim.itemStableFabric, 'y', Item.blazeRod);
|
||||||
}
|
}
|
||||||
if (properties.CraftingStabilizedRiftSignatureAllowed)
|
if (properties.CraftingStabilizedRiftSignatureAllowed)
|
||||||
{
|
{
|
||||||
GameRegistry.addRecipe(new ItemStack(mod_pocketDim.itemStabilizedLinkSignature,1),
|
|
||||||
" y ", "yxy", " y ", 'x', mod_pocketDim.itemRiftSignature, 'y', mod_pocketDim.itemWorldThread);
|
GameRegistry.addRecipe(new ItemStack(mod_pocketDim.itemStabilizedRiftSignature, 1),
|
||||||
|
" y ", "yxy", " y ", 'x', mod_pocketDim.itemStableFabric, 'y', Item.ingotIron);
|
||||||
}
|
}
|
||||||
if (properties.CraftingGoldenDimensionalDoorAllowed)
|
if (properties.CraftingGoldenDimensionalDoorAllowed)
|
||||||
{
|
{
|
||||||
GameRegistry.addRecipe(new ItemStack(mod_pocketDim.itemGoldenDimensionalDoor,1),
|
GameRegistry.addRecipe(new ItemStack(mod_pocketDim.itemGoldenDimensionalDoor, 1),
|
||||||
"yxy", 'y', mod_pocketDim.itemGoldenDoor, 'x', mod_pocketDim.itemStableFabric);
|
"yxy", 'x', mod_pocketDim.itemStableFabric, 'y', mod_pocketDim.itemGoldenDoor);
|
||||||
}
|
}
|
||||||
if (properties.CraftingGoldenDoorAllowed)
|
if (properties.CraftingGoldenDoorAllowed)
|
||||||
{
|
{
|
||||||
|
@ -162,4 +162,9 @@ public class CraftingManager implements ICraftingHandler
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public static void registerDispenserBehaviors()
|
||||||
|
{
|
||||||
|
// Register the dispenser behaviors for certain DD items
|
||||||
|
BlockDispenser.dispenseBehaviorRegistry.putObject(mod_pocketDim.itemStabilizedRiftSignature, new DispenserBehaviorStabilizedRS());
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -24,6 +24,7 @@ import StevenDimDoors.mod_pocketDim.core.DDTeleporter;
|
||||||
import StevenDimDoors.mod_pocketDim.core.DimensionType;
|
import StevenDimDoors.mod_pocketDim.core.DimensionType;
|
||||||
import StevenDimDoors.mod_pocketDim.core.NewDimData;
|
import StevenDimDoors.mod_pocketDim.core.NewDimData;
|
||||||
import StevenDimDoors.mod_pocketDim.core.PocketManager;
|
import StevenDimDoors.mod_pocketDim.core.PocketManager;
|
||||||
|
import StevenDimDoors.mod_pocketDim.items.BaseItemDoor;
|
||||||
import StevenDimDoors.mod_pocketDim.items.ItemWarpDoor;
|
import StevenDimDoors.mod_pocketDim.items.ItemWarpDoor;
|
||||||
import StevenDimDoors.mod_pocketDim.util.Point4D;
|
import StevenDimDoors.mod_pocketDim.util.Point4D;
|
||||||
import StevenDimDoors.mod_pocketDim.world.LimboProvider;
|
import StevenDimDoors.mod_pocketDim.world.LimboProvider;
|
||||||
|
@ -88,13 +89,13 @@ public class EventHookContainer
|
||||||
public void onPlayerEvent(PlayerInteractEvent event)
|
public void onPlayerEvent(PlayerInteractEvent event)
|
||||||
{
|
{
|
||||||
// Handle all door placement here
|
// Handle all door placement here
|
||||||
if(event.action == Action.LEFT_CLICK_BLOCK)
|
if (event.action == Action.LEFT_CLICK_BLOCK)
|
||||||
{
|
{
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
World world = event.entity.worldObj;
|
World world = event.entity.worldObj;
|
||||||
ItemStack stack = event.entityPlayer.inventory.getCurrentItem();
|
ItemStack stack = event.entityPlayer.inventory.getCurrentItem();
|
||||||
if (stack != null && stack.getItem() instanceof ItemDoor)
|
if (stack != null)
|
||||||
{
|
{
|
||||||
if(stack.getItem() instanceof ItemWarpDoor)
|
if(stack.getItem() instanceof ItemWarpDoor)
|
||||||
{
|
{
|
||||||
|
@ -107,13 +108,14 @@ public class EventHookContainer
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (mod_pocketDim.itemDimensionalDoor.tryToPlaceDoor(stack, event.entityPlayer, world,
|
if (BaseItemDoor.tryToPlaceDoor(stack, event.entityPlayer, world,
|
||||||
event.x, event.y, event.z, event.face))
|
event.x, event.y, event.z, event.face))
|
||||||
{
|
{
|
||||||
// Cancel the event so that we don't get two doors from vanilla doors
|
// Cancel the event so that we don't get two doors from vanilla doors
|
||||||
event.setCanceled(true);
|
event.setCanceled(true);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@ForgeSubscribe
|
@ForgeSubscribe
|
||||||
|
|
|
@ -532,10 +532,10 @@ public class DDTeleporter
|
||||||
DimLink personalHomeLink = dim.getLink(dim.origin());
|
DimLink personalHomeLink = dim.getLink(dim.origin());
|
||||||
if(personalHomeLink!=null)
|
if(personalHomeLink!=null)
|
||||||
{
|
{
|
||||||
PocketManager.getDimensionData(link.source().getDimension()).setDestination(personalHomeLink, link.source().getX(), link.source().getY(), link.source().getZ());
|
PocketManager.getDimensionData(link.source().getDimension()).setLinkDestination(personalHomeLink, link.source().getX(), link.source().getY(), link.source().getZ());
|
||||||
}
|
}
|
||||||
|
|
||||||
dim.setDestination(link, dim.origin.getX(), dim.origin.getY(), dim.origin.getZ());
|
dim.setLinkDestination(link, dim.origin.getX(), dim.origin.getY(), dim.origin.getZ());
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -598,7 +598,7 @@ public class DDTeleporter
|
||||||
Point3D destination = yCoordHelper.findDropPoint(world, source.getX(), source.getY() + 1, source.getZ());
|
Point3D destination = yCoordHelper.findDropPoint(world, source.getX(), source.getY() + 1, source.getZ());
|
||||||
if (destination != null)
|
if (destination != null)
|
||||||
{
|
{
|
||||||
current.root().setDestination(link, destination.getX(), destination.getY(), destination.getZ());
|
current.root().setLinkDestination(link, destination.getX(), destination.getY(), destination.getZ());
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -769,7 +769,7 @@ public class DDTeleporter
|
||||||
int orientation = getDestinationOrientation(source, properties);
|
int orientation = getDestinationOrientation(source, properties);
|
||||||
NewDimData sourceDim = PocketManager.getDimensionData(link.source().getDimension());
|
NewDimData sourceDim = PocketManager.getDimensionData(link.source().getDimension());
|
||||||
DimLink reverse = destinationDim.createLink(x, y + 2, z, LinkType.REVERSE,orientation);
|
DimLink reverse = destinationDim.createLink(x, y + 2, z, LinkType.REVERSE,orientation);
|
||||||
sourceDim.setDestination(reverse, source.getX(), source.getY(), source.getZ());
|
sourceDim.setLinkDestination(reverse, source.getX(), source.getY(), source.getZ());
|
||||||
|
|
||||||
// Set up the warp door at the destination
|
// Set up the warp door at the destination
|
||||||
orientation = BlockRotator.transformMetadata(orientation, 2, properties.WarpDoorID);
|
orientation = BlockRotator.transformMetadata(orientation, 2, properties.WarpDoorID);
|
||||||
|
@ -777,7 +777,7 @@ public class DDTeleporter
|
||||||
|
|
||||||
// Complete the link to the destination
|
// Complete the link to the destination
|
||||||
// This comes last so the destination isn't set unless everything else works first
|
// This comes last so the destination isn't set unless everything else works first
|
||||||
destinationDim.setDestination(link, x, y + 2, z);
|
destinationDim.setLinkDestination(link, x, y + 2, z);
|
||||||
}
|
}
|
||||||
|
|
||||||
return (destination != null);
|
return (destination != null);
|
||||||
|
|
|
@ -84,6 +84,7 @@ public abstract class DimLink
|
||||||
{
|
{
|
||||||
return tail.getDestination();
|
return tail.getDestination();
|
||||||
}
|
}
|
||||||
|
|
||||||
public int getDestinationOrientation()
|
public int getDestinationOrientation()
|
||||||
{
|
{
|
||||||
DimLink link = PocketManager.getLink(this.destination().getX(), this.destination().getY(), this.destination().getZ(), this.destination().getDimension());
|
DimLink link = PocketManager.getLink(this.destination().getX(), this.destination().getY(), this.destination().getZ(), this.destination().getDimension());
|
||||||
|
@ -93,6 +94,7 @@ public abstract class DimLink
|
||||||
}
|
}
|
||||||
return (this.orientation()+2)%4;
|
return (this.orientation()+2)%4;
|
||||||
}
|
}
|
||||||
|
|
||||||
public boolean hasDestination()
|
public boolean hasDestination()
|
||||||
{
|
{
|
||||||
return (tail.getDestination() != null);
|
return (tail.getDestination() != null);
|
||||||
|
@ -118,7 +120,7 @@ public abstract class DimLink
|
||||||
return tail.getLinkType();
|
return tail.getLinkType();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
public String toString()
|
public String toString()
|
||||||
{
|
{
|
||||||
return point + " -> " + (hasDestination() ? destination() : "");
|
return point + " -> " + (hasDestination() ? destination() : "");
|
||||||
|
|
|
@ -513,7 +513,7 @@ public abstract class NewDimData implements IPackable<PackedDimData>
|
||||||
{
|
{
|
||||||
throw new IllegalArgumentException("orientation must be between 0 and 3, inclusive.");
|
throw new IllegalArgumentException("orientation must be between 0 and 3, inclusive.");
|
||||||
}
|
}
|
||||||
setDestination(incoming, originX, originY, originZ);
|
setLinkDestination(incoming, originX, originY, originZ);
|
||||||
this.origin = incoming.destination();
|
this.origin = incoming.destination();
|
||||||
this.orientation = orientation;
|
this.orientation = orientation;
|
||||||
this.dungeon = dungeon;
|
this.dungeon = dungeon;
|
||||||
|
@ -576,13 +576,13 @@ public abstract class NewDimData implements IPackable<PackedDimData>
|
||||||
throw new IllegalStateException("The dimension has already been initialized.");
|
throw new IllegalStateException("The dimension has already been initialized.");
|
||||||
}
|
}
|
||||||
|
|
||||||
setDestination(incoming, originX, originY, originZ);
|
setLinkDestination(incoming, originX, originY, originZ);
|
||||||
this.origin = incoming.destination();
|
this.origin = incoming.destination();
|
||||||
this.orientation = orientation;
|
this.orientation = orientation;
|
||||||
this.modified = true;
|
this.modified = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setDestination(DimLink incoming, int x, int y, int z)
|
public void setLinkDestination(DimLink incoming, int x, int y, int z)
|
||||||
{
|
{
|
||||||
InnerDimLink link = (InnerDimLink) incoming;
|
InnerDimLink link = (InnerDimLink) incoming;
|
||||||
link.setDestination(x, y, z, this);
|
link.setDestination(x, y, z, this);
|
||||||
|
|
|
@ -324,7 +324,7 @@ public class DungeonSchematic extends Schematic {
|
||||||
DimLink reverseLink = dimension.createLink(pocketCenter.getX(), pocketCenter.getY(), pocketCenter.getZ(), LinkType.REVERSE, orientation);
|
DimLink reverseLink = dimension.createLink(pocketCenter.getX(), pocketCenter.getY(), pocketCenter.getZ(), LinkType.REVERSE, orientation);
|
||||||
Point4D destination = entryLink.source();
|
Point4D destination = entryLink.source();
|
||||||
NewDimData prevDim = PocketManager.getDimensionData(destination.getDimension());
|
NewDimData prevDim = PocketManager.getDimensionData(destination.getDimension());
|
||||||
prevDim.setDestination(reverseLink, destination.getX(), destination.getY(), destination.getZ());
|
prevDim.setLinkDestination(reverseLink, destination.getX(), destination.getY(), destination.getZ());
|
||||||
initDoorTileEntity(world, pocketCenter);
|
initDoorTileEntity(world, pocketCenter);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -2,6 +2,7 @@ package StevenDimDoors.mod_pocketDim.items;
|
||||||
|
|
||||||
import java.util.HashMap;
|
import java.util.HashMap;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
import net.minecraft.block.Block;
|
import net.minecraft.block.Block;
|
||||||
import net.minecraft.block.material.Material;
|
import net.minecraft.block.material.Material;
|
||||||
import net.minecraft.client.renderer.texture.IconRegister;
|
import net.minecraft.client.renderer.texture.IconRegister;
|
||||||
|
@ -23,9 +24,9 @@ import StevenDimDoors.mod_pocketDim.tileentities.TileEntityDimDoor;
|
||||||
|
|
||||||
public abstract class BaseItemDoor extends ItemDoor
|
public abstract class BaseItemDoor extends ItemDoor
|
||||||
{
|
{
|
||||||
// maps non-dimensional door items to their corresponding dimensional door
|
// Maps non-dimensional door items to their corresponding dimensional door item
|
||||||
// item
|
// Also maps dimensional door items to themselves for simplicity
|
||||||
private static HashMap<ItemDoor, BaseItemDoor> vanillaDoorMapping = new HashMap<ItemDoor, BaseItemDoor>();
|
private static HashMap<ItemDoor, BaseItemDoor> doorItemMapping = new HashMap<ItemDoor, BaseItemDoor>();
|
||||||
private static DDProperties properties = null;
|
private static DDProperties properties = null;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -34,7 +35,7 @@ public abstract class BaseItemDoor extends ItemDoor
|
||||||
* @param material
|
* @param material
|
||||||
* @param door
|
* @param door
|
||||||
*/
|
*/
|
||||||
public BaseItemDoor(int itemID, Material material, ItemDoor door)
|
public BaseItemDoor(int itemID, Material material, ItemDoor vanillaDoor)
|
||||||
{
|
{
|
||||||
super(itemID, material);
|
super(itemID, material);
|
||||||
this.setMaxStackSize(64);
|
this.setMaxStackSize(64);
|
||||||
|
@ -42,9 +43,10 @@ public abstract class BaseItemDoor extends ItemDoor
|
||||||
if (properties == null)
|
if (properties == null)
|
||||||
properties = DDProperties.instance();
|
properties = DDProperties.instance();
|
||||||
|
|
||||||
if(door!=null)
|
doorItemMapping.put(this, this);
|
||||||
|
if (vanillaDoor != null)
|
||||||
{
|
{
|
||||||
vanillaDoorMapping.put(door, this);
|
doorItemMapping.put(vanillaDoor, this);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -64,7 +66,7 @@ public abstract class BaseItemDoor extends ItemDoor
|
||||||
*
|
*
|
||||||
* @return
|
* @return
|
||||||
*/
|
*/
|
||||||
protected abstract BaseDimDoor getDoortoItemMapping();
|
protected abstract BaseDimDoor getDoorBlock();
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Overriden here to remove vanilla block placement functionality from
|
* Overriden here to remove vanilla block placement functionality from
|
||||||
|
@ -73,23 +75,12 @@ public abstract class BaseItemDoor extends ItemDoor
|
||||||
@Override
|
@Override
|
||||||
public boolean onItemUse(ItemStack stack, EntityPlayer player, World world, int x, int y, int z, int side, float hitX, float hitY, float hitZ)
|
public boolean onItemUse(ItemStack stack, EntityPlayer player, World world, int x, int y, int z, int side, float hitX, float hitY, float hitZ)
|
||||||
{
|
{
|
||||||
// TODO Auto-generated method stub
|
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
public static BaseDimDoor getDoorToPlace(Item item)
|
|
||||||
{
|
|
||||||
if (!(item instanceof BaseItemDoor))
|
|
||||||
{
|
|
||||||
item = BaseItemDoor.vanillaDoorMapping.get(item);
|
|
||||||
}
|
|
||||||
return ((BaseItemDoor) item).getDoortoItemMapping();
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Tries to place a door block, called in EventHookContainer
|
* Tries to place a door as a dimensional door
|
||||||
*
|
*
|
||||||
* @param doorBlock
|
|
||||||
* @param stack
|
* @param stack
|
||||||
* @param player
|
* @param player
|
||||||
* @param world
|
* @param world
|
||||||
|
@ -97,8 +88,6 @@ public abstract class BaseItemDoor extends ItemDoor
|
||||||
* @param y
|
* @param y
|
||||||
* @param z
|
* @param z
|
||||||
* @param side
|
* @param side
|
||||||
* @param requireLink
|
|
||||||
* @param reduceStack
|
|
||||||
* @return
|
* @return
|
||||||
*/
|
*/
|
||||||
public static boolean tryToPlaceDoor(ItemStack stack, EntityPlayer player, World world, int x, int y, int z, int side)
|
public static boolean tryToPlaceDoor(ItemStack stack, EntityPlayer player, World world, int x, int y, int z, int side)
|
||||||
|
@ -107,15 +96,20 @@ public abstract class BaseItemDoor extends ItemDoor
|
||||||
{
|
{
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
if (!(stack.getItem() instanceof ItemDoor))
|
// Retrieve the actual door type that we want to use here.
|
||||||
|
// It's okay if stack isn't an ItemDoor. In that case, the lookup will
|
||||||
|
// return null, just as if the item was an unrecognized door type.
|
||||||
|
BaseItemDoor mappedItem = doorItemMapping.get(stack.getItem());
|
||||||
|
if (mappedItem == null)
|
||||||
{
|
{
|
||||||
throw new IllegalArgumentException("The itemstack must correspond to some type of door");
|
return false;
|
||||||
}
|
}
|
||||||
if (BaseItemDoor.placeDoorOnBlock(getDoorToPlace(stack.getItem()), stack, player, world, x, y, z, side))
|
BaseDimDoor doorBlock = mappedItem.getDoorBlock();
|
||||||
|
if (BaseItemDoor.placeDoorOnBlock(doorBlock, stack, player, world, x, y, z, side))
|
||||||
{
|
{
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
return BaseItemDoor.placeDoorOnRift(getDoorToPlace(stack.getItem()), world, player, stack);
|
return BaseItemDoor.placeDoorOnRift(doorBlock, world, player, stack);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
|
@ -28,7 +28,7 @@ public class ItemDimensionalDoor extends BaseItemDoor
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected BaseDimDoor getDoortoItemMapping()
|
protected BaseDimDoor getDoorBlock()
|
||||||
{
|
{
|
||||||
return (BaseDimDoor) mod_pocketDim.dimensionalDoor;
|
return (BaseDimDoor) mod_pocketDim.dimensionalDoor;
|
||||||
}
|
}
|
||||||
|
|
|
@ -28,7 +28,7 @@ public class ItemGoldDimDoor extends BaseItemDoor
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected BaseDimDoor getDoortoItemMapping()
|
protected BaseDimDoor getDoorBlock()
|
||||||
{
|
{
|
||||||
return (BaseDimDoor) mod_pocketDim.goldenDimensionalDoor;
|
return (BaseDimDoor) mod_pocketDim.goldenDimensionalDoor;
|
||||||
}
|
}
|
||||||
|
|
|
@ -15,6 +15,7 @@ public class ItemGoldDoor extends ItemDoor
|
||||||
public ItemGoldDoor(int par1, Material par2Material)
|
public ItemGoldDoor(int par1, Material par2Material)
|
||||||
{
|
{
|
||||||
super(par1, par2Material);
|
super(par1, par2Material);
|
||||||
|
this.setMaxStackSize(16);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|
|
@ -28,7 +28,7 @@ public class ItemPersonalDoor extends BaseItemDoor
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected BaseDimDoor getDoortoItemMapping()
|
protected BaseDimDoor getDoorBlock()
|
||||||
{
|
{
|
||||||
return (BaseDimDoor) mod_pocketDim.personalDimDoor;
|
return (BaseDimDoor) mod_pocketDim.personalDimDoor;
|
||||||
}
|
}
|
||||||
|
|
|
@ -33,12 +33,13 @@ public class ItemRiftSignature extends Item
|
||||||
|
|
||||||
@SideOnly(Side.CLIENT)
|
@SideOnly(Side.CLIENT)
|
||||||
@Override
|
@Override
|
||||||
public boolean hasEffect(ItemStack stack)
|
public boolean hasEffect(ItemStack stack, int pass)
|
||||||
{
|
{
|
||||||
//Make the item glow if it has one endpoint stored
|
//Make the item glow if it has one endpoint stored
|
||||||
return (stack.getItemDamage() != 0);
|
return (stack.getItemDamage() != 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
public void registerIcons(IconRegister par1IconRegister)
|
public void registerIcons(IconRegister par1IconRegister)
|
||||||
{
|
{
|
||||||
this.itemIcon = par1IconRegister.registerIcon(mod_pocketDim.modid + ":" + this.getUnlocalizedName().replace("item.", ""));
|
this.itemIcon = par1IconRegister.registerIcon(mod_pocketDim.modid + ":" + this.getUnlocalizedName().replace("item.", ""));
|
||||||
|
@ -59,23 +60,24 @@ public class ItemRiftSignature extends Item
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
y += 2; //Increase y by 2 to place the rift at head level
|
//Increase y by 2 to place the rift at head level
|
||||||
if (!player.canPlayerEdit(x, y, z, side, stack))
|
int adjustedY = adjustYForSpecialBlocks(world, x, y + 2, z);
|
||||||
|
if (!player.canPlayerEdit(x, adjustedY, z, side, stack))
|
||||||
{
|
{
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
int adjustedY = adjustYForSpecialBlocks(world,x,y,z);
|
|
||||||
Point4DOrientation source = getSource(stack);
|
Point4DOrientation source = getSource(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 (source != null)
|
if (source != null)
|
||||||
{
|
{
|
||||||
//The link was used before and already has an endpoint stored. Create links connecting the two endpoints.
|
//The link was used before and already has an endpoint stored. Create links connecting the two endpoints.
|
||||||
NewDimData sourceDimension = PocketManager.getDimensionData(source.getDimension());
|
NewDimData sourceDimension = PocketManager.getDimensionData(source.getDimension());
|
||||||
NewDimData destinationDimension = PocketManager.getDimensionData(world);
|
NewDimData destinationDimension = PocketManager.getDimensionData(world);
|
||||||
|
|
||||||
DimLink link = sourceDimension.createLink(source.getX(), source.getY(), source.getZ(), LinkType.NORMAL,source.getOrientation());
|
DimLink link = sourceDimension.createLink(source.getX(), source.getY(), source.getZ(), LinkType.NORMAL,source.getOrientation());
|
||||||
DimLink reverse = destinationDimension.createLink(x, adjustedY, z, LinkType.NORMAL,orientation);
|
DimLink reverse = destinationDimension.createLink(x, adjustedY, z, LinkType.NORMAL,orientation);
|
||||||
destinationDimension.setDestination(link, x, adjustedY, z);
|
destinationDimension.setLinkDestination(link, x, adjustedY, z);
|
||||||
sourceDimension.setDestination(reverse, source.getX(), source.getY(), source.getZ());
|
sourceDimension.setLinkDestination(reverse, source.getX(), source.getY(), source.getZ());
|
||||||
|
|
||||||
//Try placing a rift at the destination point
|
//Try placing a rift at the destination point
|
||||||
if (!mod_pocketDim.blockRift.isBlockImmune(world, x, adjustedY, z))
|
if (!mod_pocketDim.blockRift.isBlockImmune(world, x, adjustedY, z))
|
||||||
|
@ -112,6 +114,7 @@ public class ItemRiftSignature extends Item
|
||||||
/**
|
/**
|
||||||
* allows items to add custom lines of information to the mouseover description
|
* allows items to add custom lines of information to the mouseover description
|
||||||
*/
|
*/
|
||||||
|
@Override
|
||||||
@SuppressWarnings({ "unchecked", "rawtypes" })
|
@SuppressWarnings({ "unchecked", "rawtypes" })
|
||||||
@SideOnly(Side.CLIENT)
|
@SideOnly(Side.CLIENT)
|
||||||
public void addInformation(ItemStack par1ItemStack, EntityPlayer par2EntityPlayer, List par3List, boolean par4)
|
public void addInformation(ItemStack par1ItemStack, EntityPlayer par2EntityPlayer, List par3List, boolean par4)
|
||||||
|
@ -139,26 +142,28 @@ public class ItemRiftSignature extends Item
|
||||||
*/
|
*/
|
||||||
public static int adjustYForSpecialBlocks(World world, int x, int y, int z)
|
public static int adjustYForSpecialBlocks(World world, int x, int y, int z)
|
||||||
{
|
{
|
||||||
y=y-2;//get the block the player actually clicked on
|
int targetY = y - 2; // Get the block the player actually clicked on
|
||||||
Block block = Block.blocksList[world.getBlockId(x, y, z)];
|
Block block = Block.blocksList[world.getBlockId(x, targetY, z)];
|
||||||
if(block==null)
|
if (block == null)
|
||||||
{
|
{
|
||||||
return y+2;
|
return targetY + 2;
|
||||||
}
|
}
|
||||||
if(block.isBlockReplaceable(world, x, y, z))
|
if (block.isBlockReplaceable(world, x, targetY, z))
|
||||||
{
|
{
|
||||||
return y+1;//move block placement down (-2+1) one so its directly over things like snow
|
return targetY + 1; // Move block placement down (-2+1) one so its directly over things like snow
|
||||||
}
|
}
|
||||||
if(block instanceof BaseDimDoor)
|
if (block instanceof BaseDimDoor)
|
||||||
{
|
{
|
||||||
if(world.getBlockId(x, y-1, z)==block.blockID&&world.getBlockMetadata(x, y, z)==8)
|
if (((BaseDimDoor) block).isUpperDoorBlock(world.getBlockMetadata(x, targetY, z)))
|
||||||
{
|
{
|
||||||
return y;//move rift placement down two so its in the right place on the door.
|
return targetY; // Move rift placement down two so its in the right place on the door.
|
||||||
}
|
}
|
||||||
return y+1;
|
// Move rift placement down one so its in the right place on the door.
|
||||||
|
return targetY + 1;
|
||||||
}
|
}
|
||||||
return y+2;
|
return targetY + 2;
|
||||||
}
|
}
|
||||||
|
|
||||||
public static void setSource(ItemStack itemStack, int x, int y, int z, int orientation, NewDimData dimension)
|
public static void setSource(ItemStack itemStack, int x, int y, int z, int orientation, NewDimData dimension)
|
||||||
{
|
{
|
||||||
NBTTagCompound tag = new NBTTagCompound();
|
NBTTagCompound tag = new NBTTagCompound();
|
||||||
|
@ -199,11 +204,12 @@ public class ItemRiftSignature extends Item
|
||||||
Integer orientation = tag.getInteger("orientation");
|
Integer orientation = tag.getInteger("orientation");
|
||||||
Integer dimID = tag.getInteger("linkDimID");
|
Integer dimID = tag.getInteger("linkDimID");
|
||||||
|
|
||||||
if (x != null && y != null && z != null && dimID != null)
|
if (x != null && y != null && z != null && orientation != null && dimID != null)
|
||||||
{
|
{
|
||||||
return new Point4DOrientation(x, y, z,orientation, dimID);
|
return new Point4DOrientation(x, y, z, orientation, dimID);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
// Mark the item as uninitialized if its source couldn't be read
|
||||||
itemStack.setItemDamage(0);
|
itemStack.setItemDamage(0);
|
||||||
}
|
}
|
||||||
return null;
|
return null;
|
||||||
|
@ -213,10 +219,11 @@ public class ItemRiftSignature extends Item
|
||||||
{
|
{
|
||||||
private Point4D point;
|
private Point4D point;
|
||||||
private int orientation;
|
private int orientation;
|
||||||
|
|
||||||
Point4DOrientation(int x, int y, int z, int orientation, int dimID)
|
Point4DOrientation(int x, int y, int z, int orientation, int dimID)
|
||||||
{
|
{
|
||||||
this.point= new Point4D(x,y,z,dimID);
|
this.point = new Point4D(x, y, z, dimID);
|
||||||
this.orientation=orientation;
|
this.orientation = orientation;
|
||||||
}
|
}
|
||||||
|
|
||||||
int getX()
|
int getX()
|
||||||
|
@ -238,10 +245,16 @@ public class ItemRiftSignature extends Item
|
||||||
{
|
{
|
||||||
return point.getDimension();
|
return point.getDimension();
|
||||||
}
|
}
|
||||||
|
|
||||||
int getOrientation()
|
int getOrientation()
|
||||||
{
|
{
|
||||||
return orientation;
|
return orientation;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Point4D getPoint()
|
||||||
|
{
|
||||||
|
return point;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -38,22 +38,43 @@ public class ItemStabilizedRiftSignature extends ItemRiftSignature
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
// We don't check for replaceable blocks. The user can deal with that. <_<
|
// Adjust Y so the rift is at head level, depending on the presence of certain blocks
|
||||||
y += 2; //Increase y by 2 to place the rift at head level
|
int adjustedY = adjustYForSpecialBlocks(world, x, y + 2, z);
|
||||||
if (!player.canPlayerEdit(x, y, z, side, stack))
|
if (!player.canPlayerEdit(x, adjustedY, z, side, stack))
|
||||||
{
|
{
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
Point4DOrientation source = getSource(stack);
|
int orientation = MathHelper.floor_double((player.rotationYaw + 180.0F) * 4.0F / 360.0F - 0.5D) & 3;
|
||||||
int adjustedY = adjustYForSpecialBlocks(world,x,y,z);
|
|
||||||
|
|
||||||
// Check if the Stabilized Rift Signature has been initialized
|
// Check if the Stabilized Rift Signature has been initialized
|
||||||
int orientation = MathHelper.floor_double((player.rotationYaw + 180.0F) * 4.0F / 360.0F - 0.5D) & 3;
|
Point4DOrientation source = getSource(stack);
|
||||||
if (source != null)
|
if (source != null)
|
||||||
{
|
{
|
||||||
// Yes, it's initialized. Check if the player is in creative
|
|
||||||
// or if the player can pay with Stable Fabric to create a rift.
|
// Yes, it's initialized.
|
||||||
if (!player.capabilities.isCreativeMode && !player.inventory.hasItem(Item.enderPearl.itemID))
|
NewDimData sourceDimension = PocketManager.getDimensionData(source.getDimension());
|
||||||
|
NewDimData destinationDimension = PocketManager.getDimensionData(world);
|
||||||
|
DimLink reverse = destinationDimension.getLink(x, adjustedY, z);
|
||||||
|
DimLink link;
|
||||||
|
|
||||||
|
// Check whether the SRS is being used to restore one of its previous
|
||||||
|
// link pairs. In other words, the SRS is being used on a location
|
||||||
|
// that already has a link pointing to the SRS's source, with the
|
||||||
|
// intention of overwriting the source-side link to point there.
|
||||||
|
// Those benign redirection operations will be handled for free.
|
||||||
|
|
||||||
|
if (reverse != null && source.getPoint().equals(reverse.destination()))
|
||||||
|
{
|
||||||
|
// Only the source-to-destination link is needed.
|
||||||
|
link = sourceDimension.createLink(source.getX(), source.getY(), source.getZ(), LinkType.NORMAL, source.getOrientation());
|
||||||
|
destinationDimension.setLinkDestination(link, x, adjustedY, z);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
// Check if the player is in creative mode,
|
||||||
|
// or if the player can pay with an Ender Pearl to create a rift.
|
||||||
|
if (!player.capabilities.isCreativeMode &&
|
||||||
|
!player.inventory.consumeInventoryItem(Item.enderPearl.itemID))
|
||||||
{
|
{
|
||||||
mod_pocketDim.sendChat(player, "You don't have any Ender Pearls!");
|
mod_pocketDim.sendChat(player, "You don't have any Ender Pearls!");
|
||||||
// I won't do this, but this is the chance to localize chat
|
// I won't do this, but this is the chance to localize chat
|
||||||
|
@ -62,21 +83,72 @@ public class ItemStabilizedRiftSignature extends ItemRiftSignature
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
//The link was used before and already has an endpoint stored. Create links connecting the two endpoints.
|
// Create links connecting the two endpoints.
|
||||||
NewDimData sourceDimension = PocketManager.getDimensionData(source.getDimension());
|
link = sourceDimension.createLink(source.getX(), source.getY(), source.getZ(), LinkType.NORMAL, source.getOrientation());
|
||||||
NewDimData destinationDimension = PocketManager.getDimensionData(world);
|
reverse = destinationDimension.createLink(x, adjustedY, z, LinkType.NORMAL, orientation);
|
||||||
DimLink link = sourceDimension.createLink(source.getX(), source.getY(), source.getZ(), LinkType.NORMAL,source.getOrientation());
|
destinationDimension.setLinkDestination(link, x, adjustedY, z);
|
||||||
DimLink reverse = destinationDimension.createLink(x, adjustedY, z, LinkType.NORMAL,orientation);
|
sourceDimension.setLinkDestination(reverse, source.getX(), source.getY(), source.getZ());
|
||||||
destinationDimension.setDestination(link, x, adjustedY, z);
|
|
||||||
sourceDimension.setDestination(reverse, source.getX(), source.getY(), source.getZ());
|
|
||||||
|
|
||||||
//Try placing a rift at the destination point
|
// Try placing a rift at the destination point
|
||||||
if (!mod_pocketDim.blockRift.isBlockImmune(world, x, adjustedY, z))
|
if (!mod_pocketDim.blockRift.isBlockImmune(world, x, adjustedY, z))
|
||||||
{
|
{
|
||||||
world.setBlock(x, adjustedY, z, mod_pocketDim.blockRift.blockID);
|
world.setBlock(x, adjustedY, z, mod_pocketDim.blockRift.blockID);
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
//Try placing a rift at the source point, but check if its world is loaded first
|
// Try placing a rift at the source point, but check if its world is loaded first
|
||||||
|
World sourceWorld = DimensionManager.getWorld(sourceDimension.id());
|
||||||
|
if (sourceWorld != null &&
|
||||||
|
!mod_pocketDim.blockRift.isBlockImmune(sourceWorld, source.getX(), source.getY(), source.getZ()))
|
||||||
|
{
|
||||||
|
sourceWorld.setBlock(source.getX(), source.getY(), source.getZ(), mod_pocketDim.blockRift.blockID);
|
||||||
|
}
|
||||||
|
mod_pocketDim.sendChat(player, "Rift Created");
|
||||||
|
world.playSoundAtEntity(player, "mods.DimDoors.sfx.riftEnd", 0.6f, 1);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
// The link signature has not been used. Store its current target as the first location.
|
||||||
|
setSource(stack, x, adjustedY, z, orientation, PocketManager.getDimensionData(world));
|
||||||
|
mod_pocketDim.sendChat(player,"Location Stored in Stabilized Rift Signature");
|
||||||
|
world.playSoundAtEntity(player,"mods.DimDoors.sfx.riftStart", 0.6f, 1);
|
||||||
|
}
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
public static boolean useFromDispenser(ItemStack stack, World world, int x, int y, int z)
|
||||||
|
{
|
||||||
|
// Stabilized Rift Signatures can only be used from dispensers to restore
|
||||||
|
// a previous link pair. The operation would be free for a player, so
|
||||||
|
// dispensers can also perform it for free. Otherwise, the item does nothing.
|
||||||
|
if (world.isRemote)
|
||||||
|
{
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Adjust Y so the rift is at head level, depending on the presence of certain blocks
|
||||||
|
int adjustedY = adjustYForSpecialBlocks(world, x, y + 2, z);
|
||||||
|
Point4DOrientation source = getSource(stack);
|
||||||
|
|
||||||
|
// The SRS must have been initialized
|
||||||
|
if (source != null)
|
||||||
|
{
|
||||||
|
NewDimData sourceDimension = PocketManager.getDimensionData(source.getDimension());
|
||||||
|
NewDimData destinationDimension = PocketManager.getDimensionData(world);
|
||||||
|
DimLink reverse = destinationDimension.getLink(x, adjustedY, z);
|
||||||
|
DimLink link;
|
||||||
|
|
||||||
|
// Check whether the SRS is being used to restore one of its previous
|
||||||
|
// link pairs. In other words, the SRS is being used on a location
|
||||||
|
// that already has a link pointing to the SRS's source, with the
|
||||||
|
// intention of overwriting the source-side link to point there.
|
||||||
|
if (reverse != null && source.getPoint().equals(reverse.destination()))
|
||||||
|
{
|
||||||
|
// Only the source-to-destination link is needed.
|
||||||
|
link = sourceDimension.createLink(source.getX(), source.getY(), source.getZ(), LinkType.NORMAL, source.getOrientation());
|
||||||
|
destinationDimension.setLinkDestination(link, x, adjustedY, z);
|
||||||
|
|
||||||
|
// Try placing a rift at the source point, but check if its world is loaded first
|
||||||
World sourceWorld = DimensionManager.getWorld(sourceDimension.id());
|
World sourceWorld = DimensionManager.getWorld(sourceDimension.id());
|
||||||
if (sourceWorld != null &&
|
if (sourceWorld != null &&
|
||||||
!mod_pocketDim.blockRift.isBlockImmune(sourceWorld, source.getX(), source.getY(), source.getZ()))
|
!mod_pocketDim.blockRift.isBlockImmune(sourceWorld, source.getX(), source.getY(), source.getZ()))
|
||||||
|
@ -84,22 +156,13 @@ public class ItemStabilizedRiftSignature extends ItemRiftSignature
|
||||||
sourceWorld.setBlock(source.getX(), source.getY(), source.getZ(), mod_pocketDim.blockRift.blockID);
|
sourceWorld.setBlock(source.getX(), source.getY(), source.getZ(), mod_pocketDim.blockRift.blockID);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!player.capabilities.isCreativeMode)
|
// This call doesn't seem to be working...
|
||||||
{
|
world.playSoundEffect(x + 0.5, adjustedY + 0.5, z + 0.5, "mods.DimDoors.sfx.riftEnd", 0.6f, 1);
|
||||||
player.inventory.consumeInventoryItem(Item.enderPearl.itemID);
|
|
||||||
}
|
|
||||||
mod_pocketDim.sendChat(player,"Rift Created");
|
|
||||||
world.playSoundAtEntity(player,"mods.DimDoors.sfx.riftEnd", 0.6f, 1);
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
//The link signature has not been used. Store its current target as the first location.
|
|
||||||
setSource(stack, x, adjustedY, z, orientation, PocketManager.getDimensionData(world));
|
|
||||||
mod_pocketDim.sendChat(player,"Location Stored in Stabilized Rift Signature");
|
|
||||||
world.playSoundAtEntity(player,"mods.DimDoors.sfx.riftStart", 0.6f, 1);
|
|
||||||
}
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* allows items to add custom lines of information to the mouseover description
|
* allows items to add custom lines of information to the mouseover description
|
||||||
|
|
|
@ -25,7 +25,7 @@ public class ItemUnstableDoor extends BaseItemDoor
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected BaseDimDoor getDoortoItemMapping()
|
protected BaseDimDoor getDoorBlock()
|
||||||
{
|
{
|
||||||
return (BaseDimDoor) mod_pocketDim.unstableDoor;
|
return (BaseDimDoor) mod_pocketDim.unstableDoor;
|
||||||
}
|
}
|
||||||
|
|
|
@ -28,7 +28,7 @@ public class ItemWarpDoor extends BaseItemDoor
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected BaseDimDoor getDoortoItemMapping()
|
protected BaseDimDoor getDoorBlock()
|
||||||
{
|
{
|
||||||
return (BaseDimDoor) mod_pocketDim.warpDoor;
|
return (BaseDimDoor) mod_pocketDim.warpDoor;
|
||||||
}
|
}
|
||||||
|
|
|
@ -0,0 +1,42 @@
|
||||||
|
package StevenDimDoors.mod_pocketDim.items.behaviors;
|
||||||
|
|
||||||
|
import net.minecraft.block.BlockDispenser;
|
||||||
|
import net.minecraft.dispenser.BehaviorDefaultDispenseItem;
|
||||||
|
import net.minecraft.dispenser.IBlockSource;
|
||||||
|
import net.minecraft.item.ItemStack;
|
||||||
|
import net.minecraft.util.EnumFacing;
|
||||||
|
import net.minecraft.world.World;
|
||||||
|
import StevenDimDoors.mod_pocketDim.items.ItemStabilizedRiftSignature;
|
||||||
|
|
||||||
|
public class DispenserBehaviorStabilizedRS extends BehaviorDefaultDispenseItem
|
||||||
|
{
|
||||||
|
@Override
|
||||||
|
public ItemStack dispenseStack(IBlockSource dispenser, ItemStack stack)
|
||||||
|
{
|
||||||
|
// Search for a non-air block up to 3 blocks in front of a dispenser.
|
||||||
|
// If it's found, call ItemStabilizedRiftSignature.useFromDispenser().
|
||||||
|
int x = dispenser.getXInt();
|
||||||
|
int y = dispenser.getYInt();
|
||||||
|
int z = dispenser.getZInt();
|
||||||
|
EnumFacing facing = BlockDispenser.getFacing(dispenser.getBlockMetadata());
|
||||||
|
int dx = facing.getFrontOffsetX();
|
||||||
|
int dy = facing.getFrontOffsetY();
|
||||||
|
int dz = facing.getFrontOffsetZ();
|
||||||
|
World world = dispenser.getWorld();
|
||||||
|
|
||||||
|
for (int k = 1; k <= 3; k++)
|
||||||
|
{
|
||||||
|
x += dx;
|
||||||
|
y += dy;
|
||||||
|
z += dz;
|
||||||
|
if (!world.isAirBlock(x, y, z))
|
||||||
|
{
|
||||||
|
// Found a block. Activate the item.
|
||||||
|
ItemStabilizedRiftSignature.useFromDispenser(stack, world, x, y, z);
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
// The item stack isn't modified
|
||||||
|
return stack;
|
||||||
|
}
|
||||||
|
}
|
|
@ -141,10 +141,10 @@ public class mod_pocketDim
|
||||||
public static Item itemRiftSignature;
|
public static Item itemRiftSignature;
|
||||||
public static Item itemStableFabric;
|
public static Item itemStableFabric;
|
||||||
public static Item itemUnstableDoor;
|
public static Item itemUnstableDoor;
|
||||||
public static Item itemStabilizedLinkSignature;
|
|
||||||
public static Item itemDDKey;
|
public static Item itemDDKey;
|
||||||
public static Item itemQuartzDoor;
|
public static Item itemQuartzDoor;
|
||||||
public static Item itemPersonalDoor;
|
public static Item itemPersonalDoor;
|
||||||
|
public static Item itemStabilizedRiftSignature;
|
||||||
|
|
||||||
public static BiomeGenBase limboBiome;
|
public static BiomeGenBase limboBiome;
|
||||||
public static BiomeGenBase pocketBiome;
|
public static BiomeGenBase pocketBiome;
|
||||||
|
@ -233,7 +233,7 @@ public class mod_pocketDim
|
||||||
itemStableFabric = (new ItemStableFabric(properties.StableFabricItemID, 0)).setUnlocalizedName("itemStableFabric");
|
itemStableFabric = (new ItemStableFabric(properties.StableFabricItemID, 0)).setUnlocalizedName("itemStableFabric");
|
||||||
itemUnstableDoor = (new ItemUnstableDoor(properties.UnstableDoorItemID, Material.iron, null)).setUnlocalizedName("itemChaosDoor");
|
itemUnstableDoor = (new ItemUnstableDoor(properties.UnstableDoorItemID, Material.iron, null)).setUnlocalizedName("itemChaosDoor");
|
||||||
itemRiftBlade = (new ItemRiftBlade(properties.RiftBladeItemID, properties)).setUnlocalizedName("ItemRiftBlade");
|
itemRiftBlade = (new ItemRiftBlade(properties.RiftBladeItemID, properties)).setUnlocalizedName("ItemRiftBlade");
|
||||||
itemStabilizedLinkSignature = (new ItemStabilizedRiftSignature(properties.StabilizedRiftSignatureItemID)).setUnlocalizedName("itemStabilizedRiftSig");
|
itemStabilizedRiftSignature = (new ItemStabilizedRiftSignature(properties.StabilizedRiftSignatureItemID)).setUnlocalizedName("itemStabilizedRiftSig");
|
||||||
itemWorldThread = (new ItemWorldThread(properties.WorldThreadItemID)).setUnlocalizedName("itemWorldThread");
|
itemWorldThread = (new ItemWorldThread(properties.WorldThreadItemID)).setUnlocalizedName("itemWorldThread");
|
||||||
|
|
||||||
// Check if other biomes have been registered with the same IDs we want. If so, crash Minecraft
|
// Check if other biomes have been registered with the same IDs we want. If so, crash Minecraft
|
||||||
|
@ -284,7 +284,7 @@ public class mod_pocketDim
|
||||||
LanguageRegistry.addName(itemRiftSignature, "Rift Signature");
|
LanguageRegistry.addName(itemRiftSignature, "Rift Signature");
|
||||||
LanguageRegistry.addName(itemGoldenDoor, "Golden Door");
|
LanguageRegistry.addName(itemGoldenDoor, "Golden Door");
|
||||||
LanguageRegistry.addName(itemGoldenDimensionalDoor, "Golden Dimensional Door");
|
LanguageRegistry.addName(itemGoldenDimensionalDoor, "Golden Dimensional Door");
|
||||||
LanguageRegistry.addName(itemStabilizedLinkSignature, "Stabilized Rift Signature");
|
LanguageRegistry.addName(itemStabilizedRiftSignature, "Stabilized Rift Signature");
|
||||||
LanguageRegistry.addName(itemRiftRemover, "Rift Remover");
|
LanguageRegistry.addName(itemRiftRemover, "Rift Remover");
|
||||||
LanguageRegistry.addName(itemStableFabric, "Stable Fabric");
|
LanguageRegistry.addName(itemStableFabric, "Stable Fabric");
|
||||||
LanguageRegistry.addName(itemUnstableDoor, "Unstable Door");
|
LanguageRegistry.addName(itemUnstableDoor, "Unstable Door");
|
||||||
|
@ -316,7 +316,9 @@ public class mod_pocketDim
|
||||||
LanguageRegistry.instance().addStringLocalization("entity.dimdoors.Monolith.name", "Monolith");
|
LanguageRegistry.instance().addStringLocalization("entity.dimdoors.Monolith.name", "Monolith");
|
||||||
|
|
||||||
CraftingManager.registerRecipes(properties);
|
CraftingManager.registerRecipes(properties);
|
||||||
|
CraftingManager.registerDispenserBehaviors();
|
||||||
GameRegistry.registerCraftingHandler(new CraftingManager());
|
GameRegistry.registerCraftingHandler(new CraftingManager());
|
||||||
|
|
||||||
DungeonHelper.initialize();
|
DungeonHelper.initialize();
|
||||||
gatewayGenerator = new GatewayGenerator(properties);
|
gatewayGenerator = new GatewayGenerator(properties);
|
||||||
GameRegistry.registerWorldGenerator(mod_pocketDim.gatewayGenerator);
|
GameRegistry.registerWorldGenerator(mod_pocketDim.gatewayGenerator);
|
||||||
|
|
|
@ -215,7 +215,7 @@ public class DDSaveHandler
|
||||||
Point4D destination = packedLink.tail.destination;
|
Point4D destination = packedLink.tail.destination;
|
||||||
if(destination!=null)
|
if(destination!=null)
|
||||||
{
|
{
|
||||||
PocketManager.getDimensionData(destination.getDimension()).setDestination(link, destination.getX(),destination.getY(),destination.getZ());
|
PocketManager.getDimensionData(destination.getDimension()).setLinkDestination(link, destination.getX(),destination.getY(),destination.getZ());
|
||||||
}
|
}
|
||||||
unpackedLinks.add(packedLink);
|
unpackedLinks.add(packedLink);
|
||||||
}
|
}
|
||||||
|
|
|
@ -145,9 +145,13 @@ public class MobMonolith extends EntityFlying implements IMob
|
||||||
if (player != null)
|
if (player != null)
|
||||||
{
|
{
|
||||||
this.facePlayer(player);
|
this.facePlayer(player);
|
||||||
if (!this.worldObj.isRemote)
|
if (!this.worldObj.isRemote && !(this.worldObj.provider instanceof LimboProvider))
|
||||||
{
|
{
|
||||||
// Play sounds on the server side
|
// Play sounds on the server side, if the player isn't in Limbo.
|
||||||
|
// Limbo is excluded to avoid drowning out its background music.
|
||||||
|
// Also, since it's a large open area with many Monoliths, some
|
||||||
|
// of the sounds that would usually play for a moment would
|
||||||
|
// keep playing constantly and would get very annoying.
|
||||||
this.playSounds(player);
|
this.playSounds(player);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -161,7 +165,8 @@ public class MobMonolith extends EntityFlying implements IMob
|
||||||
|
|
||||||
// Teleport the target player if various conditions are met
|
// Teleport the target player if various conditions are met
|
||||||
if (aggro >= MAX_AGGRO && !this.worldObj.isRemote &&
|
if (aggro >= MAX_AGGRO && !this.worldObj.isRemote &&
|
||||||
properties.MonolithTeleportationEnabled && !player.capabilities.isCreativeMode)
|
properties.MonolithTeleportationEnabled && !player.capabilities.isCreativeMode &&
|
||||||
|
!(this.worldObj.provider instanceof LimboProvider))
|
||||||
{
|
{
|
||||||
this.aggro = 0;
|
this.aggro = 0;
|
||||||
Point4D destination = LimboProvider.getLimboSkySpawn(player, properties);
|
Point4D destination = LimboProvider.getLimboSkySpawn(player, properties);
|
||||||
|
@ -239,7 +244,7 @@ public class MobMonolith extends EntityFlying implements IMob
|
||||||
this.worldObj.playSoundEffect(entityPlayer.posX, entityPlayer.posY, entityPlayer.posZ, mod_pocketDim.modid + ":tearing", 1F, (float) (1 + this.rand.nextGaussian()));
|
this.worldObj.playSoundEffect(entityPlayer.posX, entityPlayer.posY, entityPlayer.posZ, mod_pocketDim.modid + ":tearing", 1F, (float) (1 + this.rand.nextGaussian()));
|
||||||
this.soundTime = 100 + this.rand.nextInt(75);
|
this.soundTime = 100 + this.rand.nextInt(75);
|
||||||
}
|
}
|
||||||
if ((aggroPercent > 0.90) && this.soundTime < 200)
|
if ((aggroPercent > 0.80) && this.soundTime < 200)
|
||||||
{
|
{
|
||||||
this.worldObj.playSoundEffect(entityPlayer.posX, entityPlayer.posY, entityPlayer.posZ, mod_pocketDim.modid + ":tearing", 7, 1F);
|
this.worldObj.playSoundEffect(entityPlayer.posX, entityPlayer.posY, entityPlayer.posZ, mod_pocketDim.modid + ":tearing", 7, 1F);
|
||||||
this.soundTime = 250;
|
this.soundTime = 250;
|
||||||
|
|
|
@ -1,17 +1,9 @@
|
||||||
package StevenDimDoors.mod_pocketDim.tileentities;
|
package StevenDimDoors.mod_pocketDim.tileentities;
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.HashMap;
|
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.Random;
|
import java.util.Random;
|
||||||
|
|
||||||
import cpw.mods.fml.common.FMLCommonHandler;
|
|
||||||
import cpw.mods.fml.common.network.PacketDispatcher;
|
|
||||||
|
|
||||||
import net.minecraft.block.Block;
|
|
||||||
import net.minecraft.entity.DataWatcher;
|
|
||||||
import net.minecraft.entity.Entity;
|
import net.minecraft.entity.Entity;
|
||||||
import net.minecraft.entity.monster.EntityEnderman;
|
import net.minecraft.entity.monster.EntityEnderman;
|
||||||
import net.minecraft.entity.player.EntityPlayer;
|
import net.minecraft.entity.player.EntityPlayer;
|
||||||
|
@ -19,12 +11,7 @@ import net.minecraft.nbt.NBTTagCompound;
|
||||||
import net.minecraft.network.INetworkManager;
|
import net.minecraft.network.INetworkManager;
|
||||||
import net.minecraft.network.packet.Packet;
|
import net.minecraft.network.packet.Packet;
|
||||||
import net.minecraft.network.packet.Packet132TileEntityData;
|
import net.minecraft.network.packet.Packet132TileEntityData;
|
||||||
import net.minecraft.tileentity.TileEntity;
|
|
||||||
import net.minecraft.util.AxisAlignedBB;
|
import net.minecraft.util.AxisAlignedBB;
|
||||||
import net.minecraft.util.MathHelper;
|
|
||||||
import net.minecraft.util.MovingObjectPosition;
|
|
||||||
import net.minecraft.util.Vec3;
|
|
||||||
import net.minecraft.world.World;
|
|
||||||
import StevenDimDoors.mod_pocketDim.ServerPacketHandler;
|
import StevenDimDoors.mod_pocketDim.ServerPacketHandler;
|
||||||
import StevenDimDoors.mod_pocketDim.mod_pocketDim;
|
import StevenDimDoors.mod_pocketDim.mod_pocketDim;
|
||||||
import StevenDimDoors.mod_pocketDim.config.DDProperties;
|
import StevenDimDoors.mod_pocketDim.config.DDProperties;
|
||||||
|
@ -45,119 +32,88 @@ public class TileEntityRift extends DDTileEntityBase
|
||||||
private static final int MAX_RIFT_SPREAD_CHANCE = 256;
|
private static final int MAX_RIFT_SPREAD_CHANCE = 256;
|
||||||
private static final int HOSTILE_ENDERMAN_CHANCE = 1;
|
private static final int HOSTILE_ENDERMAN_CHANCE = 1;
|
||||||
private static final int MAX_HOSTILE_ENDERMAN_CHANCE = 3;
|
private static final int MAX_HOSTILE_ENDERMAN_CHANCE = 3;
|
||||||
private static final float[] POCKET_RENDER_COLOR= {1,1,1,.7F};
|
private static final int UPDATE_PERIOD = 200;
|
||||||
private static final float[] DEFAULT_RENDER_COLOR= {1,1,1,1};
|
private static final int CLOSING_PERIOD = 40;
|
||||||
|
|
||||||
private static Random random = new Random();
|
private static Random random = new Random();
|
||||||
|
|
||||||
private int age = 0;
|
private int updateTimer;
|
||||||
private int updateTimer = 0;
|
private int closeTimer = 0;
|
||||||
private int riftCloseTimer = 0;
|
|
||||||
public int xOffset = 0;
|
public int xOffset = 0;
|
||||||
public int yOffset = 0;
|
public int yOffset = 0;
|
||||||
public int zOffset = 0;
|
public int zOffset = 0;
|
||||||
public boolean shouldClose = false;
|
public boolean shouldClose = false;
|
||||||
private boolean hasUpdated = false;
|
|
||||||
|
|
||||||
public DimLink nearestRiftData;
|
public DimLink nearestRiftData;
|
||||||
public int spawnedEndermenID = 0;
|
public int spawnedEndermenID = 0;
|
||||||
public HashMap<Integer, double[]> renderingCenters = new HashMap<Integer, double[]>();
|
|
||||||
|
public TileEntityRift()
|
||||||
|
{
|
||||||
|
// Vary the update times of rifts to prevent all the rifts in a cluster
|
||||||
|
// from updating at the same time.
|
||||||
|
updateTimer = random.nextInt(UPDATE_PERIOD);
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void updateEntity()
|
public void updateEntity()
|
||||||
{
|
{
|
||||||
//Determines if rift should render white closing particles and spread closing effect to other rifts nearby
|
if (PocketManager.getLink(xCoord, yCoord, zCoord, worldObj.provider.dimensionId) == null)
|
||||||
if (this.shouldClose)
|
|
||||||
{
|
{
|
||||||
closeRift();
|
|
||||||
}
|
|
||||||
else if( PocketManager.getLink(xCoord, yCoord, zCoord, worldObj.provider.dimensionId) == null)
|
|
||||||
{
|
|
||||||
this.invalidate();
|
|
||||||
if (worldObj.getBlockId(xCoord, yCoord, zCoord) == mod_pocketDim.blockRift.blockID)
|
if (worldObj.getBlockId(xCoord, yCoord, zCoord) == mod_pocketDim.blockRift.blockID)
|
||||||
{
|
{
|
||||||
worldObj.setBlockToAir(xCoord, yCoord, zCoord);
|
worldObj.setBlockToAir(xCoord, yCoord, zCoord);
|
||||||
worldObj.removeBlockTileEntity(xCoord, yCoord, zCoord);
|
|
||||||
this.invalidate();
|
|
||||||
return;
|
|
||||||
}
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
this.invalidate();
|
||||||
|
}
|
||||||
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (worldObj.getBlockId(xCoord, yCoord, zCoord) != mod_pocketDim.blockRift.blockID)
|
if (worldObj.getBlockId(xCoord, yCoord, zCoord) != mod_pocketDim.blockRift.blockID)
|
||||||
{
|
{
|
||||||
worldObj.removeBlockTileEntity(xCoord, yCoord, zCoord);
|
|
||||||
this.invalidate();
|
this.invalidate();
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
//The code for the new rift rendering hooks in here, as well as in the ClientProxy to bind the TESR to the rift.
|
// Check if this rift should render white closing particles and
|
||||||
//It is inactive for now.
|
// spread the closing effect to other rifts nearby.
|
||||||
/**
|
if (this.shouldClose)
|
||||||
if(rand.nextInt(15) == 1)
|
|
||||||
{
|
{
|
||||||
age = age + 1;
|
closeRift();
|
||||||
this.calculateNextRenderQuad(age, rand);
|
return;
|
||||||
}
|
}
|
||||||
this.clearBlocksOnRift();
|
|
||||||
**/
|
|
||||||
|
|
||||||
//This code should execute once every 10 seconds
|
if (updateTimer >= UPDATE_PERIOD)
|
||||||
if (updateTimer > 200)
|
|
||||||
{
|
{
|
||||||
this.spawnEndermen();
|
this.spawnEndermen(mod_pocketDim.properties);
|
||||||
this.grow(mod_pocketDim.properties);
|
|
||||||
updateTimer = 0;
|
updateTimer = 0;
|
||||||
}
|
}
|
||||||
else if(updateTimer==0)
|
else if (updateTimer == UPDATE_PERIOD / 2)
|
||||||
{
|
{
|
||||||
this.calculateOldParticleOffset(); //this also calculates the distance for the particle stuff.
|
this.calculateParticleOffsets();
|
||||||
|
this.spread(mod_pocketDim.properties);
|
||||||
}
|
}
|
||||||
updateTimer++;
|
updateTimer++;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private void spawnEndermen(DDProperties properties)
|
||||||
|
|
||||||
private void clearBlocksOnRift()
|
|
||||||
{
|
{
|
||||||
//clears blocks for the new rending effect
|
if (worldObj.isRemote || !properties.RiftsSpawnEndermenEnabled)
|
||||||
for (double[] coord : this.renderingCenters.values())
|
|
||||||
{
|
|
||||||
int x = MathHelper.floor_double(coord[0] + 0.5);
|
|
||||||
int y = MathHelper.floor_double(coord[1] + 0.5);
|
|
||||||
int z = MathHelper.floor_double(coord[2] + 0.5);
|
|
||||||
|
|
||||||
// Right side
|
|
||||||
if (!mod_pocketDim.blockRift.isBlockImmune(worldObj, this.xCoord + x, this.yCoord + y, this.zCoord + z))
|
|
||||||
{
|
|
||||||
worldObj.setBlockToAir(this.xCoord + x, this.yCoord + y, this.zCoord + z);
|
|
||||||
}
|
|
||||||
// Left side
|
|
||||||
if (!mod_pocketDim.blockRift.isBlockImmune(worldObj, this.xCoord - x, this.yCoord - y, this.zCoord - z))
|
|
||||||
{
|
|
||||||
worldObj.setBlockToAir(this.xCoord - x, this.yCoord - y, this.zCoord - z);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
private void spawnEndermen()
|
|
||||||
{
|
|
||||||
if (worldObj.isRemote)
|
|
||||||
{
|
{
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
NewDimData dimension = PocketManager.getDimensionData(worldObj);
|
// Ensure that this rift is only spawning one Enderman at a time, to prevent hordes of Endermen
|
||||||
|
|
||||||
//Ensure that this rift is only spawning one enderman at a time, to prevent hordes of endermen
|
|
||||||
Entity entity = worldObj.getEntityByID(this.spawnedEndermenID);
|
Entity entity = worldObj.getEntityByID(this.spawnedEndermenID);
|
||||||
if (entity != null && entity instanceof EntityEnderman)
|
if (entity != null && entity instanceof EntityEnderman)
|
||||||
{
|
{
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
//enderman will only spawn in groups of rifts
|
|
||||||
if (random.nextInt(MAX_ENDERMAN_SPAWNING_CHANCE) < ENDERMAN_SPAWNING_CHANCE)
|
if (random.nextInt(MAX_ENDERMAN_SPAWNING_CHANCE) < ENDERMAN_SPAWNING_CHANCE)
|
||||||
{
|
{
|
||||||
|
// Endermen will only spawn from groups of rifts
|
||||||
if (updateNearestRift())
|
if (updateNearestRift())
|
||||||
{
|
{
|
||||||
List<Entity> list = worldObj.getEntitiesWithinAABB(EntityEnderman.class,
|
List<Entity> list = worldObj.getEntitiesWithinAABB(EntityEnderman.class,
|
||||||
|
@ -191,14 +147,14 @@ public class TileEntityRift extends DDTileEntityBase
|
||||||
private void closeRift()
|
private void closeRift()
|
||||||
{
|
{
|
||||||
NewDimData dimension = PocketManager.getDimensionData(worldObj);
|
NewDimData dimension = PocketManager.getDimensionData(worldObj);
|
||||||
if (riftCloseTimer == 20)
|
if (closeTimer == CLOSING_PERIOD / 2)
|
||||||
{
|
{
|
||||||
ArrayList<DimLink> rifts= dimension.findRiftsInRange(worldObj, 6, xCoord, yCoord, zCoord);
|
ArrayList<DimLink> riftLinks = dimension.findRiftsInRange(worldObj, 6, xCoord, yCoord, zCoord);
|
||||||
if (rifts.size()>0)
|
if (riftLinks.size() > 0)
|
||||||
{
|
{
|
||||||
for(DimLink riftToClose : rifts)
|
for (DimLink riftLink : riftLinks)
|
||||||
{
|
{
|
||||||
Point4D location = riftToClose.source();
|
Point4D location = riftLink.source();
|
||||||
TileEntityRift rift = (TileEntityRift) worldObj.getBlockTileEntity(location.getX(), location.getY(), location.getZ());
|
TileEntityRift rift = (TileEntityRift) worldObj.getBlockTileEntity(location.getX(), location.getY(), location.getZ());
|
||||||
if (rift != null)
|
if (rift != null)
|
||||||
{
|
{
|
||||||
|
@ -208,96 +164,40 @@ public class TileEntityRift extends DDTileEntityBase
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (riftCloseTimer > 40)
|
if (closeTimer >= CLOSING_PERIOD)
|
||||||
{
|
{
|
||||||
this.invalidate();
|
if (!this.worldObj.isRemote)
|
||||||
if(!this.worldObj.isRemote)
|
|
||||||
{
|
{
|
||||||
DimLink link = PocketManager.getLink(this.xCoord, this.yCoord, this.zCoord, worldObj);
|
DimLink link = PocketManager.getLink(this.xCoord, this.yCoord, this.zCoord, worldObj);
|
||||||
if(link!=null)
|
if (link != null)
|
||||||
{
|
{
|
||||||
dimension.deleteLink(link);
|
dimension.deleteLink(link);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
worldObj.setBlockToAir(xCoord, yCoord, zCoord);
|
worldObj.setBlockToAir(xCoord, yCoord, zCoord);
|
||||||
worldObj.playSound(xCoord, yCoord, zCoord, "mods.DimDoors.sfx.riftClose", (float) .7, 1, true);
|
worldObj.playSound(xCoord + 0.5, yCoord + 0.5, zCoord + 0.5, "mods.DimDoors.sfx.riftClose", 0.7f, 1, false);
|
||||||
this.worldObj.removeBlockTileEntity(xCoord, yCoord, zCoord);
|
|
||||||
return;
|
|
||||||
}
|
}
|
||||||
riftCloseTimer++;
|
closeTimer++;
|
||||||
}
|
}
|
||||||
|
|
||||||
private void calculateOldParticleOffset()
|
private void calculateParticleOffsets()
|
||||||
{
|
{
|
||||||
updateNearestRift();
|
if (updateNearestRift())
|
||||||
if (nearestRiftData != null)
|
|
||||||
{
|
{
|
||||||
Point4D location = nearestRiftData.source();
|
Point4D location = nearestRiftData.source();
|
||||||
this.xOffset = this.xCoord - location.getX();
|
this.xOffset = this.xCoord - location.getX();
|
||||||
this.yOffset = this.yCoord - location.getY();
|
this.yOffset = this.yCoord - location.getY();
|
||||||
this.zOffset = this.zCoord - location.getZ();
|
this.zOffset = this.zCoord - location.getZ();
|
||||||
int distance = Math.abs(xOffset) + Math.abs(yOffset) + Math.abs(zOffset);
|
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
this.xOffset=0;
|
this.xOffset = 0;
|
||||||
this.yOffset=0;
|
this.yOffset = 0;
|
||||||
this.xOffset=0;
|
this.xOffset = 0;
|
||||||
}
|
}
|
||||||
this.onInventoryChanged();
|
this.onInventoryChanged();
|
||||||
}
|
}
|
||||||
|
|
||||||
private void calculateNextRenderQuad(float age, Random rand)
|
|
||||||
{
|
|
||||||
int maxSize = MathHelper.floor_double((Math.log(Math.pow(age+1,2))));
|
|
||||||
int iteration=0;
|
|
||||||
while(iteration< maxSize)
|
|
||||||
{
|
|
||||||
iteration++;
|
|
||||||
double fl =Math.log(iteration+1)/(iteration);
|
|
||||||
double[] coords= new double[4];
|
|
||||||
double noise = ((rand.nextGaussian())/(2+iteration/3+1));
|
|
||||||
|
|
||||||
if(!this.renderingCenters.containsKey(iteration-1))
|
|
||||||
{
|
|
||||||
if (rand.nextBoolean())
|
|
||||||
{
|
|
||||||
coords[0] = fl*1.5;
|
|
||||||
coords[1] = rand.nextGaussian()/5;
|
|
||||||
coords[2] = 0;
|
|
||||||
coords[3] = 1;
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
coords[0] = 0;
|
|
||||||
coords[1] = rand.nextGaussian()/5;
|
|
||||||
coords[2] = fl*1.5;
|
|
||||||
coords[3] = 0;
|
|
||||||
}
|
|
||||||
this.renderingCenters.put(iteration-1,coords);
|
|
||||||
iteration--;
|
|
||||||
}
|
|
||||||
else if(!this.renderingCenters.containsKey(iteration))
|
|
||||||
{
|
|
||||||
if(this.renderingCenters.get(iteration-1)[3]==0)
|
|
||||||
{
|
|
||||||
coords[0]=noise/2+this.renderingCenters.get(iteration-1)[0];
|
|
||||||
coords[1]=noise/2+this.renderingCenters.get(iteration-1)[1];
|
|
||||||
coords[2]= this.renderingCenters.get(iteration-1)[2]+fl;
|
|
||||||
coords[3] = 0;
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
coords[0]=this.renderingCenters.get(iteration-1)[0]+fl;
|
|
||||||
coords[1]=noise/2+this.renderingCenters.get(iteration-1)[1];
|
|
||||||
coords[2]=noise/2+this.renderingCenters.get(iteration-1)[2];
|
|
||||||
coords[3] = 1;
|
|
||||||
}
|
|
||||||
this.renderingCenters.put(iteration,coords);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean shouldRenderInPass(int pass)
|
public boolean shouldRenderInPass(int pass)
|
||||||
{
|
{
|
||||||
|
@ -310,13 +210,10 @@ public class TileEntityRift extends DDTileEntityBase
|
||||||
{
|
{
|
||||||
return countAncestorLinks(link.parent()) + 1;
|
return countAncestorLinks(link.parent()) + 1;
|
||||||
}
|
}
|
||||||
else
|
|
||||||
{
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
public void grow(DDProperties properties)
|
public void spread(DDProperties properties)
|
||||||
{
|
{
|
||||||
if (worldObj.isRemote || !properties.RiftSpreadEnabled
|
if (worldObj.isRemote || !properties.RiftSpreadEnabled
|
||||||
|| random.nextInt(MAX_RIFT_SPREAD_CHANCE) < RIFT_SPREAD_CHANCE || this.shouldClose)
|
|| random.nextInt(MAX_RIFT_SPREAD_CHANCE) < RIFT_SPREAD_CHANCE || this.shouldClose)
|
||||||
|
@ -347,13 +244,10 @@ public class TileEntityRift extends DDTileEntityBase
|
||||||
public void readFromNBT(NBTTagCompound nbt)
|
public void readFromNBT(NBTTagCompound nbt)
|
||||||
{
|
{
|
||||||
super.readFromNBT(nbt);
|
super.readFromNBT(nbt);
|
||||||
this.renderingCenters = new HashMap<Integer, double[]>();
|
this.updateTimer = nbt.getInteger("updateTimer");
|
||||||
this.updateTimer = nbt.getInteger("count");
|
|
||||||
this.riftCloseTimer = nbt.getInteger("count2");
|
|
||||||
this.xOffset = nbt.getInteger("xOffset");
|
this.xOffset = nbt.getInteger("xOffset");
|
||||||
this.yOffset = nbt.getInteger("yOffset");
|
this.yOffset = nbt.getInteger("yOffset");
|
||||||
this.zOffset = nbt.getInteger("zOffset");
|
this.zOffset = nbt.getInteger("zOffset");
|
||||||
this.age = nbt.getInteger("age");
|
|
||||||
this.shouldClose = nbt.getBoolean("shouldClose");
|
this.shouldClose = nbt.getBoolean("shouldClose");
|
||||||
this.spawnedEndermenID = nbt.getInteger("spawnedEndermenID");
|
this.spawnedEndermenID = nbt.getInteger("spawnedEndermenID");
|
||||||
}
|
}
|
||||||
|
@ -362,9 +256,7 @@ public class TileEntityRift extends DDTileEntityBase
|
||||||
public void writeToNBT(NBTTagCompound nbt)
|
public void writeToNBT(NBTTagCompound nbt)
|
||||||
{
|
{
|
||||||
super.writeToNBT(nbt);
|
super.writeToNBT(nbt);
|
||||||
nbt.setInteger("age", this.age);
|
nbt.setInteger("updateTimer", this.updateTimer);
|
||||||
nbt.setInteger("count", this.updateTimer);
|
|
||||||
nbt.setInteger("count2", this.riftCloseTimer);
|
|
||||||
nbt.setInteger("xOffset", this.xOffset);
|
nbt.setInteger("xOffset", this.xOffset);
|
||||||
nbt.setInteger("yOffset", this.yOffset);
|
nbt.setInteger("yOffset", this.yOffset);
|
||||||
nbt.setInteger("zOffset", this.zOffset);
|
nbt.setInteger("zOffset", this.zOffset);
|
||||||
|
@ -372,6 +264,7 @@ public class TileEntityRift extends DDTileEntityBase
|
||||||
nbt.setInteger("spawnedEndermenID", this.spawnedEndermenID);
|
nbt.setInteger("spawnedEndermenID", this.spawnedEndermenID);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
public Packet getDescriptionPacket()
|
public Packet getDescriptionPacket()
|
||||||
{
|
{
|
||||||
if (PocketManager.getLink(xCoord, yCoord, zCoord, worldObj) != null)
|
if (PocketManager.getLink(xCoord, yCoord, zCoord, worldObj) != null)
|
||||||
|
|
|
@ -141,12 +141,14 @@ public final class Point4D implements Comparable<Point4D>
|
||||||
|
|
||||||
public Point3D toPoint3D()
|
public Point3D toPoint3D()
|
||||||
{
|
{
|
||||||
return new Point3D(this.x,this.y,this.z);
|
return new Point3D(this.x, this.y, this.z);
|
||||||
}
|
}
|
||||||
|
|
||||||
public int[] toIntArray()
|
public int[] toIntArray()
|
||||||
{
|
{
|
||||||
return new int[]{x,y,z,dimension};
|
return new int[] {x, y, z, dimension};
|
||||||
}
|
}
|
||||||
|
|
||||||
public boolean equals(Point4D other)
|
public boolean equals(Point4D other)
|
||||||
{
|
{
|
||||||
if (this == other)
|
if (this == other)
|
||||||
|
|
|
@ -356,7 +356,7 @@ public class PocketBuilder
|
||||||
|
|
||||||
//Place a link leading back out of the pocket
|
//Place a link leading back out of the pocket
|
||||||
DimLink reverseLink = dimension.createLink(source.getX(), destinationY, source.getZ(), LinkType.REVERSE,(link.orientation()+2)%4);
|
DimLink reverseLink = dimension.createLink(source.getX(), destinationY, source.getZ(), LinkType.REVERSE,(link.orientation()+2)%4);
|
||||||
parent.setDestination(reverseLink, source.getX(), source.getY(), source.getZ());
|
parent.setLinkDestination(reverseLink, source.getX(), source.getY(), source.getZ());
|
||||||
|
|
||||||
//Build the actual pocket area
|
//Build the actual pocket area
|
||||||
buildPocket(world, source.getX(), destinationY, source.getZ(), orientation, size, wallThickness, properties, door);
|
buildPocket(world, source.getX(), destinationY, source.getZ(), orientation, size, wallThickness, properties, door);
|
||||||
|
@ -400,8 +400,9 @@ public class PocketBuilder
|
||||||
int orientation = getDoorOrientation(source, properties);
|
int orientation = getDoorOrientation(source, properties);
|
||||||
|
|
||||||
//Place a link leading back out of the pocket
|
//Place a link leading back out of the pocket
|
||||||
|
|
||||||
DimLink reverseLink = dimension.createLink(source.getX(), destinationY, source.getZ(), LinkType.REVERSE,(link.orientation()+2)%4);
|
DimLink reverseLink = dimension.createLink(source.getX(), destinationY, source.getZ(), LinkType.REVERSE,(link.orientation()+2)%4);
|
||||||
parent.setDestination(reverseLink, source.getX(), source.getY(), source.getZ());
|
parent.setLinkDestination(reverseLink, source.getX(), source.getY(), source.getZ());
|
||||||
|
|
||||||
//Build the actual pocket area
|
//Build the actual pocket area
|
||||||
buildPocket(world, source.getX(), destinationY, source.getZ(), orientation, size, wallThickness, properties, door);
|
buildPocket(world, source.getX(), destinationY, source.getZ(), orientation, size, wallThickness, properties, door);
|
||||||
|
|
Loading…
Reference in a new issue