Skip to content

Commit a2e7689

Browse files
committed
Improvements to tools
* 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
1 parent cb0cadc commit a2e7689

File tree

8 files changed

+36
-34
lines changed

8 files changed

+36
-34
lines changed

src/main/java/org/dimdev/dimdoors/client/ParticleRiftEffect.java

Lines changed: 0 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -37,16 +37,4 @@ public void renderParticle(BufferBuilder buffer, Entity entity, float partialTic
3737
setRBGColorF(oldRed, oldGreen, oldBlue);
3838
setAlphaF(oldAlpha);
3939
}
40-
41-
public static class Rift extends ParticleRiftEffect {
42-
public Rift(World world, double x, double y, double z, double motionX, double motionY, double motionZ) {
43-
super(world, x, y, z, motionX, motionY, motionZ, 0.0f, 0.7f, 0.55f, 2000, 2000);
44-
}
45-
}
46-
47-
public static class ClosingRiftEffect extends ParticleRiftEffect {
48-
public ClosingRiftEffect(World world, double x, double y, double z, double motionX, double motionY, double motionZ) {
49-
super(world, x, y, z, motionX, motionY, motionZ, 0.8f, 0.4f, 0.55f, 38, 16);
50-
}
51-
}
5240
}

src/main/java/org/dimdev/dimdoors/shared/blocks/BlockDimensionalTrapdoor.java

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
package org.dimdev.dimdoors.shared.blocks;
22

33
import net.minecraft.block.material.EnumPushReaction;
4+
import org.dimdev.dimdoors.DimDoors;
45
import org.dimdev.dimdoors.shared.tileentities.TileEntityEntranceRift;
56
import net.minecraft.block.*;
67
import net.minecraft.block.material.Material;
@@ -60,6 +61,10 @@ public boolean canOpen(World world, BlockPos pos, EntityPlayer player) {
6061
public TileEntityEntranceRift createNewTileEntity(World world, int meta) {
6162
TileEntityEntranceRift rift = new TileEntityEntranceRift();
6263
rift.orientation = EnumFacing.UP;
64+
if (DimDoors.proxy.isClient()) {
65+
// Trapdoor is on the ground
66+
rift.pushIn = -0.01;
67+
}
6368
return rift;
6469
}
6570

src/main/java/org/dimdev/dimdoors/shared/blocks/BlockFloatingRift.java

Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -88,17 +88,21 @@ public void randomDisplayTick(IBlockState state, World world, BlockPos pos, Rand
8888
if (!(tileEntity instanceof TileEntityFloatingRift)) return;
8989
TileEntityFloatingRift rift = (TileEntityFloatingRift) tileEntity;
9090

91+
// TODO: direction of particles should be rift orientation, speed should depend on size
92+
double speed = 0.1d; // rift.size / 1400f;
93+
9194
if (rift.closing) { // Renders an opposite color effect if it is being closed by the rift remover
92-
FMLClientHandler.instance().getClient().effectRenderer.addEffect(new ParticleRiftEffect.ClosingRiftEffect(
95+
FMLClientHandler.instance().getClient().effectRenderer.addEffect(new ParticleRiftEffect(
9396
world,
9497
pos.getX() + .5, pos.getY() + 1.5, pos.getZ() + .5,
95-
rand.nextGaussian() * 0.1D, rand.nextGaussian() * 0.1D, rand.nextGaussian() * 0.1D));
98+
rand.nextGaussian() * speed, rand.nextGaussian() * speed, rand.nextGaussian() * speed,
99+
0.8f, 0.4f, 0.55f, 2000, 2000));
96100
}
97101

98-
// TODO: depend on size, stabilization status, direction of particles should be rift orientation
99-
FMLClientHandler.instance().getClient().effectRenderer.addEffect(new ParticleRiftEffect.Rift(
102+
FMLClientHandler.instance().getClient().effectRenderer.addEffect(new ParticleRiftEffect(
100103
world,
101104
pos.getX() + .5, pos.getY() + 1.5, pos.getZ() + .5,
102-
rand.nextGaussian() * 0.1D, rand.nextGaussian() * 0.1D, rand.nextGaussian() * 0.1D));
105+
rand.nextGaussian() * speed, rand.nextGaussian() * speed, rand.nextGaussian() * speed,
106+
0.0f, 0.7f, 0.55f, rift.stabilized ? 750 : 2000, rift.stabilized ? 750 : 2000));
103107
}
104108
}

src/main/java/org/dimdev/dimdoors/shared/items/ItemDimensionalDoor.java

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -48,8 +48,9 @@ public EnumActionResult onItemUse(EntityPlayer player, World world, BlockPos pos
4848
return EnumActionResult.FAIL;
4949
}
5050

51-
if (world.isRemote) return EnumActionResult.FAIL;
52-
51+
if (world.isRemote) {
52+
return super.onItemUse(player, world, originalPos, hand, facing, hitX, hitY, hitZ);
53+
}
5354

5455
// Store the rift entity if there's a rift block there that may be broken
5556
TileEntityFloatingRift rift = null;

src/main/java/org/dimdev/dimdoors/shared/items/ItemDimensionalTrapdoor.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ public abstract class ItemDimensionalTrapdoor extends ItemBlock {
3030
@Override
3131
public EnumActionResult onItemUse(EntityPlayer player, World world, BlockPos pos, EnumHand hand, EnumFacing facing, float hitX, float hitY, float hitZ) {
3232
if (world.isRemote) {
33-
return EnumActionResult.FAIL;
33+
return super.onItemUse(player, world, pos, hand, facing, hitX, hitY, hitZ);
3434
}
3535

3636
boolean replaceable = world.getBlockState(pos).getBlock().isReplaceable(world, pos); // Check this before calling super, since that changes the block

src/main/java/org/dimdev/dimdoors/shared/items/ItemRiftSignature.java

Lines changed: 9 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -44,14 +44,14 @@ public boolean hasEffect(ItemStack stack) {
4444
public EnumActionResult onItemUse(EntityPlayer player, World world, BlockPos pos, EnumHand hand, EnumFacing side, float hitX, float hitY, float hitZ) {
4545
ItemStack stack = player.getHeldItem(hand);
4646
pos = world.getBlockState(pos).getBlock().isReplaceable(world, pos) ? pos : pos.offset(side);
47-
// Return false on the client side to pass this request to the server
48-
if (world.isRemote) {
49-
return EnumActionResult.FAIL;
50-
}
5147

5248
// Fail if the player can't place a block there TODO: spawn protection, other plugin support
5349
if (!player.canPlayerEdit(pos, side.getOpposite(), stack)) {
54-
return EnumActionResult.PASS;
50+
return EnumActionResult.FAIL;
51+
}
52+
53+
if (world.isRemote) {
54+
return EnumActionResult.SUCCESS;
5555
}
5656

5757
RotatedLocation target = getSource(stack);
@@ -64,8 +64,10 @@ public EnumActionResult onItemUse(EntityPlayer player, World world, BlockPos pos
6464
} else {
6565
// Place a rift at the saved point TODO: check that the player still has permission
6666
if (!target.getLocation().getBlockState().getBlock().equals(ModBlocks.RIFT)) {
67-
if (!target.getLocation().getBlockState().getBlock().equals(Blocks.AIR)) {
68-
return EnumActionResult.FAIL; // TODO: send a message
67+
if (!target.getLocation().getBlockState().getBlock().isReplaceable(world, target.getLocation().getPos())) {
68+
DimDoors.sendTranslatedMessage(player, "tools.target_became_block");
69+
clearSource(stack); // TODO: But is this fair? It's a rather hidden way of unbinding your signature!
70+
return EnumActionResult.FAIL;
6971
}
7072
World sourceWorld = target.getLocation().getWorld();
7173
sourceWorld.setBlockState(target.getLocation().getPos(), ModBlocks.RIFT.getDefaultState());

src/main/java/org/dimdev/dimdoors/shared/items/ItemStabilizedRiftSignature.java

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -44,16 +44,15 @@ public boolean hasEffect(ItemStack stack) {
4444
public EnumActionResult onItemUse(EntityPlayer player, World world, BlockPos pos, EnumHand hand, EnumFacing side, float hitX, float hitY, float hitZ) {
4545
ItemStack stack = player.getHeldItem(hand);
4646
pos = world.getBlockState(pos).getBlock().isReplaceable(world, pos) ? pos : pos.offset(side);
47-
// Return false on the client side to pass this request to the server
48-
if (world.isRemote) {
49-
return EnumActionResult.FAIL;
50-
}
51-
5247
// Fail if the player can't place a block there TODO: spawn protection, other plugin support
5348
if (!player.canPlayerEdit(pos, side.getOpposite(), stack)) {
5449
return EnumActionResult.FAIL;
5550
}
5651

52+
if (world.isRemote) {
53+
return EnumActionResult.SUCCESS;
54+
}
55+
5756
RotatedLocation target = getTarget(stack);
5857

5958
if (target == null) {
@@ -64,8 +63,10 @@ public EnumActionResult onItemUse(EntityPlayer player, World world, BlockPos pos
6463
} else {
6564
// Place a rift at the target point
6665
if (!target.getLocation().getBlockState().getBlock().equals(ModBlocks.RIFT)) {
67-
if (!target.getLocation().getBlockState().getBlock().equals(Blocks.AIR)) {
68-
return EnumActionResult.FAIL; // TODO: send a message
66+
if (!target.getLocation().getBlockState().getBlock().isReplaceable(world, target.getLocation().getPos())) {
67+
DimDoors.sendTranslatedMessage(player, "tools.target_became_block");
68+
// Don't clear source, stabilized signatures always stay bound
69+
return EnumActionResult.FAIL;
6970
}
7071
World targetWorld = target.getLocation().getWorld();
7172
targetWorld.setBlockState(target.getLocation().getPos(), ModBlocks.RIFT.getDefaultState());

src/main/resources/assets/dimdoors/lang/en_US.lang

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -127,6 +127,7 @@ rifts.entrances.rift_too_close=Placing a door this close to a tear in the world
127127
rifts.entrances.cannot_be_placed_on_rift=This type of door can't be placed on a rift.
128128

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

131132
dimdoors.general=General Settings
132133
dimdoors.general.tooltip=General configuration settings for the mod

0 commit comments

Comments
 (0)