Skip to content

Commit

Permalink
fix resource reloading issues, fix mixing bowl loot table, maybe fix …
Browse files Browse the repository at this point in the history
…beehive issue
  • Loading branch information
eerussianguy committed Aug 28, 2022
1 parent 4739a51 commit 503dbf0
Show file tree
Hide file tree
Showing 6 changed files with 40 additions and 113 deletions.
2 changes: 1 addition & 1 deletion resources/assets.py
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ def generate(rm: ResourceManager):

rm.blockstate('drying_mat', model='firmalife:block/drying_mat').with_item_model().with_tag('tfc:mineable_with_sharp_tool').with_lang(lang('drying mat')).with_block_loot('firmalife:drying_mat')
block = rm.blockstate('mixing_bowl', model='firmalife:block/mixing_bowl').with_item_model().with_tag('minecraft:mineable/axe').with_lang(lang('mixing bowl'))
block.with_block_loot({'name': 'firmalife:mixing_bowl'}, {'name': 'firmalife:mixing_bowl', 'conditions': [loot_tables.block_state_property('firmalife:mixing_bowl[spoon=true]')]})
block.with_block_loot({'name': 'firmalife:mixing_bowl'}, {'name': 'firmalife:spoon', 'conditions': [loot_tables.block_state_property('firmalife:mixing_bowl[spoon=true]')]})

for fruit in TFC_FRUITS:
rm.item_model(('not_dried', fruit), 'tfc:item/food/%s' % fruit)
Expand Down
2 changes: 1 addition & 1 deletion src/main/java/com/eerussianguy/firmalife/FirmaLife.java
Original file line number Diff line number Diff line change
Expand Up @@ -55,9 +55,9 @@ public FirmaLife()

FLPackets.init();

FLEvents.init();
bus.addListener(this::setup);

FLEvents.init();
FLForgeEvents.init();
if (FMLEnvironment.dist == Dist.CLIENT)
{
Expand Down
63 changes: 32 additions & 31 deletions src/main/java/com/eerussianguy/firmalife/common/FLEvents.java
Original file line number Diff line number Diff line change
@@ -1,22 +1,23 @@
package com.eerussianguy.firmalife.common;

import net.minecraft.server.packs.PackType;

import java.io.IOException;
import java.nio.file.Path;

import javax.annotation.Nonnull;

import net.minecraft.network.chat.TextComponent;
import net.minecraft.server.packs.PackType;
import net.minecraft.server.packs.metadata.pack.PackMetadataSection;
import net.minecraft.server.packs.repository.Pack;
import net.minecraft.server.packs.repository.PackSource;
import net.minecraftforge.event.AddPackFindersEvent;
import net.minecraftforge.eventbus.api.IEventBus;
import net.minecraftforge.fml.ModList;
import net.minecraftforge.fml.javafmlmod.FMLJavaModLoadingContext;
import net.minecraftforge.resource.PathResourcePack;

import com.eerussianguy.firmalife.FirmaLife;
import com.eerussianguy.firmalife.common.util.SafePathResourcePack;

public class FLEvents
{
Expand All @@ -29,34 +30,34 @@ public static void init()

public static void onPackFinder(AddPackFindersEvent event)
{
ModList.get().getMods().forEach(mod -> FirmaLife.LOGGER.info(mod.getModId()));
// try
// {
// if (event.getPackType() == PackType.SERVER_DATA)
// {
// var modFile = ModList.get().getModFileById(FirmaLife.MOD_ID).getFile();
// var resourcePath = modFile.getFilePath();
// var pack = new SafePathResourcePack(modFile.getFileName() + ":overload", resourcePath) {
// @Nonnull
// @Override
// protected Path resolve(@Nonnull String... paths)
// {
// return modFile.findResource(paths);
// }
// };
//
// var metadata = pack.getMetadataSection(PackMetadataSection.SERIALIZER);
// if (metadata != null)
// {
// event.addRepositorySource((consumer, constructor) ->
// consumer.accept(constructor.create("builtin/firmalife_data", new TextComponent("Firmalife Data"), true, () -> pack, metadata, Pack.Position.TOP, PackSource.BUILT_IN, false))
// );
// }
// }
// }
// catch (IOException e)
// {
// throw new RuntimeException(e);
// }
try
{
if (event.getPackType() == PackType.CLIENT_RESOURCES)
{
var modFile = ModList.get().getModFileById(FirmaLife.MOD_ID).getFile();
var resourcePath = modFile.getFilePath();
var pack = new PathResourcePack(modFile.getFileName() + ":overload", resourcePath)
{
@Nonnull
@Override
protected Path resolve(@Nonnull String... paths)
{
return modFile.findResource(paths);
}
};
var metadata = pack.getMetadataSection(PackMetadataSection.SERIALIZER);
if (metadata != null)
{
event.addRepositorySource((consumer, constructor) ->
consumer.accept(constructor.create("builtin/firmalife_data", new TextComponent("Firmalife Resources"), true, () -> pack, metadata, Pack.Position.TOP, PackSource.BUILT_IN, false))
);
}
}
}
catch (IOException e)
{
throw new RuntimeException(e);
}
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -115,9 +115,12 @@ public InteractionResult use(BlockState state, Level level, BlockPos pos, Player
});
return InteractionResult.sidedSuccess(level.isClientSide);
}
else if (!player.isShiftKeyDown() && player instanceof ServerPlayer serverPlayer)
else if (!player.isShiftKeyDown())
{
level.getBlockEntity(pos, FLBlockEntities.BEEHIVE.get()).ifPresent(nest -> NetworkHooks.openGui(serverPlayer, nest, pos));
if (player instanceof ServerPlayer serverPlayer)
{
level.getBlockEntity(pos, FLBlockEntities.BEEHIVE.get()).ifPresent(nest -> NetworkHooks.openGui(serverPlayer, nest, pos));
}
return InteractionResult.sidedSuccess(level.isClientSide);
}
return InteractionResult.PASS;
Expand Down

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@
"entries": [
{
"type": "minecraft:item",
"name": "firmalife:mixing_bowl",
"name": "firmalife:spoon",
"conditions": [
{
"condition": "minecraft:block_state_property",
Expand Down

0 comments on commit 503dbf0

Please sign in to comment.