Skip to content

Commit

Permalink
Backported 1.19.3 changes to 1.18.2
Browse files Browse the repository at this point in the history
  • Loading branch information
Majrusz committed Jan 23, 2023
1 parent 53a0f05 commit e08a446
Show file tree
Hide file tree
Showing 42 changed files with 126 additions and 145 deletions.
8 changes: 4 additions & 4 deletions build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -16,13 +16,13 @@ apply plugin: 'org.spongepowered.mixin'

version = '1.6.1'
group = 'com.majruszsdifficulty'
archivesBaseName = 'majruszs-difficulty-1.19.2'
archivesBaseName = 'majruszs-difficulty-1.18.2'

// Mojang ships Java 16 to end users in 1.17+ instead of Java 8 in 1.16 or lower, so your mod should target Java 16.
java.toolchain.languageVersion = JavaLanguageVersion.of(17)

minecraft {
mappings channel: 'official', version: '1.19.2'
mappings channel: 'official', version: '1.18.2'

accessTransformer = file( 'src/main/resources/META-INF/accesstransformer.cfg' ) // Currently, this location cannot be changed from the default.

Expand Down Expand Up @@ -76,8 +76,8 @@ repositories {
}

dependencies {
minecraft 'net.minecraftforge:forge:1.19.2-43.2.0'
implementation fg.deobf( 'com.mlib:majrusz-library-1.19.2:3.1.0' )
minecraft 'net.minecraftforge:forge:1.18.2-40.2.0'
implementation fg.deobf( 'com.mlib:majrusz-library-1.18.2:3.1.0' )
}

// Example for how to get properties into the manifest for reading at runtime.
Expand Down
Binary file not shown.
4 changes: 2 additions & 2 deletions src/main/java/com/majruszsdifficulty/GameStage.java
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

import com.mlib.levels.LevelHelper;
import net.minecraft.ChatFormatting;
import net.minecraft.network.chat.Component;
import net.minecraft.network.chat.*;
import net.minecraft.network.chat.MutableComponent;
import net.minecraft.server.MinecraftServer;
import net.minecraft.server.level.ServerPlayer;
Expand Down Expand Up @@ -111,7 +111,7 @@ public static MutableComponent withStyle( MutableComponent component ) {
}

private static MutableComponent constructGameStageText( String stage, ChatFormatting color ) {
return Component.translatable( "majruszsdifficulty.stages." + stage ).withStyle( color, ChatFormatting.BOLD );
return new TranslatableComponent( "majruszsdifficulty.stages." + stage ).withStyle( color, ChatFormatting.BOLD );
}

public enum Stage {
Expand Down
6 changes: 3 additions & 3 deletions src/main/java/com/majruszsdifficulty/MajruszsHelper.java
Original file line number Diff line number Diff line change
@@ -1,15 +1,15 @@
package com.majruszsdifficulty;

import net.minecraft.ChatFormatting;
import net.minecraft.network.chat.Component;
import net.minecraft.network.chat.*;
import net.minecraft.network.chat.MutableComponent;
import net.minecraft.world.item.TooltipFlag;

import java.util.List;

public class MajruszsHelper {
public static void addTranslatableText( List< Component > tooltip, String translationKey ) {
tooltip.add( Component.translatable( translationKey ).withStyle( ChatFormatting.GRAY ) );
tooltip.add( new TranslatableComponent( translationKey ).withStyle( ChatFormatting.GRAY ) );
}

public static void addTranslatableTexts( List< Component > tooltip, String... translationKeys ) {
Expand All @@ -32,6 +32,6 @@ public static void addAdvancedTranslatableTexts( List< Component > tooltip, Tool

/** Returns formatted text with information that item is disabled. */
public static MutableComponent getDisabledItemComponent() {
return Component.translatable( "majruszsdifficulty.items.disabled_tooltip" ).withStyle( ChatFormatting.RED, ChatFormatting.BOLD );
return new TranslatableComponent( "majruszsdifficulty.items.disabled_tooltip" ).withStyle( ChatFormatting.RED, ChatFormatting.BOLD );
}
}
12 changes: 5 additions & 7 deletions src/main/java/com/majruszsdifficulty/Registries.java
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@
import net.minecraftforge.common.ForgeSpawnEggItem;
import net.minecraftforge.common.MinecraftForge;
import net.minecraftforge.event.entity.EntityAttributeCreationEvent;
import net.minecraftforge.event.level.LevelEvent;
import net.minecraftforge.event.world.WorldEvent;
import net.minecraftforge.eventbus.api.IEventBus;
import net.minecraftforge.fml.ModLoadingContext;
import net.minecraftforge.fml.event.lifecycle.FMLClientSetupEvent;
Expand Down Expand Up @@ -124,7 +124,6 @@ public class Registries {
public static final RegistryObject< TreasureBagItem > ENDER_DRAGON_TREASURE_BAG = ITEMS.register( "ender_dragon_treasure_bag", TreasureBagItem.EnderDragon::new );
public static final RegistryObject< TreasureBagItem > FISHING_TREASURE_BAG = ITEMS.register( "fishing_treasure_bag", TreasureBagItem.Fishing::new );
public static final RegistryObject< TreasureBagItem > PILLAGER_TREASURE_BAG = ITEMS.register( "pillager_treasure_bag", TreasureBagItem.Pillager::new );
public static final RegistryObject< TreasureBagItem > WARDEN_TREASURE_BAG = ITEMS.register( "warden_treasure_bag", TreasureBagItem.Warden::new );

// Item Blocks
public static final RegistryObject< EndShardOre.EndShardOreItem > ENDERIUM_SHARD_ORE_ITEM = ITEMS.register( "enderium_shard_ore", EndShardOre.EndShardOreItem::new );
Expand Down Expand Up @@ -254,8 +253,8 @@ private static void setup( final FMLCommonSetupEvent event ) {
SpawnPlacements.register( CURSED_ARMOR.get(), SpawnPlacements.Type.ON_GROUND, Heightmap.Types.MOTION_BLOCKING_NO_LEAVES, CursedArmorEntity::checkMonsterSpawnRules );
}

public static void onLoadingLevel( LevelEvent.Load event ) {
ServerLevel level = getOverworld( event.getLevel() );
public static void onLoadingLevel( WorldEvent.Load event ) {
ServerLevel level = getOverworld( event.getWorld() );
if( level == null )
return;

Expand All @@ -266,11 +265,10 @@ public static void onLoadingLevel( LevelEvent.Load event ) {
TreasureBagManager.addTreasureBagTo( EntityType.ELDER_GUARDIAN, ELDER_GUARDIAN_TREASURE_BAG.get() );
TreasureBagManager.addTreasureBagTo( EntityType.WITHER, WITHER_TREASURE_BAG.get() );
TreasureBagManager.addTreasureBagTo( EntityType.ENDER_DRAGON, ENDER_DRAGON_TREASURE_BAG.get() );
TreasureBagManager.addTreasureBagTo( EntityType.WARDEN, WARDEN_TREASURE_BAG.get() );
}

public static void onSavingLevel( LevelEvent.Save event ) {
ServerLevel level = getOverworld( event.getLevel() );
public static void onSavingLevel( WorldEvent.Save event ) {
ServerLevel level = getOverworld( event.getWorld() );
if( level == null )
return;

Expand Down
4 changes: 4 additions & 0 deletions src/main/java/com/majruszsdifficulty/RegistriesClient.java
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
package com.majruszsdifficulty;

import com.majruszsdifficulty.gui.BleedingGui;
import com.majruszsdifficulty.items.EndShardLocatorItem;
import com.majruszsdifficulty.models.BlackWidowModel;
import com.majruszsdifficulty.models.CreeperlingModel;
Expand All @@ -18,6 +19,7 @@
import net.minecraftforge.api.distmarker.Dist;
import net.minecraftforge.api.distmarker.OnlyIn;
import net.minecraftforge.client.ForgeHooksClient;
import net.minecraftforge.client.gui.OverlayRegistry;

@OnlyIn( Dist.CLIENT )
public class RegistriesClient {
Expand All @@ -35,5 +37,7 @@ public static void setup() {
EntityRenderers.register( Registries.CURSED_ARMOR.get(), CursedArmorRenderer::new );

ItemProperties.register( Registries.ENDERIUM_SHARD_LOCATOR.get(), new ResourceLocation( "shard_distance" ), EndShardLocatorItem::calculateDistanceToEndShard );

OverlayRegistry.registerOverlayBottom( "bleeding", new BleedingGui.Overlay() );
}
}
7 changes: 3 additions & 4 deletions src/main/java/com/majruszsdifficulty/blocks/EndShardOre.java
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
import net.minecraft.world.item.enchantment.Enchantments;
import net.minecraft.world.level.block.Block;
import net.minecraft.world.level.block.SoundType;
import net.minecraft.world.level.block.state.BlockState;
import net.minecraft.world.level.material.Material;
import net.minecraft.world.level.material.MaterialColor;
import net.minecraftforge.fml.common.Mod;
Expand All @@ -25,10 +26,8 @@ public EndShardOre() {
}

@Override
protected void tryDropExperience( ServerLevel level, BlockPos position, ItemStack itemStack, IntProvider intProvider ) {
if( itemStack.getEnchantmentLevel( Enchantments.SILK_TOUCH ) == 0 ) {
this.popExperience( level, position, Random.nextInt( 6, 11 ) );
}
public int getExpDrop( BlockState state, net.minecraft.world.level.LevelReader reader, BlockPos pos, int fortune, int siltTouch ) {
return siltTouch == 0 ? Random.nextInt( 6, 11 ) : 0;
}

public static class EndShardOreItem extends BlockItem {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,8 +25,8 @@ public InfestedEndStone() {
}

@Override
public void spawnAfterBreak( BlockState state, ServerLevel worldIn, BlockPos pos, ItemStack stack, boolean p_221364_ ) {
super.spawnAfterBreak( state, worldIn, pos, stack, p_221364_ );
public void spawnAfterBreak( BlockState state, ServerLevel worldIn, BlockPos pos, ItemStack stack ) {
super.spawnAfterBreak( state, worldIn, pos, stack );

GameRules gameRules = worldIn.getGameRules();
if( gameRules.getBoolean( GameRules.RULE_DOBLOCKDROPS ) && EnchantmentHelper.getItemEnchantmentLevel( Enchantments.SILK_TOUCH, stack ) == 0 )
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
import com.mlib.commands.CommandData;
import com.mlib.levels.LevelHelper;
import com.mojang.brigadier.exceptions.CommandSyntaxException;
import net.minecraft.network.chat.Component;
import net.minecraft.network.chat.*;
import net.minecraft.network.chat.MutableComponent;
import net.minecraft.server.level.ServerLevel;
import net.minecraft.world.phys.Vec3;
Expand All @@ -32,19 +32,19 @@ private MutableComponent buildMessage( CommandData data ) throws CommandSyntaxEx
Vec3 position = this.getOptionalEntityOrPlayer( data ).position();
String total = String.format( "%.2f", GameStage.getRegionalDifficulty( level, position ) );

return Component.translatable( "commands.clampedregionaldifficulty", asVec3i( position ), this.withStageStyle( total ), this.buildFormula( level, position ) );
return new TranslatableComponent( "commands.clampedregionaldifficulty", asVec3i( position ), this.withStageStyle( total ), this.buildFormula( level, position ) );
}

private MutableComponent buildFormula( ServerLevel level, Vec3 position ) {
if( GameStage.getCurrentStage() == GameStage.Stage.NORMAL )
return Component.literal( "" );
return new TextComponent( "" );

String crd = String.format( "%.2f", LevelHelper.getClampedRegionalDifficulty( level, position ) );
String stageModifier = String.format( "%.2f", GameStage.getStageModifier() );
return Component.translatable( "commands.clampedregionaldifficulty.formula", crd, this.withStageStyle( stageModifier ) );
return new TranslatableComponent( "commands.clampedregionaldifficulty.formula", crd, this.withStageStyle( stageModifier ) );
}

private MutableComponent withStageStyle( String text ) {
return GameStage.withStyle( Component.literal( text ) );
return GameStage.withStyle( new TextComponent( text ) );
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -2,13 +2,13 @@

import com.majruszsdifficulty.GameStage;
import com.mlib.commands.Command;
import net.minecraft.network.chat.Component;
import net.minecraft.network.chat.*;
import net.minecraft.network.chat.MutableComponent;
import net.minecraft.world.phys.Vec3;

public class DifficultyCommand extends Command {
protected static MutableComponent createGameStageMessage( GameStage.Stage stage, String translationKey ) {
return Component.translatable( "commands.gamestage." + translationKey, GameStage.getGameStageText( stage ) );
return new TranslatableComponent( "commands.gamestage." + translationKey, GameStage.getGameStageText( stage ) );
}

protected static String asVec3i( Vec3 position ) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
import com.mlib.annotations.AutoInstance;
import com.mlib.commands.CommandData;
import com.mojang.brigadier.exceptions.CommandSyntaxException;
import net.minecraft.network.chat.Component;
import net.minecraft.network.chat.*;
import net.minecraft.world.entity.player.Player;

@AutoInstance
Expand All @@ -25,7 +25,7 @@ private int handle( CommandData data ) throws CommandSyntaxException {
Player player = Utility.castIfPossible( Player.class, this.getOptionalEntityOrPlayer( data ) );
if( player != null ) {
LootProgressManager.cleanProgress( player );
data.source.sendSuccess( Component.translatable( "commands.treasurebag.reset", player.getName() ), true );
data.source.sendSuccess( new TranslatableComponent( "commands.treasurebag.reset", player.getName() ), true );
return 0;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
import com.mlib.commands.CommandData;
import com.mojang.brigadier.exceptions.CommandSyntaxException;
import net.minecraft.core.BlockPos;
import net.minecraft.network.chat.Component;
import net.minecraft.network.chat.*;
import net.minecraft.world.phys.Vec3;

import java.util.function.BiFunction;
Expand All @@ -29,7 +29,7 @@ public UndeadArmyCommand( String command, BiFunction< UndeadArmy, Vec3, Componen
public UndeadArmyCommand( String command, String successId, Consumer< UndeadArmy > consumer ) {
this( command, ( undeadArmy, position )->{
consumer.accept( undeadArmy );
return Component.translatable( "commands.undeadarmy." + successId, asVec3i( position ) );
return new TranslatableComponent( "commands.undeadarmy." + successId, asVec3i( position ) );
} );
}

Expand All @@ -41,7 +41,7 @@ private int handle( CommandData data ) throws CommandSyntaxException {
return 0;
}

data.source.sendSuccess( Component.translatable( "commands.undeadarmy.missing", asVec3i( position ) ), true );
data.source.sendSuccess( new TranslatableComponent( "commands.undeadarmy.missing", asVec3i( position ) ), true );
return -1;
}
}
Original file line number Diff line number Diff line change
@@ -1,14 +1,14 @@
package com.majruszsdifficulty.commands;

import com.mlib.annotations.AutoInstance;
import net.minecraft.network.chat.Component;
import net.minecraft.network.chat.*;

@AutoInstance
public class UndeadArmyMobsLeftCommand extends UndeadArmyCommand {
public UndeadArmyMobsLeftCommand() {
super( "undeadleft", ( undeadArmy, position )->{
int mobsLeft = undeadArmy.countMobsLeft();
return Component.translatable( "commands.undeadarmy.undeadleft", asVec3i( position ), mobsLeft );
return new TranslatableComponent( "commands.undeadarmy.undeadleft", asVec3i( position ), mobsLeft );
} );
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
import com.mlib.commands.CommandData;
import com.mlib.nbt.NBTHelper;
import com.mojang.brigadier.exceptions.CommandSyntaxException;
import net.minecraft.network.chat.Component;
import net.minecraft.network.chat.*;
import net.minecraft.world.entity.LivingEntity;

@AutoInstance
Expand All @@ -27,7 +27,7 @@ private int handle( CommandData data ) throws CommandSyntaxException {
int undeadKilled = undeadKilledData.get();
int undeadKilledMax = UndeadArmyConfig.getRequiredKills();

data.source.sendSuccess( Component.translatable( "commands.undeadarmy.progress", entity.getName(), undeadKilled, undeadKilledMax ), true );
data.source.sendSuccess( new TranslatableComponent( "commands.undeadarmy.progress", entity.getName(), undeadKilled, undeadKilledMax ), true );
return 0;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
import com.mlib.commands.CommandData;
import com.mojang.brigadier.exceptions.CommandSyntaxException;
import net.minecraft.core.BlockPos;
import net.minecraft.network.chat.Component;
import net.minecraft.network.chat.*;
import net.minecraft.world.phys.Vec3;

import java.util.Optional;
Expand All @@ -29,11 +29,11 @@ private int handle( CommandData data ) throws CommandSyntaxException {
Optional< Direction > direction = this.getOptionalEnumeration( data, Direction.class );
Vec3 position = this.getOptionalEntityOrPlayer( data ).position();
if( Registries.UNDEAD_ARMY_MANAGER.tryToSpawn( new BlockPos( position ), direction ) ) {
data.source.sendSuccess( Component.translatable( "commands.undeadarmy.started", asVec3i( position ) ), true );
data.source.sendSuccess( new TranslatableComponent( "commands.undeadarmy.started", asVec3i( position ) ), true );
return 0;
}

data.source.sendSuccess( Component.translatable( "commands.undeadarmy.cannot_start", asVec3i( position ) ), true );
data.source.sendSuccess( new TranslatableComponent( "commands.undeadarmy.cannot_start", asVec3i( position ) ), true );
return -1;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
import com.mlib.text.TextHelper;
import net.minecraft.ChatFormatting;
import net.minecraft.client.Minecraft;
import net.minecraft.network.chat.Component;
import net.minecraft.network.chat.*;
import net.minecraft.server.level.ServerLevel;
import net.minecraft.world.damagesource.DamageSource;
import net.minecraft.world.effect.MobEffect;
Expand Down Expand Up @@ -216,7 +216,7 @@ private void addChanceTooltip( OnItemAttributeTooltip.Data data ) {
continue;

String multiplier = TextHelper.minPrecision( GET_ARMOR_MULTIPLIER.apply( slot ) );
data.add( slot, Component.translatable( ATTRIBUTE_ID, multiplier ).withStyle( ChatFormatting.BLUE ) );
data.add( slot, new TranslatableComponent( ATTRIBUTE_ID, multiplier ).withStyle( ChatFormatting.BLUE ) );
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,12 +11,13 @@
import com.mlib.gamemodifiers.contexts.OnItemTooltip;
import com.mlib.math.Range;
import net.minecraft.ChatFormatting;
import net.minecraft.network.chat.Component;
import net.minecraft.network.chat.*;
import net.minecraft.sounds.SoundEvent;
import net.minecraft.world.entity.*;
import net.minecraft.world.entity.ai.attributes.AttributeSupplier;
import net.minecraft.world.entity.ai.attributes.Attributes;
import net.minecraft.world.entity.monster.Spider;
import net.minecraft.world.entity.player.Player;
import net.minecraft.world.level.Level;
import net.minecraft.world.level.block.Blocks;

Expand All @@ -42,7 +43,7 @@ public BlackWidowEntity( EntityType< ? extends BlackWidowEntity > type, Level wo
}

@Override
public int getExperienceReward() {
public int getExperienceReward( Player player ) {
return Random.nextInt( 3 );
}

Expand Down Expand Up @@ -101,7 +102,7 @@ public TempTooltip() {
}

private void addTooltip( OnItemTooltip.Data data ) {
data.tooltip.add( Component.literal( "This mob is not finished yet, coming soon in the next major update!" )
data.tooltip.add( new TextComponent( "This mob is not finished yet, coming soon in the next major update!" )
.withStyle( ChatFormatting.RED ) );
}
}
Expand Down
Loading

0 comments on commit e08a446

Please sign in to comment.