Skip to content

Commit

Permalink
Update to Forge 41.0.99
Browse files Browse the repository at this point in the history
  • Loading branch information
rubensworks committed Jul 17, 2022
1 parent 5440816 commit 56f2b25
Show file tree
Hide file tree
Showing 32 changed files with 81 additions and 93 deletions.
4 changes: 2 additions & 2 deletions gradle.properties
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
mod_version=1.16.0
minecraft_version=1.19
forge_version=41.0.35
forge_version=41.0.99
release_type=release
fingerprint=bd0353b3e8a2810d60dd584e256e364bc3bedd44

baubles_version=1.10.0.0-1.18
curios_version=1.19-5.1.0.0
curios_version=1.19-5.1.0.4

# Workaround for Spotless bug
# https://github.com/diffplug/spotless/issues/834
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -50,9 +50,9 @@ public Instance createInstance(JsonObject json, EntityPredicate.Composite entity

@SubscribeEvent
public void onEvent(PlayerContainerEvent.Open event) {
if (event.getPlayer() != null && event.getPlayer() instanceof ServerPlayer) {
this.trigger((ServerPlayer) event.getPlayer(),
(i) -> i.test((ServerPlayer) event.getPlayer(), event.getContainer()));
if (event.getEntity() != null && event.getEntity() instanceof ServerPlayer) {
this.trigger((ServerPlayer) event.getEntity(),
(i) -> i.test((ServerPlayer) event.getEntity(), event.getContainer()));
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -36,9 +36,9 @@ public Instance createInstance(JsonObject json, EntityPredicate.Composite entity

@SubscribeEvent
public void onCrafted(PlayerEvent.ItemCraftedEvent event) {
if (event.getPlayer() != null && event.getPlayer() instanceof ServerPlayer) {
this.trigger((ServerPlayer) event.getPlayer(),
(i) -> i.test((ServerPlayer) event.getPlayer(), event));
if (event.getEntity() != null && event.getEntity() instanceof ServerPlayer) {
this.trigger((ServerPlayer) event.getEntity(),
(i) -> i.test((ServerPlayer) event.getEntity(), event));
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -38,25 +38,25 @@ public Instance createInstance(JsonObject json, EntityPredicate.Composite entity

@SubscribeEvent
public void onPickup(EntityItemPickupEvent event) {
if (event.getPlayer() != null && event.getPlayer() instanceof ServerPlayer) {
this.trigger((ServerPlayer) event.getPlayer(),
(i) -> i.test((ServerPlayer) event.getPlayer(), event.getItem().getItem()));
if (event.getEntity() != null && event.getEntity() instanceof ServerPlayer) {
this.trigger((ServerPlayer) event.getEntity(),
(i) -> i.test((ServerPlayer) event.getEntity(), event.getItem().getItem()));
}
}

@SubscribeEvent
public void onCrafted(PlayerEvent.ItemCraftedEvent event) {
if (event.getPlayer() != null && event.getPlayer() instanceof ServerPlayer) {
this.trigger((ServerPlayer) event.getPlayer(),
(i) -> i.test((ServerPlayer) event.getPlayer(), event.getCrafting()));
if (event.getEntity() != null && event.getEntity() instanceof ServerPlayer) {
this.trigger((ServerPlayer) event.getEntity(),
(i) -> i.test((ServerPlayer) event.getEntity(), event.getCrafting()));
}
}

@SubscribeEvent
public void onSmelted(PlayerEvent.ItemSmeltedEvent event) {
if (event.getPlayer() != null && event.getPlayer() instanceof ServerPlayer) {
this.trigger((ServerPlayer) event.getPlayer(),
(i) -> i.test((ServerPlayer) event.getPlayer(), event.getSmelting()));
if (event.getEntity() != null && event.getEntity() instanceof ServerPlayer) {
this.trigger((ServerPlayer) event.getEntity(),
(i) -> i.test((ServerPlayer) event.getEntity(), event.getSmelting()));
}
}

Expand Down
2 changes: 1 addition & 1 deletion src/main/java/org/cyclops/cyclopscore/block/IBlockGui.java
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ public static InteractionResult onBlockActivatedHook(IBlockGui block, IBlockCont
if (!world.isClientSide()) {
MenuProvider containerProvider = blockContainerProvider.get(blockState, world, blockPos);
if (containerProvider != null) {
NetworkHooks.openGui((ServerPlayer) player, containerProvider,
NetworkHooks.openScreen((ServerPlayer) player, containerProvider,
packetBuffer -> block.writeExtraGuiData(packetBuffer, world, player, blockPos, hand, rayTraceResult));
Stat<ResourceLocation> openStat = block.getOpenStat();
if (openStat != null) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ public class GuiMainMenuExtensionDevWorld {
private static final String WORLD_NAME_PREFIX = "cyclops-dev";

@SubscribeEvent
public static void onMainMenuInit(ScreenEvent.InitScreenEvent event) {
public static void onMainMenuInit(ScreenEvent.Init event) {
// Add a button to the main menu if we're in a dev environment
if (GeneralConfig.devWorldButton && event.getScreen() instanceof TitleScreen) {
event.addListener(new Button(event.getScreen().width / 2 + 102, event.getScreen().height / 4 + 48,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ public interface IKeyRegistry extends IRegistry {
* Make sure to annotate this with {@link SubscribeEvent}
* @param event The input event.
*/
public void onPlayerKeyInput(InputEvent.KeyInputEvent event);
public void onPlayerKeyInput(InputEvent.Key event);

/**
* Binds a {@link IKeyHandler} to key presses of the
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ public static KeyMapping newKeyMapping(ModBase mod, String name, int defaultKey)

@Override
@SubscribeEvent(priority = EventPriority.NORMAL)
public void onPlayerKeyInput(InputEvent.KeyInputEvent event) {
public void onPlayerKeyInput(InputEvent.Key event) {
for (KeyMapping kb : keyHandlerMap.keySet()) {
if (kb.isDown()) {
fireKeyPressed(kb);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
import net.minecraft.world.item.ItemStack;
import net.minecraft.world.level.Level;
import net.minecraft.world.level.block.state.BlockState;
import net.minecraftforge.client.model.data.IModelData;
import net.minecraftforge.client.model.data.ModelData;

/**
* A dynamic model with a parent that can be used for items and blocks that delegates its blockstate.
Expand All @@ -23,7 +23,7 @@ public DelegatingChildDynamicItemAndBlockModel(BakedModel baseModel) {
}

public DelegatingChildDynamicItemAndBlockModel(BakedModel baseModel, BlockState blockState, Direction facing,
RandomSource rand, IModelData modelData) {
RandomSource rand, ModelData modelData) {
super(blockState, facing, rand, modelData);
this.baseModel = baseModel;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,7 @@
import net.minecraft.world.item.ItemStack;
import net.minecraft.world.level.Level;
import net.minecraft.world.level.block.state.BlockState;
import net.minecraftforge.client.model.data.IModelData;
import net.minecraftforge.client.model.data.ModelDataMap;
import net.minecraftforge.client.model.data.ModelData;

import javax.annotation.Nullable;

Expand All @@ -22,7 +21,7 @@ public abstract class DelegatingDynamicItemAndBlockModel extends DynamicItemAndB
@Nullable
protected final Direction facing;
protected final RandomSource rand;
protected final IModelData modelData;
protected final ModelData modelData;

protected final ItemStack itemStack;
protected final Level world;
Expand All @@ -33,14 +32,14 @@ public DelegatingDynamicItemAndBlockModel() {
this.blockState = null;
this.facing = null;
this.rand = RandomSource.create();
this.modelData = new ModelDataMap.Builder().build();
this.modelData = ModelData.builder().build();

this.itemStack = null;
this.world = null;
this.entity = null;
}

public DelegatingDynamicItemAndBlockModel(BlockState blockState, Direction facing, RandomSource rand, IModelData modelData) {
public DelegatingDynamicItemAndBlockModel(BlockState blockState, Direction facing, RandomSource rand, ModelData modelData) {
super(false, false);
this.blockState = blockState;
this.facing = facing;
Expand All @@ -57,7 +56,7 @@ public DelegatingDynamicItemAndBlockModel(ItemStack itemStack, Level world, Livi
this.blockState = null;
this.facing = null;
this.rand = RandomSource.create();
this.modelData = new ModelDataMap.Builder().build();
this.modelData = ModelData.builder().build();

this.itemStack = itemStack;
this.world = world;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
package org.cyclops.cyclopscore.client.model;

import net.minecraft.client.multiplayer.ClientLevel;
import net.minecraft.client.renderer.RenderType;
import net.minecraft.client.renderer.block.model.BakedQuad;
import net.minecraft.client.renderer.block.model.ItemOverrides;
import net.minecraft.client.resources.model.BakedModel;
Expand All @@ -10,8 +11,7 @@
import net.minecraft.world.item.ItemStack;
import net.minecraft.world.level.Level;
import net.minecraft.world.level.block.state.BlockState;
import net.minecraftforge.client.model.data.EmptyModelData;
import net.minecraftforge.client.model.data.IModelData;
import net.minecraftforge.client.model.data.ModelData;

import javax.annotation.Nonnull;
import javax.annotation.Nullable;
Expand Down Expand Up @@ -42,12 +42,13 @@ protected boolean isItemStack() {

@Override
public List<BakedQuad> getQuads(@Nullable BlockState state, @Nullable Direction side, RandomSource rand) {
return this.getQuads(state, side, rand, EmptyModelData.INSTANCE);
return this.getQuads(state, side, rand, ModelData.builder().build(), RenderType.cutout());
}

@Override
public List<BakedQuad> getQuads(@Nullable BlockState state, @Nullable Direction side,
@Nonnull RandomSource rand, @Nonnull IModelData extraData) {
@Nonnull RandomSource rand, @Nonnull ModelData extraData,
RenderType renderType) {
this.renderingSide = side;
if(factory) {
BakedModel bakedModel;
Expand All @@ -68,7 +69,7 @@ public List<BakedQuad> getGeneralQuads() {
}

public abstract BakedModel handleBlockState(@Nullable BlockState state, @Nullable Direction side,
@Nonnull RandomSource rand, @Nonnull IModelData extraData);
@Nonnull RandomSource rand, @Nonnull ModelData extraData);
public abstract BakedModel handleItemState(@Nullable ItemStack stack, @Nullable Level world,
@Nullable LivingEntity entity);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
import net.minecraft.client.resources.model.BakedModel;
import net.minecraftforge.api.distmarker.Dist;
import net.minecraftforge.api.distmarker.OnlyIn;
import net.minecraftforge.client.event.ModelBakeEvent;
import net.minecraftforge.client.event.ModelEvent;

/**
* Interface for blocks and items which can have a dynamic model.
Expand All @@ -23,6 +23,6 @@ public interface IDynamicModelElement {
* @return A dynamic model instance.
*/
@OnlyIn(Dist.CLIENT)
public BakedModel createDynamicModel(ModelBakeEvent event);
public BakedModel createDynamicModel(ModelEvent.BakingCompleted event);

}
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ public class CommandInfoBookTest implements Command<CommandSourceStack> {

@Override
public int run(CommandContext<CommandSourceStack> context) throws CommandSyntaxException {
NetworkHooks.openGui(context.getSource().getPlayerOrException(), new MenuProvider() {
NetworkHooks.openScreen(context.getSource().getPlayerOrException(), new MenuProvider() {
@Override
public Component getDisplayName() {
return Component.translatable("gui.cyclopscore.infobook");
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -120,6 +120,8 @@ public String getLanguageKey() {
public void saveToField() {
try {
field.set(null, this.configProperty.get());
} catch (IllegalStateException e) {
// Ignore illegal state exceptions thrown by Forge if config is being read too early
} catch (IllegalAccessException e) {
e.printStackTrace();
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,7 @@
import net.minecraft.world.level.block.Block;
import net.minecraftforge.api.distmarker.Dist;
import net.minecraftforge.api.distmarker.OnlyIn;
import net.minecraftforge.client.event.ModelBakeEvent;
import net.minecraftforge.client.event.ModelRegistryEvent;
import net.minecraftforge.client.event.ModelEvent;
import net.minecraftforge.fml.javafmlmod.FMLJavaModLoadingContext;
import net.minecraftforge.registries.ForgeRegistries;
import net.minecraftforge.registries.RegisterEvent;
Expand Down Expand Up @@ -80,7 +79,7 @@ public void onRegisterForgeFilled(BlockConfig eConfig) {
}

@OnlyIn(Dist.CLIENT)
public static void onModelRegistryLoad(ModelRegistryEvent event) {
public static void onModelRegistryLoad(ModelEvent.RegisterAdditional event) {
for (BlockConfig config : MODEL_ENTRIES) {
Pair<ModelResourceLocation, ModelResourceLocation> resourceLocations = config.registerDynamicModel();
config.dynamicBlockVariantLocation = resourceLocations.getLeft();
Expand All @@ -89,15 +88,15 @@ public static void onModelRegistryLoad(ModelRegistryEvent event) {
}

@OnlyIn(Dist.CLIENT)
public static void onModelBakeEvent(ModelBakeEvent event){
public static void onModelBakeEvent(ModelEvent.BakingCompleted event){
for (BlockConfig config : MODEL_ENTRIES) {
IDynamicModelElement dynamicModelElement = (IDynamicModelElement) config.getInstance();
BakedModel dynamicModel = dynamicModelElement.createDynamicModel(event);
if (config.dynamicBlockVariantLocation != null) {
event.getModelRegistry().put(config.dynamicBlockVariantLocation, dynamicModel);
event.getModels().put(config.dynamicBlockVariantLocation, dynamicModel);
}
if (config.dynamicItemVariantLocation != null) {
event.getModelRegistry().put(config.dynamicItemVariantLocation, dynamicModel);
event.getModels().put(config.dynamicItemVariantLocation, dynamicModel);
}
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,7 @@
import net.minecraft.world.item.Item;
import net.minecraftforge.api.distmarker.Dist;
import net.minecraftforge.api.distmarker.OnlyIn;
import net.minecraftforge.client.event.ModelBakeEvent;
import net.minecraftforge.client.event.ModelRegistryEvent;
import net.minecraftforge.client.event.ModelEvent;
import net.minecraftforge.fml.javafmlmod.FMLJavaModLoadingContext;
import org.cyclops.cyclopscore.client.model.IDynamicModelElement;
import org.cyclops.cyclopscore.config.extendedconfig.ItemConfig;
Expand Down Expand Up @@ -42,18 +41,18 @@ public void onRegisterForgeFilled(ItemConfig eConfig) {
}

@OnlyIn(Dist.CLIENT)
public static void onModelRegistryLoad(ModelRegistryEvent event) {
public static void onModelRegistryLoad(ModelEvent.RegisterAdditional event) {
for (ItemConfig config : MODEL_ENTRIES) {
config.dynamicItemVariantLocation = config.registerDynamicModel();
}
}

@OnlyIn(Dist.CLIENT)
public static void onModelBakeEvent(ModelBakeEvent event){
public static void onModelBakeEvent(ModelEvent.BakingCompleted event){
for (ItemConfig config : MODEL_ENTRIES) {
IDynamicModelElement dynamicModelElement = (IDynamicModelElement) config.getInstance();
if (config.dynamicItemVariantLocation != null) {
event.getModelRegistry().put(config.dynamicItemVariantLocation, dynamicModelElement.createDynamicModel(event));
event.getModels().put(config.dynamicItemVariantLocation, dynamicModelElement.createDynamicModel(event));
}
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ public ConfigurableType getConfigurableType() {

@Override
public IForgeRegistry<? super BlockEntityType<T>> getRegistry() {
return ForgeRegistries.BLOCK_ENTITIES;
return ForgeRegistries.BLOCK_ENTITY_TYPES;
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -95,7 +95,7 @@ public void onRegistered() {

@Override
public IForgeRegistry<EntityType<?>> getRegistry() {
return ForgeRegistries.ENTITIES;
return ForgeRegistries.ENTITY_TYPES;
}

@Nullable
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

import net.minecraft.resources.ResourceLocation;
import net.minecraft.world.level.material.Fluid;
import net.minecraftforge.client.IFluidTypeRenderProperties;
import net.minecraftforge.client.extensions.common.IClientFluidTypeExtensions;
import net.minecraftforge.fluids.FluidType;
import net.minecraftforge.fluids.ForgeFlowingFluid;
import org.cyclops.cyclopscore.config.ConfigurableType;
Expand Down Expand Up @@ -34,8 +34,8 @@ protected static ForgeFlowingFluid.Properties getDefaultFluidProperties(ModBase
FluidType.Properties fluidAttributes = FluidType.Properties.create();
FluidType fluidType = new FluidType(fluidAttributes) {
@Override
public void initializeClient(Consumer<IFluidTypeRenderProperties> consumer) {
consumer.accept(new IFluidTypeRenderProperties()
public void initializeClient(Consumer<IClientFluidTypeExtensions> consumer) {
consumer.accept(new IClientFluidTypeExtensions()
{
private final ResourceLocation STILL = new ResourceLocation(mod.getModId(), texturePrefixPath + "_still");
private final ResourceLocation FLOW = new ResourceLocation(mod.getModId(), texturePrefixPath + "_flow");
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ public ConfigurableType getConfigurableType() {

@Override
public IForgeRegistry<? super MenuType<T>> getRegistry() {
return ForgeRegistries.CONTAINERS;
return ForgeRegistries.MENU_TYPES;
}

@OnlyIn(Dist.CLIENT)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
import net.minecraft.core.particles.ParticleType;
import net.minecraftforge.api.distmarker.Dist;
import net.minecraftforge.api.distmarker.OnlyIn;
import net.minecraftforge.client.event.ParticleFactoryRegisterEvent;
import net.minecraftforge.client.event.RegisterParticleProvidersEvent;
import net.minecraftforge.eventbus.api.SubscribeEvent;
import net.minecraftforge.fml.javafmlmod.FMLJavaModLoadingContext;
import net.minecraftforge.registries.ForgeRegistries;
Expand Down Expand Up @@ -68,7 +68,7 @@ public IForgeRegistry<? super ParticleType<T>> getRegistry() {

@OnlyIn(Dist.CLIENT)
@SubscribeEvent
public void onParticleFactoryRegister(ParticleFactoryRegisterEvent event) {
public void onParticleFactoryRegister(RegisterParticleProvidersEvent event) {
ParticleProvider<T> factory = getParticleFactory();
if (factory != null) {
Minecraft.getInstance().particleEngine.register(getInstance(), factory);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ public ConfigurableType getConfigurableType() {

@Override
public IForgeRegistry<VillagerProfession> getRegistry() {
return ForgeRegistries.PROFESSIONS;
return ForgeRegistries.VILLAGER_PROFESSIONS;
}

}
Loading

0 comments on commit 56f2b25

Please sign in to comment.