Skip to content

Commit

Permalink
Update mod to Minecraft 1.20 (#42)
Browse files Browse the repository at this point in the history
  • Loading branch information
haykam821 authored Jun 7, 2023
1 parent f27eb41 commit 624f58b
Show file tree
Hide file tree
Showing 10 changed files with 25 additions and 25 deletions.
10 changes: 5 additions & 5 deletions gradle.properties
Original file line number Diff line number Diff line change
@@ -1,16 +1,16 @@
# Done to increase the memory available to gradle.
org.gradle.jvmargs=-Xmx1G

minecraft_version=1.19.4
yarn_mappings=1.19.4+build.1
loader_version=0.14.17
minecraft_version=1.20
yarn_mappings=1.20+build.1
loader_version=0.14.21

#Fabric api
fabric_version=0.75.3+1.19.4
fabric_version=0.83.0+1.20

mixin_extras_version=0.2.0-beta.7

# Mod Properties
mod_version=0.4.5
mod_version=0.4.6
maven_group=xyz.nucleoid
archives_base_name=stimuli
4 changes: 2 additions & 2 deletions src/main/java/xyz/nucleoid/stimuli/EventSource.java
Original file line number Diff line number Diff line change
Expand Up @@ -58,11 +58,11 @@ public static EventSource allOf(RegistryKey<World> dimension) {
}

public static EventSource forEntity(Entity entity) {
return acquire(entity.world.getRegistryKey(), entity.getBlockPos(), entity);
return acquire(entity.getWorld().getRegistryKey(), entity.getBlockPos(), entity);
}

public static EventSource forEntityAt(Entity entity, BlockPos pos) {
return acquire(entity.world.getRegistryKey(), pos, entity);
return acquire(entity.getWorld().getRegistryKey(), pos, entity);
}

static EventSource acquire(RegistryKey<World> dimension, BlockPos pos, @Nullable Entity entity) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ private void onPlace(ItemPlacementContext context, BlockState state, CallbackInf
var blockPos = context.getBlockPos();

try (var invokers = Stimuli.select().forEntityAt(player, blockPos)) {
var result = invokers.get(BlockPlaceEvent.BEFORE).onPlace(player, player.getWorld(), blockPos, state, context);
var result = invokers.get(BlockPlaceEvent.BEFORE).onPlace(player, player.getServerWorld(), blockPos, state, context);

if (result == ActionResult.FAIL) {
// notify the client that this action did not go through
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ private void onPlace(ItemPlacementContext context, CallbackInfoReturnable<Action

try (var invokers = Stimuli.select().forEntityAt(player, blockPos)) {
var state = context.getWorld().getBlockState(blockPos);
invokers.get(BlockPlaceEvent.AFTER).onPlace(player, player.getWorld(), blockPos, state);
invokers.get(BlockPlaceEvent.AFTER).onPlace(player, player.getServerWorld(), blockPos, state);
}
}

Expand All @@ -45,7 +45,7 @@ private void onPlace(ItemPlacementContext context, BlockState state, CallbackInf
var blockPos = context.getBlockPos();

try (var invokers = Stimuli.select().forEntityAt(player, blockPos)) {
var result = invokers.get(BlockPlaceEvent.BEFORE).onPlace(player, player.getWorld(), blockPos, state, context);
var result = invokers.get(BlockPlaceEvent.BEFORE).onPlace(player, player.getServerWorld(), blockPos, state, context);

if (result == ActionResult.FAIL) {
// notify the client that this action did not go through
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
import net.minecraft.entity.damage.DamageSource;
import net.minecraft.item.ItemStack;
import net.minecraft.loot.LootTable;
import net.minecraft.loot.context.LootContext;
import net.minecraft.loot.context.LootContextParameterSet;
import net.minecraft.util.ActionResult;
import net.minecraft.world.World;
import org.spongepowered.asm.mixin.Mixin;
Expand All @@ -30,7 +30,7 @@ private LivingEntityMixin(EntityType<?> type, World world) {

@Inject(method = "damage", at = @At("HEAD"), cancellable = true)
private void onDamage(DamageSource source, float amount, CallbackInfoReturnable<Boolean> ci) {
if (this.world.isClient) {
if (this.getWorld().isClient) {
return;
}

Expand All @@ -46,7 +46,7 @@ private void onDamage(DamageSource source, float amount, CallbackInfoReturnable<

@Inject(method = "onDeath", at = @At("HEAD"), cancellable = true)
private void callDeathListener(DamageSource source, CallbackInfo ci) {
if (this.world.isClient) {
if (this.getWorld().isClient) {
return;
}

Expand All @@ -62,15 +62,15 @@ private void callDeathListener(DamageSource source, CallbackInfo ci) {
}
}

@Redirect(method = "dropLoot", at = @At(value = "INVOKE", target = "Lnet/minecraft/loot/LootTable;generateLoot(Lnet/minecraft/loot/context/LootContext;Ljava/util/function/Consumer;)V"))
private void modifyDroppedLoot(LootTable lootTable, LootContext context, Consumer<ItemStack> lootConsumer) {
if (this.world.isClient) {
lootTable.generateLoot(context, lootConsumer);
@Redirect(method = "dropLoot", at = @At(value = "INVOKE", target = "Lnet/minecraft/loot/LootTable;generateLoot(Lnet/minecraft/loot/context/LootContextParameterSet;JLjava/util/function/Consumer;)V"))
private void modifyDroppedLoot(LootTable lootTable, LootContextParameterSet parameters, long seed, Consumer<ItemStack> lootConsumer) {
if (this.getWorld().isClient) {
lootTable.generateLoot(parameters, lootConsumer);
return;
}

try (var invokers = Stimuli.select().forEntity(this)) {
var droppedStacks = lootTable.generateLoot(context);
var droppedStacks = lootTable.generateLoot(parameters, seed);

var result = invokers.get(EntityDropItemsEvent.EVENT)
.onDropItems((LivingEntity) (Object) this, droppedStacks);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ public class ScreenHandlerMixin {

@Inject(method = "internalOnSlotClick", at = @At("HEAD"), cancellable = true)
private void onSlotAction(int slot, int button, SlotActionType type, PlayerEntity player, CallbackInfo ci) {
if (player.world.isClient) {
if (player.getWorld().isClient) {
return;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ public ProjectileEntityMixin(EntityType<?> type, World world) {

@Inject(method = "onCollision", at = @At("HEAD"), cancellable = true)
private void onCollision(HitResult hitResult, CallbackInfo ci) {
if (this.world.isClient) {
if (this.getWorld().isClient) {
return;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
import net.minecraft.block.Blocks;
import net.minecraft.entity.Entity;
import net.minecraft.item.ItemStack;
import net.minecraft.loot.context.LootContext;
import net.minecraft.loot.context.LootContextParameterSet;
import net.minecraft.server.world.ServerWorld;
import net.minecraft.util.ActionResult;
import net.minecraft.util.math.BlockPos;
Expand Down Expand Up @@ -46,8 +46,8 @@ private void affectWorld(boolean particles, CallbackInfo ci) {
}
}

@Redirect(method = "affectWorld", at = @At(value = "INVOKE", target = "Lnet/minecraft/block/BlockState;getDroppedStacks(Lnet/minecraft/loot/context/LootContext$Builder;)Ljava/util/List;"))
private List<ItemStack> stimuli_dropBlock(BlockState state, LootContext.Builder builder) {
@Redirect(method = "affectWorld", at = @At(value = "INVOKE", target = "Lnet/minecraft/block/BlockState;getDroppedStacks(Lnet/minecraft/loot/context/LootContextParameterSet$Builder;)Ljava/util/List;"))
private List<ItemStack> stimuli_dropBlock(BlockState state, LootContextParameterSet.Builder builder) {
var stacks = state.getDroppedStacks(builder);

var events = Stimuli.select();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ public class FireworkRocketEntityMixin {
private void explodeAndRemove(CallbackInfo ci) {
var firework = (FireworkRocketEntity) (Object) this;

if (!firework.world.isClient) {
if (!firework.getWorld().isClient) {
try (var invokers = Stimuli.select().forEntity(firework)) {
var result = invokers.get(FireworkExplodeEvent.EVENT).onFireworkExplode(firework);
if (result == ActionResult.FAIL) {
Expand Down
2 changes: 1 addition & 1 deletion src/main/resources/fabric.mod.json
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@
"depends": {
"fabricloader": ">=0.9.1",
"fabric": "*",
"minecraft": "1.19.4",
"minecraft": "1.20.x",
"java": ">=17"
}
}

0 comments on commit 624f58b

Please sign in to comment.