Skip to content

Commit 225b595

Browse files
committed
Graphics improvements and bug fixes
* Fix hand not swinging for all items * Fix dimensional trapdoor being registered client-side * Make rift blade teleport near the entity rather than on it * Rift jitter adjustment and config option * Remove "In" suffixes and "par" prefixes from remaining parameters
1 parent 3cb768b commit 225b595

16 files changed

+82
-52
lines changed

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

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -49,10 +49,4 @@ public ClosingRiftEffect(World world, double x, double y, double z, double motio
4949
super(world, x, y, z, motionX, motionY, motionZ, 0.8f, 0.4f, 0.55f, 38, 16);
5050
}
5151
}
52-
53-
public static class GogglesRiftEffect extends ParticleRiftEffect {
54-
public GogglesRiftEffect(World world, double x, double y, double z, double motionX, double motionY, double motionZ) {
55-
super(world, x, y, z, motionX, motionY, motionZ, 0.0f, 0.7f, 0.55f, 38, 16);
56-
}
57-
}
5852
}

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

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -72,33 +72,33 @@ public void doRender(EntityMonolith monolith, double x, double y, double z, floa
7272
//this.renderLeash(entity, x, y, z, par8, par9);
7373
}
7474

75-
public void render(EntityMonolith par1EntityLivingBase, double x, double y, double z, float par8, float par9) {
76-
if (MinecraftForge.EVENT_BUS.post(new RenderLivingEvent.Pre<>(par1EntityLivingBase, this, 1, x, y, z))) return;
75+
public void render(EntityMonolith monolith, double x, double y, double z, float par8, float partialTickTime) {
76+
if (MinecraftForge.EVENT_BUS.post(new RenderLivingEvent.Pre<>(monolith, this, 1, x, y, z))) return;
7777
GlStateManager.pushMatrix();
7878
GlStateManager.disableCull();
7979
GlStateManager.disableLighting();
8080
GlStateManager.enableBlend();
8181
GlStateManager.blendFunc(GL11.GL_SRC_ALPHA, GL11.GL_ONE_MINUS_SRC_ALPHA);
82-
mainModel.swingProgress = getSwingProgress(par1EntityLivingBase, par9);
82+
mainModel.swingProgress = getSwingProgress(monolith, partialTickTime);
8383

8484
try {
85-
float interpolatedYaw = interpolateRotation(par1EntityLivingBase.prevRenderYawOffset, par1EntityLivingBase.renderYawOffset, par9);
85+
float interpolatedYaw = interpolateRotation(monolith.prevRenderYawOffset, monolith.renderYawOffset, partialTickTime);
8686
float rotation;
87-
float pitch = par1EntityLivingBase.prevRotationPitch + (par1EntityLivingBase.rotationPitch - par1EntityLivingBase.prevRotationPitch) * par9;
88-
renderLivingAt(par1EntityLivingBase, x, y, z);
87+
float pitch = monolith.prevRotationPitch + (monolith.rotationPitch - monolith.prevRotationPitch) * partialTickTime;
88+
renderLivingAt(monolith, x, y, z);
8989

90-
rotation = handleRotationFloat(par1EntityLivingBase, par9);
91-
applyRotations(par1EntityLivingBase, rotation, interpolatedYaw, par9);
90+
rotation = handleRotationFloat(monolith, partialTickTime);
91+
applyRotations(monolith, rotation, interpolatedYaw, partialTickTime);
9292

9393
float f6 = 0.0625F;
9494
GlStateManager.enableRescaleNormal();
9595

9696
GlStateManager.scale(-1.0F, -1.0F, 1.0F);
97-
preRenderCallback(par1EntityLivingBase, par9);
98-
GlStateManager.rotate(par1EntityLivingBase.pitchLevel, 1.0F, 0.0F, 0.0F);
97+
preRenderCallback(monolith, partialTickTime);
98+
GlStateManager.rotate(monolith.pitchLevel, 1.0F, 0.0F, 0.0F);
9999
GlStateManager.translate(0.0F, 24.0F * f6 - 0.0078125F, 0.0F);
100100

101-
renderModel(par1EntityLivingBase, 0, 0, rotation, interpolatedYaw, pitch, f6);
101+
renderModel(monolith, 0, 0, rotation, interpolatedYaw, pitch, f6);
102102

103103
OpenGlHelper.setActiveTexture(OpenGlHelper.lightmapTexUnit);
104104
GlStateManager.disableTexture2D();
@@ -116,7 +116,7 @@ public void render(EntityMonolith par1EntityLivingBase, double x, double y, doub
116116
GlStateManager.enableLighting();
117117
GlStateManager.disableBlend();
118118
GlStateManager.popMatrix();
119-
MinecraftForge.EVENT_BUS.post(new RenderLivingEvent.Post<>(par1EntityLivingBase, this, 1, x, y, z));
119+
MinecraftForge.EVENT_BUS.post(new RenderLivingEvent.Post<>(monolith, this, 1, x, y, z));
120120
}
121121

122122
@Override

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

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
import net.minecraft.client.Minecraft;
44
import net.minecraft.client.renderer.GlStateManager;
55
import org.dimdev.ddutils.lsystem.LSystem;
6+
import org.dimdev.dimdoors.shared.ModConfig;
67
import org.lwjgl.opengl.GL11;
78

89
import java.awt.Point; // TODO: wrong point class!
@@ -38,7 +39,7 @@ public static void drawCrack(float riftRotation, LSystem.PolygonInfo poly, doubl
3839
float time = ((Minecraft.getSystemTime() + riftRandom) % 2000000) * motionSpeed;
3940
double[] jitters = new double[jCount];
4041

41-
double jitterScale = size * size / 1100f;
42+
double jitterScale = ModConfig.graphics.riftJitter * size * size * size / 2000f;
4243
// We use random constants here on purpose just to get different wave forms
4344
double xJitter = jitterScale * Math.sin(1.1f * time*size) * Math.sin(0.8f * time);
4445
double yJitter = jitterScale * Math.sin(1.2f * time*size) * Math.sin(0.9f * time);

src/main/java/org/dimdev/dimdoors/shared/ModConfig.java

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -142,6 +142,11 @@ public static class Graphics {
142142
@LangKey("dimdoors.graphics.riftSize")
143143
@RangeDouble(min = 0)
144144
public double riftSize = 1;
145+
146+
@Name("riftJitter")
147+
@LangKey("dimdoors.graphics.riftJitter")
148+
@RangeDouble(min=0)
149+
public double riftJitter = 1;
145150
}
146151

147152

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -146,7 +146,7 @@ public void breakBlock(World world, BlockPos pos, IBlockState state) {
146146
}
147147

148148
// Let vanilla handle breaking the block. If we break it here, the rift we place will later be broken.
149-
@Override public void onBlockHarvested(World worldIn, BlockPos pos, IBlockState state, EntityPlayer player) {}
149+
@Override public void onBlockHarvested(World world, BlockPos pos, IBlockState state, EntityPlayer player) {}
150150

151151
@Override
152152
public EnumPushReaction getMobilityFlag(IBlockState state) {

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

Lines changed: 3 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -84,24 +84,18 @@ public void dropWorldThread(World world, BlockPos pos, Random random) {
8484
@SideOnly(Side.CLIENT)
8585
public void randomDisplayTick(IBlockState state, World world, BlockPos pos, Random rand) {
8686
TileEntity tileEntity = world.getTileEntity(pos);
87-
// Workaround minecraft/forge bug where this is called even before the TileEntity is created in multiplayer
87+
// randomDisplayTick can be called before the tile entity is created in multiplayer
8888
if (!(tileEntity instanceof TileEntityFloatingRift)) return;
8989
TileEntityFloatingRift rift = (TileEntityFloatingRift) tileEntity;
90-
if (0 > 0) {
91-
FMLClientHandler.instance().getClient().effectRenderer.addEffect(new ParticleRiftEffect.GogglesRiftEffect(
92-
world,
93-
pos.getX() + .5, pos.getY() + .5, pos.getZ() + .5,
94-
rand.nextGaussian() * 0.01D, rand.nextGaussian() * 0.01D, rand.nextGaussian() * 0.01D));
95-
}
9690

9791
if (rift.closing) { // Renders an opposite color effect if it is being closed by the rift remover
9892
FMLClientHandler.instance().getClient().effectRenderer.addEffect(new ParticleRiftEffect.ClosingRiftEffect(
9993
world,
100-
pos.getX() + .5, pos.getY() + .5, pos.getZ() + .5,
94+
pos.getX() + .5, pos.getY() + 1.5, pos.getZ() + .5,
10195
rand.nextGaussian() * 0.1D, rand.nextGaussian() * 0.1D, rand.nextGaussian() * 0.1D));
10296
}
10397

104-
// TODO: depend on size, direction of particles should be rift orientation
98+
// TODO: depend on size, stabilization status, direction of particles should be rift orientation
10599
FMLClientHandler.instance().getClient().effectRenderer.addEffect(new ParticleRiftEffect.Rift(
106100
world,
107101
pos.getX() + .5, pos.getY() + 1.5, pos.getZ() + .5,

src/main/java/org/dimdev/dimdoors/shared/entities/EntityMonolith.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -74,7 +74,7 @@ public AxisAlignedBB getCollisionBoundingBox() {
7474
}
7575

7676
@Override
77-
public AxisAlignedBB getCollisionBox(Entity entityIn) {
77+
public AxisAlignedBB getCollisionBox(Entity entity) {
7878
return null;
7979
}
8080

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

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,10 @@ public abstract class ItemDimensionalTrapdoor extends ItemBlock {
2929
// TODO: placing trapdoors on rifts, merge this code with the dimdoor code/common interface
3030
@Override
3131
public EnumActionResult onItemUse(EntityPlayer player, World world, BlockPos pos, EnumHand hand, EnumFacing facing, float hitX, float hitY, float hitZ) {
32+
if (world.isRemote) {
33+
return EnumActionResult.FAIL;
34+
}
35+
3236
boolean replaceable = world.getBlockState(pos).getBlock().isReplaceable(world, pos); // Check this before calling super, since that changes the block
3337
EnumActionResult result = super.onItemUse(player, world, pos, hand, facing, hitX, hitY, hitZ);
3438
if (result == EnumActionResult.SUCCESS) {

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

Lines changed: 19 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,10 @@
11
package org.dimdev.dimdoors.shared.items;
22

33
import net.minecraft.client.resources.I18n;
4+
import net.minecraft.util.text.TextComponentTranslation;
45
import org.dimdev.dimdoors.DimDoors;
6+
import org.dimdev.dimdoors.client.TileEntityFloatingRiftRenderer;
7+
import org.dimdev.dimdoors.shared.ModConfig;
58
import org.dimdev.dimdoors.shared.tileentities.TileEntityFloatingRift;
69
import org.dimdev.ddutils.Location;
710
import org.dimdev.dimdoors.shared.RayTraceHelper;
@@ -41,9 +44,6 @@ public boolean hasEffect(ItemStack stack) {
4144
return true;
4245
}
4346

44-
/**
45-
* Return whether this item is repairable in an anvil.
46-
*/
4747
@Override
4848
public boolean getIsRepairable(ItemStack toRepair, ItemStack repair) {
4949
return ModItems.STABLE_FABRIC == repair.getItem();
@@ -52,12 +52,18 @@ public boolean getIsRepairable(ItemStack toRepair, ItemStack repair) {
5252
@Override
5353
public ActionResult<ItemStack> onItemRightClick(World world, EntityPlayer player, EnumHand hand) {
5454
ItemStack stack = player.getHeldItem(hand);
55+
RayTraceResult hit = rayTrace(world, player, true);
5556

5657
if (world.isRemote) {
57-
return new ActionResult<>(EnumActionResult.FAIL, stack);
58+
if (RayTraceHelper.isFloatingRift(hit, world) || RayTraceHelper.isLivingEntity(hit)) {
59+
return new ActionResult<>(EnumActionResult.SUCCESS, stack);
60+
} else {
61+
player.sendStatusMessage(new TextComponentTranslation(getUnlocalizedName() + ".rift_miss"), true);
62+
TileEntityFloatingRiftRenderer.showRiftCoreUntil = System.currentTimeMillis() + ModConfig.graphics.highlightRiftCoreFor;
63+
return new ActionResult<>(EnumActionResult.FAIL, stack);
64+
}
5865
}
59-
//SchematicHandler.Instance.getPersonalPocketTemplate().place(0, 20, 0, 20, 0, 0, 1, EnumPocketType.DUNGEON); //this line can be activated for testing purposes
60-
RayTraceResult hit = rayTrace(world, player, true);
66+
6167
if (RayTraceHelper.isFloatingRift(hit, world)) {
6268
TileEntityFloatingRift rift = (TileEntityFloatingRift) world.getTileEntity(hit.getBlockPos());
6369
rift.teleport(player);
@@ -66,7 +72,13 @@ public ActionResult<ItemStack> onItemRightClick(World world, EntityPlayer player
6672
return new ActionResult<>(EnumActionResult.SUCCESS, stack);
6773

6874
} else if (RayTraceHelper.isLivingEntity(hit)) {
69-
TeleportUtils.teleport(player, new Location(world, hit.getBlockPos()), player.rotationYaw, player.rotationPitch); //@todo teleport to a location 1 or 2 blocks distance from the entity
75+
BlockPos hitPos = hit.getBlockPos();
76+
// TODO: gaussian, and depend on rift blade's wear
77+
int xDiff = (int) (5 * (Math.random() - 0.5));
78+
int zDiff = (int) (5 * (Math.random() - 0.5));
79+
BlockPos tpPos = new BlockPos(hitPos.getX() + xDiff, hitPos.getY(), hitPos.getZ() + zDiff);
80+
while (world.getBlockState(tpPos).getMaterial().blocksMovement()) tpPos = tpPos.up(); // TODO: move to ddutils
81+
TeleportUtils.teleport(player, new Location(world, tpPos), player.rotationYaw, player.rotationPitch);
7082
stack.damageItem(1, player); // TODO: check if successful
7183
return new ActionResult<>(EnumActionResult.SUCCESS, stack);
7284
}

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

Lines changed: 17 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -9,10 +9,15 @@
99
import net.minecraft.util.EnumActionResult;
1010
import net.minecraft.util.EnumHand;
1111
import net.minecraft.util.ResourceLocation;
12+
import net.minecraft.util.math.RayTraceResult;
13+
import net.minecraft.util.text.TextComponentTranslation;
1214
import net.minecraft.world.World;
1315
import net.minecraftforge.fml.relauncher.Side;
1416
import net.minecraftforge.fml.relauncher.SideOnly;
1517
import org.dimdev.dimdoors.DimDoors;
18+
import org.dimdev.dimdoors.client.TileEntityFloatingRiftRenderer;
19+
import org.dimdev.dimdoors.shared.ModConfig;
20+
import org.dimdev.dimdoors.shared.RayTraceHelper;
1621

1722
import java.util.List;
1823

@@ -29,9 +34,18 @@ public class ItemRiftConfigurationTool extends Item {
2934
}
3035

3136
@Override
32-
public ActionResult<ItemStack> onItemRightClick(World world, EntityPlayer player, EnumHand handIn) {
33-
// TODO: reimplement this using the new registry system (open a GUI that allows configuring the rift)
34-
ItemStack stack = player.getHeldItem(handIn);
37+
public ActionResult<ItemStack> onItemRightClick(World world, EntityPlayer player, EnumHand hand) {
38+
ItemStack stack = player.getHeldItem(hand);
39+
RayTraceResult hit = rayTrace(world, player, true);
40+
41+
if (world.isRemote) {
42+
if (!RayTraceHelper.isFloatingRift(hit, world)) {
43+
player.sendStatusMessage(new TextComponentTranslation("tools.rift_miss"), true);
44+
TileEntityFloatingRiftRenderer.showRiftCoreUntil = System.currentTimeMillis() + ModConfig.graphics.highlightRiftCoreFor;
45+
}
46+
return new ActionResult<>(EnumActionResult.FAIL, stack);
47+
}
48+
3549
return new ActionResult<>(EnumActionResult.FAIL, stack);
3650
}
3751

0 commit comments

Comments
 (0)