Skip to content

Commit

Permalink
🌱 Update UHC for Minecraft 1.20.1
Browse files Browse the repository at this point in the history
  • Loading branch information
Hugman76 committed Jul 20, 2023
1 parent fe56b18 commit f177e39
Show file tree
Hide file tree
Showing 6 changed files with 32 additions and 27 deletions.
2 changes: 1 addition & 1 deletion build.gradle
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
plugins {
id "fabric-loom" version "1.0-SNAPSHOT"
id "fabric-loom" version "1.3-SNAPSHOT"
id 'maven-publish'
}

Expand Down
10 changes: 5 additions & 5 deletions gradle.properties
Original file line number Diff line number Diff line change
Expand Up @@ -2,13 +2,13 @@
org.gradle.jvmargs=-Xmx1G
# Fabric Properties
# check these on https://fabricmc.net/develop/
minecraft_version=1.19.3
yarn_mappings=1.19.3+build.5
loader_version=0.14.12
fabric_version=0.70.0+1.19.3
minecraft_version=1.20.1
yarn_mappings=1.20.1+build.9
loader_version=0.14.21
fabric_version=0.86.0+1.20.1
# Mod Properties
mod_version=2.1.0
maven_group=com.hugman
archives_base_name=uhc
# check this on https://nucleoid.xyz/use/
plasmid_version=0.5+1.19.3-SNAPSHOT
plasmid_version=0.5+1.20.1-SNAPSHOT
2 changes: 1 addition & 1 deletion gradle/wrapper/gradle-wrapper.properties
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists
distributionUrl=https\://services.gradle.org/distributions/gradle-7.3.3-bin.zip
distributionUrl=https\://services.gradle.org/distributions/gradle-8.1-bin.zip
zipStoreBase=GRADLE_USER_HOME
zipStorePath=wrapper/dists
4 changes: 2 additions & 2 deletions src/main/java/com/hugman/uhc/game/UHCSpawner.java
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ public void spawnPlayerAt(ServerPlayerEntity player, BlockPos pos) {
public void putParticipantInCage(GameTeam team, ServerPlayerEntity participant) {
BlockBounds bounds = this.cages.get(team);
if (bounds != null) {
this.spawnPlayerAt(participant, new BlockPos(bounds.centerBottom()).up());
this.spawnPlayerAt(participant, BlockPos.ofFloored(bounds.centerBottom()).up());
}
}

Expand Down Expand Up @@ -75,6 +75,6 @@ public void clearCages() {
}

public BlockPos getSurfaceBlock(int x, int z) {
return new BlockPos(getSurfaceBlock(world, x, z));
return BlockPos.ofFloored(getSurfaceBlock(world, x, z));
}
}
27 changes: 14 additions & 13 deletions src/main/java/com/hugman/uhc/modifier/BlockLootModifier.java
Original file line number Diff line number Diff line change
Expand Up @@ -8,9 +8,7 @@
import net.minecraft.item.ItemStack;
import net.minecraft.loot.LootTable;
import net.minecraft.loot.LootTables;
import net.minecraft.loot.context.LootContext;
import net.minecraft.loot.context.LootContextParameters;
import net.minecraft.loot.context.LootContextTypes;
import net.minecraft.loot.context.*;
import net.minecraft.server.world.ServerWorld;
import net.minecraft.structure.rule.RuleTest;
import net.minecraft.util.Identifier;
Expand All @@ -20,7 +18,9 @@
import org.jetbrains.annotations.Nullable;

import java.util.Collections;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

public class BlockLootModifier implements Modifier {
public static final Codec<BlockLootModifier> CODEC = RecordCodecBuilder.create(instance -> instance.group(
Expand Down Expand Up @@ -61,17 +61,18 @@ public void spawnExperience(ServerWorld world, BlockPos pos) {
}

public List<ItemStack> getLoots(ServerWorld world, BlockPos pos, @Nullable Entity entity, ItemStack stack) {
LootContext.Builder builder = new LootContext.Builder(world).random(world.random).parameter(LootContextParameters.ORIGIN, Vec3d.ofCenter(pos)).parameter(LootContextParameters.TOOL, stack).optionalParameter(LootContextParameters.BLOCK_ENTITY, world.getBlockEntity(pos));
if (entity != null) {
builder = builder.optionalParameter(LootContextParameters.THIS_ENTITY, entity);
if (this.lootTable == LootTables.EMPTY) {
return Collections.emptyList();
}
List<ItemStack> stacks = Collections.emptyList();
if (this.lootTable != LootTables.EMPTY) {
LootContext lootContext = builder.parameter(LootContextParameters.BLOCK_STATE, world.getBlockState(pos)).build(LootContextTypes.BLOCK);
LootTable lootTable = lootContext.getWorld().getServer().getLootManager().getTable(this.lootTable);
stacks = lootTable.generateLoot(lootContext);
}
return stacks;
LootContextParameterSet lootContext = new LootContextParameterSet.Builder(world)
.add(LootContextParameters.ORIGIN, Vec3d.ofCenter(pos))
.add(LootContextParameters.TOOL, stack)
.add(LootContextParameters.BLOCK_STATE, world.getBlockState(pos))
.addOptional(LootContextParameters.BLOCK_ENTITY, world.getBlockEntity(pos))
.addOptional(LootContextParameters.THIS_ENTITY, entity)
.build(LootContextTypes.BLOCK);
LootTable lootTable = world.getServer().getLootManager().getLootTable(this.lootTable);
return lootTable.generateLoot(lootContext);
}

public boolean shouldReplace() {
Expand Down
14 changes: 9 additions & 5 deletions src/main/java/com/hugman/uhc/modifier/EntityLootModifier.java
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,12 @@
import net.minecraft.entity.EntityType;
import net.minecraft.entity.LivingEntity;
import net.minecraft.entity.damage.DamageSource;
import net.minecraft.entity.damage.DamageSources;
import net.minecraft.item.ItemStack;
import net.minecraft.loot.LootTable;
import net.minecraft.loot.LootTables;
import net.minecraft.loot.context.LootContext;
import net.minecraft.loot.context.LootContextParameterSet;
import net.minecraft.loot.context.LootContextParameters;
import net.minecraft.loot.context.LootContextTypes;
import net.minecraft.registry.Registries;
Expand Down Expand Up @@ -62,14 +64,16 @@ public boolean test(LivingEntity livingEntity) {
}

public List<ItemStack> getLoots(ServerWorld world, LivingEntity livingEntity) {
LootContext.Builder builder = new LootContext.Builder(world).random(livingEntity.getRandom()).parameter(LootContextParameters.THIS_ENTITY, livingEntity).parameter(LootContextParameters.ORIGIN, livingEntity.getPos()).parameter(LootContextParameters.DAMAGE_SOURCE, DamageSource.GENERIC);
if (this.lootTable == LootTables.EMPTY) {
return Collections.emptyList();
} else {
LootContext lootContext = builder.build(LootContextTypes.ENTITY);
LootTable lootTable = lootContext.getWorld().getServer().getLootManager().getTable(this.lootTable);
return lootTable.generateLoot(lootContext);
}
LootContextParameterSet lootContext = new LootContextParameterSet.Builder(world)
.add(LootContextParameters.THIS_ENTITY, livingEntity)
.add(LootContextParameters.ORIGIN, livingEntity.getPos())
.add(LootContextParameters.DAMAGE_SOURCE, livingEntity.getDamageSources().generic())
.build(LootContextTypes.ENTITY);
LootTable lootTable = world.getServer().getLootManager().getLootTable(this.lootTable);
return lootTable.generateLoot(lootContext);
}

public boolean shouldReplace() {
Expand Down

0 comments on commit f177e39

Please sign in to comment.