mirror of
https://github.com/architectury/architectury-api.git
synced 2026-04-02 05:27:42 -05:00
Merge remote-tracking branch 'architectury/1.16' into 1.17
# Conflicts: # fabric/src/main/java/me/shedaniel/architectury/mixin/fabric/MixinBlockEntityExtension.java # fabric/src/main/resources/architectury.mixins.json # gradle.properties
This commit is contained in:
@@ -21,12 +21,13 @@ package me.shedaniel.architectury.test;
|
||||
|
||||
import me.shedaniel.architectury.platform.Platform;
|
||||
import me.shedaniel.architectury.test.debug.ConsoleMessageSink;
|
||||
import me.shedaniel.architectury.test.events.DebugEvents;
|
||||
import me.shedaniel.architectury.test.debug.MessageSink;
|
||||
import me.shedaniel.architectury.test.debug.client.ClientOverlayMessageSink;
|
||||
import me.shedaniel.architectury.test.events.DebugEvents;
|
||||
import me.shedaniel.architectury.test.gamerule.TestGameRules;
|
||||
import me.shedaniel.architectury.test.registry.TestRegistries;
|
||||
import me.shedaniel.architectury.test.registry.client.TestKeybinds;
|
||||
import me.shedaniel.architectury.test.tags.TestTags;
|
||||
import me.shedaniel.architectury.utils.Env;
|
||||
import me.shedaniel.architectury.utils.EnvExecutor;
|
||||
|
||||
@@ -38,6 +39,7 @@ public class TestMod {
|
||||
DebugEvents.initialize();
|
||||
TestRegistries.initialize();
|
||||
TestGameRules.init();
|
||||
TestTags.initialize();
|
||||
if (Platform.getEnvironment() == Env.CLIENT)
|
||||
TestKeybinds.initialize();
|
||||
}
|
||||
|
||||
@@ -27,6 +27,7 @@ import me.shedaniel.architectury.platform.Platform;
|
||||
import me.shedaniel.architectury.utils.Env;
|
||||
import net.fabricmc.api.EnvType;
|
||||
import net.fabricmc.api.Environment;
|
||||
import net.minecraft.client.gui.screens.ChatScreen;
|
||||
import net.minecraft.core.Position;
|
||||
import net.minecraft.core.Vec3i;
|
||||
import net.minecraft.network.chat.TranslatableComponent;
|
||||
@@ -49,6 +50,14 @@ public class DebugEvents {
|
||||
}
|
||||
|
||||
public static void debugEvents() {
|
||||
BlockEvent.BREAK.register((world, pos, state, player, xp) -> {
|
||||
SINK.accept(player.getScoreboardName() + " breaks " + toShortString(pos) + logSide(player.level));
|
||||
return InteractionResult.PASS;
|
||||
});
|
||||
BlockEvent.PLACE.register((world, pos, state, placer) -> {
|
||||
SINK.accept(Optional.ofNullable(placer).map(Entity::getScoreboardName).orElse("null") + " places block at " + toShortString(pos) + logSide(world));
|
||||
return InteractionResult.PASS;
|
||||
});
|
||||
ChatEvent.SERVER.register((player, message, component) -> {
|
||||
SINK.accept("Server chat received: " + message);
|
||||
return InteractionResultHolder.pass(component);
|
||||
@@ -78,10 +87,6 @@ public class DebugEvents {
|
||||
}
|
||||
return InteractionResult.PASS;
|
||||
});
|
||||
EntityEvent.PLACE_BLOCK.register((world, pos, state, placer) -> {
|
||||
SINK.accept(Optional.ofNullable(placer).map(Entity::getScoreboardName).orElse("null") + " places block at " + toShortString(pos) + logSide(world));
|
||||
return InteractionResult.PASS;
|
||||
});
|
||||
ExplosionEvent.DETONATE.register((world, explosion, affectedEntities) -> {
|
||||
SINK.accept(world.dimension().location() + " explodes at " + toShortString(ExplosionHooks.getPosition(explosion)) + logSide(world));
|
||||
});
|
||||
@@ -155,10 +160,6 @@ public class DebugEvents {
|
||||
SINK.accept(player.getScoreboardName() + " drops " + new TranslatableComponent(entity.getItem().getDescriptionId()).getString() + logSide(player.level));
|
||||
return InteractionResult.PASS;
|
||||
});
|
||||
PlayerEvent.BREAK_BLOCK.register((world, pos, state, player, xp) -> {
|
||||
SINK.accept(player.getScoreboardName() + " breaks " + toShortString(pos) + logSide(player.level));
|
||||
return InteractionResult.PASS;
|
||||
});
|
||||
PlayerEvent.OPEN_MENU.register((player, menu) -> {
|
||||
SINK.accept(player.getScoreboardName() + " opens " + toSimpleName(menu) + logSide(player.level));
|
||||
});
|
||||
@@ -168,6 +169,9 @@ public class DebugEvents {
|
||||
PlayerEvent.CHANGE_DIMENSION.register((player, oldLevel, newLevel) -> {
|
||||
SINK.accept(player.getScoreboardName() + " switched from " + oldLevel.location() + " to " + newLevel.location() + logSide(player.level));
|
||||
});
|
||||
LightningEvent.STRIKE.register((bolt, level, pos, toStrike) -> {
|
||||
SINK.accept(bolt.getScoreboardName() + " struck at " + toShortString(pos) + logSide(level));
|
||||
});
|
||||
}
|
||||
|
||||
public static String toShortString(Vec3i pos) {
|
||||
@@ -208,10 +212,6 @@ public class DebugEvents {
|
||||
ClientPlayerEvent.CLIENT_PLAYER_RESPAWN.register((oldPlayer, newPlayer) -> {
|
||||
SINK.accept(newPlayer.getScoreboardName() + " respawned (client)");
|
||||
});
|
||||
GuiEvent.SET_SCREEN.register((screen -> {
|
||||
SINK.accept("Screen has been changed to " + toSimpleName(screen));
|
||||
return InteractionResultHolder.pass(screen);
|
||||
}));
|
||||
GuiEvent.INIT_PRE.register((screen, widgets, children) -> {
|
||||
SINK.accept(toSimpleName(screen) + " initializes");
|
||||
return InteractionResult.PASS;
|
||||
@@ -268,6 +268,14 @@ public class DebugEvents {
|
||||
SINK.accept("Raw Key pressed: " + InputConstants.getKey(keyCode, scanCode).getDisplayName().getString());
|
||||
return InteractionResult.PASS;
|
||||
});
|
||||
GuiEvent.SET_SCREEN.register(screen -> {
|
||||
if (screen instanceof ChatScreen) {
|
||||
return InteractionResultHolder.fail(screen);
|
||||
}
|
||||
|
||||
SINK.accept("Screen has been changed to " + toSimpleName(screen));
|
||||
return InteractionResultHolder.pass(screen);
|
||||
});
|
||||
}
|
||||
|
||||
private static String toSimpleName(Object o) {
|
||||
|
||||
@@ -19,16 +19,24 @@
|
||||
|
||||
package me.shedaniel.architectury.test.registry;
|
||||
|
||||
import me.shedaniel.architectury.hooks.EntityHooks;
|
||||
import me.shedaniel.architectury.registry.BlockProperties;
|
||||
import me.shedaniel.architectury.registry.DeferredRegister;
|
||||
import me.shedaniel.architectury.registry.RegistrySupplier;
|
||||
import me.shedaniel.architectury.test.TestMod;
|
||||
import me.shedaniel.architectury.test.tab.TestCreativeTabs;
|
||||
import net.minecraft.core.BlockPos;
|
||||
import net.minecraft.core.Registry;
|
||||
import net.minecraft.world.item.BlockItem;
|
||||
import net.minecraft.world.item.Item;
|
||||
import net.minecraft.world.level.BlockGetter;
|
||||
import net.minecraft.world.level.block.Block;
|
||||
import net.minecraft.world.level.block.Blocks;
|
||||
import net.minecraft.world.level.block.state.BlockState;
|
||||
import net.minecraft.world.phys.shapes.CollisionContext;
|
||||
import net.minecraft.world.phys.shapes.VoxelShape;
|
||||
|
||||
import static me.shedaniel.architectury.test.TestMod.SINK;
|
||||
|
||||
public class TestRegistries {
|
||||
public static final DeferredRegister<Item> ITEMS = DeferredRegister.create(TestMod.MOD_ID, Registry.ITEM_REGISTRY);
|
||||
@@ -39,8 +47,19 @@ public class TestRegistries {
|
||||
|
||||
public static final RegistrySupplier<Block> TEST_BLOCK = BLOCKS.register("test_block", () ->
|
||||
new Block(BlockProperties.copy(Blocks.STONE)));
|
||||
public static final RegistrySupplier<Block> COLLISION_BLOCK = BLOCKS.register("collision_block", () ->
|
||||
new Block(BlockProperties.copy(Blocks.STONE)) {
|
||||
@Override
|
||||
public VoxelShape getCollisionShape(BlockState state, BlockGetter bg, BlockPos pos, CollisionContext ctx) {
|
||||
SINK.accept(EntityHooks.fromCollision(ctx) + " is colliding with " + state);
|
||||
return super.getCollisionShape(state, bg, pos, ctx);
|
||||
}
|
||||
});
|
||||
|
||||
public static final RegistrySupplier<Item> TEST_BLOCK_ITEM = ITEMS.register("test_block", () ->
|
||||
new BlockItem(TEST_BLOCK.get(), new Item.Properties().tab(TestCreativeTabs.TEST_TAB)));
|
||||
public static final RegistrySupplier<Item> COLLISION_BLOCK_ITEM = ITEMS.register("collision_block", () ->
|
||||
new BlockItem(COLLISION_BLOCK.get(), new Item.Properties().tab(TestCreativeTabs.TEST_TAB)));
|
||||
|
||||
public static void initialize() {
|
||||
BLOCKS.register();
|
||||
|
||||
@@ -0,0 +1,47 @@
|
||||
/*
|
||||
* This file is part of architectury.
|
||||
* Copyright (C) 2020, 2021 shedaniel
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU Lesser General Public
|
||||
* License as published by the Free Software Foundation; either
|
||||
* version 3 of the License, or (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
* Lesser General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Lesser General Public License
|
||||
* along with this program; if not, write to the Free Software Foundation,
|
||||
* Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
|
||||
*/
|
||||
|
||||
package me.shedaniel.architectury.test.tags;
|
||||
|
||||
import me.shedaniel.architectury.event.events.BlockEvent;
|
||||
import me.shedaniel.architectury.hooks.TagHooks;
|
||||
import me.shedaniel.architectury.test.TestMod;
|
||||
import net.minecraft.core.particles.ParticleTypes;
|
||||
import net.minecraft.resources.ResourceLocation;
|
||||
import net.minecraft.server.level.ServerLevel;
|
||||
import net.minecraft.tags.Tag;
|
||||
import net.minecraft.world.InteractionResult;
|
||||
import net.minecraft.world.level.block.Block;
|
||||
|
||||
public class TestTags {
|
||||
public static void initialize() {
|
||||
// This will not be present, but it should return an empty tag
|
||||
Tag.Named<Block> heartParticles = TagHooks.getBlockOptional(new ResourceLocation(TestMod.MOD_ID, "heart_particles"));
|
||||
// This will act like a normal tag, we have emerald block here
|
||||
Tag.Named<Block> heartParticles2 = TagHooks.getBlockOptional(new ResourceLocation(TestMod.MOD_ID, "heart_particles2"));
|
||||
|
||||
BlockEvent.BREAK.register((world, pos, state, player, xp) -> {
|
||||
if (player != null && !world.isClientSide() && (state.is(heartParticles) || state.is(heartParticles2))) {
|
||||
((ServerLevel) world).sendParticles(player, ParticleTypes.HEART, false, pos.getX() + 0.5, pos.getY() + 0.5, pos.getZ() + 0.5, 10, 0.0, 0.0, 0.0, 0.0);
|
||||
}
|
||||
|
||||
return InteractionResult.PASS;
|
||||
});
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,6 @@
|
||||
{
|
||||
"replace": false,
|
||||
"values": [
|
||||
"minecraft:emerald_block"
|
||||
]
|
||||
}
|
||||
Reference in New Issue
Block a user