Replaced Widget with Renderable. BlockPos doubles constructor is now BlockPos.containing().
GetBlitOffset is replaced with ms.z, doing 0 for now. Block Materials have been removed.
This commit is contained in:
@@ -164,7 +164,7 @@ public abstract class ThreeClicksBuildMode extends BaseBuildMode {
|
||||
}
|
||||
}
|
||||
}
|
||||
return new BlockPos(selected.lineBound);
|
||||
return BlockPos.containing(selected.lineBound);
|
||||
}
|
||||
|
||||
// protected abstract BlockEntry findSecondPos(List<BlockEntry> blocks);
|
||||
@@ -197,7 +197,7 @@ public abstract class ThreeClicksBuildMode extends BaseBuildMode {
|
||||
|
||||
//Make it from a plane into a line, on y axis only
|
||||
private Vec3 toLongestLine(Vec3 boundVec, BlockPos secondPos) {
|
||||
BlockPos bound = new BlockPos(boundVec);
|
||||
BlockPos bound = BlockPos.containing(boundVec);
|
||||
return new Vec3(secondPos.getX(), bound.getY(), secondPos.getZ());
|
||||
}
|
||||
|
||||
|
||||
@@ -20,7 +20,7 @@ public class DiagonalLine extends ThreeClicksBuildMode {
|
||||
int iterations = (int) Math.ceil(first.distanceTo(second) * sampleMultiplier);
|
||||
for (double t = 0; t <= 1.0; t += 1.0 / iterations) {
|
||||
Vec3 lerp = first.add(second.subtract(first).scale(t));
|
||||
BlockPos candidate = new BlockPos(lerp);
|
||||
BlockPos candidate = BlockPos.containing(lerp);
|
||||
//Only add if not equal to the last in the list
|
||||
if (list.isEmpty() || !list.get(list.size() - 1).equals(candidate))
|
||||
list.add(candidate);
|
||||
|
||||
@@ -34,7 +34,7 @@ public class Floor extends TwoClicksBuildMode {
|
||||
//Then only 1 can be valid, return that one
|
||||
Criteria selected = criteriaList.get(0);
|
||||
|
||||
return new BlockPos(selected.planeBound);
|
||||
return BlockPos.containing(selected.planeBound);
|
||||
}
|
||||
|
||||
public static List<BlockPos> getFloorBlocks(Player player, int x1, int y1, int z1, int x2, int y2, int z2) {
|
||||
|
||||
@@ -59,7 +59,7 @@ public class Line extends TwoClicksBuildMode {
|
||||
|
||||
}
|
||||
|
||||
return new BlockPos(selected.lineBound);
|
||||
return BlockPos.containing(selected.lineBound);
|
||||
}
|
||||
|
||||
public static List<BlockPos> getLineBlocks(Player player, int x1, int y1, int z1, int x2, int y2, int z2) {
|
||||
@@ -120,7 +120,7 @@ public class Line extends TwoClicksBuildMode {
|
||||
//Make it from a plane into a line
|
||||
//Select the axis that is longest
|
||||
private Vec3 toLongestLine(Vec3 boundVec, BlockPos firstPos) {
|
||||
BlockPos bound = new BlockPos(boundVec);
|
||||
BlockPos bound = BlockPos.containing(boundVec);
|
||||
|
||||
BlockPos firstToSecond = bound.subtract(firstPos);
|
||||
firstToSecond = new BlockPos(Math.abs(firstToSecond.getX()), Math.abs(firstToSecond.getY()), Math.abs(firstToSecond.getZ()));
|
||||
|
||||
@@ -49,7 +49,7 @@ public class Wall extends TwoClicksBuildMode {
|
||||
}
|
||||
}
|
||||
|
||||
return new BlockPos(selected.planeBound);
|
||||
return BlockPos.containing(selected.planeBound);
|
||||
}
|
||||
|
||||
public static List<BlockPos> getWallBlocks(Player player, int x1, int y1, int z1, int x2, int y2, int z2) {
|
||||
|
||||
@@ -50,7 +50,7 @@ public class Mirror extends BaseModifier {
|
||||
private void performMirrorX(BlockSet blocks, BlockEntry blockEntry) {
|
||||
//find mirror position
|
||||
double x = position.x + (position.x - blockEntry.blockPos.getX() - 0.5);
|
||||
BlockPos newBlockPos = new BlockPos(x, blockEntry.blockPos.getY(), blockEntry.blockPos.getZ());
|
||||
BlockPos newBlockPos = BlockPos.containing(x, blockEntry.blockPos.getY(), blockEntry.blockPos.getZ());
|
||||
|
||||
if (blocks.containsKey(newBlockPos)) return;
|
||||
|
||||
@@ -66,7 +66,7 @@ public class Mirror extends BaseModifier {
|
||||
private void performMirrorY(BlockSet blocks, BlockEntry blockEntry) {
|
||||
//find mirror position
|
||||
double y = position.y + (position.y - blockEntry.blockPos.getY() - 0.5);
|
||||
BlockPos newBlockPos = new BlockPos(blockEntry.blockPos.getX(), y, blockEntry.blockPos.getZ());
|
||||
BlockPos newBlockPos = BlockPos.containing(blockEntry.blockPos.getX(), y, blockEntry.blockPos.getZ());
|
||||
|
||||
if (blocks.containsKey(newBlockPos)) return;
|
||||
|
||||
@@ -81,7 +81,7 @@ public class Mirror extends BaseModifier {
|
||||
private void performMirrorZ(BlockSet blocks, BlockEntry blockEntry) {
|
||||
//find mirror position
|
||||
double z = position.z + (position.z - blockEntry.blockPos.getZ() - 0.5);
|
||||
BlockPos newBlockPos = new BlockPos(blockEntry.blockPos.getX(), blockEntry.blockPos.getY(), z);
|
||||
BlockPos newBlockPos = BlockPos.containing(blockEntry.blockPos.getX(), blockEntry.blockPos.getY(), z);
|
||||
|
||||
if (blocks.containsKey(newBlockPos)) return;
|
||||
|
||||
|
||||
@@ -77,7 +77,7 @@ public class RadialMirror extends BaseModifier {
|
||||
}
|
||||
|
||||
Vec3 relNewVec = relStartVec.yRot((float) curAngle);
|
||||
BlockPos newBlockPos = new BlockPos(position.add(relNewVec));
|
||||
BlockPos newBlockPos = BlockPos.containing(position.add(relNewVec));
|
||||
|
||||
if (blocks.containsKey(newBlockPos)) continue;
|
||||
|
||||
|
||||
@@ -8,7 +8,7 @@ import net.minecraft.world.level.Level;
|
||||
import net.minecraft.world.level.LevelAccessor;
|
||||
import net.minecraft.world.phys.Vec3;
|
||||
import net.minecraftforge.api.distmarker.Dist;
|
||||
import net.minecraftforge.client.event.RenderLevelLastEvent;
|
||||
import net.minecraftforge.client.event.RenderLevelStageEvent;
|
||||
import net.minecraftforge.client.event.ViewportEvent;
|
||||
import net.minecraftforge.event.TickEvent;
|
||||
import net.minecraftforge.event.TickEvent.ClientTickEvent;
|
||||
@@ -58,7 +58,7 @@ public class ClientEvents {
|
||||
}
|
||||
|
||||
@SubscribeEvent
|
||||
public static void onRenderWorld(RenderLevelLastEvent event) {
|
||||
public static void onRenderWorld(RenderLevelStageEvent event) {
|
||||
Vec3 cameraPos = Minecraft.getInstance().gameRenderer.getMainCamera()
|
||||
.getPosition();
|
||||
float pt = AnimationTickHolder.getPartialTicks();
|
||||
|
||||
@@ -5,7 +5,7 @@ import com.mojang.blaze3d.vertex.PoseStack;
|
||||
import nl.requios.effortlessbuilding.create.foundation.gui.widget.AbstractSimiWidget;
|
||||
import nl.requios.effortlessbuilding.create.foundation.utility.Components;
|
||||
import net.minecraft.client.gui.components.AbstractWidget;
|
||||
import net.minecraft.client.gui.components.Widget;
|
||||
import net.minecraft.client.gui.components.Renderable;
|
||||
import net.minecraft.client.gui.components.events.GuiEventListener;
|
||||
import net.minecraft.client.gui.narration.NarratableEntry;
|
||||
import net.minecraft.client.gui.screens.Screen;
|
||||
@@ -71,13 +71,13 @@ public abstract class AbstractSimiScreen extends Screen {
|
||||
}
|
||||
|
||||
@SuppressWarnings("unchecked")
|
||||
protected <W extends GuiEventListener & Widget & NarratableEntry> void addRenderableWidgets(W... widgets) {
|
||||
protected <W extends GuiEventListener & Renderable & NarratableEntry> void addRenderableWidgets(W... widgets) {
|
||||
for (W widget : widgets) {
|
||||
addRenderableWidget(widget);
|
||||
}
|
||||
}
|
||||
|
||||
protected <W extends GuiEventListener & Widget & NarratableEntry> void addRenderableWidgets(Collection<W> widgets) {
|
||||
protected <W extends GuiEventListener & Renderable & NarratableEntry> void addRenderableWidgets(Collection<W> widgets) {
|
||||
for (W widget : widgets) {
|
||||
addRenderableWidget(widget);
|
||||
}
|
||||
@@ -137,7 +137,7 @@ public abstract class AbstractSimiScreen extends Screen {
|
||||
protected abstract void renderWindow(PoseStack ms, int mouseX, int mouseY, float partialTicks);
|
||||
|
||||
protected void renderWindowForeground(PoseStack ms, int mouseX, int mouseY, float partialTicks) {
|
||||
for (Widget widget : renderables) {
|
||||
for (Renderable widget : renderables) {
|
||||
if (widget instanceof AbstractSimiWidget simiWidget && simiWidget.isHoveredOrFocused()
|
||||
&& simiWidget.visible) {
|
||||
List<Component> tooltip = simiWidget.getToolTip();
|
||||
|
||||
@@ -12,7 +12,7 @@ import net.minecraftforge.api.distmarker.OnlyIn;
|
||||
|
||||
public enum AllGuiTextures implements ScreenElement {
|
||||
|
||||
// Widgets
|
||||
// Renderables
|
||||
BUTTON("widgets", 18, 18),
|
||||
BUTTON_HOVER("widgets", 18, 0, 18, 18),
|
||||
BUTTON_DOWN("widgets", 36, 0, 18, 18),
|
||||
|
||||
@@ -6,7 +6,7 @@ import nl.requios.effortlessbuilding.create.foundation.gui.AllGuiTextures;
|
||||
import nl.requios.effortlessbuilding.create.foundation.gui.TickableGuiEventListener;
|
||||
import nl.requios.effortlessbuilding.create.foundation.gui.widget.AbstractSimiWidget;
|
||||
import net.minecraft.client.gui.components.AbstractWidget;
|
||||
import net.minecraft.client.gui.components.Widget;
|
||||
import net.minecraft.client.gui.components.Renderable;
|
||||
import net.minecraft.client.gui.components.events.GuiEventListener;
|
||||
import net.minecraft.client.gui.narration.NarratableEntry;
|
||||
import net.minecraft.client.gui.screens.inventory.AbstractContainerScreen;
|
||||
@@ -66,13 +66,13 @@ public abstract class AbstractSimiContainerScreen<T extends AbstractContainerMen
|
||||
}
|
||||
|
||||
@SuppressWarnings("unchecked")
|
||||
protected <W extends GuiEventListener & Widget & NarratableEntry> void addRenderableWidgets(W... widgets) {
|
||||
protected <W extends GuiEventListener & Renderable & NarratableEntry> void addRenderableWidgets(W... widgets) {
|
||||
for (W widget : widgets) {
|
||||
addRenderableWidget(widget);
|
||||
}
|
||||
}
|
||||
|
||||
protected <W extends GuiEventListener & Widget & NarratableEntry> void addRenderableWidgets(Collection<W> widgets) {
|
||||
protected <W extends GuiEventListener & Renderable & NarratableEntry> void addRenderableWidgets(Collection<W> widgets) {
|
||||
for (W widget : widgets) {
|
||||
addRenderableWidget(widget);
|
||||
}
|
||||
@@ -111,7 +111,7 @@ public abstract class AbstractSimiContainerScreen<T extends AbstractContainerMen
|
||||
|
||||
protected void renderForeground(PoseStack ms, int mouseX, int mouseY, float partialTicks) {
|
||||
renderTooltip(ms, mouseX, mouseY);
|
||||
for (Widget widget : renderables) {
|
||||
for (Renderable widget : renderables) {
|
||||
if (widget instanceof AbstractSimiWidget simiWidget && simiWidget.isHoveredOrFocused()) {
|
||||
List<Component> tooltip = simiWidget.getToolTip();
|
||||
if (tooltip.isEmpty())
|
||||
|
||||
@@ -478,7 +478,7 @@ public class SuperByteBuffer implements Transform<SuperByteBuffer>, TStack<Super
|
||||
}
|
||||
|
||||
private static int getLight(Level world, Vector4f lightPos) {
|
||||
BlockPos pos = new BlockPos(lightPos.x(), lightPos.y(), lightPos.z());
|
||||
BlockPos pos = BlockPos.containing(lightPos.x(), lightPos.y(), lightPos.z());
|
||||
return WORLD_LIGHT_CACHE.computeIfAbsent(pos.asLong(), $ -> LevelRenderer.getLightColor(world, pos));
|
||||
}
|
||||
|
||||
|
||||
@@ -92,7 +92,7 @@ public class TileEntityRenderHelper {
|
||||
if (lightTransform != null) {
|
||||
Vector4f lightVec = new Vector4f(contraptionPos.getX() + .5f, contraptionPos.getY() + .5f, contraptionPos.getZ() + .5f, 1);
|
||||
lightVec.transform(lightTransform);
|
||||
return new BlockPos(lightVec.x(), lightVec.y(), lightVec.z());
|
||||
return BlockPos.containing(lightVec.x(), lightVec.y(), lightVec.z());
|
||||
} else {
|
||||
return contraptionPos;
|
||||
}
|
||||
|
||||
@@ -181,9 +181,8 @@ public class BlockHelper {
|
||||
.ultraWarm())
|
||||
return false;
|
||||
|
||||
Material material = world.getBlockState(pos.below())
|
||||
.getMaterial();
|
||||
if (material.blocksMotion() || material.isLiquid())
|
||||
var blockStateBelow = world.getBlockState(pos.below());
|
||||
if (blockStateBelow.blocksMotion() || blockStateBelow.liquid())
|
||||
world.setBlockAndUpdate(pos, Blocks.WATER.defaultBlockState());
|
||||
return true;
|
||||
}
|
||||
|
||||
@@ -433,6 +433,10 @@ public class RadialMenu extends Screen {
|
||||
return n > 0 ? 1 : -1;
|
||||
}
|
||||
|
||||
private double getBlitOffset(){
|
||||
return 0;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isPauseScreen() {
|
||||
return false;
|
||||
|
||||
@@ -3,7 +3,7 @@ package nl.requios.effortlessbuilding.gui.elements;
|
||||
import com.mojang.blaze3d.vertex.PoseStack;
|
||||
import net.minecraft.client.Minecraft;
|
||||
import net.minecraft.client.gui.Font;
|
||||
import net.minecraft.client.gui.components.Widget;
|
||||
import net.minecraft.client.gui.components.Renderable;
|
||||
import net.minecraft.client.gui.screens.Screen;
|
||||
import net.minecraft.client.gui.components.AbstractWidget;
|
||||
import net.minecraftforge.api.distmarker.Dist;
|
||||
@@ -28,7 +28,7 @@ public abstract class GuiCollapsibleScrollEntry implements GuiScrollPane.IScroll
|
||||
}
|
||||
|
||||
@Override
|
||||
public void init(List<Widget> renderables) {
|
||||
public void init(List<Renderable> renderables) {
|
||||
left = scrollPane.getWidth() / 2 - 140;
|
||||
right = scrollPane.getWidth() / 2 + 140;
|
||||
top = scrollPane.getHeight() / 2 - 100;
|
||||
|
||||
@@ -4,7 +4,7 @@ import com.mojang.blaze3d.vertex.PoseStack;
|
||||
import net.minecraft.MethodsReturnNonnullByDefault;
|
||||
import net.minecraft.client.gui.GuiComponent;
|
||||
import net.minecraft.client.gui.Font;
|
||||
import net.minecraft.client.gui.components.Widget;
|
||||
import net.minecraft.client.gui.components.Renderable;
|
||||
import net.minecraft.client.gui.screens.Screen;
|
||||
import net.minecraft.client.gui.components.EditBox;
|
||||
import net.minecraft.client.gui.components.Button;
|
||||
@@ -34,7 +34,7 @@ public class GuiNumberField extends GuiComponent {
|
||||
|
||||
List<Component> tooltip = new ArrayList<>();
|
||||
|
||||
public GuiNumberField(Font font, List<Widget> renderables, int x, int y, int width, int height) {
|
||||
public GuiNumberField(Font font, List<Renderable> renderables, int x, int y, int width, int height) {
|
||||
this.x = x;
|
||||
this.y = y;
|
||||
this.width = width;
|
||||
|
||||
@@ -6,7 +6,7 @@ import com.mojang.blaze3d.systems.RenderSystem;
|
||||
import net.minecraft.MethodsReturnNonnullByDefault;
|
||||
import net.minecraft.client.Minecraft;
|
||||
import net.minecraft.client.gui.Font;
|
||||
import net.minecraft.client.gui.components.Widget;
|
||||
import net.minecraft.client.gui.components.Renderable;
|
||||
import net.minecraft.client.gui.components.events.GuiEventListener;
|
||||
import net.minecraft.client.gui.screens.Screen;
|
||||
import net.minecraft.client.gui.components.AbstractWidget;
|
||||
@@ -398,7 +398,7 @@ public class GuiScrollPane extends SlotGui {
|
||||
}
|
||||
|
||||
//PASSTHROUGHS
|
||||
public void init(List<Widget> renderables) {
|
||||
public void init(List<Renderable> renderables) {
|
||||
for (IScrollEntry entry : this.listEntries) {
|
||||
entry.init(renderables);
|
||||
}
|
||||
@@ -436,7 +436,7 @@ public class GuiScrollPane extends SlotGui {
|
||||
}
|
||||
|
||||
public interface IScrollEntry {
|
||||
void init(List<Widget> renderables);
|
||||
void init(List<Renderable> renderables);
|
||||
|
||||
void updateScreen();
|
||||
|
||||
|
||||
@@ -6,7 +6,7 @@ import net.minecraft.MethodsReturnNonnullByDefault;
|
||||
import net.minecraft.client.Minecraft;
|
||||
import net.minecraft.client.gui.components.events.AbstractContainerEventHandler;
|
||||
import net.minecraft.client.gui.components.events.GuiEventListener;
|
||||
import net.minecraft.client.gui.components.Widget;
|
||||
import net.minecraft.client.gui.components.Renderable;
|
||||
import net.minecraft.util.Mth;
|
||||
import net.minecraftforge.api.distmarker.Dist;
|
||||
import net.minecraftforge.api.distmarker.OnlyIn;
|
||||
@@ -18,7 +18,7 @@ import java.util.List;
|
||||
@OnlyIn(Dist.CLIENT)
|
||||
@ParametersAreNonnullByDefault
|
||||
@MethodsReturnNonnullByDefault
|
||||
public abstract class SlotGui extends AbstractContainerEventHandler implements Widget {
|
||||
public abstract class SlotGui extends AbstractContainerEventHandler implements Renderable {
|
||||
protected final Minecraft minecraft;
|
||||
protected final int itemHeight;
|
||||
protected int width;
|
||||
|
||||
@@ -231,7 +231,7 @@ public class BuilderChain {
|
||||
|
||||
//Offset in direction of sidehit if not quickreplace and not replaceable
|
||||
boolean shouldOffsetStartPosition = EffortlessBuildingClient.BUILD_SETTINGS.shouldOffsetStartPosition();
|
||||
boolean replaceable = player.level().getBlockState(startPos).getMaterial().isReplaceable();
|
||||
boolean replaceable = player.level().getBlockState(startPos).canBeReplaced();
|
||||
boolean becomesDoubleSlab = SurvivalHelper.doesBecomeDoubleSlab(player, startPos);
|
||||
if (!shouldOffsetStartPosition && !replaceable && !becomesDoubleSlab) {
|
||||
startPos = startPos.relative(lookingAt.getDirection());
|
||||
|
||||
@@ -44,12 +44,12 @@ public class PowerLevelCommand {
|
||||
|
||||
private static void logPowerLevel(CommandSourceStack source, Player player) {
|
||||
int powerLevel = EffortlessBuilding.SERVER_POWER_LEVEL.getPowerLevel(player);
|
||||
source.sendSuccess(Component.translatable("effortlessbuilding.commands.powerlevel", player.getDisplayName(), powerLevel), false);
|
||||
source.sendSuccess(() -> Component.translatable("effortlessbuilding.commands.powerlevel", player.getDisplayName(), powerLevel), false);
|
||||
}
|
||||
|
||||
private static void setPowerLevel(CommandSourceStack source, Player player, int powerLevel) throws CommandSyntaxException {
|
||||
EffortlessBuilding.SERVER_POWER_LEVEL.setPowerLevel(player, powerLevel);
|
||||
EffortlessBuilding.SERVER_POWER_LEVEL.sendToClient(player);
|
||||
source.sendSuccess(Component.translatable("effortlessbuilding.commands.powerlevel.success", player.getDisplayName(), powerLevel), true);
|
||||
source.sendSuccess(() -> Component.translatable("effortlessbuilding.commands.powerlevel.success", player.getDisplayName(), powerLevel), true);
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user