Skip to content

Commit

Permalink
Merge branch 'version/main' into pathdebug
Browse files Browse the repository at this point in the history
  • Loading branch information
someaddons authored Nov 2, 2024
2 parents ee29c27 + c11e5d6 commit f20b9ab
Show file tree
Hide file tree
Showing 485 changed files with 83 additions and 116 deletions.
3 changes: 1 addition & 2 deletions gradle.properties
Original file line number Diff line number Diff line change
Expand Up @@ -93,7 +93,6 @@ usesSonarQube=true

usesCrowdInTranslationManagement=true
crowdInDownloadDirectory=src/main/resources/assets/minecolonies/lang
usesCrowdInBuildingWithFilteredBranches=true
usesCrowdInUploadWithFilteredBranches=true
usesCrowdInUploadWithFilteredBranchesSpec=(version|release)\/.+

additionalModsInDataGen=structurize;domum_ornamentum
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,6 @@
import com.minecolonies.api.util.*;
import it.unimi.dsi.fastutil.objects.Object2IntLinkedOpenHashMap;
import net.minecraft.client.multiplayer.ClientLevel;
import net.minecraft.core.BlockPos;
import net.minecraft.core.registries.BuiltInRegistries;
import net.minecraft.nbt.CompoundTag;
import net.minecraft.nbt.ListTag;
Expand All @@ -31,7 +30,6 @@
import net.minecraft.world.item.*;
import net.minecraft.world.item.crafting.RecipeManager;
import net.minecraft.world.level.Level;
import net.minecraft.world.level.block.AirBlock;
import net.minecraft.world.level.block.Block;
import net.minecraft.world.level.block.Blocks;
import net.minecraft.world.level.block.entity.FurnaceBlockEntity;
Expand Down Expand Up @@ -144,16 +142,6 @@ public class CompatibilityManager implements ICompatibilityManager
*/
private static ImmutableList<ItemStack> allItems = ImmutableList.of();

/**
* Free block positions everyone can interact with.
*/
private final Set<Block> freeBlocks = new HashSet<>();

/**
* Free positions everyone can interact with.
*/
private final Set<BlockPos> freePositions = new HashSet<>();

/**
* Hashmap of mobs we may or may not attack.
*/
Expand Down Expand Up @@ -191,8 +179,6 @@ private void clear()
recruitmentCostsWeights.clear();
diseases.clear();
diseaseList.clear();
freeBlocks.clear();
freePositions.clear();
monsters = ImmutableSet.of();
creativeModeTabMap.clear();
}
Expand All @@ -211,7 +197,6 @@ public void discover(@NotNull final RecipeManager recipeManager, final Level lev
discoverLuckyOres();
discoverRecruitCosts();
discoverDiseases();
discoverFreeBlocksAndPos();
discoverModCompat();

discoverCompostRecipes(recipeManager);
Expand Down Expand Up @@ -268,7 +253,6 @@ public void deserialize(@NotNull final FriendlyByteBuf buf, final ClientLevel le
discoverLuckyOres();
discoverRecruitCosts();
discoverDiseases();
discoverFreeBlocksAndPos();
discoverModCompat();
}

Expand Down Expand Up @@ -586,18 +570,6 @@ public ItemStack getRandomLuckyOre(final double chanceBonus, final int buildingL
return ItemStack.EMPTY;
}

@Override
public boolean isFreeBlock(final Block block)
{
return freeBlocks.contains(block);
}

@Override
public boolean isFreePos(final BlockPos block)
{
return freePositions.contains(block);
}

@Override
public CreativeModeTab getCreativeTab(final ItemStorage checkItem)
{
Expand Down Expand Up @@ -988,32 +960,6 @@ private static Tuple<BlockState, ItemStorage> readLeafSaplingEntryFromNBT(final
return new Tuple<>(NbtUtils.readBlockState(BuiltInRegistries.BLOCK.asLookup(), compound), new ItemStorage(ItemStack.of(compound), false, true));
}

/**
* Load free blocks and pos from the config and add to colony.
*/
private void discoverFreeBlocksAndPos()
{
for (final String s : MinecoloniesAPIProxy.getInstance().getConfig().getServer().freeToInteractBlocks.get())
{
try
{
final Block block = ForgeRegistries.BLOCKS.getValue(new ResourceLocation(s));
if (block != null && !(block instanceof AirBlock))
{
freeBlocks.add(block);
}
}
catch (final Exception ex)
{
final BlockPos pos = BlockPosUtil.getBlockPosOfString(s);
if (pos != null)
{
freePositions.add(pos);
}
}
}
}

/**
* Inits compats
*/
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@
import com.minecolonies.api.util.Disease;
import com.minecolonies.api.util.Tuple;
import net.minecraft.client.multiplayer.ClientLevel;
import net.minecraft.core.BlockPos;
import net.minecraft.nbt.CompoundTag;
import net.minecraft.network.FriendlyByteBuf;
import net.minecraft.resources.ResourceLocation;
Expand Down Expand Up @@ -247,20 +246,6 @@ public interface ICompatibilityManager
*/
ItemStack getRandomLuckyOre(final double chanceBonus, final int buildingLevel);

/**
* Check if the block is configured to bypass the colony restrictions.
* @param block the block to check.
* @return true if so.
*/
boolean isFreeBlock(Block block);

/**
* Check if the position is configured to bypass the colony restrictions.
* @param block the position to check.
* @return true if so.
*/
boolean isFreePos(BlockPos block);

/**
* Get the creative tab for a stack.
* @param checkItem the storage wrapper.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -91,7 +91,6 @@ public class ServerConfiguration extends AbstractConfiguration

public final ForgeConfigSpec.BooleanValue enableColonyProtection;
public final ForgeConfigSpec.EnumValue<Explosions> turnOffExplosionsInColonies;
public final ForgeConfigSpec.ConfigValue<List<? extends String>> freeToInteractBlocks;

/* -------------------------------------------------------------------------------- *
* ------------------- ######## Compatibility Settings ######## ------------------- *
Expand Down Expand Up @@ -192,11 +191,6 @@ protected ServerConfiguration(final ForgeConfigSpec.Builder builder)

enableColonyProtection = defineBoolean(builder, "enablecolonyprotection", true);
turnOffExplosionsInColonies = defineEnum(builder, "turnoffexplosionsincolonies", Explosions.DAMAGE_ENTITIES);
freeToInteractBlocks = defineList(builder, "freetointeractblocks",
Arrays.asList
("dirt",
"0 0 0"),
s -> s instanceof String);

swapToCategory(builder, "compatibility");

Expand Down
2 changes: 2 additions & 0 deletions src/main/java/com/minecolonies/api/util/ShapeUtil.java
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ public static double max(final VoxelShape shape, final Direction.Axis axis)
return 1.0;
}

// Note: in vanilla this is -infinity
if (shape == Shapes.empty())
{
return 0;
Expand All @@ -45,6 +46,7 @@ public static double min(final VoxelShape shape, final Direction.Axis axis)
return 0.0;
}

// Note: in vanilla this is +infinity
if (shape == Shapes.empty())
{
return 0;
Expand Down
7 changes: 6 additions & 1 deletion src/main/java/com/minecolonies/core/colony/CitizenData.java
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
package com.minecolonies.core.colony;

import com.minecolonies.api.IMinecoloniesAPI;
import com.minecolonies.api.MinecoloniesAPIProxy;
import com.minecolonies.api.colony.CitizenNameFile;
import com.minecolonies.api.colony.ICitizenData;
Expand Down Expand Up @@ -497,8 +498,12 @@ public void initForNewCivilian()
textureId = random.nextInt(255);

saturation = MAX_SATURATION;
final int levelCap = (int) colony.getOverallHappiness();

int levelCap = (int) colony.getOverallHappiness() * 2;
if (colony.getCitizenManager().getCitizens().size() < IMinecoloniesAPI.getInstance().getConfig().getServer().initialCitizenAmount.get())
{
levelCap = Math.max(5, levelCap);
}
citizenSkillHandler.init(levelCap);

markDirty(0);
Expand Down
4 changes: 2 additions & 2 deletions src/main/java/com/minecolonies/core/colony/Colony.java
Original file line number Diff line number Diff line change
Expand Up @@ -1891,8 +1891,8 @@ public void setTextureStyle(final String style)
public String getTextureStyleId()
{
if (MineColonies.getConfig().getServer().holidayFeatures.get() &&
(LocalDateTime.now().getDayOfMonth() >= 29 && LocalDateTime.now().getMonth() == Month.OCTOBER)
|| (LocalDateTime.now().getDayOfMonth() <= 2 && LocalDateTime.now().getMonth() == Month.NOVEMBER))
((LocalDateTime.now().getDayOfMonth() >= 29 && LocalDateTime.now().getMonth() == Month.OCTOBER)
|| (LocalDateTime.now().getDayOfMonth() <= 2 && LocalDateTime.now().getMonth() == Month.NOVEMBER)))
{
return "nether";
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -417,7 +417,7 @@ public void on(final PlayerInteractEvent event)
*/
private boolean isFreeToInteractWith(@Nullable final Block block, final BlockPos pos)
{
return (block != null && (IColonyManager.getInstance().getCompatibilityManager().isFreeBlock(block) || colony.getFreeBlocks().contains(block) || block.defaultBlockState().is(ModTags.colonyProtectionException))) || colony.getFreePositions().contains(pos) || IColonyManager.getInstance().getCompatibilityManager().isFreePos(pos);
return (block != null && (colony.getFreeBlocks().contains(block) || block.defaultBlockState().is(ModTags.colonyProtectionException))) || colony.getFreePositions().contains(pos);
}

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

import com.minecolonies.api.colony.IColony;
import com.minecolonies.api.colony.IColonyManager;
import com.minecolonies.api.colony.buildings.IBuilding;
import com.minecolonies.api.util.Log;
import com.minecolonies.core.colony.events.raid.RaidManager;
import com.minecolonies.core.commands.commandTypes.IMCCommand;
Expand Down Expand Up @@ -83,16 +84,24 @@ public int onExecute(final CommandContext<CommandSourceStack> context)
context.getSource().sendSuccess(() -> literalAndRemember(last.toString()), false);
}

if (colony.getBuildingManager().getBuildings().size() > 0)
if (!colony.getBuildingManager().getBuildings().isEmpty())
{
int count = 0;
int levels = 0;

for (final IBuilding building : colony.getBuildingManager().getBuildings().values())
{
if (building.getBuildingLevel() != 0)
{
count++;
levels += building.getBuildingLevel();
}
}

final double average = (double) levels / count;

context.getSource()
.sendSuccess(() -> literalAndRemember("Buildings:" + colony.getBuildingManager().getBuildings().size() + " average level:" + colony.getBuildingManager()
.getBuildings()
.values()
.stream()
.filter(iBuilding -> iBuilding.getBuildingLevel() != 0)
.collect(
Collectors.summingInt(ibuilding -> ibuilding.getBuildingLevel())) / colony.getBuildingManager().getBuildings().size()), false);
.sendSuccess(() -> literalAndRemember("Buildings:" + colony.getBuildingManager().getBuildings().size() + " average level:" + average), false);
context.getSource()
.sendSuccess(() -> literalAndRemember(colony.getBuildingManager()
.getBuildings()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -372,7 +372,7 @@ private void initTasks()
int priority = 0;
this.goalSelector.addGoal(priority, new EntityAIFloat(this));
this.goalSelector.addGoal(priority, new EntityAIInteractToggleAble(this, FENCE_TOGGLE, TRAP_TOGGLE, DOOR_TOGGLE));
this.goalSelector.addGoal(++priority, new LookAtEntityInteractGoal(this, Player.class, WATCH_CLOSEST2, 1.0F));
this.goalSelector.addGoal(++priority, new LookAtEntityInteractGoal(this, Player.class, WATCH_CLOSEST2, 0.2F));
this.goalSelector.addGoal(++priority, new LookAtEntityInteractGoal(this, EntityCitizen.class, WATCH_CLOSEST2_FAR, WATCH_CLOSEST2_FAR_CHANCE));
this.goalSelector.addGoal(++priority, new LookAtEntityGoal(this, LivingEntity.class, WATCH_CLOSEST));
}
Expand Down Expand Up @@ -1316,10 +1316,12 @@ public boolean hurt(@NotNull final DamageSource damageSource, final float damage
Log.getLogger().warn("Error while saving:", e);
}

final RemovalReason removalReason = getRemovalReason();

Log.getLogger()
.warn("Entity:" + getName().toString() + " uuid:" + getUUID() + " id:" + getId() + " removed:" + isRemoved() + " colonyid:" + citizenColonyHandler.getColonyId()
.warn("Entity:" + getName() + " uuid:" + getUUID() + " id:" + getId() + " removed:" + isRemoved() + " colonyid:" + citizenColonyHandler.getColonyId()
+ " entitydata colony id:" + getEntityData().get(DATA_COLONY_ID) + " hascolony:" + (citizenColonyHandler.getColony() != null) +
" registered:" + citizenColonyHandler.registered() + " world:" + level + " saved data:" + tag);
" registered:" + citizenColonyHandler.registered() + " world:" + level + " saved data:" + tag + " removalReason: " + removalReason);
}

if (handleInWallDamage(damageSource))
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,14 @@ public class CitizenSkillHandler implements ICitizenSkillHandler
*/
public Map<Skill, SkillData> skillMap = new EnumMap<>(Skill.class);

public CitizenSkillHandler()
{
for (final Skill skill : Skill.values())
{
skillMap.put(skill, new SkillData(1, 0.0D));
}
}

@Override
public void init(final int levelCap)
{
Expand Down
Loading

0 comments on commit f20b9ab

Please sign in to comment.