Skip to content

Commit

Permalink
Remove old and unused pams integration code (#10614)
Browse files Browse the repository at this point in the history
Remove old and unused pams integration code
  • Loading branch information
Raycoms committed Jan 27, 2025
1 parent df093b4 commit 660ed0b
Show file tree
Hide file tree
Showing 5 changed files with 14 additions and 76 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -15,14 +15,11 @@
import net.minecraft.world.level.LevelAccessor;
import net.minecraft.world.level.block.Block;
import net.minecraft.world.level.block.state.BlockState;
import net.neoforged.fml.ModList;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;

import java.util.List;

import static com.minecolonies.api.util.constant.Constants.HARVESTCRAFTMODID;

/**
* This class is to store the methods that call the methods to check for miscellaneous compatibility problems.
*/
Expand Down Expand Up @@ -147,16 +144,6 @@ public static int getToolLevel(@NotNull final ItemStack stack)
return tinkersCompat.getToolLevel(stack);
}

/**
* Check if Pams harvestcraft is installed.
*
* @return true if so.
*/
public static boolean isPamsInstalled()
{
return ModList.get().isLoaded(HARVESTCRAFTMODID);
}

/**
* Check if dynamic tree's is present
*
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@
public final class Constants
{
public static final String MOD_ID = "minecolonies";
public static final String HARVESTCRAFTMODID = "harvestcraft";
public static final int CITIZEN_RESPAWN_INTERVAL_MIN = 10;
public static final int CITIZEN_RESPAWN_INTERVAL_MAX = 600;
public static final int MAX_BUILDING_LEVEL = 5;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

import com.ldtteam.blockui.Pane;
import com.ldtteam.blockui.PaneBuilders;
import com.ldtteam.blockui.controls.AbstractTextBuilder;
import com.ldtteam.blockui.controls.Button;
import com.ldtteam.blockui.controls.ButtonImage;
import com.ldtteam.blockui.controls.Text;
Expand Down Expand Up @@ -282,18 +283,17 @@ public void onUpdate()
textPane.show();
}

PaneBuilders.tooltipBuilder().hoverPane(textPane).append(Component.translatableEscape("com.minecolonies.core.townhall.patreon.textures"))
.paragraphBreak()
.appendNL(Component.empty())
.appendNL(Component.translatableEscape("com.minecolonies.core.townhall.patreon"))
.paragraphBreak()
.build();

PaneBuilders.tooltipBuilder().hoverPane(namePane)
.append(Component.translatableEscape("com.minecolonies.core.townhall.patreon.names")).paragraphBreak()
.appendNL(Component.empty())
.appendNL(Component.translatableEscape("com.minecolonies.core.townhall.patreon")).paragraphBreak()
.build();
final AbstractTextBuilder.TooltipBuilder textPaneToolTipBuilder = PaneBuilders.tooltipBuilder().hoverPane(textPane).append(Component.translatable("com.minecolonies.core.townhall.patreon.textures"))
.paragraphBreak()
.appendNL(Component.empty())
.appendNL(Component.translatable("com.minecolonies.core.townhall.patreon"))
.paragraphBreak();


final AbstractTextBuilder.TooltipBuilder namePaneToolTipBuilder = PaneBuilders.tooltipBuilder().hoverPane(namePane)
.append(Component.translatable("com.minecolonies.core.townhall.patreon.names")).paragraphBreak()
.appendNL(Component.empty())
.appendNL(Component.translatable("com.minecolonies.core.townhall.patreon")).paragraphBreak();

if (isFeatureUnlocked.get() && !isOwner)
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -645,15 +645,6 @@ private boolean harvestIfAble(BlockPos position)
position = findHarvestableSurface(position);
if (position != null)
{
if (Compatibility.isPamsInstalled())
{
worker.getCitizenExperienceHandler().addExperience(XP_PER_HARVEST);
harvestCrop(position.above());
worker.getCitizenColonyHandler().getColonyOrRegister().getStatisticsManager().increment(CROPS_HARVESTED, worker.getCitizenColonyHandler().getColonyOrRegister().getDay());

return true;
}

if (mineBlock(position.above()))
{
worker.getCitizenColonyHandler().getColonyOrRegister().getStatisticsManager().increment(CROPS_HARVESTED, worker.getCitizenColonyHandler().getColonyOrRegister().getDay());
Expand Down Expand Up @@ -876,45 +867,6 @@ public int getBreakSpeedLevel()
return getSecondarySkillLevel();
}

/**
* Harvest the crop (only if pams is installed).
*
* @param pos the position to harvest.
*/
private void harvestCrop(@NotNull final BlockPos pos)
{
final ItemStack tool = worker.getMainHandItem();

final int fortune = ItemStackUtils.getFortuneOf(tool, world);
final BlockState state = world.getBlockState(pos);

final double chance = worker.getCitizenColonyHandler().getColonyOrRegister().getResearchManager().getResearchEffects().getEffectStrength(FARMING);

final NonNullList<ItemStack> drops = NonNullList.create();
state.getDrops(new LootParams.Builder((ServerLevel) world).withLuck(fortune)
.withLuck(fortune)
.withParameter(LootContextParams.ORIGIN, worker.position())
.withParameter(LootContextParams.TOOL, tool)
.withParameter(LootContextParams.THIS_ENTITY, getCitizen()));
for (final ItemStack item : drops)
{
final ItemStack drop = item.copy();
if (worker.getRandom().nextDouble() < chance)
{
drop.setCount(drop.getCount() * 2);
}
InventoryUtils.addItemStackToItemHandler(worker.getInventoryCitizen(), drop);
}

if (state.getBlock() instanceof final CropBlock crops)
{
world.setBlockAndUpdate(pos, crops.getStateForAge(0));
}

this.incrementActionsDone();
worker.decreaseSaturationForContinuousAction();
}

/**
* Get's the slot in which the hoe is in.
*
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -110,10 +110,10 @@ public void tick()

fasterBreakPerXNearby /= 2;
breakChance = (int) Math.max(1,
hardness / (1 + (mob.level.getEntitiesOfClass(AbstractEntityMinecoloniesRaider.class, mob.getBoundingBox().inflate(5)).size() / fasterBreakPerXNearby)));
hardness / (1 + (mob.level().getEntitiesOfClass(AbstractEntityMinecoloniesRaider.class, mob.getBoundingBox().inflate(5)).size() / fasterBreakPerXNearby)));

// Alert nearby guards
if (this.mob.getRandom().nextInt(breakChance) == 0 && mob instanceof AbstractEntityMinecoloniesRaider raider && mob.level.getBlockState(doorPos)
if (this.mob.getRandom().nextInt(breakChance) == 0 && mob instanceof AbstractEntityMinecoloniesRaider raider && mob.level().getBlockState(doorPos)
.getBlock() instanceof AbstractBlockGate)
{
// Alerts guards of raiders reaching a building
Expand Down

0 comments on commit 660ed0b

Please sign in to comment.