Skip to content

Commit

Permalink
Step fix tweak, spectator selection tweak
Browse files Browse the repository at this point in the history
This does not fix the wall rubbing bug sadle, this just changes the code to answer the question of why 1.12 doesn't need addCord; because they use addCoord, not expand.
Spectators now show a crosshair when selecting a block they're allowed to open.
  • Loading branch information
Roadhog360 committed Aug 26, 2023
1 parent 9444bf5 commit cca3146
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 17 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -21,19 +21,22 @@ public class MixinEntity {
slice = @Slice(from = @At(value = "FIELD", opcode = Opcodes.GETFIELD, target = "Lnet/minecraft/entity/Entity;stepHeight:F", ordinal = 1))
)
private void saveOldBoundingBox(double x, double y, double z, CallbackInfo ci) {
etfu$savedBB = this.boundingBox.copy();
/* TODO the Math.abs call doesn't exist in 1.12, but without it the box would be shrunk. Why don't they need it? */
this.boundingBox.setBB(this.boundingBox.expand(Math.abs(x), 0, Math.abs(z)));
if (boundingBox != null) {
etfu$savedBB = this.boundingBox.copy();
this.boundingBox.setBB(this.boundingBox.addCoord(x + 0.01D, 0, z - 0.01D));
}
}

@Inject(method = "moveEntity",
at = @At(value = "INVOKE", target = "Lnet/minecraft/util/AxisAlignedBB;offset(DDD)Lnet/minecraft/util/AxisAlignedBB;", ordinal = 0, shift = At.Shift.BEFORE),
slice = @Slice(from = @At(value = "FIELD", opcode = Opcodes.GETFIELD, target = "Lnet/minecraft/entity/Entity;stepHeight:F", ordinal = 1))
)
private void restoreOldBoundingBox(double x, double y, double z, CallbackInfo ci) {
if(etfu$savedBB == null)
throw new IllegalStateException("A conflict has occured with another mod's transformer");
this.boundingBox.setBB(etfu$savedBB);
etfu$savedBB = null;
if (boundingBox != null) {
if (etfu$savedBB == null)
throw new IllegalStateException("A conflict has occured with another mod's transformer");
this.boundingBox.setBB(etfu$savedBB);
etfu$savedBB = null;
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -6,20 +6,18 @@
import cpw.mods.fml.common.gameevent.TickEvent;
import cpw.mods.fml.relauncher.Side;
import cpw.mods.fml.relauncher.SideOnly;
import net.minecraft.block.Block;
import net.minecraft.block.material.Material;
import net.minecraft.client.Minecraft;
import net.minecraft.client.model.ModelBiped;
import net.minecraft.client.renderer.entity.RenderManager;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.inventory.IInventory;
import net.minecraftforge.client.event.*;

import static ganymedes01.etfuturum.spectator.SpectatorMode.isSpectator;

public class SpectatorModeClient {
public static final SpectatorModeClient INSTANCE = new SpectatorModeClient();
private boolean doRefreshModel = false;
private boolean canSelect = false;

@SideOnly(Side.CLIENT)
private static void setBipedVisible(ModelBiped biped, boolean visible)
Expand Down Expand Up @@ -66,11 +64,10 @@ public void onRenderPlayerArmor(RenderPlayerEvent.Specials.Pre event) {
@SideOnly(Side.CLIENT)
public void onOverlayRenderPre(RenderGameOverlayEvent.Pre event) {
if(isSpectator(Minecraft.getMinecraft().thePlayer)) {
if(event.type == RenderGameOverlayEvent.ElementType.HOTBAR ||
event.type == RenderGameOverlayEvent.ElementType.CROSSHAIRS) {
if (event.type == RenderGameOverlayEvent.ElementType.HOTBAR || (event.type == RenderGameOverlayEvent.ElementType.CROSSHAIRS && !canSelect)) {
event.setCanceled(true);
}
if(event.type == RenderGameOverlayEvent.ElementType.ALL) {
if (event.type == RenderGameOverlayEvent.ElementType.ALL) {
hadHeldItemTooltips = Minecraft.getMinecraft().gameSettings.heldItemTooltips;
Minecraft.getMinecraft().gameSettings.heldItemTooltips = false;
}
Expand Down Expand Up @@ -107,7 +104,7 @@ public void onFireRender(RenderBlockOverlayEvent event) {
public void onRenderFogDensity(EntityViewRenderEvent.FogDensity event) {
if(event.entity instanceof EntityPlayer) {
if(isSpectator((EntityPlayer)event.entity)) {
if(event.block.getMaterial() == Material.water || event.block.getMaterial() == Material.lava) {
if (event.block.getMaterial().isLiquid()) {
event.setCanceled(true);
event.density = 0;
}
Expand All @@ -119,9 +116,8 @@ public void onRenderFogDensity(EntityViewRenderEvent.FogDensity event) {
@SideOnly(Side.CLIENT)
public void onBlockHighlight(DrawBlockHighlightEvent event) {
if(isSpectator(event.player)) {
Block block = Minecraft.getMinecraft().theWorld.getBlock(event.target.blockX, event.target.blockY, event.target.blockZ);
int meta = Minecraft.getMinecraft().theWorld.getBlockMetadata(event.target.blockX, event.target.blockY, event.target.blockZ);
if(!block.hasTileEntity(meta) || !(Minecraft.getMinecraft().theWorld.getTileEntity(event.target.blockX, event.target.blockY, event.target.blockZ) instanceof IInventory)) {
canSelect = SpectatorMode.canSpectatorSelect(Minecraft.getMinecraft().theWorld.getTileEntity(event.target.blockX, event.target.blockY, event.target.blockZ));
if (!canSelect) {
event.setCanceled(true);
}
}
Expand Down

0 comments on commit cca3146

Please sign in to comment.