Skip to content

Commit

Permalink
Fix spawn config issues & moddied biome spawning, abstract spawning r…
Browse files Browse the repository at this point in the history
…egistration to IMDLib, fix not using proper Biome dictionary, remove manual spinning fix (most have updated Forge w/ fix), fix serializable crash with newer JDKs, update mappings & Forge, fix attribute log spam on newer Forge
  • Loading branch information
itsmeow committed Apr 4, 2021
1 parent ff9923d commit daaeb97
Show file tree
Hide file tree
Showing 18 changed files with 52 additions and 174 deletions.
14 changes: 7 additions & 7 deletions gradle.properties
Original file line number Diff line number Diff line change
Expand Up @@ -4,23 +4,23 @@
maven_group = dev.itsmeow.whisperwoods

# Forge
mc_version = 1.16.4
forge_version = 35.1.4
mappings_version = 20201028
mc_version = 1.16.5
forge_version = 36.1.4
mappings_version = 20210309
mappings_channel = snapshot
mappings_mc_version = 1.16.3
mappings_mc_version = 1.16.5

# Publishing
github = itsmeow/whisperwoods
name = Whisperwoods
url = https://github.com/itsmeow/whisperwoods
curse_project_id = 349597
curse_title = Whisperwoods 1.16.4-2.0.0
curse_versions = Java 8,Forge,Minecraft 1.16:1.16.4,Minecraft 1.16:1.16.3
curse_versions = Java 8,Forge,Minecraft 1.16:1.16.5,Minecraft 1.16:1.16.4,Minecraft 1.16:1.16.3

# Misc
org.gradle.jvmargs=-Xmx6G
org.gradle.daemon=true
jei_version=7.6.0.58
imdlib_version=1.16.3-fe62adbeaca3eb6320f109a154209ffa8f415b62
jei_version=7.6.1.75
imdlib_version=1.16.5-cfc53986656fc4ab86b5570655e7af0b8723fb2b
at_file = accesstransformer
15 changes: 4 additions & 11 deletions src/main/java/dev/itsmeow/whisperwoods/WhisperwoodsMod.java
Original file line number Diff line number Diff line change
@@ -1,28 +1,21 @@
package dev.itsmeow.whisperwoods;

import org.apache.logging.log4j.LogManager;
import org.apache.logging.log4j.Logger;

import dev.itsmeow.imdlib.entity.util.EntityTypeContainer;
import dev.itsmeow.whisperwoods.config.WhisperwoodsConfig;
import dev.itsmeow.whisperwoods.init.ModBlocks;
import dev.itsmeow.whisperwoods.init.ModEntities;
import dev.itsmeow.whisperwoods.init.ModItems;
import dev.itsmeow.whisperwoods.init.ModParticles;
import dev.itsmeow.whisperwoods.init.ModSounds;
import dev.itsmeow.whisperwoods.init.ModTileEntities;
import dev.itsmeow.whisperwoods.init.*;
import dev.itsmeow.whisperwoods.network.WWNetwork;
import net.minecraft.item.ItemGroup;
import net.minecraft.item.ItemStack;
import net.minecraft.util.NonNullList;
import net.minecraftforge.common.MinecraftForge;
import net.minecraftforge.eventbus.api.IEventBus;
import net.minecraftforge.fml.ModLoadingContext;
import net.minecraftforge.fml.common.Mod;
import net.minecraftforge.fml.config.ModConfig;
import net.minecraftforge.fml.event.lifecycle.FMLCommonSetupEvent;
import net.minecraftforge.fml.event.lifecycle.FMLLoadCompleteEvent;
import net.minecraftforge.fml.javafmlmod.FMLJavaModLoadingContext;
import org.apache.logging.log4j.LogManager;
import org.apache.logging.log4j.Logger;

@Mod(value = WhisperwoodsMod.MODID)
public class WhisperwoodsMod {
Expand All @@ -34,13 +27,13 @@ public WhisperwoodsMod() {
IEventBus modBus = FMLJavaModLoadingContext.get().getModEventBus();
modBus.addListener(this::setup);
modBus.addListener(this::loadComplete);
ModEntities.subscribe(modBus);
ModBlocks.subscribe(modBus);
ModItems.subscribe(modBus);
ModSounds.subscribe(modBus);
ModTileEntities.subscribe(modBus);
ModParticles.subscribe(modBus);
WWNetwork.subscribe(modBus);
MinecraftForge.EVENT_BUS.addListener(WhisperwoodsConfig::onBiomeLoad);
ModLoadingContext.get().registerConfig(ModConfig.Type.CLIENT, WhisperwoodsConfig.getClientSpec());
LOGGER.info("Spooking you...");
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,7 @@ public boolean isLit(World world, BlockPos pos) {
@SuppressWarnings("deprecation")
@Override
public void onReplaced(BlockState state, World worldIn, BlockPos pos, BlockState newState, boolean isMoving) {
if(!state.isIn(newState.getBlock())) {
if(!state.matchesBlock(newState.getBlock())) {
TileEntity te = worldIn.getTileEntity(pos);
if(te instanceof TileEntityHandOfFate) {
((TileEntityHandOfFate)te).dropItems(worldIn, pos);
Expand Down Expand Up @@ -157,9 +157,9 @@ public void addInformation(ItemStack stack, IBlockReader worldIn, List<ITextComp
IFormattableTextComponent t = new TranslationTextComponent(recipePrefix + recipeKey)
.setStyle(Style.EMPTY.applyFormatting(recipe.getColor()).setBold(recipe.isBold()))
.appendString(": ")
.append(new TranslationTextComponent(recipe.getFirst().getTranslationKey()).setStyle(Style.EMPTY.applyFormatting(TextFormatting.WHITE).setBold(false)));
.appendSibling(new TranslationTextComponent(recipe.getFirst().getTranslationKey()).setStyle(Style.EMPTY.applyFormatting(TextFormatting.WHITE).setBold(false)));
if(I18n.hasKey(recipePrefix + recipeKey + ".hint")) {
t.appendString(" ").append(new TranslationTextComponent(recipePrefix + recipeKey + ".hint").setStyle(Style.EMPTY.applyFormatting(TextFormatting.GRAY).setBold(false)));
t.appendString(" ").appendSibling(new TranslationTextComponent(recipePrefix + recipeKey + ".hint").setStyle(Style.EMPTY.applyFormatting(TextFormatting.GRAY).setBold(false)));
}
tooltip.add(t);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ public class ClientLifecycleHandler {

public static class RenderTypes extends RenderType {
protected static final RenderState.WriteMaskState NO_WRITE = new RenderState.WriteMaskState(false, false);
private static final RenderType TRANSLUCENT_DEPTH_MASK_OFF = makeType("translucent_depth_mask_off", DefaultVertexFormats.BLOCK, 7, 262144, true, true, RenderType.State.getBuilder().shadeModel(SHADE_ENABLED).lightmap(LIGHTMAP_ENABLED).texture(BLOCK_SHEET_MIPPED).transparency(TRANSLUCENT_TRANSPARENCY).target(field_239236_S_).writeMask(COLOR_WRITE).build(true));
private static final RenderType TRANSLUCENT_DEPTH_MASK_OFF = makeType("translucent_depth_mask_off", DefaultVertexFormats.BLOCK, 7, 262144, true, true, RenderType.State.getBuilder().shadeModel(SHADE_ENABLED).lightmap(LIGHTMAP_ENABLED).texture(BLOCK_SHEET_MIPPED).transparency(TRANSLUCENT_TRANSPARENCY).target(TRANSLUCENT_TARGET).writeMask(COLOR_WRITE).build(true));

public RenderTypes() {
super(null, null, 0, 0, false, false, null, null);
Expand Down
Original file line number Diff line number Diff line change
@@ -1,19 +1,17 @@
package dev.itsmeow.whisperwoods.config;

import org.apache.commons.lang3.tuple.Pair;
import org.apache.logging.log4j.LogManager;
import org.apache.logging.log4j.Logger;

import dev.itsmeow.imdlib.entity.EntityRegistrarHandler.ClientEntityConfiguration;
import dev.itsmeow.imdlib.entity.EntityRegistrarHandler.ServerEntityConfiguration;
import dev.itsmeow.whisperwoods.WhisperwoodsMod;
import dev.itsmeow.whisperwoods.init.ModEntities;
import net.minecraftforge.common.ForgeConfigSpec;
import net.minecraftforge.event.world.BiomeLoadingEvent;
import net.minecraftforge.eventbus.api.SubscribeEvent;
import net.minecraftforge.fml.common.Mod;
import net.minecraftforge.fml.common.Mod.EventBusSubscriber;
import net.minecraftforge.fml.config.ModConfig;
import org.apache.commons.lang3.tuple.Pair;
import org.apache.logging.log4j.LogManager;
import org.apache.logging.log4j.Logger;

@Mod.EventBusSubscriber(modid = WhisperwoodsMod.MODID, bus = EventBusSubscriber.Bus.MOD)
public class WhisperwoodsConfig {
Expand Down Expand Up @@ -59,8 +57,4 @@ public static void onLoad(final ModConfig.Reloading configEvent) {
CLIENT_CONFIG.onLoad();
}
}

public static void onBiomeLoad(BiomeLoadingEvent event) {
SERVER_CONFIG.biomeLoad(event);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ public ILivingEntityData onInitialSpawn(IServerWorld world, DifficultyInstance d
}

@Override
public AgeableEntity func_241840_a(ServerWorld world, AgeableEntity ageable) {
public AgeableEntity createChild(ServerWorld world, AgeableEntity ageable) {
if(!(ageable instanceof IVariantTypes))
return null;
IVariantTypes<?> child = getBaseChild();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -56,11 +56,11 @@ public void setContainerData(ItemStack bucket) {
}

@Override
public ActionResultType func_230254_b_(PlayerEntity player, Hand hand) {
public ActionResultType getEntityInteractionResult(PlayerEntity player, Hand hand) {
if(this.processContainerInteract(player, hand)) {
return ActionResultType.SUCCESS;
}
return super.func_230254_b_(player, hand);
return super.getEntityInteractionResult(player, hand);
}

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,10 @@

import dev.itsmeow.imdlib.entity.util.EntityTypeContainer;
import dev.itsmeow.imdlib.entity.util.EntityVariant;
import dev.itsmeow.imdlib.util.BiomeDictionary.Type;
import dev.itsmeow.whisperwoods.WhisperwoodsMod;
import dev.itsmeow.whisperwoods.init.ModEntities;
import dev.itsmeow.whisperwoods.init.ModSounds;
import dev.itsmeow.whisperwoods.util.IOverrideCollisions;
import dev.itsmeow.whisperwoods.util.StopSpinningGroundPathNavigator;
import net.minecraft.block.TorchBlock;
import net.minecraft.enchantment.EnchantmentHelper;
import net.minecraft.entity.*;
Expand All @@ -22,10 +20,7 @@
import net.minecraft.network.datasync.DataParameter;
import net.minecraft.network.datasync.DataSerializers;
import net.minecraft.network.datasync.EntityDataManager;
import net.minecraft.pathfinding.PathFinder;
import net.minecraft.pathfinding.PathNavigator;
import net.minecraft.pathfinding.PathNodeType;
import net.minecraft.pathfinding.WalkNodeProcessor;
import net.minecraft.pathfinding.*;
import net.minecraft.tags.BlockTags;
import net.minecraft.util.*;
import net.minecraft.util.math.AxisAlignedBB;
Expand All @@ -38,6 +33,7 @@
import net.minecraft.world.World;
import net.minecraft.world.biome.Biome;
import net.minecraft.world.biome.Biomes;
import net.minecraftforge.common.BiomeDictionary;

import javax.annotation.Nullable;
import java.util.EnumSet;
Expand Down Expand Up @@ -303,9 +299,7 @@ public Vector3d transformMove(@Nullable Entity entity, Vector3d vec, AxisAligned
boolean flag1 = vec.y == 0.0D;
boolean flag2 = vec.z == 0.0D;
if((!flag || !flag1) && (!flag || !flag2) && (!flag1 || !flag2)) { // if moving somehow
ReuseableStream<VoxelShape> reusableStream = new ReuseableStream<>(Stream.concat(stream.createStream(), world.getCollisionShapes(entity, bb.expand(vec))).filter(shape -> {
return !world.getBlockState(new BlockPos(shape.getBoundingBox().minX, shape.getBoundingBox().minY, shape.getBoundingBox().minZ)).getBlock().isIn(BlockTags.LEAVES);
}));
ReuseableStream<VoxelShape> reusableStream = new ReuseableStream<>(Stream.concat(stream.createStream(), world.getBlockCollisionShapes(entity, bb.expand(vec))).filter(shape -> !world.getBlockState(new BlockPos(shape.getBoundingBox().minX, shape.getBoundingBox().minY, shape.getBoundingBox().minZ)).getBlock().isIn(BlockTags.LEAVES)));
return collideBoundingBox(vec, bb, reusableStream);
} else {
return getAllowedMovement(vec, bb, world, context, stream);
Expand Down Expand Up @@ -403,7 +397,7 @@ protected PathNavigator createNavigator(World world) {
return new HidebehindGroundNavigator(this, world);
}

public static class HidebehindGroundNavigator extends StopSpinningGroundPathNavigator {
public static class HidebehindGroundNavigator extends GroundPathNavigator {

public HidebehindGroundNavigator(MobEntity entityliving, World world) {
super(entityliving, world);
Expand All @@ -418,8 +412,8 @@ protected PathFinder getPathFinder(int i1) {

public static class HidebehindNodeProcessor extends WalkNodeProcessor {
@Override
protected PathNodeType func_215744_a(IBlockReader reader, boolean b1, boolean b2, BlockPos pos, PathNodeType typeIn) {
return typeIn == PathNodeType.LEAVES ? PathNodeType.OPEN : super.func_215744_a(reader, b1, b2, pos, typeIn);
protected PathNodeType refineNodeType(IBlockReader reader, boolean b1, boolean b2, BlockPos pos, PathNodeType typeIn) {
return typeIn == PathNodeType.LEAVES ? PathNodeType.OPEN : super.refineNodeType(reader, b1, b2, pos, typeIn);
}
}

Expand Down Expand Up @@ -473,14 +467,14 @@ public EntityTypeContainer<?> getContainer() {
}

@Override
public String[] getTypesFor(RegistryKey<Biome> biomeKey, Biome biome, Set<Type> types, SpawnReason reason) {
public String[] getTypesFor(RegistryKey<Biome> biomeKey, Biome biome, Set<BiomeDictionary.Type> types, SpawnReason reason) {
if(biomeKey == Biomes.GIANT_SPRUCE_TAIGA || biomeKey == Biomes.GIANT_SPRUCE_TAIGA_HILLS || biomeKey == Biomes.GIANT_TREE_TAIGA || biomeKey == Biomes.GIANT_TREE_TAIGA_HILLS) {
return new String[] { "mega_taiga", "mega_taiga", "mega_taiga", "darkforest" };
}
if(types.contains(Type.CONIFEROUS)) {
if(types.contains(BiomeDictionary.Type.CONIFEROUS)) {
return new String[] { "coniferous", "coniferous", "coniferous", "coniferous", "black", "darkforest" };
}
if(types.contains(Type.FOREST)) {
if(types.contains(BiomeDictionary.Type.FOREST)) {
return new String[] { "forest", "black", "darkforest" };
}
return new String[] { "black", "coniferous", "darkforest", "forest", "mega_taiga" };
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@
import dev.itsmeow.imdlib.entity.util.EntityTypeContainer;
import dev.itsmeow.whisperwoods.init.ModEntities;
import dev.itsmeow.whisperwoods.util.IOverrideCollisions;
import dev.itsmeow.whisperwoods.util.StopSpinningGroundPathNavigator;
import net.minecraft.block.Block;
import net.minecraft.block.BlockState;
import net.minecraft.entity.*;
Expand Down Expand Up @@ -86,13 +85,13 @@ public ILivingEntityData onInitialSpawn(IServerWorld worldIn, DifficultyInstance

@Override
protected PathNavigator createNavigator(World worldIn) {
return new StopSpinningGroundPathNavigator(this, worldIn) {
return new GroundPathNavigator(this, worldIn) {
@Override
protected PathFinder getPathFinder(int i1) {
this.nodeProcessor = new WalkNodeProcessor() {
@Override
protected PathNodeType func_215744_a(IBlockReader reader, boolean b1, boolean b2, BlockPos pos, PathNodeType typeIn) {
return typeIn == PathNodeType.LEAVES || reader.getBlockState(pos).getBlock().isIn(BlockTags.LOGS) || reader.getBlockState(pos).getBlock().isIn(BlockTags.LEAVES) ? PathNodeType.OPEN : super.func_215744_a(reader, b1, b2, pos, typeIn);
protected PathNodeType refineNodeType(IBlockReader reader, boolean b1, boolean b2, BlockPos pos, PathNodeType typeIn) {
return typeIn == PathNodeType.LEAVES || reader.getBlockState(pos).getBlock().isIn(BlockTags.LOGS) || reader.getBlockState(pos).getBlock().isIn(BlockTags.LEAVES) ? PathNodeType.OPEN : super.refineNodeType(reader, b1, b2, pos, typeIn);
}
};
this.nodeProcessor.setCanEnterDoors(true);
Expand Down Expand Up @@ -276,7 +275,7 @@ public Vector3d transformMove(@Nullable Entity entity, Vector3d vec, AxisAligned
boolean flag1 = vec.y == 0.0D;
boolean flag2 = vec.z == 0.0D;
if ((!flag || !flag1) && (!flag || !flag2) && (!flag1 || !flag2)) { // if moving somehow
ReuseableStream<VoxelShape> reusableStream = new ReuseableStream<>(Stream.concat(stream.createStream(), world.getCollisionShapes(entity, bb.expand(vec))).filter(shape -> {
ReuseableStream<VoxelShape> reusableStream = new ReuseableStream<>(Stream.concat(stream.createStream(), world.getBlockCollisionShapes(entity, bb.expand(vec))).filter(shape -> {
Block block = world.getBlockState(new BlockPos(shape.getBoundingBox().minX, shape.getBoundingBox().minY, shape.getBoundingBox().minZ)).getBlock();
return !block.isIn(BlockTags.LEAVES) && !block.isIn(BlockTags.LOGS);
}));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -288,7 +288,7 @@ public static void bottleTooltip(EntityTypeContainer<? extends MobEntity> contai
CompoundNBT tag = stack.getTag();
if(tag != null) {
if(tag.contains("SizeTag", Constants.NBT.TAG_FLOAT)) {
tooltip.add(new StringTextComponent("Size: " + tag.getFloat("SizeTag")).setStyle(Style.EMPTY.createStyleFromFormattings(new TextFormatting[] { TextFormatting.ITALIC, TextFormatting.GRAY })));
tooltip.add(new StringTextComponent("Size: " + tag.getFloat("SizeTag")).setStyle(Style.EMPTY.mergeWithFormatting(TextFormatting.ITALIC, TextFormatting.GRAY)));
}
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -356,7 +356,7 @@ public WispData(boolean isHostile, int colorVariant) {
}

@Override
public AgeableEntity func_241840_a(ServerWorld world, AgeableEntity ageable) {
public AgeableEntity createChild(ServerWorld world, AgeableEntity ageable) {
return null;
}

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

import dev.itsmeow.imdlib.entity.util.EntityTypeContainer;
import dev.itsmeow.whisperwoods.init.ModEntities;
import dev.itsmeow.whisperwoods.util.StopSpinningClimberPathNavigator;
import net.minecraft.enchantment.EnchantmentHelper;
import net.minecraft.entity.*;
import net.minecraft.entity.ai.attributes.Attributes;
Expand All @@ -18,6 +17,7 @@
import net.minecraft.network.datasync.DataSerializers;
import net.minecraft.network.datasync.EntityDataManager;
import net.minecraft.network.play.server.SSetPassengersPacket;
import net.minecraft.pathfinding.ClimberPathNavigator;
import net.minecraft.pathfinding.PathNavigator;
import net.minecraft.pathfinding.WalkAndSwimNodeProcessor;
import net.minecraft.potion.EffectInstance;
Expand Down Expand Up @@ -60,7 +60,7 @@ protected void registerGoals() {
}

protected PathNavigator createNavigator(World worldIn) {
return new StopSpinningClimberPathNavigator(this, worldIn);
return new ClimberPathNavigator(this, worldIn);
}

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,6 @@ public static void gatherData(GatherDataEvent event) {
event.getGenerator().addProvider(new WWItemModelProvider(event.getGenerator(), event.getExistingFileHelper()));
event.getGenerator().addProvider(new WWLootTableProvider(event.getGenerator()));
event.getGenerator().addProvider(new WWRecipeProvider(event.getGenerator()));
ModEntities.H.gatherData(event.getGenerator(), event.getExistingFileHelper());
}

public static class WWBlockTagsProvider extends BlockTagsProvider {
Expand Down
15 changes: 10 additions & 5 deletions src/main/java/dev/itsmeow/whisperwoods/init/ModEntities.java
Original file line number Diff line number Diff line change
@@ -1,9 +1,5 @@
package dev.itsmeow.whisperwoods.init;

import java.util.LinkedHashMap;
import java.util.function.Function;
import java.util.function.Supplier;

import dev.itsmeow.imdlib.IMDLib;
import dev.itsmeow.imdlib.entity.EntityRegistrarHandler;
import dev.itsmeow.imdlib.entity.util.EntityTypeContainer;
Expand All @@ -13,7 +9,6 @@
import dev.itsmeow.imdlib.entity.util.IContainable;
import dev.itsmeow.imdlib.item.IContainerItem;
import dev.itsmeow.imdlib.item.ItemModEntityContainer;
import dev.itsmeow.imdlib.util.BiomeDictionary.Type;
import dev.itsmeow.whisperwoods.WhisperwoodsMod;
import dev.itsmeow.whisperwoods.entity.*;
import dev.itsmeow.whisperwoods.entity.EntityHidebehind.HidebehindVariant;
Expand All @@ -26,7 +21,13 @@
import net.minecraft.item.Items;
import net.minecraft.world.Difficulty;
import net.minecraft.world.World;
import net.minecraftforge.common.BiomeDictionary.Type;
import net.minecraftforge.common.ForgeConfigSpec;
import net.minecraftforge.eventbus.api.IEventBus;

import java.util.LinkedHashMap;
import java.util.function.Function;
import java.util.function.Supplier;

public class ModEntities {

Expand Down Expand Up @@ -126,4 +127,8 @@ private static <T extends MobEntity> Builder<T> entity(Class<T> entityClass, Fun
private static <T extends MobEntity & IContainable, I extends Item & IContainerItem<T>> EntityTypeContainerContainable.Builder<T, I> entityContainable(Class<T> EntityClass, Function<World, T> func, String entityNameIn, Supplier<AttributeModifierMap.MutableAttribute> attributes) {
return EntityTypeContainerContainable.Builder.create(EntityClass, func, entityNameIn, attributes, WhisperwoodsMod.MODID);
}

public static void subscribe(IEventBus modBus) {
H.subscribe(modBus);
}
}
Loading

0 comments on commit daaeb97

Please sign in to comment.