Skip to content

Commit 022361c

Browse files
committed
Update to 1.20.6 stable and account for breaking changes
1 parent 8e4d817 commit 022361c

File tree

12 files changed

+145
-57
lines changed

12 files changed

+145
-57
lines changed

build.gradle

Lines changed: 21 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ plugins {
2020
id('eclipse')
2121
id('idea')
2222
id('maven-publish')
23-
id('net.neoforged.gradle.userdev') version('7.0.138')//https://projects.neoforged.net/neoforged/neogradle
23+
id('net.neoforged.gradle.userdev') version('7.0.142')//https://projects.neoforged.net/neoforged/neogradle
2424
}
2525

2626
tasks.named('wrapper', Wrapper).configure {
@@ -157,7 +157,7 @@ SourceSet setupExtraSourceSet(SourceSet baseSourceSet, String extra) {
157157
extraSourceSet.compileClasspath += project.sourceSets.main.output
158158
if (baseSourceSet != project.sourceSets.main) {
159159
//If the base sourceSet is main it already is the extra source set and has a reference to the base one from before this if statement
160-
extraSourceSet.compileClasspath += getExtraSourceSet(project.sourceSets.main, extra).output
160+
extraSourceSet.compileClasspath += getExtraSourceSet(project.sourceSets.main, extra).get().output
161161
extraSourceSet.compileClasspath += baseSourceSet.output
162162
extraSourceSet.runs.modIdentifier = name
163163
}
@@ -170,12 +170,12 @@ static void extendConfigurations(Configuration base, Configuration... configurat
170170
}
171171
}
172172

173-
SourceSet getExtraSourceSet(String base, String name) {
174-
return getExtraSourceSet(project.sourceSets.named(base).get(), name)
173+
Provider<SourceSet> getExtraSourceSet(String base, String name) {
174+
return project.sourceSets.named(base).flatMap(sourceSet -> getExtraSourceSet(sourceSet, name))
175175
}
176176

177-
SourceSet getExtraSourceSet(SourceSet base, String name) {
178-
return project.sourceSets.named(base.getTaskName(name, null)).get()
177+
Provider<SourceSet> getExtraSourceSet(SourceSet base, String name) {
178+
return project.sourceSets.named(base.getTaskName(name, null))
179179
}
180180

181181
setupTasks(sourceSets.main)
@@ -205,7 +205,7 @@ def setupTasks(SourceSet sourceSet) {
205205
}
206206
tasks.named(sourceSet.compileJavaTaskName, JavaCompile).configure { setGroup('compile') }
207207
for (String extraType : extraTypes) {
208-
def extraSourceSet = getExtraSourceSet(sourceSet, extraType)
208+
def extraSourceSet = getExtraSourceSet(sourceSet, extraType).get()
209209
tasks.named(extraSourceSet.processResourcesTaskName, ProcessResources).configure {
210210
setGroup('process resources')
211211
dependsOn(compileTask)
@@ -267,22 +267,22 @@ static void setupClientAcc(Run run) {
267267
}
268268

269269
runs {
270-
configureEach { Run run ->
271-
if (run.project.hasProperty('forge_force_ansi')) {
270+
configureEach {
271+
if (hasProperty('forge_force_ansi')) {
272272
//Force ansi if declared as a gradle variable, as the auto detection doesn't detect IntelliJ properly
273273
// or eclipse's plugin that adds support for ansi escape in console
274-
run.jvmArguments.add("-Dterminal.ansi=${run.project.property('forge_force_ansi')}")
274+
jvmArguments.add("-Dterminal.ansi=${property('forge_force_ansi')}")
275275
}
276276

277-
run.modSources.addAll((SourceSet[]) [sourceSets.main, sourceSets.api])
277+
modSources.add((SourceSet[]) [sourceSets.main, sourceSets.api])
278278

279279
for (String name : secondaryModules) {
280-
run.modSources.add((SourceSet) sourceSets.getByName(name))
280+
modSources.add((SourceSet) sourceSets.named(name).get())
281281
}
282282

283283
//if the selected toolchain is a JBR, enable DCEVM
284-
if (run.project.javaToolchains.launcherFor(java.toolchain).map { it.metadata.vendor }.getOrElse('').contains('JetBrains')) {
285-
run.jvmArguments.add('-XX:+AllowEnhancedClassRedefinition')
284+
if (javaToolchains.launcherFor(java.toolchain).map { it.metadata.vendor }.getOrElse('').contains('JetBrains')) {
285+
jvmArguments.add('-XX:+AllowEnhancedClassRedefinition')
286286
}
287287
}
288288
client { Run run -> setupClientAcc(run) }
@@ -314,13 +314,12 @@ runs {
314314
modSources.add((SourceSet) sourceSets.datagenMain)
315315

316316
for (String name : secondaryModules) {
317-
def modName = "mekanism${name}"
318-
modSources.add(getExtraSourceSet(name, 'datagen'))
319-
programArguments.addAll((String[]) ['--mod', modName, '--existing', file("src/${name}/resources/").absolutePath])
317+
modSources.add(getExtraSourceSet(name, 'datagen').get())
318+
programArguments.addAll((String[]) ['--mod', "mekanism${name}", '--existing', file("src/${name}/resources/").absolutePath])
320319
}
321320

322321
dependencies {
323-
runtime(project.configurations.datagenNonMod)
322+
runtime(configurations.datagenNonMod)
324323
}
325324
}
326325
}
@@ -505,8 +504,8 @@ def mergeModuleResources = tasks.register('mergeModuleResources', MergeModuleRes
505504
annotationGenerated = sourceSets.main.output.classesDirs
506505
for (String name : secondaryModules) {
507506
SourceSet secondarySourceSet = sourceSets.named(name).get()
508-
resources = resources + tasks.named(secondarySourceSet.processResourcesTaskName).get().outputs.files
509-
annotationGenerated = annotationGenerated + secondarySourceSet.output.classesDirs
507+
resources += tasks.named(secondarySourceSet.processResourcesTaskName).get().outputs.files
508+
annotationGenerated += secondarySourceSet.output.classesDirs
510509
}
511510
//Only look at generated service files as a restriction for our input
512511
annotationGenerated = annotationGenerated.asFileTree.matching(serviceFilter)
@@ -521,7 +520,7 @@ def allJar = tasks.register('allJar', AllJar, {
521520
apiOutput = sourceSets.api.output
522521
mainOutput = sourceSets.main.output
523522
for (String name : secondaryModules) {
524-
secondaryModuleOutputs = secondaryModuleOutputs + sourceSets.named(name).get().output
523+
secondaryModuleOutputs += sourceSets.named(name).get().output
525524
}
526525
})
527526

@@ -531,6 +530,7 @@ tasks.withType(JavaCompile).configureEach({
531530
})
532531

533532
tasks.withType(Javadoc).configureEach({
533+
options.encoding = 'UTF-8'
534534
options.tags = [
535535
'apiNote:a:<em>API Note:</em>',
536536
'implSpec:a:<em>Implementation Requirements:</em>',

gradle.properties

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,11 +9,11 @@ minecraft_version=1.20.6
99
previous_minecraft_version=1.20.1
1010
previous_minor_minecraft_version=1.20.4
1111
loader_version_range=[3,)
12-
forge_version=20.6.104-beta
12+
forge_version=20.6.115
1313
mod_version=10.5.20
1414
#This determines the minimum version of forge required to use Mekanism
1515
# Only bump it whenever we need access to a feature in forge that is not available in earlier versions
16-
forge_version_range=[20.6.104-beta,)
16+
forge_version_range=[20.6.113-beta,)
1717
minecraft_version_range=[1.20.6]
1818
#This specifies what type of release it will be uploaded to CurseForge and Modrinth as
1919
# options are: alpha, beta, release

src/main/java/mekanism/common/block/BlockBounding.java

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -163,6 +163,24 @@ public boolean onDestroyedByPlayer(@NotNull BlockState state, @NotNull Level wor
163163
return super.onDestroyedByPlayer(state, world, pos, player, false, fluidState);
164164
}
165165

166+
@NotNull
167+
@Override
168+
public BlockState playerWillDestroy(@NotNull Level level, @NotNull BlockPos pos, @NotNull BlockState state, @NotNull Player player) {
169+
BlockPos mainPos = getMainBlockPos(level, pos);
170+
if (mainPos != null) {
171+
BlockState mainState = level.getBlockState(mainPos);
172+
if (!mainState.isAir()) {
173+
//Call player will destroy on the main block in case we have any other logic we want to run, but then return ourselves as the state
174+
// similar to what calling super would do.
175+
// Note: We don't call super as we don't want to spawn block break particles twice, and it only really makes sense to be firing the
176+
// game event for the main block position
177+
mainState.getBlock().playerWillDestroy(level, mainPos, mainState, player);
178+
return state;
179+
}
180+
}
181+
return super.playerWillDestroy(level, pos, state, player);
182+
}
183+
166184
@Override
167185
protected void onExplosionHit(@NotNull BlockState state, @NotNull Level level, @NotNull BlockPos pos, @NotNull Explosion explosion,
168186
@NotNull BiConsumer<ItemStack, BlockPos> dropConsumer) {

src/main/java/mekanism/common/block/basic/BlockLogisticalSorter.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -82,7 +82,7 @@ protected ItemInteractionResult useItemOn(@NotNull ItemStack stack, @NotNull Blo
8282
//Note: This should always be false for the logistical sorter, but we keep it here for good measure
8383
return ItemInteractionResult.FAIL;
8484
}
85-
WorldUtils.dismantleBlock(state, world, pos, player);
85+
WorldUtils.dismantleBlock(state, world, pos, player, stack);
8686
return ItemInteractionResult.SUCCESS;
8787
}
8888
Direction change = tile.getDirection().getClockWise();

src/main/java/mekanism/common/block/prefab/BlockBase.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -136,7 +136,7 @@ protected ItemInteractionResult useItemOn(@NotNull ItemStack stack, @NotNull Blo
136136
if (player.isShiftKeyDown() && MekanismUtils.canUseAsWrench(stack)) {
137137
//Note: We don't handle checking if it is radioactive here, as the assumption is it doesn't have a tile so won't have that information
138138
if (!world.isClientSide) {
139-
WorldUtils.dismantleBlock(state, world, pos, player);
139+
WorldUtils.dismantleBlock(state, world, pos, player, stack);
140140
}
141141
return ItemInteractionResult.SUCCESS;
142142
}

src/main/java/mekanism/common/content/gear/mekatool/ModuleShearingUnit.java

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,6 @@
2626
import net.minecraft.world.entity.player.Player;
2727
import net.minecraft.world.item.ItemStack;
2828
import net.minecraft.world.item.Items;
29-
import net.minecraft.world.item.enchantment.Enchantments;
3029
import net.minecraft.world.level.Level;
3130
import net.minecraft.world.level.block.BeehiveBlock;
3231
import net.minecraft.world.level.block.Block;
@@ -131,9 +130,9 @@ private boolean tryShearLivingEntity(@Nullable IEnergyContainer energyContainer,
131130

132131
private boolean shearEntity(@Nullable IEnergyContainer energyContainer, LivingEntity entity, @Nullable Player player, ItemStack stack, Level world, BlockPos pos) {
133132
IShearable target = (IShearable) entity;
134-
if (target.isShearable(stack, world, pos)) {
133+
if (target.isShearable(player, stack, world, pos)) {
135134
if (!world.isClientSide) {
136-
for (ItemStack drop : target.onSheared(player, stack, world, pos, stack.getEnchantmentLevel(Enchantments.FORTUNE))) {
135+
for (ItemStack drop : target.onSheared(player, stack, world, pos)) {
137136
target.spawnShearedDrop(world, pos, drop);
138137
}
139138
entity.gameEvent(GameEvent.SHEAR, player);

src/main/java/mekanism/common/tile/base/TileEntityMekanism.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -588,7 +588,7 @@ public WrenchResult tryWrench(BlockState state, Player player, ItemStack stack)
588588
//Don't allow dismantling radioactive blocks
589589
return WrenchResult.RADIOACTIVE;
590590
}
591-
WorldUtils.dismantleBlock(state, getLevel(), worldPosition, this, player);
591+
WorldUtils.dismantleBlock(state, getLevel(), worldPosition, this, player, stack);
592592
return WrenchResult.DISMANTLED;
593593
}
594594
//Special ITileDirectional handling

src/main/java/mekanism/common/tile/laser/TileEntityBasicLaser.java

Lines changed: 10 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -331,7 +331,7 @@ private void withFakePlayer(ServerLevel level, double x, double y, double z, Blo
331331
level.removeBlock(hitPos, false);
332332
} else {
333333
//Use the disassembler as the item to break the block with as that is marked as being the correct tool for drops
334-
handleBreakBlock(hitState, hitPos, dummy, ItemAtomicDisassembler.fullyChargedStack());
334+
handleBreakBlock(hitState, level, hitPos, dummy, ItemAtomicDisassembler.fullyChargedStack());
335335
}
336336
}
337337
dummy.cleanupFakePlayer(level);
@@ -395,12 +395,17 @@ protected boolean handleHitItem(ItemEntity entity) {
395395
return false;
396396
}
397397

398-
protected void handleBreakBlock(BlockState state, BlockPos hitPos, Player player, ItemStack tool) {
399-
Block.dropResources(state, level, hitPos, WorldUtils.getTileEntity(level, hitPos), player, tool, false);
400-
breakBlock(state, hitPos);
398+
protected void handleBreakBlock(BlockState state, ServerLevel level, BlockPos hitPos, Player player, ItemStack tool) {
399+
for (ItemEntity drop : WorldUtils.getDrops(state, level, hitPos, WorldUtils.getTileEntity(level, hitPos), player, tool, true)) {
400+
if (!drop.getItem().isEmpty()) {
401+
level.addFreshEntity(drop);
402+
}
403+
}
404+
breakBlock(state, level, hitPos, tool);
401405
}
402406

403-
protected final void breakBlock(BlockState state, BlockPos hitPos) {
407+
protected final void breakBlock(BlockState state, ServerLevel level, BlockPos hitPos, ItemStack tool) {
408+
state.spawnAfterBreak(level, hitPos, tool, false);
404409
level.removeBlock(hitPos, false);
405410
//TODO: We may want to evaluate at some point doing this with our fake player so that it is fired as the "cause"?
406411
level.gameEvent(GameEvent.BLOCK_DESTROY, hitPos, GameEvent.Context.of(null, state));

src/main/java/mekanism/common/tile/laser/TileEntityLaserTractorBeam.java

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
package mekanism.common.tile.laser;
22

3-
import java.util.ArrayList;
43
import java.util.List;
54
import mekanism.api.Action;
65
import mekanism.api.AutomationType;
@@ -55,13 +54,13 @@ protected IInventorySlotHolder getInitialInventory(IContentsListener listener) {
5554
}
5655

5756
@Override
58-
protected void handleBreakBlock(BlockState state, BlockPos hitPos, Player player, ItemStack tool) {
59-
List<ItemStack> drops = new ArrayList<>(Block.getDrops(state, (ServerLevel) level, hitPos, WorldUtils.getTileEntity(level, hitPos), player, tool));
57+
protected void handleBreakBlock(BlockState state, ServerLevel level, BlockPos hitPos, Player player, ItemStack tool) {
58+
List<ItemStack> drops = WorldUtils.getDrops(state, level, hitPos, WorldUtils.getTileEntity(level, hitPos), player, tool);
6059
//Collect any extra drops that might have happened due to say breaking the top part of a door or flower and try to add them
6160
//Note: Technically we should just always return true rather than relying on the return result of the add method,
6261
// but as array lists always will return true as they are modified we don't have to worry about that
6362
CommonWorldTickHandler.fallbackItemCollector = drops::add;
64-
breakBlock(state, hitPos);
63+
breakBlock(state, level, hitPos, tool);
6564
CommonWorldTickHandler.fallbackItemCollector = null;
6665
if (!drops.isEmpty()) {
6766
BlockPos dropPos = null;

src/main/java/mekanism/common/tile/machine/TileEntityDigitalMiner.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1281,7 +1281,7 @@ private List<ItemStack> getDrops(BlockState state, BlockPos pos) {
12811281
ServerLevel level = (ServerLevel) getWorldNN();
12821282
MekFakePlayer dummy = MekFakePlayer.setupFakePlayer(level, this.worldPosition.getX(), this.worldPosition.getY(), this.worldPosition.getZ());
12831283
dummy.setEmulatingUUID(getOwnerUUID());//pretend to be the owner
1284-
List<ItemStack> drops = Block.getDrops(state, level, pos, WorldUtils.getTileEntity(level, pos), dummy, stack);
1284+
List<ItemStack> drops = WorldUtils.getDrops(state, level, pos, WorldUtils.getTileEntity(level, pos), dummy, stack);
12851285
dummy.cleanupFakePlayer(level);
12861286
return drops;
12871287
}

0 commit comments

Comments
 (0)