Fixed disassembling blocks with the Create Wrench duplicating the item when a build mode other than Normal is used. Disabled break outlines in survival, because breaking multiple blocks in survival is deprecated.
This commit is contained in:
@@ -12,7 +12,7 @@ apply plugin: 'net.minecraftforge.gradle'
|
||||
apply plugin: 'eclipse'
|
||||
apply plugin: 'maven-publish'
|
||||
|
||||
version = '1.18-2.34'
|
||||
version = '1.18-2.37'
|
||||
group = 'nl.requios.effortlessbuilding' // http://maven.apache.org/guides/mini/guide-naming-conventions.html
|
||||
archivesBaseName = 'effortlessbuilding'
|
||||
|
||||
|
||||
@@ -1,5 +1,8 @@
|
||||
package nl.requios.effortlessbuilding;
|
||||
|
||||
import net.minecraft.world.InteractionHand;
|
||||
import net.minecraft.world.item.BlockItem;
|
||||
import net.minecraft.world.item.ItemStack;
|
||||
import net.minecraft.world.level.block.Blocks;
|
||||
import net.minecraft.world.entity.Entity;
|
||||
import net.minecraft.world.entity.player.Player;
|
||||
@@ -19,6 +22,7 @@ import nl.requios.effortlessbuilding.buildmodifier.ModifierSettingsManager;
|
||||
import nl.requios.effortlessbuilding.buildmodifier.UndoRedo;
|
||||
import nl.requios.effortlessbuilding.capability.ModeCapabilityManager;
|
||||
import nl.requios.effortlessbuilding.capability.ModifierCapabilityManager;
|
||||
import nl.requios.effortlessbuilding.compatibility.CompatHelper;
|
||||
import nl.requios.effortlessbuilding.helper.ReachHelper;
|
||||
import nl.requios.effortlessbuilding.network.AddUndoMessage;
|
||||
import nl.requios.effortlessbuilding.network.ClearUndoMessage;
|
||||
@@ -51,7 +55,15 @@ public class EventHandler {
|
||||
ModifierSettingsManager.ModifierSettings modifierSettings = ModifierSettingsManager.getModifierSettings(player);
|
||||
|
||||
if (buildMode != BuildModes.BuildModeEnum.NORMAL) {
|
||||
|
||||
//Only cancel if itemblock in hand
|
||||
//Fixed issue with e.g. Create Wrench shift-rightclick disassembling being cancelled.
|
||||
ItemStack currentItemStack = player.getItemInHand(InteractionHand.MAIN_HAND);
|
||||
if (currentItemStack.getItem() instanceof BlockItem ||
|
||||
(CompatHelper.isItemBlockProxy(currentItemStack) && !player.isShiftKeyDown())) {
|
||||
event.setCanceled(true);
|
||||
}
|
||||
|
||||
} else if (modifierSettings.doQuickReplace()) {
|
||||
//Cancel event and send message if QuickReplace
|
||||
event.setCanceled(true);
|
||||
|
||||
@@ -1,22 +1,15 @@
|
||||
package nl.requios.effortlessbuilding;
|
||||
|
||||
import com.mojang.blaze3d.vertex.DefaultVertexFormat;
|
||||
import net.minecraft.client.Minecraft;
|
||||
import net.minecraft.client.renderer.ShaderInstance;
|
||||
import net.minecraft.client.renderer.texture.TextureAtlas;
|
||||
import net.minecraft.client.renderer.texture.TextureAtlasSprite;
|
||||
import net.minecraft.resources.ResourceLocation;
|
||||
import net.minecraftforge.api.distmarker.Dist;
|
||||
import net.minecraftforge.client.event.RegisterShadersEvent;
|
||||
import net.minecraftforge.client.event.TextureStitchEvent;
|
||||
import net.minecraftforge.eventbus.api.SubscribeEvent;
|
||||
import net.minecraftforge.fml.common.Mod;
|
||||
import nl.requios.effortlessbuilding.buildmode.BuildModes;
|
||||
import nl.requios.effortlessbuilding.buildmode.ModeOptions;
|
||||
import nl.requios.effortlessbuilding.render.BuildRenderTypes;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.util.HashMap;
|
||||
|
||||
@Mod.EventBusSubscriber(bus = Mod.EventBusSubscriber.Bus.MOD, value = {Dist.CLIENT})
|
||||
public class ModClientEventHandler {
|
||||
|
||||
@@ -53,7 +53,6 @@ public class BuildModes {
|
||||
startPos = message.getBlockPos();
|
||||
|
||||
//Offset in direction of sidehit if not quickreplace and not replaceable
|
||||
//TODO 1.13 replaceable
|
||||
boolean replaceable = player.level.getBlockState(startPos).getMaterial().isReplaceable();
|
||||
boolean becomesDoubleSlab = SurvivalHelper.doesBecomeDoubleSlab(player, startPos, message.getSideHit());
|
||||
if (!modifierSettings.doQuickReplace() && !replaceable && !becomesDoubleSlab) {
|
||||
@@ -99,7 +98,6 @@ public class BuildModes {
|
||||
//Only works when finishing a buildmode is equal to placing some blocks
|
||||
//No intermediate blocks allowed
|
||||
currentlyBreaking.remove(player);
|
||||
|
||||
}
|
||||
|
||||
//Use a network message to break blocks in the distance using clientside mouse input
|
||||
|
||||
@@ -191,7 +191,7 @@ public class PlayerSettingsGui extends Screen {
|
||||
return right - 6;
|
||||
}
|
||||
|
||||
//From AbstractList, disabled parts
|
||||
//From AbstractSelectionList, disabled parts
|
||||
@Override
|
||||
public void render(PoseStack ms, int p_render_1_, int p_render_2_, float p_render_3_) {
|
||||
this.renderBackground(ms);
|
||||
|
||||
@@ -135,7 +135,7 @@ public class ClientProxy implements IProxy {
|
||||
if (player == null) return;
|
||||
BuildModes.BuildModeEnum buildMode = ModeSettingsManager.getModeSettings(player).getBuildMode();
|
||||
|
||||
if (Minecraft.getInstance().screen != null ||
|
||||
if (mc.screen != null ||
|
||||
buildMode == BuildModes.BuildModeEnum.NORMAL ||
|
||||
RadialMenu.instance.isVisible()) {
|
||||
return;
|
||||
|
||||
@@ -76,7 +76,7 @@ public class BlockPreviewRenderer {
|
||||
lookingAt = Minecraft.getInstance().hitResult;
|
||||
|
||||
ItemStack mainhand = player.getMainHandItem();
|
||||
boolean toolInHand = !(!mainhand.isEmpty() && CompatHelper.isItemBlockProxy(mainhand));
|
||||
boolean noBlockInHand = !(!mainhand.isEmpty() && CompatHelper.isItemBlockProxy(mainhand));
|
||||
|
||||
BlockPos startPos = null;
|
||||
Direction sideHit = null;
|
||||
@@ -91,12 +91,12 @@ public class BlockPreviewRenderer {
|
||||
//TODO 1.13 replaceable
|
||||
boolean replaceable = player.level.getBlockState(startPos).getMaterial().isReplaceable();
|
||||
boolean becomesDoubleSlab = SurvivalHelper.doesBecomeDoubleSlab(player, startPos, blockLookingAt.getDirection());
|
||||
if (!modifierSettings.doQuickReplace() && !toolInHand && !replaceable && !becomesDoubleSlab) {
|
||||
if (!modifierSettings.doQuickReplace() && !noBlockInHand && !replaceable && !becomesDoubleSlab) {
|
||||
startPos = startPos.relative(blockLookingAt.getDirection());
|
||||
}
|
||||
|
||||
//Get under tall grass and other replaceable blocks
|
||||
if (modifierSettings.doQuickReplace() && !toolInHand && replaceable) {
|
||||
if (modifierSettings.doQuickReplace() && !noBlockInHand && replaceable) {
|
||||
startPos = startPos.below();
|
||||
}
|
||||
|
||||
@@ -236,12 +236,12 @@ public class BlockPreviewRenderer {
|
||||
|
||||
}
|
||||
|
||||
VertexConsumer buffer = RenderHandler.beginLines(renderTypeBuffer);
|
||||
//Draw outlines if tool in hand
|
||||
//Draw outlines if no block in hand
|
||||
//Find proper raytrace: either normal range or increased range depending on canBreakFar
|
||||
VertexConsumer buffer = RenderHandler.beginLines(renderTypeBuffer);
|
||||
HitResult objectMouseOver = Minecraft.getInstance().hitResult;
|
||||
HitResult breakingRaytrace = ReachHelper.canBreakFar(player) ? lookingAt : objectMouseOver;
|
||||
if (toolInHand && breakingRaytrace != null && breakingRaytrace.getType() == HitResult.Type.BLOCK) {
|
||||
if (player.isCreative() && noBlockInHand && breakingRaytrace != null && breakingRaytrace.getType() == HitResult.Type.BLOCK) {
|
||||
BlockHitResult blockBreakingRaytrace = (BlockHitResult) breakingRaytrace;
|
||||
List<BlockPos> breakCoordinates = BuildModifiers.findCoordinates(player, blockBreakingRaytrace.getBlockPos());
|
||||
|
||||
|
||||
Reference in New Issue
Block a user