mirror of
https://github.com/MinecraftForge/MinecraftForge.git
synced 2026-11-18 11:29:15 +00:00
Fix redstone update order not matching vanilla. (#10392)
This commit is contained in:
1 parent
f49adb285f
commit
464483db5b
4 files changed
+98
-2
No files matched your search
@@ -1,12 +1,17 @@
|
||||
--- a/net/minecraft/core/Direction.java
|
||||
+++ b/net/minecraft/core/Direction.java
|
||||
@@ -49,6 +_,10 @@
|
||||
@@ -49,6 +_,15 @@
|
||||
private final Vec3i normal;
|
||||
private final Vec3 normalVec3;
|
||||
private static final Direction[] VALUES = values();
|
||||
+ private static final List<Direction> VALUES_VIEW = java.util.Collections.unmodifiableList(Arrays.asList(VALUES));
|
||||
+ public static final List<Direction> valuesView() {
|
||||
+ return VALUES_VIEW;
|
||||
+ }
|
||||
+ // In vanilla updates are notified only on the horizontal plane, in Forge we also notify up and down
|
||||
+ private static final List<Direction> UPDATE_ORDER = java.util.Collections.unmodifiableList(Stream.concat(Plane.HORIZONTAL.stream(), Plane.VERTICAL.stream()).toList());
|
||||
+ public static final List<Direction> getUpdateOrder() {
|
||||
+ return UPDATE_ORDER;
|
||||
+ }
|
||||
private static final Direction[] BY_3D_DATA = Arrays.stream(VALUES)
|
||||
.sorted(Comparator.comparingInt(p_235687_ -> p_235687_.data3d))
|
||||
|
||||
@@ -163,7 +163,7 @@
|
||||
|
||||
public void updateNeighbourForOutputSignal(BlockPos p_46718_, Block p_46719_) {
|
||||
- for (Direction direction : Direction.Plane.HORIZONTAL) {
|
||||
+ for (Direction direction : Direction.valuesView()) {
|
||||
+ for (Direction direction : Direction.getUpdateOrder()) {
|
||||
BlockPos blockpos = p_46718_.relative(direction);
|
||||
if (this.hasChunkAt(blockpos)) {
|
||||
BlockState blockstate = this.getBlockState(blockpos);
|
||||
|
||||
@@ -0,0 +1,91 @@
|
||||
/*
|
||||
* Copyright (c) Forge Development LLC and contributors
|
||||
* SPDX-License-Identifier: LGPL-2.1-only
|
||||
*/
|
||||
|
||||
package net.minecraftforge.debug.gameplay.redstone;
|
||||
|
||||
import net.minecraft.core.BlockPos;
|
||||
import net.minecraft.gametest.framework.GameTest;
|
||||
import net.minecraft.gametest.framework.GameTestHelper;
|
||||
import net.minecraft.world.item.ItemStack;
|
||||
import net.minecraft.world.item.Items;
|
||||
import net.minecraft.world.level.block.Blocks;
|
||||
import net.minecraft.world.level.block.entity.ChestBlockEntity;
|
||||
import net.minecraftforge.fml.javafmlmod.FMLJavaModLoadingContext;
|
||||
import net.minecraftforge.test.BaseTestMod;
|
||||
import net.minecraftforge.fml.common.Mod;
|
||||
import net.minecraftforge.gametest.GameTestHolder;
|
||||
|
||||
/**
|
||||
* Redstone update orders are important in many contraptions as there are pistons and other things that could conflict with each other.
|
||||
* These tests verify just that, two pistons pushing the same block.
|
||||
*
|
||||
* Partial verification/fix for https://github.com/MinecraftForge/MinecraftForge/issues/9973
|
||||
*/
|
||||
@Mod(UpdateOrder.MODID)
|
||||
@GameTestHolder("forge." + UpdateOrder.MODID)
|
||||
public class UpdateOrder extends BaseTestMod {
|
||||
public static final String MODID = "update_order";
|
||||
private static final int PISTON_DELAY = 4;
|
||||
|
||||
public UpdateOrder(FMLJavaModLoadingContext context) {
|
||||
super(context);
|
||||
}
|
||||
|
||||
@GameTest(template = "update_order:update_order", rotationSteps = 0)
|
||||
public static void south(GameTestHelper helper) {
|
||||
var chestPos = new BlockPos(0, 1, 0);
|
||||
helper.assertBlockPresent(Blocks.CHEST, chestPos);
|
||||
var chest = helper.<ChestBlockEntity>getBlockEntity(chestPos);
|
||||
chest.setItem(0, new ItemStack(Items.DIRT));
|
||||
|
||||
helper.runAfterDelay(PISTON_DELAY, () -> {
|
||||
var expectedPos = new BlockPos(2, 1, 3);
|
||||
helper.assertBlockPresent(Blocks.WHITE_WOOL, expectedPos);
|
||||
helper.succeed();
|
||||
});
|
||||
}
|
||||
|
||||
@GameTest(template = "update_order:update_order", rotationSteps = 1)
|
||||
public static void west(GameTestHelper helper) {
|
||||
var chestPos = new BlockPos(0, 1, 0);
|
||||
helper.assertBlockPresent(Blocks.CHEST, chestPos);
|
||||
var chest = helper.<ChestBlockEntity>getBlockEntity(chestPos);
|
||||
chest.setItem(0, new ItemStack(Items.DIRT));
|
||||
|
||||
helper.runAfterDelay(PISTON_DELAY, () -> {
|
||||
var expectedPos = new BlockPos(2, 1, 3);
|
||||
helper.assertBlockPresent(Blocks.WHITE_WOOL, expectedPos);
|
||||
helper.succeed();
|
||||
});
|
||||
}
|
||||
|
||||
@GameTest(template = "update_order:update_order", rotationSteps = 2)
|
||||
public static void north(GameTestHelper helper) {
|
||||
var chestPos = new BlockPos(0, 1, 0);
|
||||
helper.assertBlockPresent(Blocks.CHEST, chestPos);
|
||||
var chest = helper.<ChestBlockEntity>getBlockEntity(chestPos);
|
||||
chest.setItem(0, new ItemStack(Items.DIRT));
|
||||
|
||||
helper.runAfterDelay(4, () -> {
|
||||
var expectedPos = new BlockPos(3, 1, 2);
|
||||
helper.assertBlockPresent(Blocks.WHITE_WOOL, expectedPos);
|
||||
helper.succeed();
|
||||
});
|
||||
}
|
||||
|
||||
@GameTest(template = "update_order:update_order", rotationSteps = 3)
|
||||
public static void east(GameTestHelper helper) {
|
||||
var chestPos = new BlockPos(0, 1, 0);
|
||||
helper.assertBlockPresent(Blocks.CHEST, chestPos);
|
||||
var chest = helper.<ChestBlockEntity>getBlockEntity(chestPos);
|
||||
chest.setItem(0, new ItemStack(Items.DIRT));
|
||||
|
||||
helper.runAfterDelay(PISTON_DELAY, () -> {
|
||||
var expectedPos = new BlockPos(2, 1, 3);
|
||||
helper.assertBlockPresent(Blocks.WHITE_WOOL, expectedPos);
|
||||
helper.succeed();
|
||||
});
|
||||
}
|
||||
}
|
||||
Binary file not shown.
Reference in new issue
Block a user