Add rift stabilizer and adjust recipes

This commit is contained in:
Runemoro 2018-04-05 18:42:02 -04:00
parent b99f624ccf
commit 3cb768bdd2
11 changed files with 144 additions and 43 deletions

View file

@ -44,6 +44,7 @@ public final class ModelManager {
register(ModItems.RIFT_BLADE);
register(ModItems.RIFT_REMOVER);
register(ModItems.RIFT_SIGNATURE);
register(ModItems.RIFT_STABILIZER);
register(ModItems.STABILIZED_RIFT_SIGNATURE);
register(ModItems.WOVEN_WORLD_THREAD_BOOTS);
register(ModItems.WOVEN_WORLD_THREAD_CHESTPLATE);

View file

@ -95,16 +95,22 @@ public final class ModRecipes {
"xxx", "xyx", "xxx", 'x', Items.GOLD_INGOT, 'y', Items.ENDER_PEARL));
registry.register(makeShapedRecipe(new ItemStack(ModItems.RIFT_REMOVER),
" x ", "xyx", " x ", 'x', Items.GOLD_INGOT, 'y', ModItems.STABLE_FABRIC));
"x x", " y ", "x x", 'x', Items.GOLD_INGOT, 'y', ModItems.STABLE_FABRIC));
registry.register(makeShapedRecipe(new ItemStack(ModItems.RIFT_SIGNATURE),
"xxx", "xyx", "xxx", 'x', Items.IRON_INGOT, 'y', Items.ENDER_PEARL));
registry.register(makeShapedRecipe(new ItemStack(ModItems.RIFT_SIGNATURE),
" x ", "xyx", " x ", 'x', Items.IRON_INGOT, 'y', ModItems.STABLE_FABRIC));
"x x", " y ", "x x", 'x', Items.IRON_INGOT, 'y', ModItems.STABLE_FABRIC));
registry.register(makeShapedRecipe(new ItemStack(ModItems.STABILIZED_RIFT_SIGNATURE),
" x ", "xyx", " x ", 'x', ModItems.STABLE_FABRIC, 'y', ModItems.RIFT_SIGNATURE));
"x x", " y ", "x x", 'x', ModItems.STABLE_FABRIC, 'y', ModItems.RIFT_SIGNATURE));
registry.register(makeShapedRecipe(new ItemStack(ModItems.RIFT_STABILIZER),
"xxx", "xyx", "xxx", 'x', Items.DIAMOND, 'y', Items.ENDER_PEARL));
registry.register(makeShapedRecipe(new ItemStack(ModItems.RIFT_STABILIZER),
"x x", " y ", "x x", 'x', Items.DIAMOND, 'y', ModItems.STABLE_FABRIC));
registry.register(makeShapedRecipe(new ItemStack(ModItems.WOVEN_WORLD_THREAD_HELMET),
"xxx", "x x", 'x', ModItems.WORLD_THREAD));

View file

@ -6,6 +6,8 @@ import net.minecraft.util.text.TextComponentTranslation;
import net.minecraftforge.fml.relauncher.Side;
import net.minecraftforge.fml.relauncher.SideOnly;
import org.dimdev.dimdoors.DimDoors;
import org.dimdev.dimdoors.client.TileEntityFloatingRiftRenderer;
import org.dimdev.dimdoors.shared.ModConfig;
import org.dimdev.dimdoors.shared.RayTraceHelper;
import org.dimdev.dimdoors.shared.sound.ModSounds;
import org.dimdev.dimdoors.shared.tileentities.TileEntityFloatingRift;
@ -40,22 +42,26 @@ public class ItemRiftRemover extends Item {
@Override
public ActionResult<ItemStack> onItemRightClick(World world, EntityPlayer player, EnumHand handIn) { // TODO: permissions
ItemStack stack = player.getHeldItem(handIn);
RayTraceResult hit = rayTrace(world, player, true);
if (world.isRemote) {
if (!RayTraceHelper.isFloatingRift(hit, world)) {
player.sendStatusMessage(new TextComponentTranslation("tools.rift_miss"), true);
TileEntityFloatingRiftRenderer.showRiftCoreUntil = System.currentTimeMillis() + ModConfig.graphics.highlightRiftCoreFor;
}
return new ActionResult<>(EnumActionResult.FAIL, stack);
}
RayTraceResult hit = rayTrace(world, player, true);
if (RayTraceHelper.isFloatingRift(hit, world)) {
TileEntityFloatingRift rift = (TileEntityFloatingRift) world.getTileEntity(hit.getBlockPos());
if (!rift.closing) {
rift.setClosing(true);
world.playSound(null, player.getPosition(), ModSounds.RIFT_CLOSE, SoundCategory.BLOCKS, 0.6f, 1);
stack.damageItem(10, player);
player.sendStatusMessage(new TextComponentTranslation("item.rift_remover.closing"), true);
player.sendStatusMessage(new TextComponentTranslation(getUnlocalizedName() + ".closing"), true);
return new ActionResult<>(EnumActionResult.SUCCESS, stack);
} else {
player.sendStatusMessage(new TextComponentTranslation("item.rift_remover.already_closing"), true);
player.sendStatusMessage(new TextComponentTranslation(getUnlocalizedName() + ".already_closing"), true);
}
}
return new ActionResult<>(EnumActionResult.FAIL, stack);

View file

@ -59,7 +59,7 @@ public class ItemRiftSignature extends Item {
if (target == null) {
// The link signature has not been used. Store its current target as the first location.
setSource(stack, new RotatedLocation(new Location(world, pos), player.rotationYaw, 0));
player.sendStatusMessage(new TextComponentTranslation("item.rift_signature.stored"), true);
player.sendStatusMessage(new TextComponentTranslation(getUnlocalizedName() + ".stored"), true);
world.playSound(null, player.getPosition(), ModSounds.RIFT_START, SoundCategory.BLOCKS, 0.6f, 1);
} else {
// Place a rift at the saved point TODO: check that the player still has permission
@ -85,7 +85,7 @@ public class ItemRiftSignature extends Item {
stack.damageItem(1, player); // TODO: calculate damage based on position?
clearSource(stack);
player.sendStatusMessage(new TextComponentTranslation("item.rift_signature.created"), true);
player.sendStatusMessage(new TextComponentTranslation(getUnlocalizedName() + ".created"), true);
// null = send sound to the player too, we have to do this because this code is not run client-side
world.playSound(null, player.getPosition(), ModSounds.RIFT_END, SoundCategory.BLOCKS, 0.6f, 1);
}

View file

@ -0,0 +1,67 @@
package org.dimdev.dimdoors.shared.items;
import net.minecraft.client.resources.I18n;
import net.minecraft.client.util.ITooltipFlag;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.item.Item;
import net.minecraft.item.ItemStack;
import net.minecraft.util.*;
import net.minecraft.util.math.RayTraceResult;
import net.minecraft.util.text.TextComponentTranslation;
import net.minecraft.world.World;
import net.minecraftforge.fml.relauncher.Side;
import net.minecraftforge.fml.relauncher.SideOnly;
import org.dimdev.dimdoors.DimDoors;
import org.dimdev.dimdoors.client.TileEntityFloatingRiftRenderer;
import org.dimdev.dimdoors.shared.ModConfig;
import org.dimdev.dimdoors.shared.RayTraceHelper;
import org.dimdev.dimdoors.shared.sound.ModSounds;
import org.dimdev.dimdoors.shared.tileentities.TileEntityFloatingRift;
import java.util.List;
public class ItemRiftStabilizer extends Item {
public static final String ID = "rift_stabilizer";
public ItemRiftStabilizer() {
setMaxStackSize(1);
setMaxDamage(6); // TODO: Add more uses and make it reduce rift growth speed instead?
setCreativeTab(DimDoors.DIM_DOORS_CREATIVE_TAB);
setUnlocalizedName(ID);
setRegistryName(new ResourceLocation(DimDoors.MODID, ID));
}
@Override
public ActionResult<ItemStack> onItemRightClick(World world, EntityPlayer player, EnumHand handIn) { // TODO: permissions
ItemStack stack = player.getHeldItem(handIn);
RayTraceResult hit = rayTrace(world, player, true);
if (world.isRemote) {
if (!RayTraceHelper.isFloatingRift(hit, world)) {
player.sendStatusMessage(new TextComponentTranslation("tools.rift_miss"), true);
TileEntityFloatingRiftRenderer.showRiftCoreUntil = System.currentTimeMillis() + ModConfig.graphics.highlightRiftCoreFor;
}
return new ActionResult<>(EnumActionResult.FAIL, stack);
}
if (RayTraceHelper.isFloatingRift(hit, world)) {
TileEntityFloatingRift rift = (TileEntityFloatingRift) world.getTileEntity(hit.getBlockPos());
if (!rift.stabilized && !rift.closing) {
rift.setStabilized(true);
world.playSound(null, player.getPosition(), ModSounds.RIFT_CLOSE, SoundCategory.BLOCKS, 0.6f, 1); // TODO: different sound
stack.damageItem(1, player);
player.sendStatusMessage(new TextComponentTranslation(getUnlocalizedName() + ".stabilized"), true);
return new ActionResult<>(EnumActionResult.SUCCESS, stack);
} else {
player.sendStatusMessage(new TextComponentTranslation(getUnlocalizedName() + ".already_stabilized"), true);
}
}
return new ActionResult<>(EnumActionResult.FAIL, stack);
}
@Override
@SideOnly(Side.CLIENT)
public void addInformation(ItemStack stack, World world, List<String> tooltip, ITooltipFlag flag) {
tooltip.add(I18n.format(I18n.format(getUnlocalizedName() + ".info")));
}
}

View file

@ -59,7 +59,7 @@ public class ItemStabilizedRiftSignature extends Item { // TODO: common supercla
if (target == null) {
// The link signature has not been used. Store its current target as the first location.
setSource(stack, new RotatedLocation(new Location(world, pos), player.rotationYaw, 0));
player.sendStatusMessage(new TextComponentTranslation("item.stabilized_rift_signature.stored"), true);
player.sendStatusMessage(new TextComponentTranslation(getUnlocalizedName() + ".stored"), true);
world.playSound(null, player.getPosition(), ModSounds.RIFT_START, SoundCategory.BLOCKS, 0.6f, 1);
} else {
// Place a rift at the target point
@ -83,7 +83,7 @@ public class ItemStabilizedRiftSignature extends Item { // TODO: common supercla
stack.damageItem(1, player);
player.sendStatusMessage(new TextComponentTranslation("item.stabilized_rift_signature.created"), true);
player.sendStatusMessage(new TextComponentTranslation(getUnlocalizedName() + ".created"), true);
world.playSound(null, player.getPosition(), ModSounds.RIFT_END, SoundCategory.BLOCKS, 0.6f, 1);
}
@ -116,9 +116,9 @@ public class ItemStabilizedRiftSignature extends Item { // TODO: common supercla
public void addInformation(ItemStack stack, World world, List<String> tooltip, ITooltipFlag flag) {
RotatedLocation transform = getTarget(stack);
if (transform != null) {
tooltip.add(I18n.format("item.stabilized_rift_signature.bound.info", transform.getLocation().getX(), transform.getLocation().getY(), transform.getLocation().getZ(), transform.getLocation().getDim()));
tooltip.add(I18n.format(getUnlocalizedName() + ".bound.info", transform.getLocation().getX(), transform.getLocation().getY(), transform.getLocation().getZ(), transform.getLocation().getDim()));
} else {
tooltip.add(I18n.format("item.stabilized_rift_signature.unbound.info"));
tooltip.add(I18n.format(getUnlocalizedName() + ".unbound.info"));
}
}
}

View file

@ -35,6 +35,7 @@ public final class ModItems {
public static final ItemRiftRemover RIFT_REMOVER = new ItemRiftRemover();
public static final ItemRiftSignature RIFT_SIGNATURE = new ItemRiftSignature();
public static final ItemStabilizedRiftSignature STABILIZED_RIFT_SIGNATURE = new ItemStabilizedRiftSignature();
public static final ItemRiftStabilizer RIFT_STABILIZER = new ItemRiftStabilizer();
// Armors
public static final ItemWovenWorldThreadArmor WOVEN_WORLD_THREAD_HELMET = new ItemWovenWorldThreadArmor("woven_world_thread_helmet", 1, EntityEquipmentSlot.HEAD);
@ -65,6 +66,7 @@ public final class ModItems {
RIFT_REMOVER,
RIFT_SIGNATURE,
STABILIZED_RIFT_SIGNATURE,
RIFT_STABILIZER,
WOVEN_WORLD_THREAD_HELMET,
WOVEN_WORLD_THREAD_CHESTPLATE,
WOVEN_WORLD_THREAD_LEGGINGS,

View file

@ -34,9 +34,9 @@ import java.util.Random;
private static final Random random = new Random();
// TODO: Some of these properties will need to persist when converting to door and then back to rift!
//Need to be saved:
// Need to be saved:
@Saved public boolean closing = false; // TODO: maybe we could have a closingSpeed instead?
@Saved public boolean stabilized = false;
@Saved public int spawnedEndermenID = 0;
@Saved public float size = 0; // TODO: store size in blocks
@Saved public float riftYaw = random.nextInt(360);
@ -63,17 +63,6 @@ import java.util.Random;
return;
}
// Check if this rift should render white closing particles and
// spread the closing effect to other rifts nearby.
if (closing) {
if (size > 0) {
size -= ModConfig.general.riftCloseSpeed;
} else {
world.setBlockToAir(pos);
}
return;
}
if (updateTimer >= UPDATE_PERIOD) {
spawnEndermen();
updateTimer = 0;
@ -82,10 +71,20 @@ import java.util.Random;
}
updateTimer++;
// Logarithmic growth
for (int n = 0; n < 10; n++) {
// TODO: growthSpeed and growthSize config options
size += 1F / (size + 1);
// Check if this rift should render white closing particles and
// spread the closing effect to other rifts nearby.
if (closing) {
if (size > 0) {
size -= ModConfig.general.riftCloseSpeed;
} else {
world.setBlockToAir(pos);
}
} else if (!stabilized) {
// Logarithmic growth
for (int n = 0; n < 10; n++) {
// TODO: growthSpeed and growthSize config options
size += 1F / (size + 1);
}
}
}
@ -134,6 +133,13 @@ import java.util.Random;
markDirty();
}
public void setStabilized(boolean stabilized) {
this.stabilized = stabilized;
IBlockState state = world.getBlockState(pos);
world.notifyBlockUpdate(pos, state, state, 0);
markDirty();
}
@Override
public boolean shouldRefresh(World world, BlockPos pos, IBlockState oldState, IBlockState newSate) {
// newState is not accurate if we change the state during onBlockBreak

View file

@ -73,6 +73,10 @@ item.rift_configuration_tool.name=Rift Configuration Tool
item.rift_remover.name=Rift Remover
item.rift_remover.closing=The rift will close soon
item.rift_remover.already_closing=This rift is already closing
item.rift_stabilizer.name=Rift Stabilizer
item.rift_stabilizer.info=Use on a rift's core to stop its growth.
item.rift_stabilizer.stabilized=The rift has been stabilized and will stop growing
item.rift_stabilizer.already_stabilized=This rift is already stable
item.rift_blade.name=Rift Blade
item.world_thread.name=World Thread
@ -121,8 +125,10 @@ rifts.destinations.private_pocket_exit.rift_has_closed=The rift you used to ente
rifts.entrances.rift_too_close=Placing a door this close to a tear in the world would be dangerous. Shift-right-click to place anyway, or place it on the rift's core (tesseract) to bind it to the rift.
rifts.entrances.cannot_be_placed_on_rift=This type of door can't be placed on a rift.
dimdoors.general=General Options
dimdoors.general.tooltip=General configuration options for the mod
tools.rift_miss=You can only use this item on a rift's core (tesseract)
dimdoors.general=General Settings
dimdoors.general.tooltip=General configuration settings for the mod
dimdoors.general.baseDimensionID=Base Dimension ID
dimdoors.general.baseDimensionID.tooltip=Dimension ID of the first Dimensional Doors dimension. Other dimensions will use consecutive IDs. It is strongly recommended to leave this to the default value.
dimdoors.general.useStatusBar=Status Bar Messages
@ -131,6 +137,7 @@ dimdoors.general.closeDoorBehind=Close Door Behind
dimdoors.general.closeDoorBehind.tooltip=When true, Dimensional Doors will automatically close when the player enters their portal.
dimdoors.general.depthSpreadFactor=Depth Spread Factor
dimdoors.general.depthSpreadFactor.tooltip=The scale of the dispersion when escaping from a pocket or limbo, in blocks/depth. It is important to remember that by default, limbo is treated as depth 50.
dimdoors.general.riftCloseSpeed=Rift Close Speed
dimdoors.general.riftCloseSpeed.tooltip=The speed at which rifts close when using the rift remover, in units of rift size per tick.
dimdoors.general.closeDoorBehind.tooltip=When true, Dimensional Doors will automatically close when the player enters their portal.
dimdoors.general.teleportOffset=Teleport Offset
@ -138,8 +145,8 @@ dimdoors.general.teleportOffset.tooltip=Distance in blocks to teleport the playe
dimdoors.general.riftBoundingBoxInCreative=Rift Bounding Box in Creative
dimdoors.general.riftBoundingBoxInCreative.tooltip=When true, shows the bounding boxes of floating rifts when the player is in creative.
dimdoors.pockets=Pocket Dimension Options
dimdoors.pockets.tooltip=Options that determine the spacing and maximum size of pockets in the pocket world
dimdoors.pockets=Pocket Dimension Settings
dimdoors.pockets.tooltip=Settings that determine the spacing and maximum size of pockets in the pocket world
dimdoors.pockets.pocketGridSize=Pocket Grid Size
dimdoors.pockets.pocketGridSize.tooltip=Sets how many chunks apart all pockets in any pocket dimensions should be placed.
dimdoors.pockets.maxPocketSize=Maximum Pocket Size
@ -151,8 +158,8 @@ dimdoors.pockets.publicPocketSize.tooltip=Sets the minimum size of a newly creat
dimdoors.pockets.loadAllSchematics=Load All Schematics
dimdoors.pockets.loadAllSchematics.tooltip= When true, all available Pocket Schematics will be loaded on game-start, even if the gridSize and pocketSize configuration fields would exclude these schematics from being used in 'naturally generated' pockets. The /pocket command can be used to force-generate these pockets for dungeon building or testing purposes.
dimdoors.world=World Generation Options
dimdoors.world.tooltip=Options that determine where dimensional gateways and rift clusters can be generated and at what frequency
dimdoors.world=World Generation Settings
dimdoors.world.tooltip=Settings that determine where dimensional gateways and rift clusters can be generated and at what frequency
dimdoors.world.clusterGenChance=Cluster Generation Chance
dimdoors.world.clusterGenChance.tooltip=Sets the chance (out of 1.0) that a cluster of Rift Scars will generate in a given chunk.
dimdoors.world.gatewayGenChance=Gateway Generation Chance
@ -162,27 +169,27 @@ dimdoors.world.clusterDimBlacklist.tooltip=Dimension Blacklist for the generatio
dimdoors.world.gatewayDimBlacklist=Gateway Dimension Blacklist
dimdoors.world.gatewayDimBlacklist.tooltip=Dimension Blacklist for the generation of Transient Portal gateways. Add a dimension ID here to prevent generation in certain dimensions.
dimdoors.dungeons=Dungeon Options
dimdoors.dungeons.tooltip=Options that affect the generation of pocket dungeons
dimdoors.dungeons=Dungeon Settings
dimdoors.dungeons.tooltip=Settings that affect the generation of pocket dungeons
dimdoors.dungeons.maxDungeonDepth=Maximum Dungeon Depth
dimdoors.dungeons.maxDungeonDepth.tooltip=The depth at which limbo is located. If a Rift reaches any deeper than this while searching for a new destination, the player trying to enter the Rift will be sent straight to Limbo.
dimdoors.monoliths=Monolith Options
dimdoors.monoliths.tooltip=Options that determine how dangerous monoliths are
dimdoors.monoliths=Monolith Settings
dimdoors.monoliths.tooltip=Settings that determine how dangerous monoliths are
dimdoors.monoliths.dangerousLimboMonoliths=Dangerous Limbo Monoliths
dimdoors.monoliths.dangerousLimboMonoliths.tooltip=When true, Monoliths in Limbo attack the player and deal damage.
dimdoors.monoliths.monolithTeleportation=Monolith Teleportation
dimdoors.monoliths.monolithTeleportation.tooltip=When true, being exposed to the gaze of Monoliths for too long, will cause the player to be teleported to the void above Limbo.
dimdoors.limbo=Limbo Options
dimdoors.limbo.tooltip=Options that control various aspects of the Limbo dimension
dimdoors.limbo=Limbo Settings
dimdoors.limbo.tooltip=Settings that control various aspects of the Limbo dimension
dimdoors.limbo.universalLimbo=Universal Limbo
dimdoors.limbo.universalLimbo.tooltip=When true, players are also teleported to Limbo when they die in any non-Pocket Dimension (except Limbo itself). Otherwise, players only go to Limbo if they die in a Pocket Dimension.
dimdoors.limbo.hardcoreLimbo=Hardcore Limbo
dimdoors.limbo.hardcoreLimbo.tooltip=When true, a player dying in Limbo will respawn in Limbo, making Eternal Fluid or Golden Dimensional Doors the only way to escape Limbo.
dimdoors.graphics=Graphics Options
dimdoors.graphics.tooltip=Options that control the appearance of dimdoors, such as the rift animation.
dimdoors.graphics=Graphics Settings
dimdoors.graphics.tooltip=Settings that control the appearance of dimdoors, such as the rift animation.
dimdoors.graphics.highlightRiftCoreFor=Time to Highlight Rift Core
dimdoors.graphics.highlightRiftCoreFor.tooltip=How long, in milliseconds, the rift's core (tesseract animation) should be shown for when attempting to place a door near a large rift but not directly on it. Set to -1 to disable.
dimdoors.graphics.showRiftCore=Always Show Rift Cores

View file

@ -0,0 +1,6 @@
{
"parent": "item/handheld",
"textures": {
"layer0": "dimdoors:items/rift_stabilizer"
}
}

Binary file not shown.

After

Width:  |  Height:  |  Size: 361 B