mirror of
https://github.com/MinecraftForge/MinecraftForge.git
synced 2026-11-28 07:55:53 +00:00
Forge 1.20
- Creative mode tabs are now a registry; the `BuildContents` event was renamed to `BuildCreativeModeTabContentsEvent` and moved it to its own class - The pack format is now 15 for both resource packs and data packs - `ScreenUtils` was deprecated in favor of a `GuiGraphics` extension - Forge and the MDK were updated to Gradle 8 and FG6 - The Forge common config file was removed (it only contained the deprecated old fields for resource caching, which was removed in 1.19.3) - Registry dummy entries were removed - `RemappingVertexPipeline` was fixed to forward the `endVertex()` call - Forge tool tags were removed in favor of vanilla ones Co-authored-by: ChampionAsh5357 <[email protected]> Co-authored-by: coehlrich <[email protected]> Co-authored-by: Dennis C <[email protected]> Co-authored-by: Matyrobbrt <[email protected]>
This commit is contained in:
1 parent
658e614dc1
commit
d8c84e2949
568 files changed
+5114
-5807
No files matched your search
@@ -5,9 +5,9 @@
|
||||
|
||||
package net.minecraftforge.debug;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import net.minecraft.core.registries.Registries;
|
||||
import net.minecraft.network.chat.Component;
|
||||
import net.minecraft.resources.ResourceKey;
|
||||
import net.minecraft.resources.ResourceLocation;
|
||||
import net.minecraft.world.item.CreativeModeTab;
|
||||
import net.minecraft.world.item.CreativeModeTab.TabVisibility;
|
||||
@@ -17,10 +17,11 @@ import net.minecraft.world.item.DyeItem;
|
||||
import net.minecraft.world.item.ItemStack;
|
||||
import net.minecraft.world.level.ItemLike;
|
||||
import net.minecraft.world.level.block.Blocks;
|
||||
import net.minecraftforge.event.CreativeModeTabEvent;
|
||||
import net.minecraftforge.event.BuildCreativeModeTabContentsEvent;
|
||||
import net.minecraftforge.eventbus.api.IEventBus;
|
||||
import net.minecraftforge.fml.common.Mod;
|
||||
import net.minecraftforge.fml.javafmlmod.FMLJavaModLoadingContext;
|
||||
import net.minecraftforge.registries.RegisterEvent;
|
||||
|
||||
@Mod(CreativeModeTabTest.MOD_ID)
|
||||
public class CreativeModeTabTest
|
||||
@@ -28,8 +29,8 @@ public class CreativeModeTabTest
|
||||
public static final String MOD_ID = "creative_mode_tab_test";
|
||||
private static final boolean ENABLED = true;
|
||||
|
||||
private static CreativeModeTab LOGS;
|
||||
private static CreativeModeTab STONE;
|
||||
private static final ResourceKey<CreativeModeTab> LOGS = ResourceKey.create(Registries.CREATIVE_MODE_TAB, new ResourceLocation(MOD_ID, "logs"));
|
||||
private static final ResourceKey<CreativeModeTab> STONE = ResourceKey.create(Registries.CREATIVE_MODE_TAB, new ResourceLocation(MOD_ID, "stone"));
|
||||
|
||||
public CreativeModeTabTest()
|
||||
{
|
||||
@@ -42,49 +43,55 @@ public class CreativeModeTabTest
|
||||
modEventBus.addListener(CreativeModeTabTest::onCreativeModeTabBuildContents);
|
||||
}
|
||||
|
||||
private static void onCreativeModeTabRegister(CreativeModeTabEvent.Register event)
|
||||
private static void onCreativeModeTabRegister(RegisterEvent event)
|
||||
{
|
||||
LOGS = event.registerCreativeModeTab(new ResourceLocation(MOD_ID, "logs"), builder -> builder.icon(() -> new ItemStack(Blocks.ACACIA_LOG))
|
||||
.title(Component.literal("Logs"))
|
||||
.withLabelColor(0x00FF00)
|
||||
.displayItems((params, output) -> {
|
||||
output.accept(new ItemStack(Blocks.ACACIA_LOG));
|
||||
output.accept(new ItemStack(Blocks.BIRCH_LOG));
|
||||
output.accept(new ItemStack(Blocks.DARK_OAK_LOG));
|
||||
output.accept(new ItemStack(Blocks.JUNGLE_LOG));
|
||||
output.accept(new ItemStack(Blocks.OAK_LOG));
|
||||
output.accept(new ItemStack(Blocks.SPRUCE_LOG));
|
||||
}));
|
||||
event.register(Registries.CREATIVE_MODE_TAB, helper -> {
|
||||
helper.register(LOGS, CreativeModeTab.builder().icon(() -> new ItemStack(Blocks.ACACIA_LOG))
|
||||
.title(Component.literal("Logs"))
|
||||
.withLabelColor(0x00FF00)
|
||||
.displayItems((params, output) -> {
|
||||
output.accept(new ItemStack(Blocks.ACACIA_LOG));
|
||||
output.accept(new ItemStack(Blocks.BIRCH_LOG));
|
||||
output.accept(new ItemStack(Blocks.DARK_OAK_LOG));
|
||||
output.accept(new ItemStack(Blocks.JUNGLE_LOG));
|
||||
output.accept(new ItemStack(Blocks.OAK_LOG));
|
||||
output.accept(new ItemStack(Blocks.SPRUCE_LOG));
|
||||
})
|
||||
.build());
|
||||
helper.register(STONE, CreativeModeTab.builder().icon(() -> new ItemStack(Blocks.STONE))
|
||||
.title(Component.literal("Stone"))
|
||||
.withLabelColor(0x0000FF)
|
||||
.displayItems((params, output) -> {
|
||||
output.accept(new ItemStack(Blocks.STONE));
|
||||
output.accept(new ItemStack(Blocks.GRANITE));
|
||||
output.accept(new ItemStack(Blocks.DIORITE));
|
||||
output.accept(new ItemStack(Blocks.ANDESITE));
|
||||
})
|
||||
.withTabsAfter(CreativeModeTabs.BUILDING_BLOCKS)
|
||||
.build());
|
||||
|
||||
STONE = event.registerCreativeModeTab(new ResourceLocation(MOD_ID, "stone"), List.of(CreativeModeTabs.BUILDING_BLOCKS), List.of(), builder -> builder.icon(() -> new ItemStack(Blocks.STONE))
|
||||
.title(Component.literal("Stone"))
|
||||
.withLabelColor(0x0000FF)
|
||||
.displayItems((params, output) -> {
|
||||
output.accept(new ItemStack(Blocks.STONE));
|
||||
output.accept(new ItemStack(Blocks.GRANITE));
|
||||
output.accept(new ItemStack(Blocks.DIORITE));
|
||||
output.accept(new ItemStack(Blocks.ANDESITE));
|
||||
}));
|
||||
|
||||
event.registerCreativeModeTab(new ResourceLocation(MOD_ID, "colors"), builder -> builder.title(Component.literal("Colors"))
|
||||
.displayItems((params, output) ->
|
||||
{
|
||||
for (DyeColor color : DyeColor.values())
|
||||
helper.register(new ResourceLocation(MOD_ID, "colors"), CreativeModeTab.builder().title(Component.literal("Colors"))
|
||||
.displayItems((params, output) ->
|
||||
{
|
||||
output.accept(DyeItem.byColor(color));
|
||||
}
|
||||
})
|
||||
.withTabFactory(CreativeModeColorTab::new)
|
||||
);
|
||||
for (DyeColor color : DyeColor.values())
|
||||
{
|
||||
output.accept(DyeItem.byColor(color));
|
||||
}
|
||||
})
|
||||
.withTabFactory(CreativeModeColorTab::new)
|
||||
.withTabsBefore(CreativeModeTabs.COLORED_BLOCKS)
|
||||
.build()
|
||||
);
|
||||
});
|
||||
}
|
||||
|
||||
private static ItemStack i(ItemLike item) { return new ItemStack(item); }
|
||||
|
||||
private static void onCreativeModeTabBuildContents(CreativeModeTabEvent.BuildContents event)
|
||||
private static void onCreativeModeTabBuildContents(BuildCreativeModeTabContentsEvent event)
|
||||
{
|
||||
var entries = event.getEntries();
|
||||
var vis = TabVisibility.PARENT_AND_SEARCH_TABS;
|
||||
if (event.getTab() == LOGS)
|
||||
if (event.getTabKey() == LOGS)
|
||||
{
|
||||
entries.putAfter(i(Blocks.ACACIA_LOG), i(Blocks.STRIPPED_ACACIA_LOG), vis);
|
||||
entries.putAfter(i(Blocks.BIRCH_LOG), i(Blocks.STRIPPED_BIRCH_LOG), vis);
|
||||
@@ -94,7 +101,7 @@ public class CreativeModeTabTest
|
||||
entries.putAfter(i(Blocks.SPRUCE_LOG), i(Blocks.STRIPPED_SPRUCE_LOG), vis);
|
||||
}
|
||||
|
||||
if (event.getTab() == STONE)
|
||||
if (event.getTabKey() == STONE)
|
||||
{
|
||||
entries.putBefore(i(Blocks.STONE), i(Blocks.SMOOTH_STONE), vis);
|
||||
entries.putBefore(i(Blocks.GRANITE), i(Blocks.POLISHED_GRANITE), vis);
|
||||
|
||||
@@ -9,13 +9,13 @@ import net.minecraft.world.item.CreativeModeTabs;
|
||||
import net.minecraft.world.level.block.state.BlockBehaviour;
|
||||
import net.minecraft.world.level.block.Block;
|
||||
import net.minecraft.world.level.block.SoundType;
|
||||
import net.minecraft.world.level.material.Material;
|
||||
import net.minecraft.world.level.material.MapColor;
|
||||
import net.minecraft.world.item.BlockItem;
|
||||
import net.minecraft.world.item.Item;
|
||||
import net.minecraft.resources.ResourceLocation;
|
||||
import net.minecraft.sounds.SoundEvent;
|
||||
import net.minecraftforge.common.util.ForgeSoundType;
|
||||
import net.minecraftforge.event.CreativeModeTabEvent;
|
||||
import net.minecraftforge.event.BuildCreativeModeTabContentsEvent;
|
||||
import net.minecraftforge.eventbus.api.IEventBus;
|
||||
import net.minecraftforge.registries.RegistryObject;
|
||||
import net.minecraftforge.fml.common.Mod;
|
||||
@@ -37,7 +37,7 @@ public class CustomSoundTypeTest
|
||||
private static final SoundType TEST_SOUND_TYPE = new ForgeSoundType(1.0F, 1.0F, TEST_STEP_EVENT, TEST_STEP_EVENT, TEST_STEP_EVENT, TEST_STEP_EVENT, TEST_STEP_EVENT);
|
||||
|
||||
private static final RegistryObject<Block> TEST_STEP_BLOCK = BLOCKS.register("test_block",
|
||||
() -> new Block(BlockBehaviour.Properties.of(Material.WOOD).sound(TEST_SOUND_TYPE)));
|
||||
() -> new Block(BlockBehaviour.Properties.of().mapColor(MapColor.WOOD).sound(TEST_SOUND_TYPE)));
|
||||
|
||||
private static final RegistryObject<Item> TEST_STEP_BLOCK_ITEM = ITEMS.register("test_block",
|
||||
() -> new BlockItem(TEST_STEP_BLOCK.get(), new Item.Properties()));
|
||||
@@ -51,9 +51,9 @@ public class CustomSoundTypeTest
|
||||
modEventBus.addListener(this::addCreative);
|
||||
}
|
||||
|
||||
private void addCreative(CreativeModeTabEvent.BuildContents event)
|
||||
private void addCreative(BuildCreativeModeTabContentsEvent event)
|
||||
{
|
||||
if (event.getTab() == CreativeModeTabs.INGREDIENTS)
|
||||
if (event.getTabKey() == CreativeModeTabs.INGREDIENTS)
|
||||
event.accept(TEST_STEP_BLOCK_ITEM);
|
||||
}
|
||||
}
|
||||
@@ -460,8 +460,13 @@ public class DataGeneratorTest
|
||||
}
|
||||
final JsonObject actual;
|
||||
try {
|
||||
List<Resource> resourceStack = this.helper.getResourceStack(new ResourceLocation("sounds.json"), PackType.CLIENT_RESOURCES);
|
||||
// Get the first resource in the stack
|
||||
// This guarantees vanilla even when a forge sounds.json is present because getResourceStack reverses the list
|
||||
// so that the lower priority resources are first (to allow overwriting data in later entries)
|
||||
Resource vanillaSoundResource = resourceStack.get(0);
|
||||
actual = GSON.fromJson(
|
||||
this.helper.getResource(new ResourceLocation("sounds.json"), PackType.CLIENT_RESOURCES).openAsReader(),
|
||||
vanillaSoundResource.openAsReader(),
|
||||
JsonObject.class
|
||||
);
|
||||
} catch (IOException e) {
|
||||
|
||||
@@ -6,7 +6,6 @@
|
||||
package net.minecraftforge.debug;
|
||||
|
||||
import java.util.Set;
|
||||
import java.util.function.Consumer;
|
||||
import java.util.function.Supplier;
|
||||
|
||||
import net.minecraft.resources.ResourceLocation;
|
||||
@@ -14,25 +13,19 @@ import net.minecraft.tags.TagKey;
|
||||
import net.minecraft.world.item.CreativeModeTabs;
|
||||
import net.minecraft.world.item.crafting.RecipeType;
|
||||
import net.minecraftforge.common.MinecraftForge;
|
||||
import net.minecraftforge.event.CreativeModeTabEvent;
|
||||
import net.minecraftforge.event.BuildCreativeModeTabContentsEvent;
|
||||
import net.minecraftforge.event.server.ServerStartedEvent;
|
||||
import org.apache.logging.log4j.LogManager;
|
||||
import org.apache.logging.log4j.Logger;
|
||||
|
||||
import net.minecraft.world.level.block.Block;
|
||||
import net.minecraft.world.level.levelgen.placement.PlacedFeature;
|
||||
import net.minecraft.world.level.levelgen.structure.templatesystem.PosRuleTestType;
|
||||
import net.minecraft.world.level.material.Material;
|
||||
import net.minecraft.core.Holder;
|
||||
import net.minecraft.core.Registry;
|
||||
import net.minecraft.core.registries.BuiltInRegistries;
|
||||
import net.minecraft.world.level.material.MapColor;
|
||||
import net.minecraft.core.registries.Registries;
|
||||
import net.minecraft.data.DataGenerator;
|
||||
import net.minecraft.data.worldgen.features.OreFeatures;
|
||||
import net.minecraft.world.item.BlockItem;
|
||||
import net.minecraft.world.item.Item;
|
||||
import net.minecraftforge.client.model.generators.BlockStateProvider;
|
||||
import net.minecraftforge.client.model.generators.ModelFile;
|
||||
import net.minecraftforge.eventbus.api.IEventBus;
|
||||
import net.minecraftforge.registries.RegistryObject;
|
||||
import net.minecraftforge.fml.common.Mod;
|
||||
@@ -57,7 +50,7 @@ public class DeferredRegistryTest {
|
||||
// Vanilla Registry - filled directly after all RegistryEvent.Register events are fired
|
||||
private static final DeferredRegister<PosRuleTestType<?>> POS_RULE_TEST_TYPES = DeferredRegister.create(Registries.POS_RULE_TEST, MODID);
|
||||
|
||||
private static final RegistryObject<Block> BLOCK = BLOCKS.register("test", () -> new Block(Block.Properties.of(Material.STONE)));
|
||||
private static final RegistryObject<Block> BLOCK = BLOCKS.register("test", () -> new Block(Block.Properties.of().mapColor(MapColor.STONE)));
|
||||
private static final RegistryObject<Item> ITEM = ITEMS .register("test", () -> new BlockItem(BLOCK.get(), new Item.Properties()));
|
||||
private static final RegistryObject<Custom> CUSTOM = CUSTOMS.register("test", () -> new Custom(){});
|
||||
// Should never be created as the registry doesn't exist - this should silently fail and remain empty
|
||||
@@ -84,9 +77,9 @@ public class DeferredRegistryTest {
|
||||
modBus.addListener(this::addCreative);
|
||||
}
|
||||
|
||||
private void addCreative(CreativeModeTabEvent.BuildContents event)
|
||||
private void addCreative(BuildCreativeModeTabContentsEvent event)
|
||||
{
|
||||
if (event.getTab() == CreativeModeTabs.INGREDIENTS)
|
||||
if (event.getTabKey() == CreativeModeTabs.INGREDIENTS)
|
||||
event.accept(ITEM);
|
||||
}
|
||||
|
||||
|
||||
@@ -5,7 +5,7 @@
|
||||
|
||||
package net.minecraftforge.debug;
|
||||
|
||||
import net.minecraft.core.NonNullList;
|
||||
import net.minecraft.core.registries.Registries;
|
||||
import net.minecraft.network.chat.Component;
|
||||
import net.minecraft.resources.ResourceLocation;
|
||||
import net.minecraft.world.effect.MobEffect;
|
||||
@@ -19,21 +19,19 @@ import net.minecraft.world.item.Items;
|
||||
import net.minecraft.world.item.SuspiciousStewItem;
|
||||
import net.minecraft.world.item.alchemy.PotionUtils;
|
||||
import net.minecraftforge.common.MinecraftForge;
|
||||
import net.minecraftforge.event.CreativeModeTabEvent;
|
||||
import net.minecraftforge.event.entity.player.PlayerInteractEvent;
|
||||
import net.minecraftforge.eventbus.api.Event;
|
||||
import net.minecraftforge.eventbus.api.IEventBus;
|
||||
import net.minecraftforge.fml.common.Mod;
|
||||
import net.minecraftforge.fml.javafmlmod.FMLJavaModLoadingContext;
|
||||
import net.minecraftforge.fml.util.ObfuscationReflectionHelper;
|
||||
import net.minecraftforge.registries.DeferredRegister;
|
||||
import net.minecraftforge.registries.ForgeRegistries;
|
||||
import net.minecraftforge.registries.RegisterEvent;
|
||||
import net.minecraftforge.registries.RegistryObject;
|
||||
import org.apache.logging.log4j.LogManager;
|
||||
import org.apache.logging.log4j.Logger;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.function.Consumer;
|
||||
|
||||
/**
|
||||
* Registers 255 mob effects that log every tick on the client.
|
||||
@@ -69,7 +67,7 @@ public class ManyMobEffectsTest
|
||||
@Override
|
||||
public void applyEffectTick(LivingEntity entity, int amplifier)
|
||||
{
|
||||
if (entity.level.isClientSide)
|
||||
if (entity.level().isClientSide)
|
||||
{
|
||||
LOGGER.info("Effect Tick for {} on the client", index);
|
||||
}
|
||||
@@ -91,22 +89,24 @@ public class ManyMobEffectsTest
|
||||
IEventBus modBus = FMLJavaModLoadingContext.get().getModEventBus();
|
||||
MOB_EFFECTS.register(modBus);
|
||||
MinecraftForge.EVENT_BUS.addListener(ManyMobEffectsTest::mobInteract);
|
||||
modBus.addListener((CreativeModeTabEvent.Register event) -> event.registerCreativeModeTab(new ResourceLocation(MODID, "many_mob_effects_test"), builder -> builder.withSearchBar()
|
||||
.icon(() -> new ItemStack(Items.POTION))
|
||||
.displayItems((params, output) -> {
|
||||
var stack = new ItemStack(Items.POTION);
|
||||
PotionUtils.setCustomEffects(stack, List.of(new MobEffectInstance(LAST_EFFECT.get(), 1000)));
|
||||
output.accept(stack);
|
||||
modBus.addListener((final RegisterEvent event) -> event.register(Registries.CREATIVE_MODE_TAB, helper ->
|
||||
helper.register(new ResourceLocation(MODID, "many_mob_effects_test"), CreativeModeTab.builder().withSearchBar()
|
||||
.icon(() -> new ItemStack(Items.POTION))
|
||||
.displayItems((params, output) -> {
|
||||
var stack = new ItemStack(Items.POTION);
|
||||
PotionUtils.setCustomEffects(stack, List.of(new MobEffectInstance(LAST_EFFECT.get(), 1000)));
|
||||
output.accept(stack);
|
||||
|
||||
stack = new ItemStack(Items.SUSPICIOUS_STEW);
|
||||
SuspiciousStewItem.saveMobEffect(stack, LAST_EFFECT.get(), 1000);
|
||||
output.accept(stack);
|
||||
})));
|
||||
stack = new ItemStack(Items.SUSPICIOUS_STEW);
|
||||
SuspiciousStewItem.saveMobEffect(stack, LAST_EFFECT.get(), 1000);
|
||||
output.accept(stack);
|
||||
})
|
||||
.build())));
|
||||
}
|
||||
|
||||
private static void mobInteract(PlayerInteractEvent.EntityInteract event)
|
||||
{
|
||||
if (!event.getTarget().getLevel().isClientSide() && event.getTarget() instanceof MushroomCow cow)
|
||||
if (!event.getTarget().level().isClientSide() && event.getTarget() instanceof MushroomCow cow)
|
||||
{
|
||||
var heldItem = event.getEntity().getItemInHand(event.getHand());
|
||||
if (heldItem.is(Items.POTION))
|
||||
|
||||
@@ -56,10 +56,10 @@ public class PermissionTest
|
||||
event.getDispatcher().register(Commands.literal("permtest")
|
||||
.requires(src -> canUseCommand(src, boolPerm))
|
||||
.executes(context -> {
|
||||
context.getSource().sendSuccess(Component.literal("Blob"), false);
|
||||
context.getSource().sendSuccess(Component.literal("String:" + PermissionAPI.getPermission((ServerPlayer) context.getSource().getEntity(), stringPerm)), false);
|
||||
context.getSource().sendSuccess(Component.literal("Int: " + PermissionAPI.getPermission((ServerPlayer) context.getSource().getEntity(), intPerm)), false);
|
||||
context.getSource().sendSuccess(PermissionAPI.getPermission((ServerPlayer) context.getSource().getEntity(), componentPerm), false);
|
||||
context.getSource().sendSuccess(() -> Component.literal("Blob"), false);
|
||||
context.getSource().sendSuccess(() -> Component.literal("String:" + PermissionAPI.getPermission((ServerPlayer) context.getSource().getEntity(), stringPerm)), false);
|
||||
context.getSource().sendSuccess(() -> Component.literal("Int: " + PermissionAPI.getPermission((ServerPlayer) context.getSource().getEntity(), intPerm)), false);
|
||||
context.getSource().sendSuccess(() -> PermissionAPI.getPermission((ServerPlayer) context.getSource().getEntity(), componentPerm), false);
|
||||
|
||||
return 1;
|
||||
}));
|
||||
@@ -69,7 +69,7 @@ public class PermissionTest
|
||||
event.getDispatcher().register(Commands.literal("permtesterr")
|
||||
.requires(src -> canUseCommand(src, unregisteredPerm))
|
||||
.executes(context -> {
|
||||
context.getSource().sendSuccess(Component.literal("Blob"), false);
|
||||
context.getSource().sendSuccess(() -> Component.literal("Blob"), false);
|
||||
return 1;
|
||||
}));
|
||||
}
|
||||
|
||||
@@ -16,10 +16,9 @@ import net.minecraft.world.level.block.*;
|
||||
import net.minecraft.world.level.block.entity.*;
|
||||
import net.minecraft.world.level.block.state.BlockBehaviour.Properties;
|
||||
import net.minecraft.world.level.block.state.BlockState;
|
||||
import net.minecraft.world.level.material.Material;
|
||||
import net.minecraft.world.level.material.MaterialColor;
|
||||
import net.minecraft.world.level.material.MapColor;
|
||||
import net.minecraft.world.phys.BlockHitResult;
|
||||
import net.minecraftforge.event.CreativeModeTabEvent;
|
||||
import net.minecraftforge.event.BuildCreativeModeTabContentsEvent;
|
||||
import net.minecraftforge.eventbus.api.IEventBus;
|
||||
import net.minecraftforge.fml.common.Mod;
|
||||
import net.minecraftforge.fml.javafmlmod.FMLJavaModLoadingContext;
|
||||
@@ -41,7 +40,7 @@ public class BlockEntityOnLoadTest
|
||||
private static final DeferredRegister<Item> ITEMS = DeferredRegister.create(ForgeRegistries.ITEMS, "be_onload_test");
|
||||
private static final DeferredRegister<BlockEntityType<?>> BE_TYPES = DeferredRegister.create(ForgeRegistries.BLOCK_ENTITY_TYPES, "be_onload_test");
|
||||
|
||||
private static final RegistryObject<Block> TEST_BLOCK = BLOCKS.register("be_onload_testblock", () -> new TestBlock(Properties.of(Material.DECORATION, MaterialColor.SAND)));
|
||||
private static final RegistryObject<Block> TEST_BLOCK = BLOCKS.register("be_onload_testblock", () -> new TestBlock(Properties.of().mapColor(MapColor.SAND)));
|
||||
private static final RegistryObject<Item> TEST_BLOCK_ITEM = ITEMS.register("be_onload_testblock", () -> new BlockItem(TEST_BLOCK.get(), new Item.Properties()));
|
||||
private static final RegistryObject<BlockEntityType<TestBlockEntity>> TEST_BE_TYPE = BE_TYPES.register("be_onload_testbe", () -> BlockEntityType.Builder.of(TestBlockEntity::new, TEST_BLOCK.get()).build(null));
|
||||
|
||||
@@ -57,9 +56,9 @@ public class BlockEntityOnLoadTest
|
||||
}
|
||||
}
|
||||
|
||||
private void addCreative(CreativeModeTabEvent.BuildContents event)
|
||||
private void addCreative(BuildCreativeModeTabContentsEvent event)
|
||||
{
|
||||
if (event.getTab() == CreativeModeTabs.BUILDING_BLOCKS)
|
||||
if (event.getTabKey() == CreativeModeTabs.BUILDING_BLOCKS)
|
||||
event.accept(TEST_BLOCK_ITEM);
|
||||
}
|
||||
|
||||
|
||||
@@ -20,11 +20,10 @@ import net.minecraft.world.level.block.entity.BlockEntityType;
|
||||
import net.minecraft.world.level.block.entity.SkullBlockEntity;
|
||||
import net.minecraft.world.level.block.state.BlockBehaviour;
|
||||
import net.minecraft.world.level.block.state.BlockState;
|
||||
import net.minecraft.world.level.material.Material;
|
||||
import net.minecraftforge.api.distmarker.Dist;
|
||||
import net.minecraftforge.client.event.EntityRenderersEvent;
|
||||
import net.minecraftforge.common.util.Lazy;
|
||||
import net.minecraftforge.event.CreativeModeTabEvent;
|
||||
import net.minecraftforge.event.BuildCreativeModeTabContentsEvent;
|
||||
import net.minecraftforge.eventbus.api.IEventBus;
|
||||
import net.minecraftforge.eventbus.api.SubscribeEvent;
|
||||
import net.minecraftforge.fml.common.Mod;
|
||||
@@ -48,8 +47,8 @@ public class CustomHeadTest
|
||||
private static final DeferredRegister<Block> BLOCKS = DeferredRegister.create(ForgeRegistries.BLOCKS, MODID);
|
||||
private static final DeferredRegister<Item> ITEMS = DeferredRegister.create(ForgeRegistries.ITEMS, MODID);
|
||||
private static final DeferredRegister<BlockEntityType<?>> BLOCK_ENTITIES = DeferredRegister.create(ForgeRegistries.BLOCK_ENTITY_TYPES, MODID);
|
||||
private static final RegistryObject<Block> BLAZE_HEAD = BLOCKS.register("blaze_head", () -> new CustomSkullBlock(SkullType.BLAZE, BlockBehaviour.Properties.of(Material.DECORATION).strength(1.0F)));
|
||||
private static final RegistryObject<Block> BLAZE_HEAD_WALL = BLOCKS.register("blaze_wall_head", () -> new CustomWallSkullBlock(SkullType.BLAZE, BlockBehaviour.Properties.of(Material.DECORATION).strength(1.0F).lootFrom(BLAZE_HEAD)));
|
||||
private static final RegistryObject<Block> BLAZE_HEAD = BLOCKS.register("blaze_head", () -> new CustomSkullBlock(SkullType.BLAZE, BlockBehaviour.Properties.of().strength(1.0F)));
|
||||
private static final RegistryObject<Block> BLAZE_HEAD_WALL = BLOCKS.register("blaze_wall_head", () -> new CustomWallSkullBlock(SkullType.BLAZE, BlockBehaviour.Properties.of().strength(1.0F).lootFrom(BLAZE_HEAD)));
|
||||
private static final RegistryObject<Item> BLAZE_HEAD_ITEM = ITEMS.register("blaze_head", () -> new StandingAndWallBlockItem(BLAZE_HEAD.get(), BLAZE_HEAD_WALL.get(), new Item.Properties().rarity(Rarity.UNCOMMON), Direction.DOWN));
|
||||
private static final RegistryObject<BlockEntityType<CustomSkullBlockEntity>> CUSTOM_SKULL = BLOCK_ENTITIES.register("custom_skull", () -> BlockEntityType.Builder.of(CustomSkullBlockEntity::new, BLAZE_HEAD.get(), BLAZE_HEAD_WALL.get()).build(null));
|
||||
|
||||
@@ -62,9 +61,9 @@ public class CustomHeadTest
|
||||
modBus.addListener(this::addCreative);
|
||||
}
|
||||
|
||||
private void addCreative(CreativeModeTabEvent.BuildContents event)
|
||||
private void addCreative(BuildCreativeModeTabContentsEvent event)
|
||||
{
|
||||
if (event.getTab() == CreativeModeTabs.BUILDING_BLOCKS)
|
||||
if (event.getTabKey() == CreativeModeTabs.BUILDING_BLOCKS)
|
||||
event.accept(BLAZE_HEAD_ITEM);
|
||||
}
|
||||
|
||||
|
||||
@@ -9,7 +9,7 @@ import net.minecraft.world.level.block.Block;
|
||||
import net.minecraft.world.level.block.state.BlockState;
|
||||
import net.minecraft.world.level.block.FlowerBlock;
|
||||
import net.minecraft.world.level.block.SoundType;
|
||||
import net.minecraft.world.level.material.Material;
|
||||
import net.minecraft.world.level.material.MapColor;
|
||||
import net.minecraft.world.item.BlockItem;
|
||||
import net.minecraft.world.item.Item;
|
||||
import net.minecraft.world.effect.MobEffects;
|
||||
@@ -63,7 +63,7 @@ public class CustomPlantTypeTest
|
||||
{
|
||||
public CustomBlock()
|
||||
{
|
||||
super(Properties.of(Material.STONE));
|
||||
super(Properties.of().mapColor(MapColor.STONE));
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -84,7 +84,7 @@ public class CustomPlantTypeTest
|
||||
|
||||
public CustomPlantBlock()
|
||||
{
|
||||
super(MobEffects.WEAKNESS, 9, Properties.of(Material.PLANT).noCollission().sound(SoundType.GRASS));
|
||||
super(MobEffects.WEAKNESS, 9, Properties.of().mapColor(MapColor.PLANT).noCollission().sound(SoundType.GRASS));
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -19,7 +19,7 @@ import net.minecraft.world.level.LevelReader;
|
||||
import net.minecraft.world.level.block.Block;
|
||||
import net.minecraft.world.level.block.RespawnAnchorBlock;
|
||||
import net.minecraft.world.level.block.state.BlockState;
|
||||
import net.minecraft.world.level.material.Material;
|
||||
import net.minecraft.world.level.material.MapColor;
|
||||
import net.minecraft.world.phys.BlockHitResult;
|
||||
import net.minecraft.world.phys.Vec3;
|
||||
import net.minecraftforge.eventbus.api.IEventBus;
|
||||
@@ -39,7 +39,7 @@ public class CustomRespawnTest
|
||||
public static final String MODID = "custom_respawn_test";
|
||||
|
||||
private static final DeferredRegister<Block> BLOCKS = DeferredRegister.create(ForgeRegistries.BLOCKS, MODID);
|
||||
public static final RegistryObject<Block> TEST_RESPAWN_BLOCK = BLOCKS.register("test_respawn_block", () -> new CustomRespawnBlock(Block.Properties.of(Material.WOOD)));
|
||||
public static final RegistryObject<Block> TEST_RESPAWN_BLOCK = BLOCKS.register("test_respawn_block", () -> new CustomRespawnBlock(Block.Properties.of().mapColor(MapColor.WOOD)));
|
||||
|
||||
private static final DeferredRegister<Item> ITEMS = DeferredRegister.create(ForgeRegistries.ITEMS, MODID);
|
||||
public static final RegistryObject<Item> TEST_RESPAWN_BLOCK_ITEM = ITEMS.register("test_respawn_block", () -> new BlockItem(TEST_RESPAWN_BLOCK.get(), (new Item.Properties())));
|
||||
|
||||
@@ -14,7 +14,6 @@ import net.minecraft.world.level.block.CeilingHangingSignBlock;
|
||||
import net.minecraft.world.level.block.WallHangingSignBlock;
|
||||
import net.minecraft.world.level.block.entity.HangingSignBlockEntity;
|
||||
import net.minecraft.world.level.block.state.properties.BlockSetType;
|
||||
import net.minecraft.world.level.material.Material;
|
||||
import net.minecraft.client.renderer.Sheets;
|
||||
import net.minecraft.client.renderer.blockentity.SignRenderer;
|
||||
import net.minecraft.world.item.Item;
|
||||
@@ -23,7 +22,7 @@ import net.minecraft.world.level.block.entity.SignBlockEntity;
|
||||
import net.minecraft.world.level.block.entity.BlockEntity;
|
||||
import net.minecraft.world.level.block.entity.BlockEntityType;
|
||||
import net.minecraft.resources.ResourceLocation;
|
||||
import net.minecraftforge.event.CreativeModeTabEvent;
|
||||
import net.minecraftforge.event.BuildCreativeModeTabContentsEvent;
|
||||
import net.minecraftforge.eventbus.api.IEventBus;
|
||||
import net.minecraftforge.registries.RegistryObject;
|
||||
import net.minecraftforge.fml.common.Mod;
|
||||
@@ -50,10 +49,10 @@ public class CustomSignsTest
|
||||
public static final WoodType TEST_WOOD_TYPE = WoodType.register(new WoodType(new ResourceLocation(MODID, "test").toString(), BlockSetType.ACACIA));
|
||||
|
||||
private static final DeferredRegister<Block> BLOCKS = DeferredRegister.create(ForgeRegistries.BLOCKS, MODID);
|
||||
public static final RegistryObject<CustomStandingSignBlock> TEST_STANDING_SIGN = BLOCKS.register("test_sign", () -> new CustomStandingSignBlock(Properties.of(Material.WOOD).noCollission().strength(1.0F).sound(SoundType.WOOD), CustomSignsTest.TEST_WOOD_TYPE));
|
||||
public static final RegistryObject<CustomWallSignBlock> TEST_WALL_SIGN = BLOCKS.register("test_wall_sign", () -> new CustomWallSignBlock(Properties.of(Material.WOOD).noCollission().strength(1.0F).sound(SoundType.WOOD), CustomSignsTest.TEST_WOOD_TYPE));
|
||||
public static final RegistryObject<CustomCeilingHangingSignBlock> TEST_CEILING_HANGING_SIGN = BLOCKS.register("test_hanging_sign", () -> new CustomCeilingHangingSignBlock(Properties.of(Material.WOOD).noCollission().strength(1.0F).sound(SoundType.WOOD), CustomSignsTest.TEST_WOOD_TYPE));
|
||||
public static final RegistryObject<CustomWallHangingSignBlock> TEST_WALL_HANGING_SIGN = BLOCKS.register("test_wall_hanging_sign", () -> new CustomWallHangingSignBlock(Properties.of(Material.WOOD).noCollission().strength(1.0F).sound(SoundType.WOOD), CustomSignsTest.TEST_WOOD_TYPE));
|
||||
public static final RegistryObject<CustomStandingSignBlock> TEST_STANDING_SIGN = BLOCKS.register("test_sign", () -> new CustomStandingSignBlock(Properties.of().noCollission().strength(1.0F).sound(SoundType.WOOD), CustomSignsTest.TEST_WOOD_TYPE));
|
||||
public static final RegistryObject<CustomWallSignBlock> TEST_WALL_SIGN = BLOCKS.register("test_wall_sign", () -> new CustomWallSignBlock(Properties.of().noCollission().strength(1.0F).sound(SoundType.WOOD), CustomSignsTest.TEST_WOOD_TYPE));
|
||||
public static final RegistryObject<CustomCeilingHangingSignBlock> TEST_CEILING_HANGING_SIGN = BLOCKS.register("test_hanging_sign", () -> new CustomCeilingHangingSignBlock(Properties.of().noCollission().strength(1.0F).sound(SoundType.WOOD), CustomSignsTest.TEST_WOOD_TYPE));
|
||||
public static final RegistryObject<CustomWallHangingSignBlock> TEST_WALL_HANGING_SIGN = BLOCKS.register("test_wall_hanging_sign", () -> new CustomWallHangingSignBlock(Properties.of().noCollission().strength(1.0F).sound(SoundType.WOOD), CustomSignsTest.TEST_WOOD_TYPE));
|
||||
|
||||
private static final DeferredRegister<Item> ITEMS = DeferredRegister.create(ForgeRegistries.ITEMS, MODID);
|
||||
public static final RegistryObject<SignItem> TEST_SIGN = ITEMS.register("test_sign", () -> new SignItem((new Item.Properties()).stacksTo(16), TEST_STANDING_SIGN.get(), TEST_WALL_SIGN.get()));
|
||||
@@ -78,9 +77,9 @@ public class CustomSignsTest
|
||||
}
|
||||
}
|
||||
|
||||
private void addCreative(CreativeModeTabEvent.BuildContents event)
|
||||
private void addCreative(BuildCreativeModeTabContentsEvent event)
|
||||
{
|
||||
if (event.getTab() == CreativeModeTabs.BUILDING_BLOCKS)
|
||||
if (event.getTabKey() == CreativeModeTabs.BUILDING_BLOCKS)
|
||||
{
|
||||
event.accept(TEST_SIGN);
|
||||
event.accept(TEST_HANGING_SIGN);
|
||||
|
||||
@@ -31,7 +31,7 @@ import net.minecraft.world.level.block.entity.BlockEntity;
|
||||
import net.minecraft.world.level.block.entity.BlockEntityType;
|
||||
import net.minecraft.world.level.block.state.BlockState;
|
||||
import net.minecraft.world.level.gameevent.GameEvent;
|
||||
import net.minecraft.world.level.material.Material;
|
||||
import net.minecraft.world.level.material.MapColor;
|
||||
import net.minecraft.world.phys.BlockHitResult;
|
||||
import net.minecraft.world.phys.shapes.CollisionContext;
|
||||
import net.minecraft.world.phys.shapes.VoxelShape;
|
||||
@@ -44,7 +44,7 @@ import net.minecraftforge.client.model.geometry.IGeometryBakingContext;
|
||||
import net.minecraftforge.client.model.geometry.IGeometryLoader;
|
||||
import net.minecraftforge.client.model.geometry.IUnbakedGeometry;
|
||||
import net.minecraftforge.common.util.ConcatenatedListView;
|
||||
import net.minecraftforge.event.CreativeModeTabEvent;
|
||||
import net.minecraftforge.event.BuildCreativeModeTabContentsEvent;
|
||||
import net.minecraftforge.eventbus.api.IEventBus;
|
||||
import net.minecraftforge.eventbus.api.SubscribeEvent;
|
||||
import net.minecraftforge.fml.common.Mod;
|
||||
@@ -91,9 +91,9 @@ public class FullPotsAccessorDemo
|
||||
}
|
||||
}
|
||||
|
||||
private void addCreative(CreativeModeTabEvent.BuildContents event)
|
||||
private void addCreative(BuildCreativeModeTabContentsEvent event)
|
||||
{
|
||||
if (event.getTab() == CreativeModeTabs.INGREDIENTS)
|
||||
if (event.getTabKey() == CreativeModeTabs.INGREDIENTS)
|
||||
event.accept(DIORITE_POT_ITEM);
|
||||
}
|
||||
|
||||
@@ -103,7 +103,7 @@ public class FullPotsAccessorDemo
|
||||
|
||||
public DioriteFlowerPotBlock()
|
||||
{
|
||||
super(Properties.of(Material.DECORATION).instabreak().noOcclusion());
|
||||
super(Properties.of().mapColor(MapColor.NONE).instabreak().noOcclusion());
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -17,8 +17,7 @@ import net.minecraft.world.level.block.SaplingBlock;
|
||||
import net.minecraft.world.level.block.state.BlockBehaviour;
|
||||
import net.minecraft.world.level.block.state.BlockState;
|
||||
import net.minecraft.world.level.levelgen.feature.configurations.TreeConfiguration;
|
||||
import net.minecraft.world.level.material.Material;
|
||||
import net.minecraft.world.level.material.MaterialColor;
|
||||
import net.minecraft.world.level.material.MapColor;
|
||||
import net.minecraftforge.common.IPlantable;
|
||||
import net.minecraftforge.common.extensions.IForgeBlockState;
|
||||
import net.minecraftforge.eventbus.api.IEventBus;
|
||||
@@ -45,7 +44,7 @@ public class OnTreeGrowBlockTest
|
||||
public static final DeferredRegister<Block> BLOCKS = DeferredRegister.create(ForgeRegistries.Keys.BLOCKS, ID);
|
||||
public static final DeferredRegister<Item> ITEMS = DeferredRegister.create(ForgeRegistries.Keys.ITEMS, ID);
|
||||
|
||||
public static final RegistryObject<Block> TEST_GRASS_BLOCK = BLOCKS.register("test_grass_block", () -> new Block(BlockBehaviour.Properties.of(Material.GRASS, MaterialColor.COLOR_LIGHT_BLUE).destroyTime(1.5f))
|
||||
public static final RegistryObject<Block> TEST_GRASS_BLOCK = BLOCKS.register("test_grass_block", () -> new Block(BlockBehaviour.Properties.of().mapColor(MapColor.COLOR_LIGHT_BLUE).destroyTime(1.5f))
|
||||
{
|
||||
@Override
|
||||
public boolean canSustainPlant(BlockState state, BlockGetter world, BlockPos pos, Direction facing, IPlantable plantable)
|
||||
@@ -68,7 +67,7 @@ public class OnTreeGrowBlockTest
|
||||
}
|
||||
}
|
||||
});
|
||||
public static final RegistryObject<Block> TEST_DIRT = BLOCKS.register("test_dirt", () -> new Block(BlockBehaviour.Properties.of(Material.GRASS, MaterialColor.COLOR_LIGHT_BLUE).destroyTime(1.5f))
|
||||
public static final RegistryObject<Block> TEST_DIRT = BLOCKS.register("test_dirt", () -> new Block(BlockBehaviour.Properties.of().mapColor(MapColor.COLOR_LIGHT_BLUE).destroyTime(1.5f))
|
||||
{
|
||||
@Override
|
||||
public boolean canSustainPlant(BlockState state, BlockGetter world, BlockPos pos, Direction facing, IPlantable plantable)
|
||||
|
||||
@@ -21,11 +21,11 @@ import net.minecraft.world.level.block.Blocks;
|
||||
import net.minecraft.world.level.block.piston.PistonBaseBlock;
|
||||
import net.minecraft.world.level.block.piston.PistonStructureResolver;
|
||||
import net.minecraft.world.level.block.state.BlockState;
|
||||
import net.minecraft.world.level.material.Material;
|
||||
import net.minecraft.world.level.material.MapColor;
|
||||
import net.minecraftforge.client.model.generators.BlockStateProvider;
|
||||
import net.minecraftforge.common.data.ExistingFileHelper;
|
||||
import net.minecraftforge.data.event.GatherDataEvent;
|
||||
import net.minecraftforge.event.CreativeModeTabEvent;
|
||||
import net.minecraftforge.event.BuildCreativeModeTabContentsEvent;
|
||||
import net.minecraftforge.event.level.PistonEvent;
|
||||
import net.minecraftforge.event.level.PistonEvent.PistonMoveType;
|
||||
import net.minecraftforge.eventbus.api.IEventBus;
|
||||
@@ -57,7 +57,7 @@ public class PistonEventTest
|
||||
private static final DeferredRegister<Block> BLOCKS = DeferredRegister.create(ForgeRegistries.BLOCKS, MODID);
|
||||
private static final DeferredRegister<Item> ITEMS = DeferredRegister.create(ForgeRegistries.ITEMS, MODID);
|
||||
|
||||
private static final RegistryObject<Block> SHIFT_ON_MOVE = BLOCKS.register(blockName, () -> new Block(Block.Properties.of(Material.STONE)));
|
||||
private static final RegistryObject<Block> SHIFT_ON_MOVE = BLOCKS.register(blockName, () -> new Block(Block.Properties.of().mapColor(MapColor.STONE)));
|
||||
private static final RegistryObject<Item> SHIFT_ON_MOVE_ITEM = ITEMS.register(blockName, () -> new BlockItem(SHIFT_ON_MOVE.get(), new Item.Properties()));
|
||||
|
||||
public PistonEventTest()
|
||||
@@ -69,9 +69,9 @@ public class PistonEventTest
|
||||
modBus.addListener(this::addCreative);
|
||||
}
|
||||
|
||||
private void addCreative(CreativeModeTabEvent.BuildContents event)
|
||||
private void addCreative(BuildCreativeModeTabContentsEvent event)
|
||||
{
|
||||
if (event.getTab() == CreativeModeTabs.BUILDING_BLOCKS)
|
||||
if (event.getTabKey() == CreativeModeTabs.BUILDING_BLOCKS)
|
||||
event.accept(SHIFT_ON_MOVE_ITEM);
|
||||
}
|
||||
|
||||
|
||||
@@ -15,14 +15,13 @@ import net.minecraft.world.level.Level;
|
||||
import net.minecraft.world.level.block.Block;
|
||||
import net.minecraft.world.level.block.entity.FurnaceBlockEntity;
|
||||
import net.minecraft.world.level.block.state.BlockState;
|
||||
import net.minecraft.world.level.material.Material;
|
||||
import net.minecraftforge.event.CreativeModeTabEvent;
|
||||
import net.minecraftforge.event.BuildCreativeModeTabContentsEvent;
|
||||
import net.minecraftforge.eventbus.api.IEventBus;
|
||||
import net.minecraftforge.fml.common.Mod;
|
||||
import net.minecraftforge.fml.javafmlmod.FMLJavaModLoadingContext;
|
||||
import net.minecraftforge.registries.RegistryObject;
|
||||
import net.minecraftforge.registries.DeferredRegister;
|
||||
import net.minecraftforge.registries.ForgeRegistries;
|
||||
import net.minecraftforge.registries.RegistryObject;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
|
||||
@Mod(RedstoneSidedConnectivityTest.MODID)
|
||||
@@ -49,9 +48,9 @@ public class RedstoneSidedConnectivityTest
|
||||
modBus.addListener(this::addCreative);
|
||||
}
|
||||
|
||||
private void addCreative(CreativeModeTabEvent.BuildContents event)
|
||||
private void addCreative(BuildCreativeModeTabContentsEvent event)
|
||||
{
|
||||
if (event.getTab() == CreativeModeTabs.BUILDING_BLOCKS)
|
||||
if (event.getTabKey() == CreativeModeTabs.BUILDING_BLOCKS)
|
||||
event.accept(TEST_REDSTONE_BLOCKITEM);
|
||||
}
|
||||
|
||||
@@ -62,7 +61,7 @@ public class RedstoneSidedConnectivityTest
|
||||
|
||||
public EastRedstoneBlock()
|
||||
{
|
||||
super(Properties.of(Material.METAL));
|
||||
super(Properties.of());
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -10,8 +10,7 @@ import net.minecraft.world.level.block.Block;
|
||||
import net.minecraft.world.level.block.state.BlockState;
|
||||
import net.minecraft.world.level.block.ScaffoldingBlock;
|
||||
import net.minecraft.world.level.block.SoundType;
|
||||
import net.minecraft.world.level.material.Material;
|
||||
import net.minecraft.world.level.material.MaterialColor;
|
||||
import net.minecraft.world.level.material.MapColor;
|
||||
import net.minecraft.data.DataGenerator;
|
||||
import net.minecraft.data.PackOutput;
|
||||
import net.minecraft.world.entity.LivingEntity;
|
||||
@@ -44,7 +43,7 @@ public class ScaffoldingTest
|
||||
static final DeferredRegister<Block> BLOCKS = DeferredRegister.create(ForgeRegistries.BLOCKS, MODID);
|
||||
static final TagKey<Block> SCAFFOLDING = BlockTags.create(new ResourceLocation("forge", "scaffolding"));
|
||||
|
||||
static final RegistryObject<Block> SCAFFOLDING_METHOD_TEST = BLOCKS.register("scaffolding_method_test", () -> new ScaffoldingMethodTestBlock(Properties.of(Material.DECORATION, MaterialColor.SAND).noCollission().sound(SoundType.SCAFFOLDING).dynamicShape()));
|
||||
static final RegistryObject<Block> SCAFFOLDING_METHOD_TEST = BLOCKS.register("scaffolding_method_test", () -> new ScaffoldingMethodTestBlock(Properties.of().mapColor(MapColor.SAND).noCollission().sound(SoundType.SCAFFOLDING).dynamicShape()));
|
||||
|
||||
public ScaffoldingTest()
|
||||
{
|
||||
|
||||
@@ -5,20 +5,19 @@
|
||||
|
||||
package net.minecraftforge.debug.block;
|
||||
|
||||
import net.minecraft.world.level.block.Block;
|
||||
import net.minecraft.world.level.block.state.BlockState;
|
||||
import net.minecraft.world.level.material.Material;
|
||||
import net.minecraft.core.BlockPos;
|
||||
import net.minecraft.world.entity.Entity;
|
||||
import net.minecraft.world.entity.vehicle.Boat;
|
||||
import net.minecraft.world.item.BlockItem;
|
||||
import net.minecraft.world.item.Item;
|
||||
import net.minecraft.core.BlockPos;
|
||||
import net.minecraft.world.level.LevelReader;
|
||||
import net.minecraft.world.level.block.Block;
|
||||
import net.minecraft.world.level.block.state.BlockState;
|
||||
import net.minecraftforge.eventbus.api.SubscribeEvent;
|
||||
import net.minecraftforge.fml.common.Mod;
|
||||
import net.minecraftforge.fml.common.Mod.EventBusSubscriber;
|
||||
import net.minecraftforge.registries.ForgeRegistries;
|
||||
import net.minecraftforge.registries.ObjectHolder;
|
||||
import net.minecraftforge.eventbus.api.SubscribeEvent;
|
||||
import net.minecraftforge.registries.RegisterEvent;
|
||||
|
||||
@Mod(SlipperinessTest.MOD_ID)
|
||||
@@ -34,7 +33,7 @@ public class SlipperinessTest
|
||||
@SubscribeEvent
|
||||
public static void registerBlocks(RegisterEvent e)
|
||||
{
|
||||
e.register(ForgeRegistries.Keys.BLOCKS, helper -> helper.register(BLOCK_ID, new Block(Block.Properties.of(Material.ICE_SOLID))
|
||||
e.register(ForgeRegistries.Keys.BLOCKS, helper -> helper.register(BLOCK_ID, new Block(Block.Properties.of())
|
||||
{
|
||||
@Override
|
||||
public float getFriction(BlockState state, LevelReader level, BlockPos pos, Entity entity)
|
||||
|
||||
@@ -8,7 +8,7 @@ package net.minecraftforge.debug.block;
|
||||
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.level.material.Material;
|
||||
import net.minecraft.world.level.material.MapColor;
|
||||
import net.minecraft.world.item.BlockItem;
|
||||
import net.minecraft.world.item.Item;
|
||||
import net.minecraftforge.common.MinecraftForge;
|
||||
@@ -35,7 +35,7 @@ public class StickyBlockTest
|
||||
public static final DeferredRegister<Block> BLOCKS = DeferredRegister.create(ForgeRegistries.BLOCKS, MODID);
|
||||
public static final DeferredRegister<Item> ITEMS = DeferredRegister.create(ForgeRegistries.ITEMS.getRegistryName(), MODID);
|
||||
|
||||
public static final RegistryObject<Block> BLUE_BLOCK = BLOCKS.register(BLOCK_ID, () -> new Block(Block.Properties.of(Material.STONE))
|
||||
public static final RegistryObject<Block> BLUE_BLOCK = BLOCKS.register(BLOCK_ID, () -> new Block(Block.Properties.of().mapColor(MapColor.STONE))
|
||||
{
|
||||
@Override
|
||||
public boolean isStickyBlock(BlockState state)
|
||||
@@ -44,7 +44,7 @@ public class StickyBlockTest
|
||||
}
|
||||
});
|
||||
|
||||
public static final RegistryObject<Block> RED_BLOCK = BLOCKS.register(BLOCK_ID_2, () -> new Block(Block.Properties.of(Material.STONE))
|
||||
public static final RegistryObject<Block> RED_BLOCK = BLOCKS.register(BLOCK_ID_2, () -> new Block(Block.Properties.of().mapColor(MapColor.STONE))
|
||||
{
|
||||
@Override
|
||||
public boolean isStickyBlock(BlockState state)
|
||||
|
||||
@@ -11,15 +11,22 @@ import net.minecraft.world.item.BlockItem;
|
||||
import net.minecraft.world.item.Item;
|
||||
import net.minecraft.world.item.context.BlockPlaceContext;
|
||||
import net.minecraft.world.level.LevelReader;
|
||||
import net.minecraft.world.level.block.*;
|
||||
import net.minecraft.world.level.block.BaseRailBlock;
|
||||
import net.minecraft.world.level.block.Block;
|
||||
import net.minecraft.world.level.block.SoundType;
|
||||
import net.minecraft.world.level.block.state.BlockState;
|
||||
import net.minecraft.world.level.block.state.StateDefinition;
|
||||
import net.minecraft.world.level.block.state.properties.*;
|
||||
import net.minecraft.world.level.material.*;
|
||||
import net.minecraft.world.level.block.state.properties.EnumProperty;
|
||||
import net.minecraft.world.level.block.state.properties.Property;
|
||||
import net.minecraft.world.level.block.state.properties.RailShape;
|
||||
import net.minecraft.world.level.material.FluidState;
|
||||
import net.minecraft.world.level.material.Fluids;
|
||||
import net.minecraftforge.eventbus.api.IEventBus;
|
||||
import net.minecraftforge.fml.common.Mod;
|
||||
import net.minecraftforge.fml.javafmlmod.FMLJavaModLoadingContext;
|
||||
import net.minecraftforge.registries.*;
|
||||
import net.minecraftforge.registries.DeferredRegister;
|
||||
import net.minecraftforge.registries.ForgeRegistries;
|
||||
import net.minecraftforge.registries.RegistryObject;
|
||||
|
||||
@Mod(ValidRailShapeTest.MOD_ID)
|
||||
public class ValidRailShapeTest
|
||||
@@ -49,7 +56,7 @@ public class ValidRailShapeTest
|
||||
|
||||
protected RailSlopeBlock()
|
||||
{
|
||||
super(true, Properties.of(Material.DECORATION).noCollission().strength(0.7F).sound(SoundType.METAL));
|
||||
super(true, Properties.of().noCollission().strength(0.7F).sound(SoundType.METAL));
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -50,60 +50,64 @@ public class ClientCommandTest
|
||||
.then(Commands.literal("server")
|
||||
.executes((context) -> {
|
||||
context.getSource().getServer();
|
||||
context.getSource().sendSuccess(Component.literal("Successfully called getServer should have errored"), false);
|
||||
context.getSource().sendSuccess(() ->Component.literal("Successfully called getServer should have errored"), false);
|
||||
return 1;
|
||||
}))
|
||||
// Used for checking if attempting to get the server level on the client side errors
|
||||
.then(Commands.literal("level")
|
||||
.executes((context) -> {
|
||||
context.getSource().getLevel();
|
||||
context.getSource().sendSuccess(Component.literal("Successfully called getLevel should have errored"), false);
|
||||
context.getSource().sendSuccess(() ->Component.literal("Successfully called getLevel should have errored"), false);
|
||||
return 1;
|
||||
}))
|
||||
// Used for checking if getting a known objective argument works on the client side
|
||||
.then(Commands.literal("get_objective")
|
||||
.then(Commands.argument("objective", ObjectiveArgument.objective())
|
||||
.executes((context) -> {
|
||||
context.getSource().sendSuccess(Component.literal("Regular: ")
|
||||
.append(ObjectiveArgument.getObjective(context, "objective").getFormattedDisplayName()), false);
|
||||
final Component msg = Component.literal("Regular: ")
|
||||
.append(ObjectiveArgument.getObjective(context, "objective").getFormattedDisplayName());
|
||||
context.getSource().sendSuccess(() -> msg, false);
|
||||
return 1;
|
||||
})))
|
||||
// Used for checking if getting a known advancement works on the client side
|
||||
.then(Commands.literal("get_advancement")
|
||||
.then(Commands.argument("advancement", ResourceLocationArgument.id())
|
||||
.executes((context) -> {
|
||||
context.getSource().sendSuccess(ResourceLocationArgument.getAdvancement(context, "advancement").getChatComponent(),
|
||||
false);
|
||||
final Component msg = ResourceLocationArgument.getAdvancement(context, "advancement").getChatComponent();
|
||||
context.getSource().sendSuccess(() -> msg, false);
|
||||
return 1;
|
||||
})))
|
||||
// Used for checking if getting a known recipe works on the client side
|
||||
.then(Commands.literal("get_recipe")
|
||||
.then(Commands.argument("recipe", ResourceLocationArgument.id())
|
||||
.executes((context) -> {
|
||||
final Component msg = ResourceLocationArgument.getRecipe(context, "recipe").getResultItem(context.getSource().registryAccess()).getDisplayName();
|
||||
context.getSource()
|
||||
.sendSuccess(ResourceLocationArgument.getRecipe(context, "recipe").getResultItem(context.getSource().registryAccess()).getDisplayName(), false);
|
||||
.sendSuccess(() -> msg, false);
|
||||
return 1;
|
||||
})))
|
||||
// Used for checking if getting a team works on the client side
|
||||
.then(Commands.literal("get_team")
|
||||
.then(Commands.argument("team", TeamArgument.team())
|
||||
.executes((context) -> {
|
||||
context.getSource().sendSuccess(TeamArgument.getTeam(context, "team").getFormattedDisplayName(), false);
|
||||
final Component msg = TeamArgument.getTeam(context, "team").getFormattedDisplayName();
|
||||
context.getSource().sendSuccess(() -> msg, false);
|
||||
return 1;
|
||||
})))
|
||||
// Used for checking if a block position is valid works on the client side
|
||||
.then(Commands.literal("get_loaded_blockpos")
|
||||
.then(Commands.argument("blockpos", BlockPosArgument.blockPos())
|
||||
.executes((context) -> {
|
||||
final Component msg = Component.literal(BlockPosArgument.getLoadedBlockPos(context, "blockpos").toString());
|
||||
context.getSource()
|
||||
.sendSuccess(Component.literal(BlockPosArgument.getLoadedBlockPos(context, "blockpos").toString()), false);
|
||||
.sendSuccess(() -> msg, false);
|
||||
return 1;
|
||||
})))
|
||||
// Used for checking if a command can have a requirement
|
||||
.then(Commands.literal("requires")
|
||||
.requires((source) -> false)
|
||||
.executes((context) -> {
|
||||
context.getSource().sendSuccess(Component.literal("Executed command"), false);
|
||||
context.getSource().sendSuccess(() ->Component.literal("Executed command"), false);
|
||||
return 1;
|
||||
}))
|
||||
// Used for testing the screen after using commands
|
||||
@@ -114,7 +118,7 @@ public class ClientCommandTest
|
||||
LiteralArgumentBuilder<CommandSourceStack> fork = Commands.literal("clientcommandfork");
|
||||
fork.fork(event.getDispatcher().getRoot(), (context) -> List.of(context.getSource(), context.getSource()))
|
||||
.executes((context) -> {
|
||||
context.getSource().sendSuccess(Component.literal("Executing forked command"), false);
|
||||
context.getSource().sendSuccess(() ->Component.literal("Executing forked command"), false);
|
||||
return 1;
|
||||
});
|
||||
event.getDispatcher().register(fork);
|
||||
@@ -122,12 +126,12 @@ public class ClientCommandTest
|
||||
|
||||
private int testCommand(CommandContext<CommandSourceStack> context)
|
||||
{
|
||||
context.getSource().sendSuccess(Component.literal("Input: " + ResourceLocationArgument.getId(context, "block")), false);
|
||||
context.getSource().sendSuccess(Component.literal("Teams: " + context.getSource().getAllTeams()), false);
|
||||
context.getSource().sendSuccess(Component.literal("Players: " + context.getSource().getOnlinePlayerNames()), false);
|
||||
context.getSource().sendSuccess(Component.literal("First recipe: " + context.getSource().getRecipeNames().findFirst().get()), false);
|
||||
context.getSource().sendSuccess(Component.literal("Levels: " + context.getSource().levels()), false);
|
||||
context.getSource().sendSuccess(Component.literal("Registry Access: " + context.getSource().registryAccess()), false);
|
||||
context.getSource().sendSuccess(() ->Component.literal("Input: " + ResourceLocationArgument.getId(context, "block")), false);
|
||||
context.getSource().sendSuccess(() ->Component.literal("Teams: " + context.getSource().getAllTeams()), false);
|
||||
context.getSource().sendSuccess(() ->Component.literal("Players: " + context.getSource().getOnlinePlayerNames()), false);
|
||||
context.getSource().sendSuccess(() ->Component.literal("First recipe: " + context.getSource().getRecipeNames().findFirst().get()), false);
|
||||
context.getSource().sendSuccess(() ->Component.literal("Levels: " + context.getSource().levels()), false);
|
||||
context.getSource().sendSuccess(() ->Component.literal("Registry Access: " + context.getSource().registryAccess()), false);
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
@@ -10,8 +10,8 @@ import net.minecraft.world.item.CreativeModeTabs;
|
||||
import net.minecraft.world.item.Item;
|
||||
import net.minecraft.world.level.block.Block;
|
||||
import net.minecraft.world.level.block.state.BlockBehaviour;
|
||||
import net.minecraft.world.level.material.Material;
|
||||
import net.minecraftforge.event.CreativeModeTabEvent;
|
||||
import net.minecraft.world.level.material.MapColor;
|
||||
import net.minecraftforge.event.BuildCreativeModeTabContentsEvent;
|
||||
import net.minecraftforge.eventbus.api.IEventBus;
|
||||
import net.minecraftforge.fml.common.Mod;
|
||||
import net.minecraftforge.fml.javafmlmod.FMLJavaModLoadingContext;
|
||||
@@ -31,10 +31,10 @@ public class AmbientOcclusionElementsTest
|
||||
private static final DeferredRegister<Block> BLOCKS = DeferredRegister.create(ForgeRegistries.BLOCKS, MOD_ID);
|
||||
private static final DeferredRegister<Item> ITEMS = DeferredRegister.create(ForgeRegistries.ITEMS, MOD_ID);
|
||||
|
||||
public static final RegistryObject<Block> AO_BLOCK_SHADE = BLOCKS.register("ambient_occlusion_shade", () -> new Block(BlockBehaviour.Properties.of(Material.STONE)));
|
||||
public static final RegistryObject<Block> AO_BLOCK_NO_SHADE = BLOCKS.register("ambient_occlusion_no_shade", () -> new Block(BlockBehaviour.Properties.of(Material.STONE)));
|
||||
public static final RegistryObject<Block> NO_AO_BLOCK_SHADE = BLOCKS.register("no_ambient_occlusion_shade", () -> new Block(BlockBehaviour.Properties.of(Material.STONE)));
|
||||
public static final RegistryObject<Block> NO_AO_BLOCK_NO_SHADE = BLOCKS.register("no_ambient_occlusion_no_shade", () -> new Block(BlockBehaviour.Properties.of(Material.STONE)));
|
||||
public static final RegistryObject<Block> AO_BLOCK_SHADE = BLOCKS.register("ambient_occlusion_shade", () -> new Block(BlockBehaviour.Properties.of().mapColor(MapColor.STONE)));
|
||||
public static final RegistryObject<Block> AO_BLOCK_NO_SHADE = BLOCKS.register("ambient_occlusion_no_shade", () -> new Block(BlockBehaviour.Properties.of().mapColor(MapColor.STONE)));
|
||||
public static final RegistryObject<Block> NO_AO_BLOCK_SHADE = BLOCKS.register("no_ambient_occlusion_shade", () -> new Block(BlockBehaviour.Properties.of().mapColor(MapColor.STONE)));
|
||||
public static final RegistryObject<Block> NO_AO_BLOCK_NO_SHADE = BLOCKS.register("no_ambient_occlusion_no_shade", () -> new Block(BlockBehaviour.Properties.of().mapColor(MapColor.STONE)));
|
||||
public static final RegistryObject<Item> AO_BLOCK_SHADE_ITEM = ITEMS.register("ambient_occlusion_shade", () -> new BlockItem(AO_BLOCK_SHADE.get(), new Item.Properties()));
|
||||
public static final RegistryObject<Item> AO_BLOCK_NO_SHADE_ITEM = ITEMS.register("ambient_occlusion_no_shade", () -> new BlockItem(AO_BLOCK_NO_SHADE.get(), new Item.Properties()));
|
||||
public static final RegistryObject<Item> NO_AO_BLOCK_SHADE_ITEM = ITEMS.register("no_ambient_occlusion_shade", () -> new BlockItem(NO_AO_BLOCK_SHADE.get(), new Item.Properties()));
|
||||
@@ -51,9 +51,9 @@ public class AmbientOcclusionElementsTest
|
||||
modEventBus.addListener(this::addCreative);
|
||||
}
|
||||
|
||||
private void addCreative(CreativeModeTabEvent.BuildContents event)
|
||||
private void addCreative(BuildCreativeModeTabContentsEvent event)
|
||||
{
|
||||
if (event.getTab() == CreativeModeTabs.BUILDING_BLOCKS)
|
||||
if (event.getTabKey() == CreativeModeTabs.BUILDING_BLOCKS)
|
||||
{
|
||||
event.accept(AO_BLOCK_SHADE_ITEM);
|
||||
event.accept(AO_BLOCK_NO_SHADE_ITEM);
|
||||
|
||||
@@ -20,7 +20,7 @@ import net.minecraft.world.item.*;
|
||||
import net.minecraft.world.item.Item.Properties;
|
||||
import net.minecraftforge.client.extensions.common.IClientItemExtensions;
|
||||
import net.minecraftforge.common.util.Lazy;
|
||||
import net.minecraftforge.event.CreativeModeTabEvent;
|
||||
import net.minecraftforge.event.BuildCreativeModeTabContentsEvent;
|
||||
import net.minecraftforge.eventbus.api.IEventBus;
|
||||
import net.minecraftforge.fml.common.Mod;
|
||||
import net.minecraftforge.fml.javafmlmod.FMLJavaModLoadingContext;
|
||||
@@ -51,9 +51,9 @@ public class CustomArmorModelTest
|
||||
modBus.addListener(this::addCreative);
|
||||
}
|
||||
|
||||
private void addCreative(CreativeModeTabEvent.BuildContents event)
|
||||
private void addCreative(BuildCreativeModeTabContentsEvent event)
|
||||
{
|
||||
if (event.getTab() == CreativeModeTabs.INGREDIENTS)
|
||||
if (event.getTabKey() == CreativeModeTabs.INGREDIENTS)
|
||||
{
|
||||
event.accept(RED_LEGGINGS);
|
||||
event.accept(ENDERMAN_CHESTPLATE);
|
||||
|
||||
@@ -12,7 +12,7 @@ import net.minecraft.world.level.ColorResolver;
|
||||
import net.minecraft.world.level.biome.Biome;
|
||||
import net.minecraft.world.level.block.Block;
|
||||
import net.minecraft.world.level.block.state.BlockBehaviour;
|
||||
import net.minecraft.world.level.material.Material;
|
||||
import net.minecraft.world.level.material.MapColor;
|
||||
import net.minecraftforge.api.distmarker.Dist;
|
||||
import net.minecraftforge.client.event.RegisterColorHandlersEvent;
|
||||
import net.minecraftforge.eventbus.api.IEventBus;
|
||||
@@ -35,7 +35,7 @@ public class CustomColorResolverTest
|
||||
private static final DeferredRegister<Item> ITEMS = DeferredRegister.create(ForgeRegistries.ITEMS, MOD_ID);
|
||||
private static final DeferredRegister<Block> BLOCKS = DeferredRegister.create(ForgeRegistries.BLOCKS, MOD_ID);
|
||||
|
||||
private static final RegistryObject<Block> BLOCK = BLOCKS.register("test_block", () -> new Block(BlockBehaviour.Properties.of(Material.STONE)));
|
||||
private static final RegistryObject<Block> BLOCK = BLOCKS.register("test_block", () -> new Block(BlockBehaviour.Properties.of().mapColor(MapColor.STONE)));
|
||||
|
||||
public CustomColorResolverTest()
|
||||
{
|
||||
|
||||
@@ -5,58 +5,59 @@
|
||||
|
||||
package net.minecraftforge.debug.client;
|
||||
|
||||
import com.google.common.collect.ImmutableMap;
|
||||
import com.mojang.blaze3d.vertex.PoseStack;
|
||||
import com.mojang.datafixers.util.Either;
|
||||
import net.minecraft.ChatFormatting;
|
||||
import net.minecraft.client.Minecraft;
|
||||
import net.minecraft.client.gui.Font;
|
||||
import net.minecraft.client.gui.GuiComponent;
|
||||
import net.minecraft.client.gui.font.FontManager;
|
||||
import net.minecraft.client.gui.GuiGraphics;
|
||||
import net.minecraft.client.gui.components.Button;
|
||||
import net.minecraft.client.gui.screens.Screen;
|
||||
import net.minecraft.client.gui.screens.inventory.tooltip.ClientTooltipComponent;
|
||||
import net.minecraft.client.renderer.entity.ItemRenderer;
|
||||
import net.minecraft.network.chat.Component;
|
||||
import net.minecraft.server.packs.resources.ReloadableResourceManager;
|
||||
import net.minecraft.world.InteractionHand;
|
||||
import net.minecraft.world.InteractionResultHolder;
|
||||
import net.minecraft.world.entity.player.Player;
|
||||
import net.minecraft.world.inventory.tooltip.TooltipComponent;
|
||||
import net.minecraft.world.item.*;
|
||||
import net.minecraft.world.item.CreativeModeTabs;
|
||||
import net.minecraft.world.item.Item;
|
||||
import net.minecraft.world.item.ItemStack;
|
||||
import net.minecraft.world.item.Items;
|
||||
import net.minecraft.world.item.TooltipFlag;
|
||||
import net.minecraft.world.level.Level;
|
||||
import net.minecraftforge.api.distmarker.Dist;
|
||||
import net.minecraftforge.client.event.RegisterClientTooltipComponentFactoriesEvent;
|
||||
import net.minecraftforge.client.event.RenderTooltipEvent;
|
||||
import net.minecraftforge.common.MinecraftForge;
|
||||
import net.minecraftforge.event.CreativeModeTabEvent;
|
||||
import net.minecraftforge.event.BuildCreativeModeTabContentsEvent;
|
||||
import net.minecraftforge.eventbus.api.IEventBus;
|
||||
import net.minecraftforge.eventbus.api.SubscribeEvent;
|
||||
import net.minecraftforge.fml.DistExecutor;
|
||||
import net.minecraftforge.fml.common.Mod;
|
||||
import net.minecraftforge.fml.event.lifecycle.FMLClientSetupEvent;
|
||||
import net.minecraftforge.fml.javafmlmod.FMLJavaModLoadingContext;
|
||||
import net.minecraftforge.fml.loading.FMLEnvironment;
|
||||
import net.minecraftforge.registries.RegistryObject;
|
||||
import net.minecraftforge.registries.DeferredRegister;
|
||||
import net.minecraftforge.registries.ForgeRegistries;
|
||||
import net.minecraftforge.registries.RegistryObject;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
|
||||
import java.util.Arrays;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.Optional;
|
||||
|
||||
@Mod(CustomTooltipTest.ID)
|
||||
public class CustomTooltipTest
|
||||
{
|
||||
|
||||
static final boolean ENABLED = true;
|
||||
static final String ID = "custom_tooltip_test";
|
||||
|
||||
private static final DeferredRegister<Item> ITEMS = DeferredRegister.create(ForgeRegistries.ITEMS, ID);
|
||||
static final RegistryObject<Item> CUSTOM_ITEM = ITEMS.register(
|
||||
"test_item",
|
||||
() -> new CustomItemWithTooltip(new Item.Properties())
|
||||
);
|
||||
static final RegistryObject<Item> CUSTOM_ITEM = ITEMS.register("test_item", () -> new CustomItemWithTooltip(new Item.Properties()));
|
||||
|
||||
public CustomTooltipTest()
|
||||
{
|
||||
if (ENABLED) {
|
||||
if (ENABLED)
|
||||
{
|
||||
IEventBus modEventBus = FMLJavaModLoadingContext.get().getModEventBus();
|
||||
if (FMLEnvironment.dist.isClient())
|
||||
{
|
||||
@@ -68,19 +69,16 @@ public class CustomTooltipTest
|
||||
}
|
||||
}
|
||||
|
||||
private void addCreative(CreativeModeTabEvent.BuildContents event)
|
||||
private void addCreative(BuildCreativeModeTabContentsEvent event)
|
||||
{
|
||||
if (event.getTab() == CreativeModeTabs.INGREDIENTS)
|
||||
if (event.getTabKey() == CreativeModeTabs.INGREDIENTS)
|
||||
event.accept(CUSTOM_ITEM);
|
||||
}
|
||||
|
||||
static record CustomTooltip(int color) implements TooltipComponent
|
||||
{
|
||||
}
|
||||
record CustomTooltip(int color) implements TooltipComponent {}
|
||||
|
||||
record CustomClientTooltip(CustomTooltip tooltip) implements ClientTooltipComponent
|
||||
{
|
||||
|
||||
@Override
|
||||
public int getHeight()
|
||||
{
|
||||
@@ -94,9 +92,9 @@ public class CustomTooltipTest
|
||||
}
|
||||
|
||||
@Override
|
||||
public void renderImage(Font font, int x, int y, PoseStack poseStack, ItemRenderer itemRenderer_)
|
||||
public void renderImage(Font font, int x, int y, GuiGraphics graphics)
|
||||
{
|
||||
GuiComponent.fill(poseStack, x, y, x + 10, y+ 10, tooltip.color);
|
||||
graphics.fill(x, y, x + 10, y + 10,tooltip.color);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -117,10 +115,10 @@ public class CustomTooltipTest
|
||||
@Override
|
||||
public InteractionResultHolder<ItemStack> use(Level level, Player player, InteractionHand hand)
|
||||
{
|
||||
/* if (level.isClientSide) Update to 1.19.3: Disable screen tests since logic for tooltips on buttons has changed massively!
|
||||
if (level.isClientSide)
|
||||
{
|
||||
DistExecutor.unsafeRunWhenOn(Dist.CLIENT, () -> TooltipTestScreen::show);
|
||||
}*/
|
||||
}
|
||||
return InteractionResultHolder.success(player.getItemInHand(hand));
|
||||
}
|
||||
|
||||
@@ -134,32 +132,15 @@ public class CustomTooltipTest
|
||||
|
||||
private static class ClientModBusEventHandler
|
||||
{
|
||||
|
||||
static FontManager customFontManager;
|
||||
static Font customFont;
|
||||
|
||||
@SubscribeEvent
|
||||
public static void clientSetup(FMLClientSetupEvent event)
|
||||
{
|
||||
event.enqueueWork(() -> {
|
||||
customFontManager = new FontManager(Minecraft.getInstance().textureManager);
|
||||
customFont = customFontManager.createFont();
|
||||
((ReloadableResourceManager) Minecraft.getInstance().getResourceManager()).registerReloadListener(customFontManager.getReloadListener());
|
||||
customFontManager.setRenames(ImmutableMap.of(Minecraft.DEFAULT_FONT, Minecraft.UNIFORM_FONT));
|
||||
});
|
||||
}
|
||||
|
||||
@SubscribeEvent
|
||||
public static void onRegisterClientTooltipComponentFactories(RegisterClientTooltipComponentFactoriesEvent event)
|
||||
{
|
||||
event.register(CustomTooltip.class, CustomClientTooltip::new);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
private static class ClientEventHandler
|
||||
{
|
||||
|
||||
@SubscribeEvent
|
||||
public static void gatherTooltips(RenderTooltipEvent.GatherComponents event)
|
||||
{
|
||||
@@ -181,19 +162,15 @@ public class CustomTooltipTest
|
||||
event.setBackgroundStart(0xFF0000FF);
|
||||
event.setBackgroundEnd(0xFFFFFF00);
|
||||
event.setBorderStart(0xFFFF0000);
|
||||
event.setBorderEnd(0xFFFF0011);
|
||||
event.setBorderEnd(0xFF000011);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
/* Disabled on update to 1.19.3: Tooltips have changed massively, and mojang now handles them differently
|
||||
|
||||
static class TooltipTestScreen extends Screen
|
||||
static class TooltipTestScreen extends Screen
|
||||
{
|
||||
|
||||
private ItemStack testStack = ItemStack.EMPTY;
|
||||
private Font testFont = null;
|
||||
private boolean testFont = false;
|
||||
|
||||
protected TooltipTestScreen()
|
||||
{
|
||||
@@ -206,10 +183,11 @@ static class TooltipTestScreen extends Screen
|
||||
}
|
||||
|
||||
@Override
|
||||
public void render(PoseStack poseStack, int mouseX, int mouseY, float partialTicks)
|
||||
public void render(GuiGraphics graphics, int mouseX, int mouseY, float partialTicks)
|
||||
{
|
||||
super.render(poseStack, mouseX, mouseY, partialTicks);
|
||||
this.font.draw(poseStack, "* must have Stack, # must have custom font", 0, 0, 0xFFFFFF);
|
||||
this.renderBackground(graphics);
|
||||
super.render(graphics, mouseX, mouseY, partialTicks);
|
||||
graphics.drawString(font, "* must have Stack, # must have custom font", 0, 0, 0xFFFFFF);
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -218,17 +196,15 @@ static class TooltipTestScreen extends Screen
|
||||
addRenderableWidget(Button.builder(Component.literal("Toggle Stack: EMPTY"), button -> {
|
||||
this.testStack = this.testStack.isEmpty() ? new ItemStack(Items.APPLE) : ItemStack.EMPTY;
|
||||
button.setMessage(Component.literal("Toggle Stack: " + (testStack.isEmpty() ? "EMPTY" : "Apple")));
|
||||
}).pos(10, 10).size(200,20).build());
|
||||
addRenderableWidget(Button.builder(Component.literal("Toggle Font: null"), button -> {
|
||||
this.testFont = this.testFont == null ? ClientModBusEventHandler.customFont : null;
|
||||
button.setMessage(Component.literal("Toggle Font: " + (testFont == null ? "null" : "customFont")));
|
||||
}).pos(220, 10).size(200,20).build());
|
||||
|
||||
|
||||
}).pos(10, 10).size(200, 20).build());
|
||||
addRenderableWidget(Button.builder(Component.literal("Toggle Font: Default"), button -> {
|
||||
this.testFont = !this.testFont;
|
||||
button.setMessage(Component.literal("Toggle Font: " + (this.testFont ? "Unicode" : "Default")));
|
||||
}).pos(220, 10).size(200, 20).build());
|
||||
|
||||
// * must have stack context
|
||||
// # must have custom font
|
||||
List<Map.Entry<String, Tooltip>> tooltipTests = Arrays.asList(
|
||||
List<Map.Entry<String, TooltipTest>> tooltipTests = Arrays.asList(
|
||||
Map.entry(" 1 * ", this::test1),
|
||||
Map.entry(" 2 * ", this::test2),
|
||||
Map.entry(" 3 #", this::test3),
|
||||
@@ -248,7 +224,18 @@ static class TooltipTestScreen extends Screen
|
||||
int y = 50;
|
||||
for (var test : tooltipTests)
|
||||
{
|
||||
addRenderableWidget(new Button(x, y, 100, 20, Component.literal(test.getKey()), button -> {}, test.getValue()));
|
||||
addRenderableWidget(new Button.Builder(Component.literal(test.getKey()), button -> {})
|
||||
.bounds(x, y, 100, 20).build(b -> new Button(b) {
|
||||
@Override
|
||||
public void renderWidget(GuiGraphics graphics, int mouseX, int mouseY, float partialTick)
|
||||
{
|
||||
super.renderWidget(graphics, mouseX, mouseY, partialTick);
|
||||
|
||||
boolean showTooltip = this.isHovered || this.isFocused() && Minecraft.getInstance().getLastInputType().isKeyboard();
|
||||
if (showTooltip)
|
||||
test.getValue().render(graphics, mouseX, mouseY);
|
||||
}
|
||||
}));
|
||||
y+= 22;
|
||||
if (y >= height - 50)
|
||||
{
|
||||
@@ -258,81 +245,89 @@ static class TooltipTestScreen extends Screen
|
||||
}
|
||||
}
|
||||
|
||||
private void test1(Button button, PoseStack poseStack, int mouseX, int mouseY)
|
||||
private Component getTestComponent(boolean testFont)
|
||||
{
|
||||
renderTooltip(poseStack, this.testStack, mouseX, mouseY);
|
||||
return Component.literal("test").withStyle(s -> s.withFont(testFont ? Minecraft.UNIFORM_FONT : Minecraft.DEFAULT_FONT));
|
||||
}
|
||||
|
||||
private void test1(GuiGraphics graphics, int mouseX, int mouseY)
|
||||
{
|
||||
graphics.renderTooltip(this.font, this.testStack, mouseX, mouseY);
|
||||
}
|
||||
|
||||
// renderTooltip with List<Component> and all combinations of ItemStack/Font
|
||||
private void test2(Button button, PoseStack poseStack, int mouseX, int mouseY)
|
||||
private void test2(GuiGraphics graphics, int mouseX, int mouseY)
|
||||
{
|
||||
renderTooltip(poseStack, List.of(Component.literal("test")), Optional.empty(), mouseX, mouseY, this.testStack);
|
||||
graphics.renderTooltip(this.font, List.of(this.getTestComponent(false)), Optional.empty(), mouseX, mouseY);
|
||||
}
|
||||
|
||||
private void test3(Button button, PoseStack poseStack, int mouseX, int mouseY)
|
||||
private void test3(GuiGraphics graphics, int mouseX, int mouseY)
|
||||
{
|
||||
renderTooltip(poseStack, List.of(Component.literal("test")), Optional.empty(), mouseX, mouseY, this.testFont);
|
||||
graphics.renderTooltip(this.font, List.of(this.getTestComponent(this.testFont)), Optional.empty(), mouseX, mouseY);
|
||||
}
|
||||
|
||||
private void test4(Button button, PoseStack poseStack, int mouseX, int mouseY)
|
||||
private void test4(GuiGraphics graphics, int mouseX, int mouseY)
|
||||
{
|
||||
renderTooltip(poseStack, List.of(Component.literal("test")), Optional.empty(), mouseX, mouseY, this.testFont, this.testStack);
|
||||
graphics.renderTooltip(this.font, List.of(this.getTestComponent(this.testFont)), Optional.empty(), mouseX, mouseY);
|
||||
}
|
||||
|
||||
private void test5(Button button, PoseStack poseStack, int mouseX, int mouseY)
|
||||
private void test5(GuiGraphics graphics, int mouseX, int mouseY)
|
||||
{
|
||||
renderTooltip(poseStack, List.of(Component.literal("test")), Optional.empty(), mouseX, mouseY);
|
||||
graphics.renderTooltip(this.font, List.of(this.getTestComponent(false)), Optional.empty(), mouseX, mouseY);
|
||||
}
|
||||
|
||||
// renderTooltip with just Component
|
||||
private void test6(Button button, PoseStack poseStack, int mouseX, int mouseY)
|
||||
private void test6(GuiGraphics graphics, int mouseX, int mouseY)
|
||||
{
|
||||
renderTooltip(poseStack, Component.literal("test"), mouseX, mouseY);
|
||||
graphics.renderTooltip(this.font, this.getTestComponent(false), mouseX, mouseY);
|
||||
}
|
||||
|
||||
// renderComponentTooltip with all combinations of ItemStack/Font
|
||||
private void test7(Button button, PoseStack poseStack, int mouseX, int mouseY)
|
||||
private void test7(GuiGraphics graphics, int mouseX, int mouseY)
|
||||
{
|
||||
renderComponentTooltip(poseStack, List.of(Component.literal("test")), mouseX, mouseY, this.testStack);
|
||||
graphics.renderComponentTooltip(this.font, List.of(this.getTestComponent(false)), mouseX, mouseY);
|
||||
}
|
||||
|
||||
private void test8(Button button, PoseStack poseStack, int mouseX, int mouseY)
|
||||
private void test8(GuiGraphics graphics, int mouseX, int mouseY)
|
||||
{
|
||||
renderComponentTooltip(poseStack, List.of(Component.literal("test")), mouseX, mouseY, this.testFont);
|
||||
graphics.renderComponentTooltip(this.font, List.of(this.getTestComponent(this.testFont)), mouseX, mouseY);
|
||||
}
|
||||
|
||||
private void test9(Button button, PoseStack poseStack, int mouseX, int mouseY)
|
||||
private void test9(GuiGraphics graphics, int mouseX, int mouseY)
|
||||
{
|
||||
renderComponentTooltip(poseStack, List.of(Component.literal("test")), mouseX, mouseY, this.testFont, this.testStack);
|
||||
graphics.renderComponentTooltip(this.font, List.of(this.getTestComponent(this.testFont)), mouseX, mouseY);
|
||||
}
|
||||
|
||||
private void test10(Button button, PoseStack poseStack, int mouseX, int mouseY)
|
||||
private void test10(GuiGraphics graphics, int mouseX, int mouseY)
|
||||
{
|
||||
renderComponentTooltip(poseStack, List.of(Component.literal("test")), mouseX, mouseY);
|
||||
graphics.renderComponentTooltip(this.font, List.of(this.getTestComponent(false)), mouseX, mouseY);
|
||||
}
|
||||
|
||||
// renderTooltip with list of FormattedCharSequence
|
||||
private void test11(Button button, PoseStack poseStack, int mouseX, int mouseY)
|
||||
private void test11(GuiGraphics graphics, int mouseX, int mouseY)
|
||||
{
|
||||
renderTooltip(poseStack, List.of(Component.literal("test").getVisualOrderText()), mouseX, mouseY);
|
||||
graphics.renderTooltip(this.font, List.of(this.getTestComponent(false).getVisualOrderText()), mouseX, mouseY);
|
||||
}
|
||||
|
||||
// renderTooltip with list of FormattedCharSequence and Font
|
||||
private void test12(Button button, PoseStack poseStack, int mouseX, int mouseY)
|
||||
private void test12(GuiGraphics graphics, int mouseX, int mouseY)
|
||||
{
|
||||
renderTooltip(poseStack, List.of(Component.literal("test").getVisualOrderText()), mouseX, mouseY, this.testFont);
|
||||
graphics.renderTooltip(this.font, List.of(this.getTestComponent(this.testFont).getVisualOrderText()), mouseX, mouseY);
|
||||
}
|
||||
|
||||
// legacy ToolTip methods
|
||||
private void test13(Button button, PoseStack poseStack, int mouseX, int mouseY)
|
||||
private void test13(GuiGraphics graphics, int mouseX, int mouseY)
|
||||
{
|
||||
renderTooltip(poseStack, List.of(Component.literal("test").getVisualOrderText()), mouseX, mouseY, this.testFont);
|
||||
graphics.renderTooltip(this.font, List.of(this.getTestComponent(this.testFont).getVisualOrderText()), mouseX, mouseY);
|
||||
}
|
||||
|
||||
private void test14(Button button, PoseStack poseStack, int mouseX, int mouseY)
|
||||
private void test14(GuiGraphics graphics, int mouseX, int mouseY)
|
||||
{
|
||||
renderComponentTooltip(poseStack, List.of(Component.literal("test")), mouseX, mouseY, this.testFont, ItemStack.EMPTY);
|
||||
graphics.renderComponentTooltip(this.font, List.of(this.getTestComponent(this.testFont)), mouseX, mouseY);
|
||||
}
|
||||
}*/
|
||||
}
|
||||
|
||||
private interface TooltipTest {
|
||||
void render(GuiGraphics graphics, int mouseX, int mouseY);
|
||||
}
|
||||
}
|
||||
@@ -10,8 +10,8 @@ import net.minecraft.world.item.CreativeModeTabs;
|
||||
import net.minecraft.world.item.Item;
|
||||
import net.minecraft.world.level.block.Block;
|
||||
import net.minecraft.world.level.block.state.BlockBehaviour;
|
||||
import net.minecraft.world.level.material.Material;
|
||||
import net.minecraftforge.event.CreativeModeTabEvent;
|
||||
import net.minecraft.world.level.material.MapColor;
|
||||
import net.minecraftforge.event.BuildCreativeModeTabContentsEvent;
|
||||
import net.minecraftforge.eventbus.api.IEventBus;
|
||||
import net.minecraftforge.fml.common.Mod;
|
||||
import net.minecraftforge.fml.javafmlmod.FMLJavaModLoadingContext;
|
||||
@@ -29,7 +29,7 @@ public class EmissiveElementsTest
|
||||
private static final DeferredRegister<Block> BLOCKS = DeferredRegister.create(ForgeRegistries.BLOCKS, MOD_ID);
|
||||
private static final DeferredRegister<Item> ITEMS = DeferredRegister.create(ForgeRegistries.ITEMS, MOD_ID);
|
||||
|
||||
public static final RegistryObject<Block> TEST_BLOCK = BLOCKS.register("emissive", () -> new Block(BlockBehaviour.Properties.of(Material.STONE)));
|
||||
public static final RegistryObject<Block> TEST_BLOCK = BLOCKS.register("emissive", () -> new Block(BlockBehaviour.Properties.of().mapColor(MapColor.STONE)));
|
||||
public static final RegistryObject<Item> TEST_BLOCK_ITEM = ITEMS.register("emissive", () -> new BlockItem(TEST_BLOCK.get(), new Item.Properties()));
|
||||
|
||||
public EmissiveElementsTest()
|
||||
@@ -40,9 +40,9 @@ public class EmissiveElementsTest
|
||||
modEventBus.addListener(this::addCreative);
|
||||
}
|
||||
|
||||
private void addCreative(CreativeModeTabEvent.BuildContents event)
|
||||
private void addCreative(BuildCreativeModeTabContentsEvent event)
|
||||
{
|
||||
if (event.getTab() == CreativeModeTabs.BUILDING_BLOCKS)
|
||||
if (event.getTabKey() == CreativeModeTabs.BUILDING_BLOCKS)
|
||||
event.accept(TEST_BLOCK_ITEM);
|
||||
}
|
||||
}
|
||||
@@ -8,6 +8,7 @@ package net.minecraftforge.debug.client;
|
||||
import com.mojang.blaze3d.vertex.PoseStack;
|
||||
import net.minecraft.ChatFormatting;
|
||||
import net.minecraft.client.Minecraft;
|
||||
import net.minecraft.client.gui.GuiGraphics;
|
||||
import net.minecraft.client.gui.components.Button;
|
||||
import net.minecraft.client.gui.screens.Screen;
|
||||
import net.minecraft.client.gui.screens.inventory.AbstractContainerScreen;
|
||||
@@ -55,11 +56,11 @@ public class GuiLayeringTest
|
||||
}
|
||||
|
||||
@Override
|
||||
public void render(PoseStack poseStack, int mouseX, int mouseY, float partialTicks)
|
||||
public void render(GuiGraphics graphics, int mouseX, int mouseY, float partialTicks)
|
||||
{
|
||||
this.renderBackground(poseStack);
|
||||
drawString(poseStack, this.font, this.title, this.width / 2, 15, 0xFFFFFF);
|
||||
super.render(poseStack, mouseX, mouseY, partialTicks);
|
||||
this.renderBackground(graphics);
|
||||
graphics.drawString(this.font, this.title, this.width / 2, 15, 0xFFFFFF);
|
||||
super.render(graphics, mouseX, mouseY, partialTicks);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -8,6 +8,7 @@ package net.minecraftforge.debug.client;
|
||||
import com.mojang.blaze3d.vertex.PoseStack;
|
||||
import com.mojang.brigadier.Command;
|
||||
import net.minecraft.client.Minecraft;
|
||||
import net.minecraft.client.gui.GuiGraphics;
|
||||
import net.minecraft.client.gui.screens.Screen;
|
||||
import net.minecraft.network.chat.Component;
|
||||
|
||||
@@ -25,8 +26,8 @@ public class TestScreen extends Screen
|
||||
}
|
||||
|
||||
@Override
|
||||
public void render(PoseStack PoseStack, int MouseX, int MouseY, float PartialTick)
|
||||
public void render(GuiGraphics graphics, int MouseX, int MouseY, float PartialTick)
|
||||
{
|
||||
renderBackground(PoseStack);
|
||||
renderBackground(graphics);
|
||||
}
|
||||
}
|
||||
@@ -8,7 +8,7 @@ package net.minecraftforge.debug.client.model;
|
||||
import net.minecraft.world.item.*;
|
||||
import net.minecraft.world.level.block.Block;
|
||||
import net.minecraft.world.level.block.state.BlockState;
|
||||
import net.minecraft.world.level.material.Material;
|
||||
import net.minecraft.world.level.material.MapColor;
|
||||
import net.minecraft.world.entity.Entity;
|
||||
import net.minecraft.world.entity.EquipmentSlot;
|
||||
import net.minecraft.world.item.context.BlockPlaceContext;
|
||||
@@ -19,7 +19,7 @@ import net.minecraft.world.phys.shapes.CollisionContext;
|
||||
import net.minecraft.world.phys.shapes.VoxelShape;
|
||||
import net.minecraft.world.phys.shapes.Shapes;
|
||||
import net.minecraft.world.level.BlockGetter;
|
||||
import net.minecraftforge.event.CreativeModeTabEvent;
|
||||
import net.minecraftforge.event.BuildCreativeModeTabContentsEvent;
|
||||
import net.minecraftforge.eventbus.api.IEventBus;
|
||||
import net.minecraftforge.registries.RegistryObject;
|
||||
import net.minecraftforge.fml.common.Mod;
|
||||
@@ -36,7 +36,7 @@ public class CompositeModelTest
|
||||
public static final DeferredRegister<Item> ITEMS = DeferredRegister.create(ForgeRegistries.ITEMS, MODID);
|
||||
|
||||
public static RegistryObject<Block> composite_block = BLOCKS.register("composite_block", () ->
|
||||
new Block(Block.Properties.of(Material.WOOD).strength(10)) {
|
||||
new Block(Block.Properties.of().mapColor(MapColor.WOOD).strength(10)) {
|
||||
@Override
|
||||
protected void createBlockStateDefinition(StateDefinition.Builder<Block, BlockState> builder)
|
||||
{
|
||||
@@ -88,9 +88,9 @@ public class CompositeModelTest
|
||||
modEventBus.addListener(this::addCreative);
|
||||
}
|
||||
|
||||
private void addCreative(CreativeModeTabEvent.BuildContents event)
|
||||
private void addCreative(BuildCreativeModeTabContentsEvent event)
|
||||
{
|
||||
if (event.getTab() == CreativeModeTabs.INGREDIENTS)
|
||||
if (event.getTabKey() == CreativeModeTabs.INGREDIENTS)
|
||||
event.accept(composite_item);
|
||||
}
|
||||
}
|
||||
+4
-5
@@ -35,12 +35,11 @@ import net.minecraft.world.level.block.entity.BlockEntityType;
|
||||
import net.minecraft.world.level.block.state.BlockBehaviour;
|
||||
import net.minecraft.world.level.block.state.BlockState;
|
||||
import net.minecraft.world.level.block.state.StateDefinition;
|
||||
import net.minecraft.world.level.material.Material;
|
||||
import net.minecraftforge.api.distmarker.Dist;
|
||||
import net.minecraftforge.client.event.EntityRenderersEvent;
|
||||
import net.minecraftforge.client.model.generators.*;
|
||||
import net.minecraftforge.common.data.ExistingFileHelper;
|
||||
import net.minecraftforge.event.CreativeModeTabEvent;
|
||||
import net.minecraftforge.event.BuildCreativeModeTabContentsEvent;
|
||||
import net.minecraftforge.eventbus.api.SubscribeEvent;
|
||||
import net.minecraftforge.fml.common.Mod;
|
||||
import net.minecraftforge.fml.javafmlmod.FMLJavaModLoadingContext;
|
||||
@@ -116,7 +115,7 @@ public class CustomItemDisplayContextTest
|
||||
public static final DeferredRegister<BlockEntityType<?>> BLOCK_ENTITY_TYPES = DeferredRegister.create(ForgeRegistries.BLOCK_ENTITY_TYPES, MODID);
|
||||
|
||||
public static final RegistryObject<Block>
|
||||
ITEM_HANGER_BLOCK = BLOCKS.register("item_hanger", () -> new ItemHangerBlock(BlockBehaviour.Properties.of(Material.WOOL).noCollission().noOcclusion().noLootTable()));
|
||||
ITEM_HANGER_BLOCK = BLOCKS.register("item_hanger", () -> new ItemHangerBlock(BlockBehaviour.Properties.of().noCollission().noOcclusion().noLootTable()));
|
||||
public static final RegistryObject<BlockEntityType<ItemHangerBlockEntity>>
|
||||
ITEM_HANGER_BE = BLOCK_ENTITY_TYPES.register("item_hanger", () -> BlockEntityType.Builder.of(ItemHangerBlockEntity::new, ITEM_HANGER_BLOCK.get()).build(null));
|
||||
public static final RegistryObject<Item>
|
||||
@@ -132,9 +131,9 @@ public class CustomItemDisplayContextTest
|
||||
modBus.addListener(this::addCreative);
|
||||
}
|
||||
|
||||
private void addCreative(CreativeModeTabEvent.BuildContents event)
|
||||
private void addCreative(BuildCreativeModeTabContentsEvent event)
|
||||
{
|
||||
if (event.getTab() == CreativeModeTabs.INGREDIENTS)
|
||||
if (event.getTabKey() == CreativeModeTabs.INGREDIENTS)
|
||||
event.accept(ITEM_HANGER_ITEM);
|
||||
}
|
||||
|
||||
|
||||
@@ -7,7 +7,7 @@ package net.minecraftforge.debug.client.model;
|
||||
|
||||
import net.minecraft.world.item.CreativeModeTabs;
|
||||
import net.minecraft.world.item.Item;
|
||||
import net.minecraftforge.event.CreativeModeTabEvent;
|
||||
import net.minecraftforge.event.BuildCreativeModeTabContentsEvent;
|
||||
import net.minecraftforge.eventbus.api.IEventBus;
|
||||
import net.minecraftforge.registries.RegistryObject;
|
||||
import net.minecraftforge.fml.common.Mod;
|
||||
@@ -35,9 +35,9 @@ public class DynBucketModelTest
|
||||
}
|
||||
}
|
||||
|
||||
private void addCreative(CreativeModeTabEvent.BuildContents event)
|
||||
private void addCreative(BuildCreativeModeTabContentsEvent event)
|
||||
{
|
||||
if (event.getTab() == CreativeModeTabs.INGREDIENTS)
|
||||
if (event.getTabKey() == CreativeModeTabs.INGREDIENTS)
|
||||
{
|
||||
event.accept(DRIP_BUCKET);
|
||||
event.accept(LAVA_OBSIDIAN);
|
||||
|
||||
@@ -26,15 +26,16 @@ import net.minecraft.world.level.block.EntityBlock;
|
||||
import net.minecraft.world.level.block.entity.BlockEntity;
|
||||
import net.minecraft.world.level.block.entity.BlockEntityType;
|
||||
import net.minecraft.world.level.block.state.BlockState;
|
||||
import net.minecraft.world.level.material.Material;
|
||||
import net.minecraft.world.level.material.MapColor;
|
||||
import net.minecraft.world.phys.BlockHitResult;
|
||||
import net.minecraftforge.api.distmarker.Dist;
|
||||
import net.minecraftforge.client.event.ModelEvent;
|
||||
import net.minecraftforge.client.model.BakedModelWrapper;
|
||||
import net.minecraftforge.client.model.IQuadTransformer;
|
||||
import net.minecraftforge.client.model.QuadTransformers;
|
||||
import net.minecraftforge.client.model.data.ModelData;
|
||||
import net.minecraftforge.client.model.data.ModelProperty;
|
||||
import net.minecraftforge.event.CreativeModeTabEvent;
|
||||
import net.minecraftforge.event.BuildCreativeModeTabContentsEvent;
|
||||
import net.minecraftforge.eventbus.api.IEventBus;
|
||||
import net.minecraftforge.eventbus.api.SubscribeEvent;
|
||||
import net.minecraftforge.fml.common.Mod;
|
||||
@@ -49,7 +50,6 @@ import org.joml.Vector3f;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.Set;
|
||||
import java.util.function.Consumer;
|
||||
|
||||
/**
|
||||
* Test mod that demos most Forge-provided model loaders in a single block + item, as well as in-JSON render states
|
||||
@@ -91,9 +91,9 @@ public class MegaModelTest
|
||||
modEventBus.addListener(this::addCreative);
|
||||
}
|
||||
|
||||
private void addCreative(CreativeModeTabEvent.BuildContents event)
|
||||
private void addCreative(BuildCreativeModeTabContentsEvent event)
|
||||
{
|
||||
if (event.getTab() == CreativeModeTabs.BUILDING_BLOCKS)
|
||||
if (event.getTabKey() == CreativeModeTabs.BUILDING_BLOCKS)
|
||||
event.accept(TEST_BLOCK_ITEM);
|
||||
}
|
||||
|
||||
@@ -114,7 +114,7 @@ public class MegaModelTest
|
||||
{
|
||||
public TestBlock()
|
||||
{
|
||||
super(Properties.of(Material.STONE));
|
||||
super(Properties.of().mapColor(MapColor.STONE));
|
||||
}
|
||||
|
||||
@Nullable
|
||||
@@ -178,7 +178,7 @@ public class MegaModelTest
|
||||
var quads = super.getQuads(state, side, rand, data, renderType);
|
||||
if (!data.has(TestData.PROPERTY))
|
||||
return quads;
|
||||
return IQuadTransformer.applying(data.get(TestData.PROPERTY).transform()).process(quads);
|
||||
return QuadTransformers.applying(data.get(TestData.PROPERTY).transform()).process(quads);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -7,12 +7,12 @@ package net.minecraftforge.debug.client.model;
|
||||
|
||||
import net.minecraft.world.item.CreativeModeTabs;
|
||||
import net.minecraft.world.level.block.Block;
|
||||
import net.minecraft.world.level.material.Material;
|
||||
import net.minecraft.world.level.material.MapColor;
|
||||
import net.minecraft.client.renderer.RenderType;
|
||||
import net.minecraft.client.renderer.ItemBlockRenderTypes;
|
||||
import net.minecraft.world.item.BlockItem;
|
||||
import net.minecraft.world.item.Item;
|
||||
import net.minecraftforge.event.CreativeModeTabEvent;
|
||||
import net.minecraftforge.event.BuildCreativeModeTabContentsEvent;
|
||||
import net.minecraftforge.eventbus.api.IEventBus;
|
||||
import net.minecraftforge.fml.common.Mod;
|
||||
import net.minecraftforge.fml.event.lifecycle.FMLClientSetupEvent;
|
||||
@@ -32,7 +32,7 @@ public class MultiLayerModelTest
|
||||
|
||||
private static final DeferredRegister<Block> BLOCKS = DeferredRegister.create(ForgeRegistries.BLOCKS, MODID);
|
||||
private static final DeferredRegister<Item> ITEMS = DeferredRegister.create(ForgeRegistries.ITEMS, MODID);
|
||||
private static final RegistryObject<Block> TEST_BLOCK = BLOCKS.register(blockName, () -> new Block(Block.Properties.of(Material.WOOD).noOcclusion()));
|
||||
private static final RegistryObject<Block> TEST_BLOCK = BLOCKS.register(blockName, () -> new Block(Block.Properties.of().mapColor(MapColor.WOOD).noOcclusion()));
|
||||
private static final RegistryObject<Item> TEST_BLOCK_ITEM = ITEMS.register(blockName, () -> new BlockItem(TEST_BLOCK.get(), new Item.Properties()));
|
||||
|
||||
public MultiLayerModelTest()
|
||||
@@ -47,9 +47,9 @@ public class MultiLayerModelTest
|
||||
modEventBus.addListener(this::addCreative);
|
||||
}
|
||||
|
||||
private void addCreative(CreativeModeTabEvent.BuildContents event)
|
||||
private void addCreative(BuildCreativeModeTabContentsEvent event)
|
||||
{
|
||||
if (event.getTab() == CreativeModeTabs.INGREDIENTS)
|
||||
if (event.getTabKey() == CreativeModeTabs.INGREDIENTS)
|
||||
event.accept(TEST_BLOCK);
|
||||
}
|
||||
|
||||
|
||||
@@ -12,7 +12,7 @@ import net.minecraft.data.PackOutput;
|
||||
import net.minecraft.world.item.*;
|
||||
import net.minecraft.world.level.block.Block;
|
||||
import net.minecraft.world.level.block.state.BlockState;
|
||||
import net.minecraft.world.level.material.Material;
|
||||
import net.minecraft.world.level.material.MapColor;
|
||||
import net.minecraft.client.renderer.texture.TextureAtlasSprite;
|
||||
import net.minecraft.data.DataGenerator;
|
||||
import net.minecraft.world.entity.Entity;
|
||||
@@ -39,7 +39,7 @@ import net.minecraftforge.client.model.generators.loaders.SeparateTransformsMode
|
||||
import net.minecraftforge.client.model.geometry.SimpleUnbakedGeometry;
|
||||
import net.minecraftforge.client.model.pipeline.QuadBakingVertexConsumer;
|
||||
import net.minecraftforge.common.data.ExistingFileHelper;
|
||||
import net.minecraftforge.event.CreativeModeTabEvent;
|
||||
import net.minecraftforge.event.BuildCreativeModeTabContentsEvent;
|
||||
import net.minecraftforge.eventbus.api.IEventBus;
|
||||
import net.minecraftforge.registries.RegistryObject;
|
||||
import net.minecraftforge.fml.common.Mod;
|
||||
@@ -51,7 +51,6 @@ import net.minecraftforge.registries.ForgeRegistries;
|
||||
import java.util.Arrays;
|
||||
import java.util.function.Function;
|
||||
|
||||
import net.minecraft.client.renderer.block.model.ItemTransforms;
|
||||
import net.minecraft.client.resources.model.ModelState;
|
||||
import net.minecraft.world.item.context.BlockPlaceContext;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
@@ -64,7 +63,7 @@ public class NewModelLoaderTest
|
||||
public static final DeferredRegister<Item> ITEMS = DeferredRegister.create(ForgeRegistries.ITEMS, MODID);
|
||||
|
||||
public static RegistryObject<Block> obj_block = BLOCKS.register("obj_block", () ->
|
||||
new Block(Block.Properties.of(Material.WOOD).strength(10)) {
|
||||
new Block(Block.Properties.of().mapColor(MapColor.WOOD).strength(10)) {
|
||||
@Override
|
||||
protected void createBlockStateDefinition(StateDefinition.Builder<Block, BlockState> builder)
|
||||
{
|
||||
@@ -130,9 +129,9 @@ public class NewModelLoaderTest
|
||||
modEventBus.addListener(this::addCreative);
|
||||
}
|
||||
|
||||
private void addCreative(CreativeModeTabEvent.BuildContents event)
|
||||
private void addCreative(BuildCreativeModeTabContentsEvent event)
|
||||
{
|
||||
if (event.getTab() == CreativeModeTabs.INGREDIENTS)
|
||||
if (event.getTabKey() == CreativeModeTabs.INGREDIENTS)
|
||||
{
|
||||
Arrays.asList(
|
||||
obj_item,
|
||||
|
||||
@@ -11,7 +11,7 @@ import net.minecraft.util.RandomSource;
|
||||
import net.minecraft.world.item.CreativeModeTabs;
|
||||
import net.minecraft.world.level.block.Block;
|
||||
import net.minecraft.world.level.block.state.BlockState;
|
||||
import net.minecraft.world.level.material.Material;
|
||||
import net.minecraft.world.level.material.MapColor;
|
||||
import net.minecraft.client.renderer.block.model.BakedQuad;
|
||||
import net.minecraft.client.resources.model.BakedModel;
|
||||
import net.minecraft.client.renderer.block.model.ItemOverrides;
|
||||
@@ -25,9 +25,10 @@ import net.minecraftforge.api.distmarker.Dist;
|
||||
import net.minecraftforge.client.event.ModelEvent;
|
||||
import net.minecraftforge.client.model.IQuadTransformer;
|
||||
import net.minecraftforge.client.model.IDynamicBakedModel;
|
||||
import net.minecraftforge.client.model.QuadTransformers;
|
||||
import net.minecraftforge.client.model.data.ModelData;
|
||||
import net.minecraftforge.common.util.TransformationHelper;
|
||||
import net.minecraftforge.event.CreativeModeTabEvent;
|
||||
import net.minecraftforge.event.BuildCreativeModeTabContentsEvent;
|
||||
import net.minecraftforge.eventbus.api.IEventBus;
|
||||
import net.minecraftforge.fml.DistExecutor;
|
||||
import net.minecraftforge.registries.RegistryObject;
|
||||
@@ -45,7 +46,7 @@ public class TRSRTransformerTest {
|
||||
private static final DeferredRegister<Block> BLOCKS = DeferredRegister.create(ForgeRegistries.BLOCKS, MODID);
|
||||
private static final DeferredRegister<Item> ITEMS = DeferredRegister.create(ForgeRegistries.ITEMS, MODID);
|
||||
|
||||
private static final RegistryObject<Block> TEST_BLOCK = BLOCKS.register("test", () -> new Block(Block.Properties.of(Material.STONE)));
|
||||
private static final RegistryObject<Block> TEST_BLOCK = BLOCKS.register("test", () -> new Block(Block.Properties.of().mapColor(MapColor.STONE)));
|
||||
@SuppressWarnings("unused")
|
||||
private static final RegistryObject<Item> TEST_ITEM = ITEMS.register("test", () -> new BlockItem(TEST_BLOCK.get(), new Item.Properties()));
|
||||
|
||||
@@ -57,9 +58,9 @@ public class TRSRTransformerTest {
|
||||
mod.addListener(this::addCreative);
|
||||
}
|
||||
|
||||
private void addCreative(CreativeModeTabEvent.BuildContents event)
|
||||
private void addCreative(BuildCreativeModeTabContentsEvent event)
|
||||
{
|
||||
if (event.getTab() == CreativeModeTabs.BUILDING_BLOCKS)
|
||||
if (event.getTabKey() == CreativeModeTabs.BUILDING_BLOCKS)
|
||||
event.accept(TEST_ITEM);
|
||||
}
|
||||
|
||||
@@ -84,7 +85,7 @@ public class TRSRTransformerTest {
|
||||
Vector3f translation = new Vector3f(0, 0.33f, 0);
|
||||
|
||||
Transformation trans = new Transformation(translation, rot, null, null).blockCenterToCorner();
|
||||
var transformer = IQuadTransformer.applying(trans);
|
||||
var transformer = QuadTransformers.applying(trans);
|
||||
|
||||
return transformer.process(base.getQuads(state, side, rand, data, renderType));
|
||||
}
|
||||
|
||||
+7
-7
@@ -9,7 +9,7 @@ import com.mojang.blaze3d.systems.RenderSystem;
|
||||
import com.mojang.blaze3d.vertex.PoseStack;
|
||||
|
||||
import net.minecraft.client.gui.Font;
|
||||
import net.minecraft.client.gui.GuiComponent;
|
||||
import net.minecraft.client.gui.GuiGraphics;
|
||||
import net.minecraft.client.renderer.entity.ItemRenderer;
|
||||
import net.minecraft.util.Mth;
|
||||
import net.minecraft.world.item.ItemStack;
|
||||
@@ -42,7 +42,7 @@ public class CustomItemDecorationsTest
|
||||
private static class StackSizeDurabilityBar implements IItemDecorator
|
||||
{
|
||||
@Override
|
||||
public boolean render(PoseStack poseStack, Font font, ItemStack stack, int xOffset, int yOffset)
|
||||
public boolean render(GuiGraphics graphics, Font font, ItemStack stack, int xOffset, int yOffset)
|
||||
{
|
||||
RenderSystem.disableBlend();
|
||||
float f = Math.max(0.0F, (float)stack.getCount() / stack.getMaxStackSize());
|
||||
@@ -50,11 +50,11 @@ public class CustomItemDecorationsTest
|
||||
int j = Mth.hsvToRgb(f / 3.0F, 1f, 1f) | 0xFF000000;
|
||||
int x = xOffset + 2;
|
||||
int y = yOffset + 13;
|
||||
poseStack.pushPose();
|
||||
poseStack.translate(0.0F, 0.0F, ItemRenderer.ITEM_COUNT_BLIT_OFFSET + 1F);
|
||||
GuiComponent.fill(poseStack, x, y, x + 13, y + 2, 0xFF000000);
|
||||
GuiComponent.fill(poseStack, x, y, x + i, y + 1, j);
|
||||
poseStack.popPose();
|
||||
graphics.pose().pushPose();
|
||||
graphics.pose().translate(0.0F, 0.0F, ItemRenderer.ITEM_COUNT_BLIT_OFFSET + 1F);
|
||||
graphics.fill(x, y, x + 13, y + 2, 0xFF000000);
|
||||
graphics.fill(x, y, x + i, y + 1, j);
|
||||
graphics.pose().popPose();
|
||||
RenderSystem.enableBlend();
|
||||
return true;
|
||||
}
|
||||
|
||||
@@ -7,8 +7,6 @@ package net.minecraftforge.debug.client.rendering;
|
||||
|
||||
import java.util.Map;
|
||||
|
||||
import com.mojang.math.Transformation;
|
||||
import net.minecraftforge.common.util.TransformationHelper;
|
||||
import org.apache.logging.log4j.LogManager;
|
||||
import org.apache.logging.log4j.Logger;
|
||||
|
||||
@@ -29,7 +27,6 @@ import net.minecraftforge.api.distmarker.Dist;
|
||||
import net.minecraftforge.client.ForgeRenderTypes;
|
||||
import net.minecraftforge.client.event.ModelEvent;
|
||||
import net.minecraftforge.client.event.RegisterClientReloadListenersEvent;
|
||||
import net.minecraftforge.client.event.RenderLevelLastEvent;
|
||||
import net.minecraftforge.client.event.RenderLevelStageEvent;
|
||||
import net.minecraftforge.client.event.RenderLevelStageEvent.Stage;
|
||||
import net.minecraftforge.client.model.geometry.StandaloneGeometryBakingContext;
|
||||
@@ -44,11 +41,10 @@ import net.minecraftforge.fml.common.Mod;
|
||||
import net.minecraftforge.fml.javafmlmod.FMLJavaModLoadingContext;
|
||||
import net.minecraftforge.fml.loading.FMLEnvironment;
|
||||
import org.joml.Matrix4f;
|
||||
import org.joml.Quaternionf;
|
||||
|
||||
/**
|
||||
* This mod is testing the use of {@link RenderLevelStageEvent} and is a modifaction of a pre-existing test mod that used the old
|
||||
* {@link RenderLevelLastEvent}. To restore the old behavior, set {@link #USE_LEVEL_RENDERER_STAGE} to false.
|
||||
* RenderLevelLastEvent. To restore the old behavior, set {@link #USE_LEVEL_RENDERER_STAGE} to false.
|
||||
*
|
||||
* When you enter a world, there should be 6 sugar gliders rendering at (0, 120, 0) that test the various stages in {@link RenderLevelStageEvent}.
|
||||
* From left to right (with the sugar gliders facing you) they represent {@link Stage#AFTER_SKY}, {@link Stage#AFTER_SOLID_BLOCKS},
|
||||
@@ -64,8 +60,6 @@ public class RenderableTest
|
||||
private static final Logger LOGGER = LogManager.getLogger();
|
||||
|
||||
public static final boolean ENABLED = false; // Renders at (0, 120, 0)
|
||||
public static final boolean USE_LEVEL_RENDERER_STAGE = true; // True when using RenderLevelStageEvent. False when using RenderLevelLastEvent
|
||||
|
||||
public RenderableTest()
|
||||
{
|
||||
if (ENABLED)
|
||||
@@ -90,13 +84,8 @@ public class RenderableTest
|
||||
var forgeBus = MinecraftForge.EVENT_BUS;
|
||||
modBus.addListener(Client::registerModels);
|
||||
modBus.addListener(Client::registerReloadListeners);
|
||||
if (USE_LEVEL_RENDERER_STAGE)
|
||||
{
|
||||
modBus.addListener(Client::registerStage);
|
||||
forgeBus.addListener(Client::renderStage);
|
||||
}
|
||||
else
|
||||
forgeBus.addListener(Client::renderLast);
|
||||
modBus.addListener(Client::registerStage);
|
||||
forgeBus.addListener(Client::renderStage);
|
||||
}
|
||||
|
||||
private static void registerModels(ModelEvent.RegisterAdditional event)
|
||||
@@ -139,12 +128,6 @@ public class RenderableTest
|
||||
LOGGER.info("Registered RenderLevelStageEvent.Stage: {}", stage);
|
||||
}
|
||||
|
||||
public static void renderLast(RenderLevelLastEvent event)
|
||||
{
|
||||
Vec3 cam = Minecraft.getInstance().gameRenderer.getMainCamera().getPosition();
|
||||
render(Stage.AFTER_SKY, event.getPoseStack(), 0, event.getPartialTick(), cam.x, cam.y, cam.z, 0);
|
||||
}
|
||||
|
||||
private static void renderStage(RenderLevelStageEvent event)
|
||||
{
|
||||
int xOffset = -1;
|
||||
|
||||
@@ -1,24 +0,0 @@
|
||||
/*
|
||||
* Copyright (c) Forge Development LLC and contributors
|
||||
* SPDX-License-Identifier: LGPL-2.1-only
|
||||
*/
|
||||
|
||||
package net.minecraftforge.debug.client.rendering;
|
||||
|
||||
import net.minecraft.resources.ResourceLocation;
|
||||
import net.minecraft.world.entity.EntityType;
|
||||
import net.minecraftforge.api.distmarker.Dist;
|
||||
import net.minecraftforge.client.event.RegisterEntitySpectatorShadersEvent;
|
||||
import net.minecraftforge.eventbus.api.SubscribeEvent;
|
||||
import net.minecraftforge.fml.common.Mod;
|
||||
|
||||
@Mod("shader_fix_test")
|
||||
@Mod.EventBusSubscriber(value = Dist.CLIENT, bus = Mod.EventBusSubscriber.Bus.MOD)
|
||||
public class ShaderFixTest
|
||||
{
|
||||
@SubscribeEvent
|
||||
public static void onRegisterEntitySpectatorShaders(final RegisterEntitySpectatorShadersEvent event)
|
||||
{
|
||||
event.register(EntityType.PLAYER, new ResourceLocation("shaders/post/desaturate.json"));
|
||||
}
|
||||
}
|
||||
@@ -32,14 +32,14 @@ public class EnumArgumentTest
|
||||
event.getDispatcher().register(Commands.literal("enumargumenttest")
|
||||
.then(Commands.argument("string", StringArgumentType.string())
|
||||
.executes(context -> {
|
||||
context.getSource().sendSuccess(Component.literal("string: " + StringArgumentType.getString(context, "string")), false);
|
||||
context.getSource().sendSuccess(() -> Component.literal("string: " + StringArgumentType.getString(context, "string")), false);
|
||||
|
||||
return 1;
|
||||
}))
|
||||
.then(Commands.argument("enum", EnumArgument.enumArgument(ExampleEnum.class))
|
||||
.executes(context -> {
|
||||
context.getSource()
|
||||
.sendSuccess(Component.literal("enum: " + context.getArgument("enum", ExampleEnum.class)), false);
|
||||
.sendSuccess(() -> Component.literal("enum: " + context.getArgument("enum", ExampleEnum.class)), false);
|
||||
|
||||
return 1;
|
||||
})));
|
||||
|
||||
@@ -16,7 +16,7 @@ import net.minecraft.tags.BiomeTags;
|
||||
import net.minecraft.world.entity.ai.attributes.AttributeInstance;
|
||||
import net.minecraft.world.item.CreativeModeTabs;
|
||||
import net.minecraftforge.common.ForgeMod;
|
||||
import net.minecraftforge.event.CreativeModeTabEvent;
|
||||
import net.minecraftforge.event.BuildCreativeModeTabContentsEvent;
|
||||
import net.minecraftforge.registries.DeferredRegister;
|
||||
import net.minecraftforge.registries.ForgeRegistries;
|
||||
import net.minecraftforge.registries.RegistryObject;
|
||||
@@ -105,7 +105,7 @@ public class GravityAttributeTest
|
||||
{
|
||||
AttributeInstance grav = liv.getAttribute(ForgeMod.ENTITY_GRAVITY.get());
|
||||
|
||||
boolean inPlains = liv.level.getBiome(liv.blockPosition()).is(BiomeTags.IS_FOREST);
|
||||
boolean inPlains = liv.level().getBiome(liv.blockPosition()).is(BiomeTags.IS_FOREST);
|
||||
if (inPlains && !grav.hasModifier(REDUCED_GRAVITY))
|
||||
{
|
||||
logger.info("Granted low gravity to Entity: {}", liv);
|
||||
@@ -122,9 +122,9 @@ public class GravityAttributeTest
|
||||
}
|
||||
}
|
||||
|
||||
private void addCreative(CreativeModeTabEvent.BuildContents event)
|
||||
private void addCreative(BuildCreativeModeTabContentsEvent event)
|
||||
{
|
||||
if (event.getTab() == CreativeModeTabs.TOOLS_AND_UTILITIES)
|
||||
if (event.getTabKey() == CreativeModeTabs.TOOLS_AND_UTILITIES)
|
||||
event.accept(TEST_ITEM);
|
||||
}
|
||||
|
||||
|
||||
-11
@@ -10,7 +10,6 @@ import net.minecraft.world.entity.player.Player;
|
||||
import net.minecraft.world.item.Items;
|
||||
import net.minecraftforge.common.MinecraftForge;
|
||||
import net.minecraftforge.event.entity.living.LivingChangeTargetEvent;
|
||||
import net.minecraftforge.event.entity.living.LivingSetAttackTargetEvent;
|
||||
import net.minecraftforge.eventbus.api.SubscribeEvent;
|
||||
import net.minecraftforge.fml.common.Mod;
|
||||
|
||||
@@ -26,16 +25,6 @@ public class LivingSetAttackTargetEventTest
|
||||
MinecraftForge.EVENT_BUS.register(this);
|
||||
}
|
||||
}
|
||||
|
||||
@SubscribeEvent
|
||||
public void onLivingSetAttackTarget(LivingSetAttackTargetEvent event)
|
||||
{
|
||||
// Make piglins die when they start attacking a player who is not holding a stick in their main hand.
|
||||
if (event.getTarget() instanceof Player player && event.getEntity() instanceof AbstractPiglin piglin && player.getMainHandItem().getItem() != Items.STICK)
|
||||
{
|
||||
event.getEntity().kill();
|
||||
}
|
||||
}
|
||||
|
||||
@SubscribeEvent
|
||||
public void onLivingChangeTargetEvent(LivingChangeTargetEvent event)
|
||||
|
||||
@@ -14,7 +14,7 @@ import net.minecraft.world.entity.LivingEntity;
|
||||
import net.minecraft.world.food.FoodProperties;
|
||||
import net.minecraft.world.item.*;
|
||||
import net.minecraftforge.client.extensions.common.IClientItemExtensions;
|
||||
import net.minecraftforge.event.CreativeModeTabEvent;
|
||||
import net.minecraftforge.event.BuildCreativeModeTabContentsEvent;
|
||||
import net.minecraftforge.fml.common.Mod;
|
||||
import net.minecraftforge.fml.javafmlmod.FMLJavaModLoadingContext;
|
||||
import net.minecraftforge.registries.DeferredRegister;
|
||||
@@ -46,9 +46,9 @@ public class ItemUseAnimationTest
|
||||
modBus.addListener(this::addCreative);
|
||||
}
|
||||
|
||||
private void addCreative(CreativeModeTabEvent.BuildContents event)
|
||||
private void addCreative(BuildCreativeModeTabContentsEvent event)
|
||||
{
|
||||
if (event.getTab() == CreativeModeTabs.COMBAT)
|
||||
if (event.getTabKey() == CreativeModeTabs.COMBAT)
|
||||
event.accept(THING);
|
||||
}
|
||||
|
||||
|
||||
@@ -12,7 +12,7 @@ import net.minecraft.world.entity.ai.attributes.Attribute;
|
||||
import net.minecraft.world.entity.ai.attributes.AttributeModifier;
|
||||
import net.minecraft.world.entity.ai.attributes.Attributes;
|
||||
import net.minecraft.world.item.*;
|
||||
import net.minecraftforge.event.CreativeModeTabEvent;
|
||||
import net.minecraftforge.event.BuildCreativeModeTabContentsEvent;
|
||||
import net.minecraftforge.eventbus.api.IEventBus;
|
||||
import net.minecraftforge.fml.common.Mod;
|
||||
import net.minecraftforge.fml.javafmlmod.FMLJavaModLoadingContext;
|
||||
@@ -48,9 +48,9 @@ public class PlayerAttackKnockbackTest {
|
||||
modEventBus.addListener(this::addCreative);
|
||||
}
|
||||
|
||||
private void addCreative(CreativeModeTabEvent.BuildContents event)
|
||||
private void addCreative(BuildCreativeModeTabContentsEvent event)
|
||||
{
|
||||
if (event.getTab() == CreativeModeTabs.COMBAT)
|
||||
if (event.getTabKey() == CreativeModeTabs.COMBAT)
|
||||
event.accept(KNOCKBACK_SWORD);
|
||||
}
|
||||
|
||||
|
||||
@@ -22,12 +22,11 @@ import net.minecraft.world.level.block.state.BlockBehaviour;
|
||||
import net.minecraft.world.level.material.FlowingFluid;
|
||||
import net.minecraft.world.level.material.Fluid;
|
||||
import net.minecraft.world.level.material.FluidState;
|
||||
import net.minecraft.world.level.material.Material;
|
||||
import net.minecraftforge.api.distmarker.Dist;
|
||||
import net.minecraftforge.client.extensions.common.IClientFluidTypeExtensions;
|
||||
import net.minecraftforge.client.event.RegisterColorHandlersEvent;
|
||||
import net.minecraftforge.common.ForgeMod;
|
||||
import net.minecraftforge.event.CreativeModeTabEvent;
|
||||
import net.minecraftforge.event.BuildCreativeModeTabContentsEvent;
|
||||
import net.minecraftforge.eventbus.api.IEventBus;
|
||||
import net.minecraftforge.fluids.FluidInteractionRegistry;
|
||||
import net.minecraftforge.fluids.FluidType;
|
||||
@@ -154,7 +153,7 @@ public class FluidTypeTest
|
||||
private static final RegistryObject<Fluid> TEST_FLUID_FLOWING = FLUIDS.register("test_fluid_flowing", () ->
|
||||
new ForgeFlowingFluid.Flowing(fluidProperties()));
|
||||
private static final RegistryObject<LiquidBlock> TEST_FLUID_BLOCK = BLOCKS.register("test_fluid_block", () ->
|
||||
new LiquidBlock(TEST_FLUID, BlockBehaviour.Properties.of(Material.WATER).noCollission().strength(100.0F).noLootTable()));
|
||||
new LiquidBlock(TEST_FLUID, BlockBehaviour.Properties.of().noCollission().strength(100.0F).noLootTable()));
|
||||
private static final RegistryObject<Item> TEST_FLUID_BUCKET = ITEMS.register("test_fluid_bucket", () ->
|
||||
new BucketItem(TEST_FLUID, new Item.Properties().craftRemainder(Items.BUCKET).stacksTo(1)));
|
||||
|
||||
@@ -179,9 +178,9 @@ public class FluidTypeTest
|
||||
}
|
||||
}
|
||||
|
||||
private void addCreative(CreativeModeTabEvent.BuildContents event)
|
||||
private void addCreative(BuildCreativeModeTabContentsEvent event)
|
||||
{
|
||||
if (event.getTab() == CreativeModeTabs.INGREDIENTS)
|
||||
if (event.getTabKey() == CreativeModeTabs.INGREDIENTS)
|
||||
event.accept(TEST_FLUID_BUCKET);
|
||||
}
|
||||
|
||||
|
||||
@@ -6,7 +6,7 @@
|
||||
package net.minecraftforge.debug.fluid;
|
||||
|
||||
import net.minecraft.world.item.*;
|
||||
import net.minecraft.world.level.material.Material;
|
||||
import net.minecraft.world.level.material.MapColor;
|
||||
import net.minecraft.world.level.material.FluidState;
|
||||
import net.minecraft.world.level.block.state.properties.BooleanProperty;
|
||||
import net.minecraft.world.level.block.state.StateDefinition;
|
||||
@@ -14,7 +14,7 @@ import net.minecraft.core.BlockPos;
|
||||
import net.minecraft.world.level.BlockGetter;
|
||||
import net.minecraft.world.level.LevelAccessor;
|
||||
import net.minecraftforge.client.extensions.common.IClientFluidTypeExtensions;
|
||||
import net.minecraftforge.event.CreativeModeTabEvent;
|
||||
import net.minecraftforge.event.BuildCreativeModeTabContentsEvent;
|
||||
import net.minecraftforge.fluids.DispenseFluidContainer;
|
||||
import net.minecraftforge.fluids.FluidType;
|
||||
import org.apache.commons.lang3.Validate;
|
||||
@@ -109,7 +109,7 @@ public class NewFluidTest
|
||||
);
|
||||
|
||||
public static RegistryObject<LiquidBlock> test_fluid_block = BLOCKS.register("test_fluid_block", () ->
|
||||
new LiquidBlock(test_fluid, Properties.of(Material.WATER).noCollission().strength(100.0F).noLootTable())
|
||||
new LiquidBlock(test_fluid, Properties.of().noCollission().strength(100.0F).noLootTable())
|
||||
);
|
||||
public static RegistryObject<Item> TEST_FLUID_BUCKET = ITEMS.register("test_fluid_bucket", () ->
|
||||
new BucketItem(test_fluid, new Item.Properties().craftRemainder(Items.BUCKET).stacksTo(1))
|
||||
@@ -117,7 +117,7 @@ public class NewFluidTest
|
||||
|
||||
// WARNING: this doesn't allow "any fluid", only the fluid from this test mod!
|
||||
public static RegistryObject<Block> fluidloggable_block = BLOCKS.register("fluidloggable_block", () ->
|
||||
new FluidloggableBlock(Properties.of(Material.WOOD).noCollission().strength(100.0F).noLootTable())
|
||||
new FluidloggableBlock(Properties.of().mapColor(MapColor.WOOD).noCollission().strength(100.0F).noLootTable())
|
||||
);
|
||||
public static RegistryObject<Item> FLUID_LOGGABLE_BLOCK_ITEM = ITEMS.register("fluidloggable_block", () ->
|
||||
new BlockItem(fluidloggable_block.get(), new Item.Properties())
|
||||
@@ -139,9 +139,9 @@ public class NewFluidTest
|
||||
}
|
||||
}
|
||||
|
||||
private void addCreative(CreativeModeTabEvent.BuildContents event)
|
||||
private void addCreative(BuildCreativeModeTabContentsEvent event)
|
||||
{
|
||||
if (event.getTab() == CreativeModeTabs.INGREDIENTS)
|
||||
if (event.getTabKey() == CreativeModeTabs.INGREDIENTS)
|
||||
{
|
||||
event.accept(FLUID_LOGGABLE_BLOCK_ITEM);
|
||||
event.accept(TEST_FLUID_BUCKET);
|
||||
|
||||
@@ -12,6 +12,7 @@ import it.unimi.dsi.fastutil.objects.ObjectArrayList;
|
||||
import net.minecraft.advancements.critereon.EnchantmentPredicate;
|
||||
import net.minecraft.advancements.critereon.ItemPredicate;
|
||||
import net.minecraft.advancements.critereon.MinMaxBounds;
|
||||
import net.minecraft.core.registries.Registries;
|
||||
import net.minecraft.util.ExtraCodecs;
|
||||
import net.minecraft.world.level.block.Blocks;
|
||||
import net.minecraft.data.DataGenerator;
|
||||
@@ -29,6 +30,8 @@ import net.minecraft.world.item.Items;
|
||||
import net.minecraft.world.item.crafting.SmeltingRecipe;
|
||||
import net.minecraft.world.item.crafting.RecipeType;
|
||||
import net.minecraft.world.level.storage.loot.LootContext;
|
||||
import net.minecraft.world.level.storage.loot.LootParams;
|
||||
import net.minecraft.world.level.storage.loot.parameters.LootContextParamSet;
|
||||
import net.minecraft.world.level.storage.loot.parameters.LootContextParamSets;
|
||||
import net.minecraft.world.level.storage.loot.parameters.LootContextParams;
|
||||
import net.minecraft.world.level.storage.loot.LootTable;
|
||||
@@ -179,11 +182,10 @@ public class GlobalLootModifiersTest {
|
||||
if(ctxTool == null || EnchantmentHelper.getItemEnchantmentLevel(Enchantments.SILK_TOUCH, ctxTool) > 0) return generatedLoot;
|
||||
ItemStack fakeTool = ctxTool.copy();
|
||||
fakeTool.enchant(Enchantments.SILK_TOUCH, 1);
|
||||
LootContext.Builder builder = new LootContext.Builder(context);
|
||||
LootParams.Builder builder = new LootParams.Builder(context.getLevel());
|
||||
builder.withParameter(LootContextParams.TOOL, fakeTool);
|
||||
LootContext ctx = builder.create(LootContextParamSets.BLOCK);
|
||||
LootTable loottable = context.getLevel().getServer().getLootTables().get(context.getParamOrNull(LootContextParams.BLOCK_STATE).getBlock().getLootTable());
|
||||
return loottable.getRandomItems(ctx);
|
||||
LootTable loottable = context.getLevel().getServer().getLootData().getLootTable(context.getParamOrNull(LootContextParams.BLOCK_STATE).getBlock().getLootTable());
|
||||
return loottable.getRandomItems(builder.create(LootContextParamSets.EMPTY)); // TODO - porting: we need an AT
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -20,7 +20,7 @@ import net.minecraft.resources.ResourceLocation;
|
||||
import net.minecraft.world.level.gameevent.GameEvent;
|
||||
import net.minecraftforge.api.distmarker.Dist;
|
||||
import net.minecraftforge.api.distmarker.OnlyIn;
|
||||
import net.minecraftforge.event.CreativeModeTabEvent;
|
||||
import net.minecraftforge.event.BuildCreativeModeTabContentsEvent;
|
||||
import net.minecraftforge.eventbus.api.IEventBus;
|
||||
import net.minecraftforge.registries.RegistryObject;
|
||||
import net.minecraftforge.fml.common.Mod;
|
||||
@@ -49,9 +49,9 @@ public class CustomElytraTest
|
||||
modBus.addListener(this::addCreative);
|
||||
}
|
||||
|
||||
private void addCreative(CreativeModeTabEvent.BuildContents event)
|
||||
private void addCreative(BuildCreativeModeTabContentsEvent event)
|
||||
{
|
||||
if (event.getTab() == CreativeModeTabs.INGREDIENTS)
|
||||
if (event.getTabKey() == CreativeModeTabs.INGREDIENTS)
|
||||
event.accept(TEST_ELYTRA);
|
||||
}
|
||||
|
||||
@@ -94,7 +94,7 @@ public class CustomElytraTest
|
||||
@Override
|
||||
public boolean elytraFlightTick(ItemStack stack, LivingEntity entity, int flightTicks)
|
||||
{
|
||||
if (!entity.level.isClientSide)
|
||||
if (!entity.level().isClientSide)
|
||||
{
|
||||
//Adding 1 to flightTicks prevents damage on the very first tick.
|
||||
int nextFlightTick = flightTicks + 1;
|
||||
|
||||
@@ -11,7 +11,7 @@ import net.minecraft.world.item.CreativeModeTabs;
|
||||
import net.minecraft.world.item.Item;
|
||||
import net.minecraft.world.item.MobBucketItem;
|
||||
import net.minecraft.world.level.material.Fluids;
|
||||
import net.minecraftforge.event.CreativeModeTabEvent;
|
||||
import net.minecraftforge.event.BuildCreativeModeTabContentsEvent;
|
||||
import net.minecraftforge.eventbus.api.IEventBus;
|
||||
import net.minecraftforge.fml.common.Mod;
|
||||
import net.minecraftforge.fml.javafmlmod.FMLJavaModLoadingContext;
|
||||
@@ -43,9 +43,9 @@ public class CustomMobBucketTest
|
||||
}
|
||||
}
|
||||
|
||||
private void addCreative(CreativeModeTabEvent.BuildContents event)
|
||||
private void addCreative(BuildCreativeModeTabContentsEvent event)
|
||||
{
|
||||
if (event.getTab() == CreativeModeTabs.INGREDIENTS)
|
||||
if (event.getTabKey() == CreativeModeTabs.INGREDIENTS)
|
||||
event.accept(COW_BUCKET);
|
||||
}
|
||||
}
|
||||
@@ -12,15 +12,13 @@ import net.minecraft.world.item.*;
|
||||
import net.minecraft.world.level.Level;
|
||||
import net.minecraftforge.common.ToolAction;
|
||||
import net.minecraftforge.common.ToolActions;
|
||||
import net.minecraftforge.event.CreativeModeTabEvent;
|
||||
import net.minecraftforge.event.BuildCreativeModeTabContentsEvent;
|
||||
import net.minecraftforge.fml.common.Mod;
|
||||
import net.minecraftforge.fml.javafmlmod.FMLJavaModLoadingContext;
|
||||
import net.minecraftforge.registries.ForgeRegistries;
|
||||
import net.minecraftforge.registries.RegistryObject;
|
||||
import net.minecraftforge.registries.DeferredRegister;
|
||||
|
||||
import java.util.function.Consumer;
|
||||
|
||||
@Mod("custom_shield_test")
|
||||
public class CustomShieldTest
|
||||
{
|
||||
@@ -36,9 +34,9 @@ public class CustomShieldTest
|
||||
modBus.addListener(this::addCreative);
|
||||
}
|
||||
|
||||
private void addCreative(CreativeModeTabEvent.BuildContents event)
|
||||
private void addCreative(BuildCreativeModeTabContentsEvent event)
|
||||
{
|
||||
if (event.getTab() == CreativeModeTabs.COMBAT)
|
||||
if (event.getTabKey() == CreativeModeTabs.COMBAT)
|
||||
event.accept(CUSTOM_SHIELD_ITEM);
|
||||
}
|
||||
|
||||
|
||||
@@ -7,9 +7,8 @@ package net.minecraftforge.debug.item;
|
||||
|
||||
import net.minecraft.world.entity.monster.EnderMan;
|
||||
import net.minecraft.world.entity.player.Player;
|
||||
import net.minecraft.world.entity.EquipmentSlot;
|
||||
import net.minecraft.world.item.*;
|
||||
import net.minecraftforge.event.CreativeModeTabEvent;
|
||||
import net.minecraftforge.event.BuildCreativeModeTabContentsEvent;
|
||||
import net.minecraftforge.eventbus.api.IEventBus;
|
||||
import net.minecraftforge.registries.RegistryObject;
|
||||
import net.minecraftforge.fml.common.Mod;
|
||||
@@ -41,9 +40,9 @@ public class EnderMaskTest
|
||||
modEventBus.addListener(this::addCreative);
|
||||
}
|
||||
|
||||
private void addCreative(CreativeModeTabEvent.BuildContents event)
|
||||
private void addCreative(BuildCreativeModeTabContentsEvent event)
|
||||
{
|
||||
if (event.getTab() == CreativeModeTabs.INGREDIENTS)
|
||||
if (event.getTabKey() == CreativeModeTabs.INGREDIENTS)
|
||||
event.accept(ENDER_MASK);
|
||||
}
|
||||
}
|
||||
@@ -19,7 +19,7 @@ import net.minecraftforge.api.distmarker.Dist;
|
||||
import net.minecraftforge.client.event.EntityRenderersEvent;
|
||||
import net.minecraftforge.common.ForgeMod;
|
||||
import net.minecraftforge.common.ForgeSpawnEggItem;
|
||||
import net.minecraftforge.event.CreativeModeTabEvent;
|
||||
import net.minecraftforge.event.BuildCreativeModeTabContentsEvent;
|
||||
import net.minecraftforge.event.entity.EntityAttributeCreationEvent;
|
||||
import net.minecraftforge.eventbus.api.SubscribeEvent;
|
||||
import net.minecraftforge.fml.common.Mod;
|
||||
@@ -57,9 +57,9 @@ public class ForgeSpawnEggItemTest
|
||||
}
|
||||
}
|
||||
|
||||
private void addCreative(CreativeModeTabEvent.BuildContents event)
|
||||
private void addCreative(BuildCreativeModeTabContentsEvent event)
|
||||
{
|
||||
if (event.getTab() == CreativeModeTabs.INGREDIENTS)
|
||||
if (event.getTabKey() == CreativeModeTabs.INGREDIENTS)
|
||||
event.accept(EGG);
|
||||
}
|
||||
|
||||
|
||||
@@ -15,7 +15,7 @@ import net.minecraft.world.entity.ai.attributes.Attributes;
|
||||
import net.minecraft.world.item.CreativeModeTabs;
|
||||
import net.minecraft.world.item.Item;
|
||||
import net.minecraft.world.item.ItemStack;
|
||||
import net.minecraftforge.event.CreativeModeTabEvent;
|
||||
import net.minecraftforge.event.BuildCreativeModeTabContentsEvent;
|
||||
import net.minecraftforge.fml.common.Mod;
|
||||
import net.minecraftforge.fml.javafmlmod.FMLJavaModLoadingContext;
|
||||
import net.minecraftforge.registries.DeferredRegister;
|
||||
@@ -40,9 +40,9 @@ public class HiddenTooltipPartsTest
|
||||
modBus.addListener(this::addCreative);
|
||||
}
|
||||
|
||||
private void addCreative(CreativeModeTabEvent.BuildContents event)
|
||||
private void addCreative(BuildCreativeModeTabContentsEvent event)
|
||||
{
|
||||
if (event.getTab() == CreativeModeTabs.INGREDIENTS)
|
||||
if (event.getTabKey() == CreativeModeTabs.INGREDIENTS)
|
||||
event.accept(TEST_ITEM);
|
||||
}
|
||||
|
||||
|
||||
@@ -8,7 +8,7 @@ package net.minecraftforge.debug.item;
|
||||
import net.minecraft.client.renderer.item.ItemProperties;
|
||||
import net.minecraft.resources.ResourceLocation;
|
||||
import net.minecraft.world.item.*;
|
||||
import net.minecraftforge.event.CreativeModeTabEvent;
|
||||
import net.minecraftforge.event.BuildCreativeModeTabContentsEvent;
|
||||
import net.minecraftforge.eventbus.api.IEventBus;
|
||||
import net.minecraftforge.fml.common.Mod;
|
||||
import net.minecraftforge.fml.event.lifecycle.FMLClientSetupEvent;
|
||||
@@ -47,9 +47,9 @@ public class RangedMobsUseModdedWeaponsTest {
|
||||
}
|
||||
}
|
||||
|
||||
private void addCreative(CreativeModeTabEvent.BuildContents event)
|
||||
private void addCreative(BuildCreativeModeTabContentsEvent event)
|
||||
{
|
||||
if (event.getTab() == CreativeModeTabs.COMBAT)
|
||||
if (event.getTabKey() == CreativeModeTabs.COMBAT)
|
||||
{
|
||||
event.accept(MODDED_BOW);
|
||||
event.accept(MODDED_CROSSBOW);
|
||||
|
||||
@@ -5,10 +5,9 @@
|
||||
|
||||
package net.minecraftforge.debug.item;
|
||||
|
||||
import net.minecraft.world.entity.EquipmentSlot;
|
||||
import net.minecraft.world.entity.LivingEntity;
|
||||
import net.minecraft.world.item.*;
|
||||
import net.minecraftforge.event.CreativeModeTabEvent;
|
||||
import net.minecraftforge.event.BuildCreativeModeTabContentsEvent;
|
||||
import net.minecraftforge.eventbus.api.IEventBus;
|
||||
import net.minecraftforge.fml.common.Mod;
|
||||
import net.minecraftforge.fml.javafmlmod.FMLJavaModLoadingContext;
|
||||
@@ -39,9 +38,9 @@ public class SnowBootsTest
|
||||
modEventBus.addListener(this::addCreative);
|
||||
}
|
||||
|
||||
private void addCreative(CreativeModeTabEvent.BuildContents event)
|
||||
private void addCreative(BuildCreativeModeTabContentsEvent event)
|
||||
{
|
||||
if (event.getTab() == CreativeModeTabs.COMBAT)
|
||||
if (event.getTabKey() == CreativeModeTabs.COMBAT)
|
||||
event.accept(SNOW_BOOTS);
|
||||
}
|
||||
}
|
||||
@@ -18,7 +18,7 @@ import net.minecraft.world.level.gameevent.GameEvent;
|
||||
import net.minecraftforge.api.distmarker.Dist;
|
||||
import net.minecraftforge.client.event.ComputeFovModifierEvent;
|
||||
import net.minecraftforge.common.MinecraftForge;
|
||||
import net.minecraftforge.event.CreativeModeTabEvent;
|
||||
import net.minecraftforge.event.BuildCreativeModeTabContentsEvent;
|
||||
import net.minecraftforge.event.VanillaGameEvent;
|
||||
import net.minecraftforge.eventbus.api.IEventBus;
|
||||
import net.minecraftforge.eventbus.api.SubscribeEvent;
|
||||
@@ -86,9 +86,9 @@ public class StopUsingItemTest
|
||||
}
|
||||
});
|
||||
|
||||
private void addCreative(CreativeModeTabEvent.BuildContents event)
|
||||
private void addCreative(BuildCreativeModeTabContentsEvent event)
|
||||
{
|
||||
if (event.getTab() == CreativeModeTabs.COMBAT)
|
||||
if (event.getTabKey() == CreativeModeTabs.COMBAT)
|
||||
{
|
||||
event.accept(BAD);
|
||||
event.accept(GOOD);
|
||||
@@ -125,14 +125,14 @@ public class StopUsingItemTest
|
||||
{
|
||||
player.startUsingItem(hand);
|
||||
player.getAbilities().mayfly = true;
|
||||
if (player.level.isClientSide)
|
||||
if (player.level().isClientSide)
|
||||
fovChange = 10f;
|
||||
return InteractionResultHolder.consume(player.getItemInHand(hand));
|
||||
}
|
||||
|
||||
public static void removeFov(LivingEntity living)
|
||||
{
|
||||
if (living.level.isClientSide)
|
||||
if (living.level().isClientSide)
|
||||
fovChange = 1f;
|
||||
if (living instanceof Player player)
|
||||
{
|
||||
|
||||
@@ -19,18 +19,16 @@ import net.minecraft.world.item.crafting.Ingredient;
|
||||
import net.minecraft.world.level.block.Block;
|
||||
import net.minecraft.world.level.block.state.BlockBehaviour;
|
||||
import net.minecraft.world.level.block.state.BlockState;
|
||||
import net.minecraft.world.level.material.Material;
|
||||
import net.minecraft.world.level.material.MaterialColor;
|
||||
import net.minecraft.world.level.material.MapColor;
|
||||
import net.minecraft.world.level.storage.loot.parameters.LootContextParamSets;
|
||||
import net.minecraftforge.client.model.generators.BlockStateProvider;
|
||||
import net.minecraftforge.client.model.generators.ItemModelProvider;
|
||||
import net.minecraftforge.client.model.generators.ModelFile;
|
||||
import net.minecraftforge.client.model.generators.ModelFile.UncheckedModelFile;
|
||||
import net.minecraftforge.common.ForgeTier;
|
||||
import net.minecraftforge.common.TierSortingRegistry;
|
||||
import net.minecraftforge.common.data.BlockTagsProvider;
|
||||
import net.minecraftforge.common.data.ExistingFileHelper;
|
||||
import net.minecraftforge.event.CreativeModeTabEvent;
|
||||
import net.minecraftforge.event.BuildCreativeModeTabContentsEvent;
|
||||
import net.minecraftforge.eventbus.api.IEventBus;
|
||||
import net.minecraftforge.eventbus.api.SubscribeEvent;
|
||||
import net.minecraftforge.fml.common.Mod;
|
||||
@@ -60,7 +58,7 @@ public class TagBasedToolTypesTest
|
||||
);
|
||||
|
||||
private static final DeferredRegister<Block> BLOCKS = DeferredRegister.create(ForgeRegistries.BLOCKS, MODID);
|
||||
private static final RegistryObject<Block> STONE = BLOCKS.register("test_stone", () -> new Block(BlockBehaviour.Properties.of(Material.STONE, MaterialColor.DIRT).requiresCorrectToolForDrops().strength(1.5F, 6.0F)));
|
||||
private static final RegistryObject<Block> STONE = BLOCKS.register("test_stone", () -> new Block(BlockBehaviour.Properties.of().mapColor(MapColor.DIRT).requiresCorrectToolForDrops().strength(1.5F, 6.0F)));
|
||||
|
||||
private static final DeferredRegister<Item> ITEMS = DeferredRegister.create(ForgeRegistries.ITEMS, MODID);
|
||||
@SuppressWarnings("unused")
|
||||
@@ -100,11 +98,11 @@ public class TagBasedToolTypesTest
|
||||
modEventBus.addListener(this::addCreative);
|
||||
}
|
||||
|
||||
private void addCreative(CreativeModeTabEvent.BuildContents event)
|
||||
private void addCreative(BuildCreativeModeTabContentsEvent event)
|
||||
{
|
||||
if (event.getTab() == CreativeModeTabs.TOOLS_AND_UTILITIES)
|
||||
if (event.getTabKey() == CreativeModeTabs.TOOLS_AND_UTILITIES)
|
||||
event.accept(TOOL);
|
||||
if (event.getTab() == CreativeModeTabs.BUILDING_BLOCKS)
|
||||
if (event.getTabKey() == CreativeModeTabs.BUILDING_BLOCKS)
|
||||
event.accept(ORE_ITEM);
|
||||
}
|
||||
|
||||
|
||||
@@ -6,6 +6,7 @@
|
||||
package net.minecraftforge.debug.misc;
|
||||
|
||||
import com.mojang.blaze3d.vertex.PoseStack;
|
||||
import net.minecraft.client.gui.GuiGraphics;
|
||||
import net.minecraft.world.level.block.Blocks;
|
||||
import net.minecraft.client.gui.screens.MenuScreens;
|
||||
import net.minecraft.client.gui.screens.inventory.AbstractContainerScreen;
|
||||
@@ -78,9 +79,9 @@ public class ContainerTypeTest
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void renderBg(PoseStack poseStack, float partialTick, int mouseX, int mouseY)
|
||||
protected void renderBg(GuiGraphics graphics, float partialTick, int mouseX, int mouseY)
|
||||
{
|
||||
drawString(poseStack, this.font, getMenu().text, mouseX, mouseY, -1);
|
||||
graphics.drawString(this.font, getMenu().text, mouseX, mouseY, -1);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -21,14 +21,13 @@ import net.minecraft.world.level.block.entity.BlockEntity;
|
||||
import net.minecraft.world.level.block.entity.BlockEntityType;
|
||||
import net.minecraft.world.level.block.state.BlockBehaviour.Properties;
|
||||
import net.minecraft.world.level.block.state.BlockState;
|
||||
import net.minecraft.world.level.material.Material;
|
||||
import net.minecraft.world.level.material.MaterialColor;
|
||||
import net.minecraft.world.level.material.MapColor;
|
||||
import net.minecraftforge.common.capabilities.Capability;
|
||||
import net.minecraftforge.common.capabilities.ForgeCapabilities;
|
||||
import net.minecraftforge.common.util.LazyOptional;
|
||||
import net.minecraftforge.energy.EnergyStorage;
|
||||
import net.minecraftforge.energy.IEnergyStorage;
|
||||
import net.minecraftforge.event.CreativeModeTabEvent;
|
||||
import net.minecraftforge.event.BuildCreativeModeTabContentsEvent;
|
||||
import net.minecraftforge.event.RegisterGameTestsEvent;
|
||||
import net.minecraftforge.eventbus.api.IEventBus;
|
||||
import net.minecraftforge.eventbus.api.SubscribeEvent;
|
||||
@@ -42,7 +41,6 @@ import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.function.Consumer;
|
||||
|
||||
@Mod(GameTestTest.MODID)
|
||||
public class GameTestTest
|
||||
@@ -53,7 +51,7 @@ public class GameTestTest
|
||||
private static final DeferredRegister<Item> ITEMS = DeferredRegister.create(ForgeRegistries.ITEMS, MODID);
|
||||
private static final DeferredRegister<BlockEntityType<?>> BLOCK_ENTITIES = DeferredRegister.create(ForgeRegistries.BLOCK_ENTITY_TYPES, MODID);
|
||||
private static final RegistryObject<Block> ENERGY_BLOCK = BLOCKS.register("energy_block",
|
||||
() -> new EnergyBlock(Properties.of(Material.STONE, MaterialColor.STONE)));
|
||||
() -> new EnergyBlock(Properties.of().mapColor(MapColor.STONE)));
|
||||
@SuppressWarnings("unused")
|
||||
private static final RegistryObject<Item> ENERGY_BLOCK_ITEM = ITEMS.register("energy_block",
|
||||
() -> new BlockItem(ENERGY_BLOCK.get(), new Item.Properties()));
|
||||
@@ -74,9 +72,9 @@ public class GameTestTest
|
||||
}
|
||||
}
|
||||
|
||||
private void addCreative(CreativeModeTabEvent.BuildContents event)
|
||||
private void addCreative(BuildCreativeModeTabContentsEvent event)
|
||||
{
|
||||
if (event.getTab() == CreativeModeTabs.INGREDIENTS)
|
||||
if (event.getTabKey() == CreativeModeTabs.INGREDIENTS)
|
||||
event.accept(ENERGY_BLOCK_ITEM);
|
||||
}
|
||||
|
||||
|
||||
@@ -10,7 +10,6 @@ import net.minecraft.world.item.Items;
|
||||
import net.minecraftforge.common.MinecraftForge;
|
||||
import net.minecraftforge.event.GrindstoneEvent;
|
||||
import net.minecraftforge.eventbus.api.SubscribeEvent;
|
||||
import net.minecraftforge.fml.Bindings;
|
||||
import net.minecraftforge.fml.common.Mod;
|
||||
|
||||
@Mod("grindstone_event_test")
|
||||
@@ -23,7 +22,7 @@ public class GrindstoneEventTest {
|
||||
}
|
||||
|
||||
@SubscribeEvent
|
||||
public void onGrindstonePlace(GrindstoneEvent.OnplaceItem event)
|
||||
public void onGrindstonePlace(GrindstoneEvent.OnPlaceItem event)
|
||||
{
|
||||
// TODO 1.20: This will not work once IForgeItem#canGrindstoneRepair is changed to have items opt-in to being able to place
|
||||
// rather than the current opt-out (the hook will no longer fire after the change). Fix?
|
||||
|
||||
@@ -18,6 +18,7 @@ import net.minecraft.world.item.crafting.Recipe;
|
||||
import net.minecraft.world.level.block.Blocks;
|
||||
import net.minecraftforge.debug.recipe.recipebook.RecipeBookExtensionTest.RecipeBookTestContainer;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.Optional;
|
||||
|
||||
public class RecipeBookTestMenu extends RecipeBookMenu<RecipeBookTestContainer>
|
||||
@@ -58,7 +59,8 @@ public class RecipeBookTestMenu extends RecipeBookMenu<RecipeBookTestContainer>
|
||||
{
|
||||
this.checkTakeAchievements(stack);
|
||||
Container craftingContainer = RecipeBookTestMenu.this.container;
|
||||
NonNullList<ItemStack> remainders = player.level.getRecipeManager().getRemainingItemsFor(RecipeBookExtensionTest.RECIPE_BOOK_TEST_RECIPE_TYPE.get(), RecipeBookTestMenu.this.container, player.level);
|
||||
NonNullList<ItemStack> remainders = player.level()
|
||||
.getRecipeManager().getRemainingItemsFor(RecipeBookExtensionTest.RECIPE_BOOK_TEST_RECIPE_TYPE.get(), RecipeBookTestMenu.this.container, player.level());
|
||||
for (int i = 0; i < remainders.size(); ++i)
|
||||
{
|
||||
ItemStack toRemove = craftingContainer.getItem(i);
|
||||
@@ -73,7 +75,7 @@ public class RecipeBookTestMenu extends RecipeBookMenu<RecipeBookTestContainer>
|
||||
{
|
||||
if (toRemove.isEmpty())
|
||||
craftingContainer.setItem(i, toRemove);
|
||||
else if (ItemStack.isSame(toRemove, toReplace) && ItemStack.tagMatches(toRemove, toReplace))
|
||||
else if (ItemStack.isSameItemSameTags(toRemove, toReplace))
|
||||
{
|
||||
toReplace.grow(toRemove.getCount());
|
||||
craftingContainer.setItem(i, toReplace);
|
||||
@@ -108,9 +110,9 @@ public class RecipeBookTestMenu extends RecipeBookMenu<RecipeBookTestContainer>
|
||||
protected void checkTakeAchievements(ItemStack stack)
|
||||
{
|
||||
if (this.removeCount > 0)
|
||||
stack.onCraftedBy(RecipeBookTestMenu.this.player.level, RecipeBookTestMenu.this.player, this.removeCount);
|
||||
stack.onCraftedBy(RecipeBookTestMenu.this.player.level(), RecipeBookTestMenu.this.player, this.removeCount);
|
||||
if (this.container instanceof RecipeHolder recipeHolder)
|
||||
recipeHolder.awardUsedRecipes(RecipeBookTestMenu.this.player);
|
||||
recipeHolder.awardUsedRecipes(RecipeBookTestMenu.this.player, List.of());
|
||||
this.removeCount = 0;
|
||||
}
|
||||
};
|
||||
@@ -250,7 +252,7 @@ public class RecipeBookTestMenu extends RecipeBookMenu<RecipeBookTestContainer>
|
||||
@Override
|
||||
public boolean recipeMatches(Recipe<? super RecipeBookTestContainer> recipe)
|
||||
{
|
||||
return recipe.matches(this.container, this.player.level);
|
||||
return recipe.matches(this.container, this.player.level());
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -23,6 +23,7 @@ import net.minecraft.world.item.crafting.RecipeSerializer;
|
||||
import net.minecraft.world.item.crafting.RecipeType;
|
||||
import net.minecraft.world.item.crafting.ShapedRecipe;
|
||||
import net.minecraft.world.level.Level;
|
||||
import net.minecraftforge.common.ForgeHooks;
|
||||
|
||||
import java.util.*;
|
||||
import java.util.function.Function;
|
||||
@@ -149,7 +150,7 @@ public class RecipeBookTestRecipe implements Recipe<RecipeBookExtensionTest.Reci
|
||||
return this.getIngredients().isEmpty() ||
|
||||
this.getIngredients().stream()
|
||||
.filter((ingredient) -> !ingredient.isEmpty())
|
||||
.anyMatch(i -> i.getItems().length == 0);
|
||||
.anyMatch(ForgeHooks::hasNoElements);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
+14
-14
@@ -7,6 +7,7 @@ package net.minecraftforge.debug.recipe.recipebook;
|
||||
|
||||
import com.mojang.blaze3d.systems.RenderSystem;
|
||||
import com.mojang.blaze3d.vertex.PoseStack;
|
||||
import net.minecraft.client.gui.GuiGraphics;
|
||||
import net.minecraft.client.gui.components.ImageButton;
|
||||
import net.minecraft.client.gui.screens.inventory.AbstractContainerScreen;
|
||||
import net.minecraft.client.gui.screens.inventory.CraftingScreen;
|
||||
@@ -61,41 +62,40 @@ public class RecipeBookTestScreen extends AbstractContainerScreen<RecipeBookTest
|
||||
}
|
||||
|
||||
@Override
|
||||
public void render(PoseStack stack, int mouseX, int mouseY, float partialTicks)
|
||||
public void render(GuiGraphics graphics, int mouseX, int mouseY, float partialTicks)
|
||||
{
|
||||
this.renderBackground(stack);
|
||||
this.renderBackground(graphics);
|
||||
if (this.recipeBookComponent.isVisible() && this.widthTooNarrow)
|
||||
{
|
||||
this.renderBg(stack, partialTicks, mouseX, mouseY);
|
||||
this.recipeBookComponent.render(stack, mouseX, mouseY, partialTicks);
|
||||
this.renderBg(graphics, partialTicks, mouseX, mouseY);
|
||||
this.recipeBookComponent.render(graphics, mouseX, mouseY, partialTicks);
|
||||
}
|
||||
else
|
||||
{
|
||||
this.recipeBookComponent.render(stack, mouseX, mouseY, partialTicks);
|
||||
super.render(stack, mouseX, mouseY, partialTicks);
|
||||
this.recipeBookComponent.renderGhostRecipe(stack, this.leftPos, this.topPos, true, partialTicks);
|
||||
this.recipeBookComponent.render(graphics, mouseX, mouseY, partialTicks);
|
||||
super.render(graphics, mouseX, mouseY, partialTicks);
|
||||
this.recipeBookComponent.renderGhostRecipe(graphics, this.leftPos, this.topPos, true, partialTicks);
|
||||
}
|
||||
this.renderTooltip(stack, mouseX, mouseY);
|
||||
this.recipeBookComponent.renderTooltip(stack, this.leftPos, this.topPos, mouseX, mouseY);
|
||||
this.renderTooltip(graphics, mouseX, mouseY);
|
||||
this.recipeBookComponent.renderTooltip(graphics, this.leftPos, this.topPos, mouseX, mouseY);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void renderBg(PoseStack stack, float partialTicks, int mouseX, int mouseY)
|
||||
protected void renderBg(GuiGraphics graphics, float partialTicks, int mouseX, int mouseY)
|
||||
{
|
||||
RenderSystem.setShader(GameRenderer::getPositionTexShader);
|
||||
RenderSystem.setShaderTexture(0, TEXTURE);
|
||||
int x = this.leftPos;
|
||||
int y = this.topPos;
|
||||
this.blit(stack, x, y, 0, 0, this.imageWidth, this.imageHeight);
|
||||
graphics.blit(TEXTURE, x, y, 0, 0, this.imageWidth, this.imageHeight);
|
||||
}
|
||||
|
||||
/**
|
||||
* Color gotten from super
|
||||
*/
|
||||
@Override
|
||||
protected void renderLabels(PoseStack stack, int mouseX, int mouseY)
|
||||
protected void renderLabels(GuiGraphics graphics, int mouseX, int mouseY)
|
||||
{
|
||||
this.font.draw(stack, this.title, this.titleLabelX, this.titleLabelY, 4210752);
|
||||
graphics.drawString(this.font, this.title, this.titleLabelX, this.titleLabelY, 4210752);
|
||||
}
|
||||
|
||||
protected boolean isHovering(int x, int y, int width, int height, double mouseX, double mouseY)
|
||||
|
||||
@@ -12,7 +12,7 @@ import java.util.UUID;
|
||||
import net.minecraft.world.item.CreativeModeTabs;
|
||||
import net.minecraft.world.level.block.Block;
|
||||
import net.minecraft.world.level.block.state.BlockState;
|
||||
import net.minecraft.world.level.material.Material;
|
||||
import net.minecraft.world.level.material.MapColor;
|
||||
import net.minecraft.world.item.BlockItem;
|
||||
import net.minecraft.world.item.Item;
|
||||
import net.minecraft.core.BlockPos;
|
||||
@@ -20,7 +20,7 @@ import net.minecraft.world.level.ChunkPos;
|
||||
import net.minecraft.world.level.Level;
|
||||
import net.minecraft.server.level.ServerLevel;
|
||||
import net.minecraftforge.common.world.ForgeChunkManager;
|
||||
import net.minecraftforge.event.CreativeModeTabEvent;
|
||||
import net.minecraftforge.event.BuildCreativeModeTabContentsEvent;
|
||||
import net.minecraftforge.eventbus.api.IEventBus;
|
||||
import net.minecraftforge.registries.RegistryObject;
|
||||
import net.minecraftforge.fml.common.Mod;
|
||||
@@ -40,7 +40,7 @@ public class ForgeChunkManagerTest
|
||||
private static final Logger LOGGER = LogManager.getLogger(MODID);
|
||||
private static final DeferredRegister<Block> BLOCKS = DeferredRegister.create(ForgeRegistries.BLOCKS, MODID);
|
||||
private static final DeferredRegister<Item> ITEMS = DeferredRegister.create(ForgeRegistries.ITEMS, MODID);
|
||||
private static final RegistryObject<Block> CHUNK_LOADER_BLOCK = BLOCKS.register("chunk_loader", () -> new ChunkLoaderBlock(Properties.of(Material.STONE)));
|
||||
private static final RegistryObject<Block> CHUNK_LOADER_BLOCK = BLOCKS.register("chunk_loader", () -> new ChunkLoaderBlock(Properties.of().mapColor(MapColor.STONE)));
|
||||
private static final RegistryObject<Item> CHUNK_LOADER_ITEM = ITEMS.register("chunk_loader", () -> new BlockItem(CHUNK_LOADER_BLOCK.get(), new Item.Properties()));
|
||||
|
||||
public ForgeChunkManagerTest()
|
||||
@@ -52,9 +52,9 @@ public class ForgeChunkManagerTest
|
||||
modEventBus.addListener(this::addCreative);
|
||||
}
|
||||
|
||||
private void addCreative(CreativeModeTabEvent.BuildContents event)
|
||||
private void addCreative(BuildCreativeModeTabContentsEvent event)
|
||||
{
|
||||
if (event.getTab() == CreativeModeTabs.INGREDIENTS)
|
||||
if (event.getTabKey() == CreativeModeTabs.INGREDIENTS)
|
||||
event.accept(CHUNK_LOADER_ITEM);
|
||||
}
|
||||
|
||||
|
||||
@@ -19,6 +19,7 @@ import net.minecraft.commands.Commands;
|
||||
import net.minecraft.core.MappedRegistry;
|
||||
import net.minecraft.core.Registry;
|
||||
import net.minecraft.core.RegistryCodecs;
|
||||
import net.minecraft.nbt.NbtOps;
|
||||
import net.minecraft.network.CompressionDecoder;
|
||||
import net.minecraft.network.FriendlyByteBuf;
|
||||
import net.minecraft.network.chat.Component;
|
||||
@@ -104,7 +105,7 @@ public class LoginPacketSplitTest
|
||||
MinecraftForge.EVENT_BUS.addListener((final RegisterClientCommandsEvent event) -> event.getDispatcher().register(Commands.literal("big_data")
|
||||
.executes(context ->
|
||||
{
|
||||
context.getSource().sendSuccess(Component.literal("Registry has " + context.getSource().registryAccess().registryOrThrow(BIG_DATA).holders().count() + " entries."), true);
|
||||
context.getSource().sendSuccess(() -> Component.literal("Registry has " + context.getSource().registryAccess().registryOrThrow(BIG_DATA).holders().count() + " entries."), true);
|
||||
return Command.SINGLE_SUCCESS;
|
||||
})));
|
||||
}
|
||||
|
||||
@@ -34,7 +34,7 @@ public class MdkDatagen
|
||||
var packOutput = gen.getPackOutput();
|
||||
gen.addProvider(true, new PackMetadataGenerator(packOutput)
|
||||
.add(PackMetadataSection.TYPE, new PackMetadataSection(
|
||||
Component.literal("examplemod resources"),
|
||||
Component.literal("${mod_id} resources"),
|
||||
DetectedVersion.BUILT_IN.getPackVersion(PackType.CLIENT_RESOURCES),
|
||||
Arrays.stream(PackType.values()).collect(Collectors.toMap(Function.identity(), DetectedVersion.BUILT_IN::getPackVersion))
|
||||
))
|
||||
|
||||
Reference in new issue
Block a user