Skip to content

Commit

Permalink
Update to 1.21.2
Browse files Browse the repository at this point in the history
  • Loading branch information
Killarexe committed Nov 26, 2024
1 parent 3da7209 commit 49fc1ae
Show file tree
Hide file tree
Showing 33 changed files with 67 additions and 132 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/gradle.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ permissions:
contents: read

env:
mod_version: 1.4.0
mod_version: 1.4.2

jobs:
build:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@
import net.minecraft.util.RandomSource;
import net.minecraft.world.InteractionHand;
import net.minecraft.world.InteractionResult;
import net.minecraft.world.InteractionResultHolder;
import net.minecraft.world.entity.EquipmentSlot;
import net.minecraft.world.entity.item.ItemEntity;
import net.minecraft.world.entity.player.Player;
Expand Down Expand Up @@ -41,7 +40,7 @@ private static void scrap(Item scarpItem, ItemStack currentStack, ItemStack othe
ItemEntity itemEntity = new ItemEntity(level, serverPlayer.getX(), serverPlayer.getY(), serverPlayer.getZ(), result);

level.addFreshEntity(itemEntity);
serverPlayer.getCooldowns().addCooldown(otherStack.getItem(), amount * 8);
serverPlayer.getCooldowns().addCooldown(otherStack, amount * 8);
}

private static Optional<Item> getScrapItem(Item item) {
Expand All @@ -58,21 +57,21 @@ private static Optional<Item> getScrapItem(Item item) {
return Optional.empty();
}

public static void scrapUse(Player player, InteractionHand hand, CallbackInfoReturnable<InteractionResultHolder<ItemStack>> callbackInfo) {
public static void scrapUse(Player player, InteractionHand hand, CallbackInfoReturnable<InteractionResult> callbackInfo) {
ItemStack currentHandStack = player.getItemInHand(hand);
ItemStack otherHandStack = player.getOffhandItem();
Optional<Item> scrapItem = getScrapItem(currentHandStack.getItem());
if (scrapItem.isPresent() && otherHandStack.is(ItemTags.AXES)) {
if (player instanceof ServerPlayer serverPlayer && !player.getCooldowns().isOnCooldown(otherHandStack.getItem())) {
if (player instanceof ServerPlayer serverPlayer && !player.getCooldowns().isOnCooldown(otherHandStack)) {
scrap(scrapItem.get(), currentHandStack, otherHandStack, serverPlayer, serverPlayer.isShiftKeyDown() ? currentHandStack.getCount() : 1);
callbackInfo.setReturnValue(InteractionResultHolder.success(currentHandStack));
callbackInfo.setReturnValue(InteractionResult.SUCCESS.heldItemTransformedTo(currentHandStack));
}
callbackInfo.setReturnValue(InteractionResultHolder.consume(currentHandStack));
callbackInfo.setReturnValue(InteractionResult.CONSUME.heldItemTransformedTo(currentHandStack));
}
}

public static <T extends Item> void rustEntityStack(
T nextItem, ItemStack stack, Level level,
T nextItem, ItemStack stack, ServerLevel level,
ItemEntity entity, GameRules.Key<GameRules.IntegerValue> oxidationGameRule, RandomSource random)
{
int count = stack.getCount();
Expand All @@ -81,7 +80,7 @@ public static <T extends Item> void rustEntityStack(
ItemEntity newItemEntity = new ItemEntity(level, pos.x, pos.y, pos.z, new ItemStack(nextItem, count));
newItemEntity.copyPosition(entity);
level.addFreshEntity(newItemEntity);
entity.kill();
entity.kill(level);
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,7 @@
"type": "minecraft:crafting_shaped",
"category": "building",
"key": {
"#": {
"item": "copper_extension:exposed_copper_ingot"
}
"#": "copper_extension:exposed_copper_ingot"
},
"pattern": [
"###",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,7 @@
"##"
],
"key": {
"#": {
"item": "copper_extension:exposed_copper_ingot"
}
"#": "copper_extension:exposed_copper_ingot"
},
"result": {
"id": "minecraft:exposed_copper_door",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,7 @@
"###"
],
"key": {
"#": {
"item": "copper_extension:exposed_copper_ingot"
}
"#": "copper_extension:exposed_copper_ingot"
},
"result": {
"id": "minecraft:exposed_copper_trapdoor",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,7 @@
"type": "minecraft:crafting_shaped",
"category": "building",
"key": {
"#": {
"item": "copper_extension:oxidized_copper_ingot"
}
"#": "copper_extension:oxidized_copper_ingot"
},
"pattern": [
"###",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,7 @@
"##"
],
"key": {
"#": {
"item": "copper_extension:oxidized_copper_ingot"
}
"#": "copper_extension:oxidized_copper_ingot"
},
"result": {
"id": "minecraft:oxidized_copper_door",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,7 @@
"###"
],
"key": {
"#": {
"item": "copper_extension:oxidized_copper_ingot"
}
"#": "copper_extension:oxidized_copper_ingot"
},
"result": {
"id": "minecraft:oxidized_copper_trapdoor",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,7 @@
"type": "minecraft:crafting_shaped",
"category": "building",
"key": {
"#": {
"item": "copper_extension:waxed_copper_ingot"
}
"#": "copper_extension:waxed_copper_ingot"
},
"pattern": [
"###",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,7 @@
"##"
],
"key": {
"#": {
"item": "copper_extension:waxed_copper_ingot"
}
"#": "copper_extension:waxed_copper_ingot"
},
"result": {
"id": "minecraft:waxed_copper_door",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,8 @@
"type": "minecraft:crafting_shapeless",
"category": "misc",
"ingredients": [
{
"item": "minecraft:copper_ingot"
},
{
"item": "minecraft:honeycomb"
}
"minecraft:copper_ingot",
"minecraft:honeycomb"
],
"result": {
"id": "copper_extension:waxed_copper_ingot"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,7 @@
"###"
],
"key": {
"#": {
"item": "copper_extension:waxed_copper_ingot"
}
"#": "copper_extension:waxed_copper_ingot"
},
"result": {
"id": "minecraft:waxed_copper_trapdoor",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,7 @@
"type": "minecraft:crafting_shaped",
"category": "building",
"key": {
"#": {
"item": "copper_extension:waxed_exposed_copper_ingot"
}
"#": "copper_extension:waxed_exposed_copper_ingot"
},
"pattern": [
"###",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,7 @@
"##"
],
"key": {
"#": {
"item": "copper_extension:waxed_exposed_copper_ingot"
}
"#": "copper_extension:waxed_exposed_copper_ingot"
},
"result": {
"id": "minecraft:waxed_exposed_copper_door",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,8 @@
"type": "minecraft:crafting_shapeless",
"category": "misc",
"ingredients": [
{
"item": "copper_extension:exposed_copper_ingot"
},
{
"item": "minecraft:honeycomb"
}
"copper_extension:exposed_copper_ingot",
"minecraft:honeycomb"
],
"result": {
"id": "copper_extension:waxed_exposed_copper_ingot"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,7 @@
"###"
],
"key": {
"#": {
"item": "copper_extension:waxed_exposed_copper_ingot"
}
"#": "copper_extension:waxed_exposed_copper_ingot"
},
"result": {
"id": "minecraft:waxed_exposed_copper_trapdoor",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,7 @@
"type": "minecraft:crafting_shaped",
"category": "building",
"key": {
"#": {
"item": "copper_extension:waxed_oxidized_copper_ingot"
}
"#": "copper_extension:waxed_oxidized_copper_ingot"
},
"pattern": [
"###",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,7 @@
"##"
],
"key": {
"#": {
"item": "copper_extension:waxed_oxidized_copper_ingot"
}
"#": "copper_extension:waxed_oxidized_copper_ingot"
},
"result": {
"id": "minecraft:waxed_oxidized_copper_door",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,8 @@
"type": "minecraft:crafting_shapeless",
"category": "misc",
"ingredients": [
{
"item": "copper_extension:oxidized_copper_ingot"
},
{
"item": "minecraft:honeycomb"
}
"copper_extension:oxidized_copper_ingot",
"minecraft:honeycomb"
],
"result": {
"id": "copper_extension:waxed_oxidized_copper_ingot"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,7 @@
"###"
],
"key": {
"#": {
"item": "copper_extension:waxed_oxidized_copper_ingot"
}
"#": "copper_extension:waxed_oxidized_copper_ingot"
},
"result": {
"id": "minecraft:waxed_oxidized_copper_trapdoor",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,7 @@
"type": "minecraft:crafting_shaped",
"category": "building",
"key": {
"#": {
"item": "copper_extension:waxed_weathered_copper_ingot"
}
"#": "copper_extension:waxed_weathered_copper_ingot"
},
"pattern": [
"###",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,7 @@
"##"
],
"key": {
"#": {
"item": "copper_extension:waxed_weathered_copper_ingot"
}
"#": "copper_extension:waxed_weathered_copper_ingot"
},
"result": {
"id": "minecraft:waxed_weathered_copper_door",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,8 @@
"type": "minecraft:crafting_shapeless",
"category": "misc",
"ingredients": [
{
"item": "copper_extension:weathered_copper_ingot"
},
{
"item": "minecraft:honeycomb"
}
"copper_extension:weathered_copper_ingot",
"minecraft:honeycomb"
],
"result": {
"id": "copper_extension:waxed_weathered_copper_ingot"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,7 @@
"###"
],
"key": {
"#": {
"item": "copper_extension:waxed_weathered_copper_ingot"
}
"#": "copper_extension:waxed_weathered_copper_ingot"
},
"result": {
"id": "minecraft:waxed_weathered_copper_trapdoor",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,7 @@
"type": "minecraft:crafting_shaped",
"category": "building",
"key": {
"#": {
"item": "copper_extension:weathered_copper_ingot"
}
"#": "copper_extension:weathered_copper_ingot"
},
"pattern": [
"###",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,7 @@
"##"
],
"key": {
"#": {
"item": "copper_extension:weathered_copper_ingot"
}
"#": "copper_extension:weathered_copper_ingot"
},
"result": {
"id": "minecraft:weathered_copper_door",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,7 @@
"###"
],
"key": {
"#": {
"item": "copper_extension:weathered_copper_ingot"
}
"#": "copper_extension:weathered_copper_ingot"
},
"result": {
"id": "minecraft:weathered_copper_trapdoor",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
import github.killarexe.copper_extension.CEActions;
import github.killarexe.copper_extension.CEMaps;
import github.killarexe.copper_extension.fabric.registry.CEGameRules;
import net.minecraft.server.level.ServerLevel;
import net.minecraft.world.item.Item;
import org.spongepowered.asm.mixin.Mixin;
import org.spongepowered.asm.mixin.injection.At;
Expand All @@ -28,8 +29,8 @@ public void tick(CallbackInfo callbackInfo) {
ItemEntity itemEntity = ItemEntity.class.cast(this);
ItemStack stack = itemEntity.getItem();
Item nextItem = CEMaps.OXIDATION_MAP_ITEMS.get(stack.getItem());
if (nextItem != null) {
CEActions.rustEntityStack(nextItem, stack, level(), itemEntity, CEGameRules.COPPER_OXIDATION_CHANCE, random);
if (nextItem != null && level() instanceof ServerLevel level) {
CEActions.rustEntityStack(nextItem, stack, level, itemEntity, CEGameRules.COPPER_OXIDATION_CHANCE, random);
}
}
}
Loading

0 comments on commit 49fc1ae

Please sign in to comment.