Skip to content

Commit

Permalink
Improvements to tools
Browse files Browse the repository at this point in the history
 * Fix dimensional door and trapdoor arm swing
 * Make trapdoor animation render above the ground rather than below
 * Allow rift signatures to replace any replaceable source block
 * Send message when rift signature fails because the block at the stored location is no longer replaceable
  • Loading branch information
Runemoro committed Apr 6, 2018
1 parent cb0cadc commit a2e7689
Show file tree
Hide file tree
Showing 8 changed files with 36 additions and 34 deletions.
12 changes: 0 additions & 12 deletions src/main/java/org/dimdev/dimdoors/client/ParticleRiftEffect.java
Original file line number Diff line number Diff line change
Expand Up @@ -37,16 +37,4 @@ public void renderParticle(BufferBuilder buffer, Entity entity, float partialTic
setRBGColorF(oldRed, oldGreen, oldBlue);
setAlphaF(oldAlpha);
}

public static class Rift extends ParticleRiftEffect {
public Rift(World world, double x, double y, double z, double motionX, double motionY, double motionZ) {
super(world, x, y, z, motionX, motionY, motionZ, 0.0f, 0.7f, 0.55f, 2000, 2000);
}
}

public static class ClosingRiftEffect extends ParticleRiftEffect {
public ClosingRiftEffect(World world, double x, double y, double z, double motionX, double motionY, double motionZ) {
super(world, x, y, z, motionX, motionY, motionZ, 0.8f, 0.4f, 0.55f, 38, 16);
}
}
}
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
package org.dimdev.dimdoors.shared.blocks;

import net.minecraft.block.material.EnumPushReaction;
import org.dimdev.dimdoors.DimDoors;
import org.dimdev.dimdoors.shared.tileentities.TileEntityEntranceRift;
import net.minecraft.block.*;
import net.minecraft.block.material.Material;
Expand Down Expand Up @@ -60,6 +61,10 @@ public boolean canOpen(World world, BlockPos pos, EntityPlayer player) {
public TileEntityEntranceRift createNewTileEntity(World world, int meta) {
TileEntityEntranceRift rift = new TileEntityEntranceRift();
rift.orientation = EnumFacing.UP;
if (DimDoors.proxy.isClient()) {
// Trapdoor is on the ground
rift.pushIn = -0.01;
}
return rift;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -88,17 +88,21 @@ public void randomDisplayTick(IBlockState state, World world, BlockPos pos, Rand
if (!(tileEntity instanceof TileEntityFloatingRift)) return;
TileEntityFloatingRift rift = (TileEntityFloatingRift) tileEntity;

// TODO: direction of particles should be rift orientation, speed should depend on size
double speed = 0.1d; // rift.size / 1400f;

if (rift.closing) { // Renders an opposite color effect if it is being closed by the rift remover
FMLClientHandler.instance().getClient().effectRenderer.addEffect(new ParticleRiftEffect.ClosingRiftEffect(
FMLClientHandler.instance().getClient().effectRenderer.addEffect(new ParticleRiftEffect(
world,
pos.getX() + .5, pos.getY() + 1.5, pos.getZ() + .5,
rand.nextGaussian() * 0.1D, rand.nextGaussian() * 0.1D, rand.nextGaussian() * 0.1D));
rand.nextGaussian() * speed, rand.nextGaussian() * speed, rand.nextGaussian() * speed,
0.8f, 0.4f, 0.55f, 2000, 2000));
}

// TODO: depend on size, stabilization status, direction of particles should be rift orientation
FMLClientHandler.instance().getClient().effectRenderer.addEffect(new ParticleRiftEffect.Rift(
FMLClientHandler.instance().getClient().effectRenderer.addEffect(new ParticleRiftEffect(
world,
pos.getX() + .5, pos.getY() + 1.5, pos.getZ() + .5,
rand.nextGaussian() * 0.1D, rand.nextGaussian() * 0.1D, rand.nextGaussian() * 0.1D));
rand.nextGaussian() * speed, rand.nextGaussian() * speed, rand.nextGaussian() * speed,
0.0f, 0.7f, 0.55f, rift.stabilized ? 750 : 2000, rift.stabilized ? 750 : 2000));
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -48,8 +48,9 @@ public EnumActionResult onItemUse(EntityPlayer player, World world, BlockPos pos
return EnumActionResult.FAIL;
}

if (world.isRemote) return EnumActionResult.FAIL;

if (world.isRemote) {
return super.onItemUse(player, world, originalPos, hand, facing, hitX, hitY, hitZ);
}

// Store the rift entity if there's a rift block there that may be broken
TileEntityFloatingRift rift = null;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ public abstract class ItemDimensionalTrapdoor extends ItemBlock {
@Override
public EnumActionResult onItemUse(EntityPlayer player, World world, BlockPos pos, EnumHand hand, EnumFacing facing, float hitX, float hitY, float hitZ) {
if (world.isRemote) {
return EnumActionResult.FAIL;
return super.onItemUse(player, world, pos, hand, facing, hitX, hitY, hitZ);
}

boolean replaceable = world.getBlockState(pos).getBlock().isReplaceable(world, pos); // Check this before calling super, since that changes the block
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -44,14 +44,14 @@ public boolean hasEffect(ItemStack stack) {
public EnumActionResult onItemUse(EntityPlayer player, World world, BlockPos pos, EnumHand hand, EnumFacing side, float hitX, float hitY, float hitZ) {
ItemStack stack = player.getHeldItem(hand);
pos = world.getBlockState(pos).getBlock().isReplaceable(world, pos) ? pos : pos.offset(side);
// Return false on the client side to pass this request to the server
if (world.isRemote) {
return EnumActionResult.FAIL;
}

// Fail if the player can't place a block there TODO: spawn protection, other plugin support
if (!player.canPlayerEdit(pos, side.getOpposite(), stack)) {
return EnumActionResult.PASS;
return EnumActionResult.FAIL;
}

if (world.isRemote) {
return EnumActionResult.SUCCESS;
}

RotatedLocation target = getSource(stack);
Expand All @@ -64,8 +64,10 @@ public EnumActionResult onItemUse(EntityPlayer player, World world, BlockPos pos
} else {
// Place a rift at the saved point TODO: check that the player still has permission
if (!target.getLocation().getBlockState().getBlock().equals(ModBlocks.RIFT)) {
if (!target.getLocation().getBlockState().getBlock().equals(Blocks.AIR)) {
return EnumActionResult.FAIL; // TODO: send a message
if (!target.getLocation().getBlockState().getBlock().isReplaceable(world, target.getLocation().getPos())) {
DimDoors.sendTranslatedMessage(player, "tools.target_became_block");
clearSource(stack); // TODO: But is this fair? It's a rather hidden way of unbinding your signature!
return EnumActionResult.FAIL;
}
World sourceWorld = target.getLocation().getWorld();
sourceWorld.setBlockState(target.getLocation().getPos(), ModBlocks.RIFT.getDefaultState());
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -44,16 +44,15 @@ public boolean hasEffect(ItemStack stack) {
public EnumActionResult onItemUse(EntityPlayer player, World world, BlockPos pos, EnumHand hand, EnumFacing side, float hitX, float hitY, float hitZ) {
ItemStack stack = player.getHeldItem(hand);
pos = world.getBlockState(pos).getBlock().isReplaceable(world, pos) ? pos : pos.offset(side);
// Return false on the client side to pass this request to the server
if (world.isRemote) {
return EnumActionResult.FAIL;
}

// Fail if the player can't place a block there TODO: spawn protection, other plugin support
if (!player.canPlayerEdit(pos, side.getOpposite(), stack)) {
return EnumActionResult.FAIL;
}

if (world.isRemote) {
return EnumActionResult.SUCCESS;
}

RotatedLocation target = getTarget(stack);

if (target == null) {
Expand All @@ -64,8 +63,10 @@ public EnumActionResult onItemUse(EntityPlayer player, World world, BlockPos pos
} else {
// Place a rift at the target point
if (!target.getLocation().getBlockState().getBlock().equals(ModBlocks.RIFT)) {
if (!target.getLocation().getBlockState().getBlock().equals(Blocks.AIR)) {
return EnumActionResult.FAIL; // TODO: send a message
if (!target.getLocation().getBlockState().getBlock().isReplaceable(world, target.getLocation().getPos())) {
DimDoors.sendTranslatedMessage(player, "tools.target_became_block");
// Don't clear source, stabilized signatures always stay bound
return EnumActionResult.FAIL;
}
World targetWorld = target.getLocation().getWorld();
targetWorld.setBlockState(target.getLocation().getPos(), ModBlocks.RIFT.getDefaultState());
Expand Down
1 change: 1 addition & 0 deletions src/main/resources/assets/dimdoors/lang/en_US.lang
Original file line number Diff line number Diff line change
Expand Up @@ -127,6 +127,7 @@ rifts.entrances.rift_too_close=Placing a door this close to a tear in the world
rifts.entrances.cannot_be_placed_on_rift=This type of door can't be placed on a rift.

tools.rift_miss=You can only use this item on a rift's core
tools.target_became_block=Failed, there is now a block at the stored location

dimdoors.general=General Settings
dimdoors.general.tooltip=General configuration settings for the mod
Expand Down

0 comments on commit a2e7689

Please sign in to comment.