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;
|
||||
|
||||
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.BlockDispenser;
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.inventory.IInventory;
|
||||
import net.minecraft.item.Item;
|
||||
|
@ -17,6 +11,7 @@ import net.minecraftforge.oredict.ShapedOreRecipe;
|
|||
import StevenDimDoors.mod_pocketDim.config.DDProperties;
|
||||
import StevenDimDoors.mod_pocketDim.core.DDLock;
|
||||
import StevenDimDoors.mod_pocketDim.items.ItemDDKey;
|
||||
import StevenDimDoors.mod_pocketDim.items.behaviors.DispenserBehaviorStabilizedRS;
|
||||
import cpw.mods.fml.common.ICraftingHandler;
|
||||
import cpw.mods.fml.common.registry.GameRegistry;
|
||||
|
||||
|
@ -31,19 +26,19 @@ public class CraftingManager implements ICraftingHandler
|
|||
switch (properties.WorldThreadRequirementLevel)
|
||||
{
|
||||
case 1:
|
||||
GameRegistry.addShapelessRecipe(new ItemStack(itemStableFabric, 1),
|
||||
GameRegistry.addShapelessRecipe(new ItemStack(mod_pocketDim.itemStableFabric, 1),
|
||||
Item.enderPearl, mod_pocketDim.itemWorldThread);
|
||||
break;
|
||||
case 2:
|
||||
GameRegistry.addRecipe(new ItemStack(itemStableFabric, 1),
|
||||
GameRegistry.addRecipe(new ItemStack(mod_pocketDim.itemStableFabric, 1),
|
||||
"yxy", 'x', Item.enderPearl, 'y', mod_pocketDim.itemWorldThread);
|
||||
break;
|
||||
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);
|
||||
break;
|
||||
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);
|
||||
break;
|
||||
}
|
||||
|
@ -51,48 +46,53 @@ public class CraftingManager implements ICraftingHandler
|
|||
|
||||
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);
|
||||
}
|
||||
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);
|
||||
}
|
||||
if (properties.CraftingWarpDoorAllowed)
|
||||
{
|
||||
GameRegistry.addRecipe(new ItemStack(itemWarpDoor, 1),
|
||||
|
||||
GameRegistry.addRecipe(new ItemStack(mod_pocketDim.itemWarpDoor, 1),
|
||||
"yxy", 'x', Item.enderPearl, 'y', Item.doorWood);
|
||||
}
|
||||
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);
|
||||
}
|
||||
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);
|
||||
}
|
||||
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);
|
||||
}
|
||||
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);
|
||||
}
|
||||
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)
|
||||
{
|
||||
GameRegistry.addRecipe(new ItemStack(mod_pocketDim.itemGoldenDimensionalDoor,1),
|
||||
"yxy", 'y', mod_pocketDim.itemGoldenDoor, 'x', mod_pocketDim.itemStableFabric);
|
||||
GameRegistry.addRecipe(new ItemStack(mod_pocketDim.itemGoldenDimensionalDoor, 1),
|
||||
"yxy", 'x', mod_pocketDim.itemStableFabric, 'y', mod_pocketDim.itemGoldenDoor);
|
||||
}
|
||||
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.NewDimData;
|
||||
import StevenDimDoors.mod_pocketDim.core.PocketManager;
|
||||
import StevenDimDoors.mod_pocketDim.items.BaseItemDoor;
|
||||
import StevenDimDoors.mod_pocketDim.items.ItemWarpDoor;
|
||||
import StevenDimDoors.mod_pocketDim.util.Point4D;
|
||||
import StevenDimDoors.mod_pocketDim.world.LimboProvider;
|
||||
|
@ -88,13 +89,13 @@ public class EventHookContainer
|
|||
public void onPlayerEvent(PlayerInteractEvent event)
|
||||
{
|
||||
// Handle all door placement here
|
||||
if(event.action == Action.LEFT_CLICK_BLOCK)
|
||||
if (event.action == Action.LEFT_CLICK_BLOCK)
|
||||
{
|
||||
return;
|
||||
}
|
||||
World world = event.entity.worldObj;
|
||||
ItemStack stack = event.entityPlayer.inventory.getCurrentItem();
|
||||
if (stack != null && stack.getItem() instanceof ItemDoor)
|
||||
if (stack != null)
|
||||
{
|
||||
if(stack.getItem() instanceof ItemWarpDoor)
|
||||
{
|
||||
|
@ -107,13 +108,14 @@ public class EventHookContainer
|
|||
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))
|
||||
{
|
||||
// Cancel the event so that we don't get two doors from vanilla doors
|
||||
event.setCanceled(true);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@ForgeSubscribe
|
||||
|
|
|
@ -532,10 +532,10 @@ public class DDTeleporter
|
|||
DimLink personalHomeLink = dim.getLink(dim.origin());
|
||||
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;
|
||||
}
|
||||
|
||||
|
@ -598,7 +598,7 @@ public class DDTeleporter
|
|||
Point3D destination = yCoordHelper.findDropPoint(world, source.getX(), source.getY() + 1, source.getZ());
|
||||
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;
|
||||
}
|
||||
}
|
||||
|
@ -769,7 +769,7 @@ public class DDTeleporter
|
|||
int orientation = getDestinationOrientation(source, properties);
|
||||
NewDimData sourceDim = PocketManager.getDimensionData(link.source().getDimension());
|
||||
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
|
||||
orientation = BlockRotator.transformMetadata(orientation, 2, properties.WarpDoorID);
|
||||
|
@ -777,7 +777,7 @@ public class DDTeleporter
|
|||
|
||||
// Complete the link to the destination
|
||||
// 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);
|
||||
|
|
|
@ -84,6 +84,7 @@ public abstract class DimLink
|
|||
{
|
||||
return tail.getDestination();
|
||||
}
|
||||
|
||||
public int getDestinationOrientation()
|
||||
{
|
||||
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;
|
||||
}
|
||||
|
||||
public boolean hasDestination()
|
||||
{
|
||||
return (tail.getDestination() != null);
|
||||
|
@ -118,7 +120,7 @@ public abstract class DimLink
|
|||
return tail.getLinkType();
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public String toString()
|
||||
{
|
||||
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.");
|
||||
}
|
||||
setDestination(incoming, originX, originY, originZ);
|
||||
setLinkDestination(incoming, originX, originY, originZ);
|
||||
this.origin = incoming.destination();
|
||||
this.orientation = orientation;
|
||||
this.dungeon = dungeon;
|
||||
|
@ -576,13 +576,13 @@ public abstract class NewDimData implements IPackable<PackedDimData>
|
|||
throw new IllegalStateException("The dimension has already been initialized.");
|
||||
}
|
||||
|
||||
setDestination(incoming, originX, originY, originZ);
|
||||
setLinkDestination(incoming, originX, originY, originZ);
|
||||
this.origin = incoming.destination();
|
||||
this.orientation = orientation;
|
||||
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;
|
||||
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);
|
||||
Point4D destination = entryLink.source();
|
||||
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);
|
||||
}
|
||||
|
||||
|
|
|
@ -2,6 +2,7 @@ package StevenDimDoors.mod_pocketDim.items;
|
|||
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
|
||||
import net.minecraft.block.Block;
|
||||
import net.minecraft.block.material.Material;
|
||||
import net.minecraft.client.renderer.texture.IconRegister;
|
||||
|
@ -23,9 +24,9 @@ import StevenDimDoors.mod_pocketDim.tileentities.TileEntityDimDoor;
|
|||
|
||||
public abstract class BaseItemDoor extends ItemDoor
|
||||
{
|
||||
// maps non-dimensional door items to their corresponding dimensional door
|
||||
// item
|
||||
private static HashMap<ItemDoor, BaseItemDoor> vanillaDoorMapping = new HashMap<ItemDoor, BaseItemDoor>();
|
||||
// Maps non-dimensional door items to their corresponding dimensional door item
|
||||
// Also maps dimensional door items to themselves for simplicity
|
||||
private static HashMap<ItemDoor, BaseItemDoor> doorItemMapping = new HashMap<ItemDoor, BaseItemDoor>();
|
||||
private static DDProperties properties = null;
|
||||
|
||||
/**
|
||||
|
@ -34,7 +35,7 @@ public abstract class BaseItemDoor extends ItemDoor
|
|||
* @param material
|
||||
* @param door
|
||||
*/
|
||||
public BaseItemDoor(int itemID, Material material, ItemDoor door)
|
||||
public BaseItemDoor(int itemID, Material material, ItemDoor vanillaDoor)
|
||||
{
|
||||
super(itemID, material);
|
||||
this.setMaxStackSize(64);
|
||||
|
@ -42,9 +43,10 @@ public abstract class BaseItemDoor extends ItemDoor
|
|||
if (properties == null)
|
||||
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
|
||||
*/
|
||||
protected abstract BaseDimDoor getDoortoItemMapping();
|
||||
protected abstract BaseDimDoor getDoorBlock();
|
||||
|
||||
/**
|
||||
* Overriden here to remove vanilla block placement functionality from
|
||||
|
@ -73,23 +75,12 @@ public abstract class BaseItemDoor extends ItemDoor
|
|||
@Override
|
||||
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;
|
||||
}
|
||||
|
||||
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 player
|
||||
* @param world
|
||||
|
@ -97,8 +88,6 @@ public abstract class BaseItemDoor extends ItemDoor
|
|||
* @param y
|
||||
* @param z
|
||||
* @param side
|
||||
* @param requireLink
|
||||
* @param reduceStack
|
||||
* @return
|
||||
*/
|
||||
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;
|
||||
}
|
||||
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 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
|
||||
protected BaseDimDoor getDoortoItemMapping()
|
||||
protected BaseDimDoor getDoorBlock()
|
||||
{
|
||||
return (BaseDimDoor) mod_pocketDim.dimensionalDoor;
|
||||
}
|
||||
|
|
|
@ -28,7 +28,7 @@ public class ItemGoldDimDoor extends BaseItemDoor
|
|||
}
|
||||
|
||||
@Override
|
||||
protected BaseDimDoor getDoortoItemMapping()
|
||||
protected BaseDimDoor getDoorBlock()
|
||||
{
|
||||
return (BaseDimDoor) mod_pocketDim.goldenDimensionalDoor;
|
||||
}
|
||||
|
|
|
@ -15,6 +15,7 @@ public class ItemGoldDoor extends ItemDoor
|
|||
public ItemGoldDoor(int par1, Material par2Material)
|
||||
{
|
||||
super(par1, par2Material);
|
||||
this.setMaxStackSize(16);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
|
@ -28,7 +28,7 @@ public class ItemPersonalDoor extends BaseItemDoor
|
|||
}
|
||||
|
||||
@Override
|
||||
protected BaseDimDoor getDoortoItemMapping()
|
||||
protected BaseDimDoor getDoorBlock()
|
||||
{
|
||||
return (BaseDimDoor) mod_pocketDim.personalDimDoor;
|
||||
}
|
||||
|
|
|
@ -33,12 +33,13 @@ public class ItemRiftSignature extends Item
|
|||
|
||||
@SideOnly(Side.CLIENT)
|
||||
@Override
|
||||
public boolean hasEffect(ItemStack stack)
|
||||
public boolean hasEffect(ItemStack stack, int pass)
|
||||
{
|
||||
//Make the item glow if it has one endpoint stored
|
||||
return (stack.getItemDamage() != 0);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void registerIcons(IconRegister par1IconRegister)
|
||||
{
|
||||
this.itemIcon = par1IconRegister.registerIcon(mod_pocketDim.modid + ":" + this.getUnlocalizedName().replace("item.", ""));
|
||||
|
@ -59,23 +60,24 @@ public class ItemRiftSignature extends Item
|
|||
return false;
|
||||
}
|
||||
|
||||
y += 2; //Increase y by 2 to place the rift at head level
|
||||
if (!player.canPlayerEdit(x, y, z, side, stack))
|
||||
//Increase y by 2 to place the rift at head level
|
||||
int adjustedY = adjustYForSpecialBlocks(world, x, y + 2, z);
|
||||
if (!player.canPlayerEdit(x, adjustedY, z, side, stack))
|
||||
{
|
||||
return true;
|
||||
}
|
||||
int adjustedY = adjustYForSpecialBlocks(world,x,y,z);
|
||||
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)
|
||||
{
|
||||
//The link was used before and already has an endpoint stored. Create links connecting the two endpoints.
|
||||
NewDimData sourceDimension = PocketManager.getDimensionData(source.getDimension());
|
||||
NewDimData destinationDimension = PocketManager.getDimensionData(world);
|
||||
|
||||
DimLink link = sourceDimension.createLink(source.getX(), source.getY(), source.getZ(), LinkType.NORMAL,source.getOrientation());
|
||||
DimLink reverse = destinationDimension.createLink(x, adjustedY, z, LinkType.NORMAL,orientation);
|
||||
destinationDimension.setDestination(link, x, adjustedY, z);
|
||||
sourceDimension.setDestination(reverse, source.getX(), source.getY(), source.getZ());
|
||||
destinationDimension.setLinkDestination(link, x, adjustedY, z);
|
||||
sourceDimension.setLinkDestination(reverse, source.getX(), source.getY(), source.getZ());
|
||||
|
||||
//Try placing a rift at the destination point
|
||||
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
|
||||
*/
|
||||
@Override
|
||||
@SuppressWarnings({ "unchecked", "rawtypes" })
|
||||
@SideOnly(Side.CLIENT)
|
||||
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)
|
||||
{
|
||||
y=y-2;//get the block the player actually clicked on
|
||||
Block block = Block.blocksList[world.getBlockId(x, y, z)];
|
||||
if(block==null)
|
||||
int targetY = y - 2; // Get the block the player actually clicked on
|
||||
Block block = Block.blocksList[world.getBlockId(x, targetY, z)];
|
||||
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)
|
||||
{
|
||||
NBTTagCompound tag = new NBTTagCompound();
|
||||
|
@ -199,11 +204,12 @@ public class ItemRiftSignature extends Item
|
|||
Integer orientation = tag.getInteger("orientation");
|
||||
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);
|
||||
}
|
||||
return null;
|
||||
|
@ -213,10 +219,11 @@ public class ItemRiftSignature extends Item
|
|||
{
|
||||
private Point4D point;
|
||||
private int orientation;
|
||||
|
||||
Point4DOrientation(int x, int y, int z, int orientation, int dimID)
|
||||
{
|
||||
this.point= new Point4D(x,y,z,dimID);
|
||||
this.orientation=orientation;
|
||||
this.point = new Point4D(x, y, z, dimID);
|
||||
this.orientation = orientation;
|
||||
}
|
||||
|
||||
int getX()
|
||||
|
@ -238,10 +245,16 @@ public class ItemRiftSignature extends Item
|
|||
{
|
||||
return point.getDimension();
|
||||
}
|
||||
|
||||
int getOrientation()
|
||||
{
|
||||
return orientation;
|
||||
}
|
||||
|
||||
Point4D getPoint()
|
||||
{
|
||||
return point;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -38,62 +38,77 @@ public class ItemStabilizedRiftSignature extends ItemRiftSignature
|
|||
return false;
|
||||
}
|
||||
|
||||
// We don't check for replaceable blocks. The user can deal with that. <_<
|
||||
y += 2; //Increase y by 2 to place the rift at head level
|
||||
if (!player.canPlayerEdit(x, y, z, side, stack))
|
||||
// Adjust Y so the rift is at head level, depending on the presence of certain blocks
|
||||
int adjustedY = adjustYForSpecialBlocks(world, x, y + 2, z);
|
||||
if (!player.canPlayerEdit(x, adjustedY, z, side, stack))
|
||||
{
|
||||
return true;
|
||||
}
|
||||
Point4DOrientation source = getSource(stack);
|
||||
int adjustedY = adjustYForSpecialBlocks(world,x,y,z);
|
||||
int orientation = MathHelper.floor_double((player.rotationYaw + 180.0F) * 4.0F / 360.0F - 0.5D) & 3;
|
||||
|
||||
// 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)
|
||||
{
|
||||
// Yes, it's initialized. Check if the player is in creative
|
||||
// or if the player can pay with Stable Fabric to create a rift.
|
||||
if (!player.capabilities.isCreativeMode && !player.inventory.hasItem(Item.enderPearl.itemID))
|
||||
{
|
||||
mod_pocketDim.sendChat(player, "You don't have any Ender Pearls!");
|
||||
// I won't do this, but this is the chance to localize chat
|
||||
// messages sent to the player; look at ChatMessageComponent
|
||||
// and how MFR does it with items like the safari net launcher
|
||||
return true;
|
||||
}
|
||||
|
||||
//The link was used before and already has an endpoint stored. Create links connecting the two endpoints.
|
||||
// Yes, it's initialized.
|
||||
NewDimData sourceDimension = PocketManager.getDimensionData(source.getDimension());
|
||||
NewDimData destinationDimension = PocketManager.getDimensionData(world);
|
||||
DimLink link = sourceDimension.createLink(source.getX(), source.getY(), source.getZ(), LinkType.NORMAL,source.getOrientation());
|
||||
DimLink reverse = destinationDimension.createLink(x, adjustedY, z, LinkType.NORMAL,orientation);
|
||||
destinationDimension.setDestination(link, x, adjustedY, z);
|
||||
sourceDimension.setDestination(reverse, source.getX(), source.getY(), source.getZ());
|
||||
|
||||
//Try placing a rift at the destination point
|
||||
if (!mod_pocketDim.blockRift.isBlockImmune(world, x, adjustedY, z))
|
||||
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()))
|
||||
{
|
||||
world.setBlock(x, adjustedY, z, mod_pocketDim.blockRift.blockID);
|
||||
// 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!");
|
||||
// I won't do this, but this is the chance to localize chat
|
||||
// messages sent to the player; look at ChatMessageComponent
|
||||
// and how MFR does it with items like the safari net launcher
|
||||
return true;
|
||||
}
|
||||
|
||||
// Create links connecting the two endpoints.
|
||||
link = sourceDimension.createLink(source.getX(), source.getY(), source.getZ(), LinkType.NORMAL, source.getOrientation());
|
||||
reverse = destinationDimension.createLink(x, adjustedY, z, LinkType.NORMAL, orientation);
|
||||
destinationDimension.setLinkDestination(link, x, adjustedY, z);
|
||||
sourceDimension.setLinkDestination(reverse, source.getX(), source.getY(), source.getZ());
|
||||
|
||||
// Try placing a rift at the destination point
|
||||
if (!mod_pocketDim.blockRift.isBlockImmune(world, x, adjustedY, z))
|
||||
{
|
||||
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);
|
||||
}
|
||||
|
||||
if (!player.capabilities.isCreativeMode)
|
||||
{
|
||||
player.inventory.consumeInventoryItem(Item.enderPearl.itemID);
|
||||
}
|
||||
mod_pocketDim.sendChat(player,"Rift Created");
|
||||
world.playSoundAtEntity(player,"mods.DimDoors.sfx.riftEnd", 0.6f, 1);
|
||||
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.
|
||||
// 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);
|
||||
|
@ -101,6 +116,54 @@ public class ItemStabilizedRiftSignature extends ItemRiftSignature
|
|||
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());
|
||||
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);
|
||||
}
|
||||
|
||||
// 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);
|
||||
return true;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
* allows items to add custom lines of information to the mouseover description
|
||||
*/
|
||||
|
|
|
@ -25,7 +25,7 @@ public class ItemUnstableDoor extends BaseItemDoor
|
|||
}
|
||||
|
||||
@Override
|
||||
protected BaseDimDoor getDoortoItemMapping()
|
||||
protected BaseDimDoor getDoorBlock()
|
||||
{
|
||||
return (BaseDimDoor) mod_pocketDim.unstableDoor;
|
||||
}
|
||||
|
|
|
@ -28,7 +28,7 @@ public class ItemWarpDoor extends BaseItemDoor
|
|||
}
|
||||
|
||||
@Override
|
||||
protected BaseDimDoor getDoortoItemMapping()
|
||||
protected BaseDimDoor getDoorBlock()
|
||||
{
|
||||
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 itemStableFabric;
|
||||
public static Item itemUnstableDoor;
|
||||
public static Item itemStabilizedLinkSignature;
|
||||
public static Item itemDDKey;
|
||||
public static Item itemQuartzDoor;
|
||||
public static Item itemPersonalDoor;
|
||||
public static Item itemStabilizedRiftSignature;
|
||||
|
||||
public static BiomeGenBase limboBiome;
|
||||
public static BiomeGenBase pocketBiome;
|
||||
|
@ -233,7 +233,7 @@ public class mod_pocketDim
|
|||
itemStableFabric = (new ItemStableFabric(properties.StableFabricItemID, 0)).setUnlocalizedName("itemStableFabric");
|
||||
itemUnstableDoor = (new ItemUnstableDoor(properties.UnstableDoorItemID, Material.iron, null)).setUnlocalizedName("itemChaosDoor");
|
||||
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");
|
||||
|
||||
// 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(itemGoldenDoor, "Golden 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(itemStableFabric, "Stable Fabric");
|
||||
LanguageRegistry.addName(itemUnstableDoor, "Unstable Door");
|
||||
|
@ -316,7 +316,9 @@ public class mod_pocketDim
|
|||
LanguageRegistry.instance().addStringLocalization("entity.dimdoors.Monolith.name", "Monolith");
|
||||
|
||||
CraftingManager.registerRecipes(properties);
|
||||
CraftingManager.registerDispenserBehaviors();
|
||||
GameRegistry.registerCraftingHandler(new CraftingManager());
|
||||
|
||||
DungeonHelper.initialize();
|
||||
gatewayGenerator = new GatewayGenerator(properties);
|
||||
GameRegistry.registerWorldGenerator(mod_pocketDim.gatewayGenerator);
|
||||
|
|
|
@ -215,7 +215,7 @@ public class DDSaveHandler
|
|||
Point4D destination = packedLink.tail.destination;
|
||||
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);
|
||||
}
|
||||
|
|
|
@ -145,9 +145,13 @@ public class MobMonolith extends EntityFlying implements IMob
|
|||
if (player != null)
|
||||
{
|
||||
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);
|
||||
}
|
||||
|
||||
|
@ -161,7 +165,8 @@ public class MobMonolith extends EntityFlying implements IMob
|
|||
|
||||
// Teleport the target player if various conditions are met
|
||||
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;
|
||||
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.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.soundTime = 250;
|
||||
|
|
|
@ -1,17 +1,9 @@
|
|||
package StevenDimDoors.mod_pocketDim.tileentities;
|
||||
|
||||
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
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.monster.EntityEnderman;
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
|
@ -19,12 +11,7 @@ import net.minecraft.nbt.NBTTagCompound;
|
|||
import net.minecraft.network.INetworkManager;
|
||||
import net.minecraft.network.packet.Packet;
|
||||
import net.minecraft.network.packet.Packet132TileEntityData;
|
||||
import net.minecraft.tileentity.TileEntity;
|
||||
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.mod_pocketDim;
|
||||
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 HOSTILE_ENDERMAN_CHANCE = 1;
|
||||
private static final int MAX_HOSTILE_ENDERMAN_CHANCE = 3;
|
||||
private static final float[] POCKET_RENDER_COLOR= {1,1,1,.7F};
|
||||
private static final float[] DEFAULT_RENDER_COLOR= {1,1,1,1};
|
||||
private static final int UPDATE_PERIOD = 200;
|
||||
private static final int CLOSING_PERIOD = 40;
|
||||
|
||||
private static Random random = new Random();
|
||||
|
||||
private int age = 0;
|
||||
private int updateTimer = 0;
|
||||
private int riftCloseTimer = 0;
|
||||
private int updateTimer;
|
||||
private int closeTimer = 0;
|
||||
public int xOffset = 0;
|
||||
public int yOffset = 0;
|
||||
public int zOffset = 0;
|
||||
public boolean shouldClose = false;
|
||||
private boolean hasUpdated = false;
|
||||
|
||||
public DimLink nearestRiftData;
|
||||
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
|
||||
public void updateEntity()
|
||||
{
|
||||
//Determines if rift should render white closing particles and spread closing effect to other rifts nearby
|
||||
if (this.shouldClose)
|
||||
if (PocketManager.getLink(xCoord, yCoord, zCoord, worldObj.provider.dimensionId) == null)
|
||||
{
|
||||
closeRift();
|
||||
}
|
||||
else if( PocketManager.getLink(xCoord, yCoord, zCoord, worldObj.provider.dimensionId) == null)
|
||||
{
|
||||
this.invalidate();
|
||||
if (worldObj.getBlockId(xCoord, yCoord, zCoord) == mod_pocketDim.blockRift.blockID)
|
||||
{
|
||||
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)
|
||||
{
|
||||
worldObj.removeBlockTileEntity(xCoord, yCoord, zCoord);
|
||||
this.invalidate();
|
||||
return;
|
||||
}
|
||||
|
||||
//The code for the new rift rendering hooks in here, as well as in the ClientProxy to bind the TESR to the rift.
|
||||
//It is inactive for now.
|
||||
/**
|
||||
if(rand.nextInt(15) == 1)
|
||||
{
|
||||
age = age + 1;
|
||||
this.calculateNextRenderQuad(age, rand);
|
||||
}
|
||||
this.clearBlocksOnRift();
|
||||
**/
|
||||
|
||||
//This code should execute once every 10 seconds
|
||||
if (updateTimer > 200)
|
||||
|
||||
// Check if this rift should render white closing particles and
|
||||
// spread the closing effect to other rifts nearby.
|
||||
if (this.shouldClose)
|
||||
{
|
||||
this.spawnEndermen();
|
||||
this.grow(mod_pocketDim.properties);
|
||||
closeRift();
|
||||
return;
|
||||
}
|
||||
|
||||
if (updateTimer >= UPDATE_PERIOD)
|
||||
{
|
||||
this.spawnEndermen(mod_pocketDim.properties);
|
||||
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++;
|
||||
}
|
||||
|
||||
|
||||
|
||||
private void clearBlocksOnRift()
|
||||
private void spawnEndermen(DDProperties properties)
|
||||
{
|
||||
//clears blocks for the new rending effect
|
||||
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)
|
||||
if (worldObj.isRemote || !properties.RiftsSpawnEndermenEnabled)
|
||||
{
|
||||
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);
|
||||
if (entity != null && entity instanceof EntityEnderman)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
//enderman will only spawn in groups of rifts
|
||||
if (random.nextInt(MAX_ENDERMAN_SPAWNING_CHANCE) < ENDERMAN_SPAWNING_CHANCE)
|
||||
{
|
||||
// Endermen will only spawn from groups of rifts
|
||||
if (updateNearestRift())
|
||||
{
|
||||
List<Entity> list = worldObj.getEntitiesWithinAABB(EntityEnderman.class,
|
||||
|
@ -191,14 +147,14 @@ public class TileEntityRift extends DDTileEntityBase
|
|||
private void closeRift()
|
||||
{
|
||||
NewDimData dimension = PocketManager.getDimensionData(worldObj);
|
||||
if (riftCloseTimer == 20)
|
||||
if (closeTimer == CLOSING_PERIOD / 2)
|
||||
{
|
||||
ArrayList<DimLink> rifts= dimension.findRiftsInRange(worldObj, 6, xCoord, yCoord, zCoord);
|
||||
if (rifts.size()>0)
|
||||
ArrayList<DimLink> riftLinks = dimension.findRiftsInRange(worldObj, 6, xCoord, yCoord, zCoord);
|
||||
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());
|
||||
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);
|
||||
if(link!=null)
|
||||
if (link != null)
|
||||
{
|
||||
dimension.deleteLink(link);
|
||||
}
|
||||
}
|
||||
worldObj.setBlockToAir(xCoord, yCoord, zCoord);
|
||||
worldObj.playSound(xCoord, yCoord, zCoord, "mods.DimDoors.sfx.riftClose", (float) .7, 1, true);
|
||||
this.worldObj.removeBlockTileEntity(xCoord, yCoord, zCoord);
|
||||
return;
|
||||
worldObj.playSound(xCoord + 0.5, yCoord + 0.5, zCoord + 0.5, "mods.DimDoors.sfx.riftClose", 0.7f, 1, false);
|
||||
}
|
||||
riftCloseTimer++;
|
||||
closeTimer++;
|
||||
}
|
||||
|
||||
private void calculateOldParticleOffset()
|
||||
private void calculateParticleOffsets()
|
||||
{
|
||||
updateNearestRift();
|
||||
if (nearestRiftData != null)
|
||||
if (updateNearestRift())
|
||||
{
|
||||
Point4D location = nearestRiftData.source();
|
||||
this.xOffset = this.xCoord - location.getX();
|
||||
this.yOffset = this.yCoord - location.getY();
|
||||
this.zOffset = this.zCoord - location.getZ();
|
||||
int distance = Math.abs(xOffset) + Math.abs(yOffset) + Math.abs(zOffset);
|
||||
}
|
||||
else
|
||||
{
|
||||
this.xOffset=0;
|
||||
this.yOffset=0;
|
||||
this.xOffset=0;
|
||||
this.xOffset = 0;
|
||||
this.yOffset = 0;
|
||||
this.xOffset = 0;
|
||||
}
|
||||
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
|
||||
public boolean shouldRenderInPass(int pass)
|
||||
{
|
||||
|
@ -310,13 +210,10 @@ public class TileEntityRift extends DDTileEntityBase
|
|||
{
|
||||
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
|
||||
|| 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)
|
||||
{
|
||||
super.readFromNBT(nbt);
|
||||
this.renderingCenters = new HashMap<Integer, double[]>();
|
||||
this.updateTimer = nbt.getInteger("count");
|
||||
this.riftCloseTimer = nbt.getInteger("count2");
|
||||
this.updateTimer = nbt.getInteger("updateTimer");
|
||||
this.xOffset = nbt.getInteger("xOffset");
|
||||
this.yOffset = nbt.getInteger("yOffset");
|
||||
this.zOffset = nbt.getInteger("zOffset");
|
||||
this.age = nbt.getInteger("age");
|
||||
this.shouldClose = nbt.getBoolean("shouldClose");
|
||||
this.spawnedEndermenID = nbt.getInteger("spawnedEndermenID");
|
||||
}
|
||||
|
@ -362,9 +256,7 @@ public class TileEntityRift extends DDTileEntityBase
|
|||
public void writeToNBT(NBTTagCompound nbt)
|
||||
{
|
||||
super.writeToNBT(nbt);
|
||||
nbt.setInteger("age", this.age);
|
||||
nbt.setInteger("count", this.updateTimer);
|
||||
nbt.setInteger("count2", this.riftCloseTimer);
|
||||
nbt.setInteger("updateTimer", this.updateTimer);
|
||||
nbt.setInteger("xOffset", this.xOffset);
|
||||
nbt.setInteger("yOffset", this.yOffset);
|
||||
nbt.setInteger("zOffset", this.zOffset);
|
||||
|
@ -372,6 +264,7 @@ public class TileEntityRift extends DDTileEntityBase
|
|||
nbt.setInteger("spawnedEndermenID", this.spawnedEndermenID);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Packet getDescriptionPacket()
|
||||
{
|
||||
if (PocketManager.getLink(xCoord, yCoord, zCoord, worldObj) != null)
|
||||
|
|
|
@ -141,12 +141,14 @@ public final class Point4D implements Comparable<Point4D>
|
|||
|
||||
public Point3D toPoint3D()
|
||||
{
|
||||
return new Point3D(this.x,this.y,this.z);
|
||||
return new Point3D(this.x, this.y, this.z);
|
||||
}
|
||||
|
||||
public int[] toIntArray()
|
||||
{
|
||||
return new int[]{x,y,z,dimension};
|
||||
return new int[] {x, y, z, dimension};
|
||||
}
|
||||
|
||||
public boolean equals(Point4D other)
|
||||
{
|
||||
if (this == other)
|
||||
|
|
|
@ -356,7 +356,7 @@ public class PocketBuilder
|
|||
|
||||
//Place a link leading back out of the pocket
|
||||
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
|
||||
buildPocket(world, source.getX(), destinationY, source.getZ(), orientation, size, wallThickness, properties, door);
|
||||
|
@ -400,8 +400,9 @@ public class PocketBuilder
|
|||
int orientation = getDoorOrientation(source, properties);
|
||||
|
||||
//Place a link leading back out of the pocket
|
||||
|
||||
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
|
||||
buildPocket(world, source.getX(), destinationY, source.getZ(), orientation, size, wallThickness, properties, door);
|
||||
|
|
Loading…
Reference in a new issue