Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

修改腐化信标,修复16物品堆叠 #235

Merged
merged 1 commit into from
Apr 12, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,7 @@ public ItemStack insert(int slot, @NotNull ItemStack stack, boolean simulate, bo
ItemStack stackInSlot = this.getStack(slot);
int limit = this.getSlotLimit(slot);
if (!stackInSlot.isEmpty() && !ItemStack.isSameItemSameTags(stackInSlot, stack)) return stack;
limit = Math.min(limit, stackInSlot.getItem().getMaxStackSize());
limit -= stackInSlot.getCount();
if (limit <= 0) return stack;
boolean reachedLimit = stack.getCount() > limit;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
import net.minecraft.tags.BlockTags;
import net.minecraft.world.effect.MobEffectInstance;
import net.minecraft.world.effect.MobEffects;
import net.minecraft.world.entity.player.Player;
import net.minecraft.world.entity.LivingEntity;
import net.minecraft.world.level.Level;
import net.minecraft.world.level.block.BeaconBeamBlock;
import net.minecraft.world.level.block.Block;
Expand Down Expand Up @@ -151,9 +151,9 @@ public void setRemoved() {
private static void applyEffects(@NotNull Level level, BlockPos pos) {
if (level.isClientSide) return;
AABB aABB = new AABB(pos).expandTowards(0.0, level.getHeight(), 0.0);
List<Player> list = level.getEntitiesOfClass(Player.class, aABB);
for (Player player : list) {
player.addEffect(new MobEffectInstance(MobEffects.WITHER, 120, 0, true, true));
List<LivingEntity> list = level.getEntitiesOfClass(LivingEntity.class, aABB);
for (LivingEntity livingEntity : list) {
livingEntity.addEffect(new MobEffectInstance(MobEffects.WITHER, 120, 0, true, true));
}
}

Expand Down
6 changes: 3 additions & 3 deletions common/src/main/java/dev/dubhe/anvilcraft/init/ModBlocks.java
Original file line number Diff line number Diff line change
Expand Up @@ -288,7 +288,7 @@ public class ModBlocks {
.initialProperties(() -> Blocks.EMERALD_BLOCK)
.simpleItem()
.defaultLoot()
.tag(BlockTags.MINEABLE_WITH_PICKAXE)
.tag(BlockTags.MINEABLE_WITH_PICKAXE, BlockTags.BEACON_BASE_BLOCKS)
.recipe((ctx, provider) -> ShapedRecipeBuilder.shaped(RecipeCategory.MISC, ctx.get())
.pattern("AAA")
.pattern("AAA")
Expand All @@ -302,7 +302,7 @@ public class ModBlocks {
.initialProperties(() -> Blocks.EMERALD_BLOCK)
.simpleItem()
.defaultLoot()
.tag(BlockTags.MINEABLE_WITH_PICKAXE)
.tag(BlockTags.MINEABLE_WITH_PICKAXE, BlockTags.BEACON_BASE_BLOCKS)
.recipe((ctx, provider) -> ShapedRecipeBuilder.shaped(RecipeCategory.MISC, ctx.get())
.pattern("AAA")
.pattern("AAA")
Expand All @@ -316,7 +316,7 @@ public class ModBlocks {
.initialProperties(() -> Blocks.EMERALD_BLOCK)
.simpleItem()
.defaultLoot()
.tag(BlockTags.MINEABLE_WITH_PICKAXE)
.tag(BlockTags.MINEABLE_WITH_PICKAXE, BlockTags.BEACON_BASE_BLOCKS)
.recipe((ctx, provider) -> ShapedRecipeBuilder.shaped(RecipeCategory.MISC, ctx.get())
.pattern("AAA")
.pattern("AAA")
Expand Down
3 changes: 3 additions & 0 deletions common/src/main/java/dev/dubhe/anvilcraft/init/ModItems.java
Original file line number Diff line number Diff line change
Expand Up @@ -383,6 +383,7 @@ public void appendHoverText(@NotNull ItemStack stack, @Nullable Level level, @No
.register();
public static final ItemEntry<TopazItem> TOPAZ = REGISTRATE
.item("topaz", TopazItem::new)
.tag(ItemTags.BEACON_PAYMENT_ITEMS)
.recipe((ctx, provider) -> ShapelessRecipeBuilder.shapeless(RecipeCategory.MISC, ctx.get(), 9)
.requires(ModBlocks.TOPAZ_BLOCK)
.unlockedBy("hasitem", RegistrateRecipeProvider.has(ModBlocks.TOPAZ_BLOCK))
Expand All @@ -391,6 +392,7 @@ public void appendHoverText(@NotNull ItemStack stack, @Nullable Level level, @No
.register();
public static final ItemEntry<Item> RUBY = REGISTRATE
.item("ruby", Item::new)
.tag(ItemTags.BEACON_PAYMENT_ITEMS)
.recipe((ctx, provider) -> ShapelessRecipeBuilder.shapeless(RecipeCategory.MISC, ctx.get(), 9)
.requires(ModBlocks.RUBY_BLOCK)
.unlockedBy("hasitem", RegistrateRecipeProvider.has(ModBlocks.RUBY_BLOCK))
Expand All @@ -399,6 +401,7 @@ public void appendHoverText(@NotNull ItemStack stack, @Nullable Level level, @No
.register();
public static final ItemEntry<Item> SAPPHIRE = REGISTRATE
.item("sapphire", Item::new)
.tag(ItemTags.BEACON_PAYMENT_ITEMS)
.recipe((ctx, provider) -> ShapelessRecipeBuilder.shapeless(RecipeCategory.MISC, ctx.get(), 9)
.requires(ModBlocks.SAPPHIRE_BLOCK)
.unlockedBy("hasitem", RegistrateRecipeProvider.has(ModBlocks.SAPPHIRE_BLOCK))
Expand Down
16 changes: 9 additions & 7 deletions common/src/main/java/dev/dubhe/anvilcraft/item/GeodeItem.java
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,11 @@
import dev.dubhe.anvilcraft.util.BlockHighlightUtil;
import net.minecraft.core.BlockPos;
import net.minecraft.tags.BlockTags;
import net.minecraft.world.InteractionResult;
import net.minecraft.world.InteractionHand;
import net.minecraft.world.InteractionResultHolder;
import net.minecraft.world.entity.player.Player;
import net.minecraft.world.item.Item;
import net.minecraft.world.item.context.UseOnContext;
import net.minecraft.world.item.ItemStack;
import net.minecraft.world.level.Level;
import net.minecraft.world.level.block.state.BlockState;
import net.minecraft.world.level.levelgen.Heightmap;
Expand All @@ -18,10 +20,10 @@
}

@Override
public @NotNull InteractionResult useOn(@NotNull UseOnContext context) {
Level level = context.getLevel();
BlockPos pos = context.getClickedPos();
if (!level.isClientSide) return InteractionResult.SUCCESS;
public @NotNull InteractionResultHolder<ItemStack> use(Level level, Player player, @NotNull InteractionHand usedHand) {

Check warning on line 23 in common/src/main/java/dev/dubhe/anvilcraft/item/GeodeItem.java

View workflow job for this annotation

GitHub Actions / checkstyle

[Checkstyle] reported by reviewdog 🐶 Line is longer than 100 characters (found 123). Raw Output: /home/runner/work/AnvilCraftMod/AnvilCraftMod/common/src/main/java/dev/dubhe/anvilcraft/item/GeodeItem.java:23:0: warning: Line is longer than 100 characters (found 123). (com.puppycrawl.tools.checkstyle.checks.sizes.LineLengthCheck)
ItemStack itemStack = player.getItemInHand(usedHand);
BlockPos pos = player.getOnPos().below();
if (!level.isClientSide) return InteractionResultHolder.success(itemStack);

Check warning on line 26 in common/src/main/java/dev/dubhe/anvilcraft/item/GeodeItem.java

View workflow job for this annotation

GitHub Actions / checkstyle

[Checkstyle] reported by reviewdog 🐶 'if' construct must use '{}'s. Raw Output: /home/runner/work/AnvilCraftMod/AnvilCraftMod/common/src/main/java/dev/dubhe/anvilcraft/item/GeodeItem.java:26:9: warning: 'if' construct must use '{}'s. (com.puppycrawl.tools.checkstyle.checks.blocks.NeedBracesCheck)
int interval = AnvilCraft.config.geodeInterval;
int radius = AnvilCraft.config.geodeRadius;
for (int x = -radius; x <= radius; x += interval) {
Expand All @@ -36,6 +38,6 @@
}
}
}
return InteractionResult.SUCCESS;
return InteractionResultHolder.success(itemStack);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,9 @@
"replace": false,
"values": [
"anvilcraft:royal_steel_block",
"anvilcraft:cursed_gold_block"
"anvilcraft:cursed_gold_block",
"anvilcraft:topaz_block",
"anvilcraft:ruby_block",
"anvilcraft:sapphire_block"
]
}
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,9 @@
"replace": false,
"values": [
"anvilcraft:royal_steel_ingot",
"anvilcraft:cursed_gold_ingot"
"anvilcraft:cursed_gold_ingot",
"anvilcraft:topaz",
"anvilcraft:ruby",
"anvilcraft:sapphire"
]
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
{
"parent": "minecraft:recipes/root",
"criteria": {
"has_royal_steel_block": {
"conditions": {
"items": [
{
"items": [
"anvilcraft:royal_steel_block"
]
}
]
},
"trigger": "minecraft:inventory_changed"
},
"has_the_recipe": {
"conditions": {
"recipe": "minecraft:cut_royal_steel_block_from_royal_steel_block_stonecutting"
},
"trigger": "minecraft:recipe_unlocked"
}
},
"requirements": [
[
"has_royal_steel_block",
"has_the_recipe"
]
],
"rewards": {
"recipes": [
"minecraft:cut_royal_steel_block_from_royal_steel_block_stonecutting"
]
},
"sends_telemetry_event": false
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
{
"parent": "minecraft:recipes/root",
"criteria": {
"has_cut_royal_steel_block": {
"conditions": {
"items": [
{
"items": [
"anvilcraft:cut_royal_steel_block"
]
}
]
},
"trigger": "minecraft:inventory_changed"
},
"has_the_recipe": {
"conditions": {
"recipe": "minecraft:cut_royal_steel_slab_from_cut_royal_steel_block_stonecutting"
},
"trigger": "minecraft:recipe_unlocked"
}
},
"requirements": [
[
"has_cut_royal_steel_block",
"has_the_recipe"
]
],
"rewards": {
"recipes": [
"minecraft:cut_royal_steel_slab_from_cut_royal_steel_block_stonecutting"
]
},
"sends_telemetry_event": false
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
{
"parent": "minecraft:recipes/root",
"criteria": {
"has_royal_steel_block": {
"conditions": {
"items": [
{
"items": [
"anvilcraft:royal_steel_block"
]
}
]
},
"trigger": "minecraft:inventory_changed"
},
"has_the_recipe": {
"conditions": {
"recipe": "minecraft:cut_royal_steel_slab_from_royal_steel_block_stonecutting"
},
"trigger": "minecraft:recipe_unlocked"
}
},
"requirements": [
[
"has_royal_steel_block",
"has_the_recipe"
]
],
"rewards": {
"recipes": [
"minecraft:cut_royal_steel_slab_from_royal_steel_block_stonecutting"
]
},
"sends_telemetry_event": false
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
{
"parent": "minecraft:recipes/root",
"criteria": {
"has_cut_royal_steel_block": {
"conditions": {
"items": [
{
"items": [
"anvilcraft:cut_royal_steel_block"
]
}
]
},
"trigger": "minecraft:inventory_changed"
},
"has_the_recipe": {
"conditions": {
"recipe": "minecraft:cut_royal_steel_stairs_from_cut_royal_steel_block_stonecutting"
},
"trigger": "minecraft:recipe_unlocked"
}
},
"requirements": [
[
"has_cut_royal_steel_block",
"has_the_recipe"
]
],
"rewards": {
"recipes": [
"minecraft:cut_royal_steel_stairs_from_cut_royal_steel_block_stonecutting"
]
},
"sends_telemetry_event": false
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
{
"parent": "minecraft:recipes/root",
"criteria": {
"has_royal_steel_block": {
"conditions": {
"items": [
{
"items": [
"anvilcraft:royal_steel_block"
]
}
]
},
"trigger": "minecraft:inventory_changed"
},
"has_the_recipe": {
"conditions": {
"recipe": "minecraft:cut_royal_steel_stairs_from_royal_steel_block_stonecutting"
},
"trigger": "minecraft:recipe_unlocked"
}
},
"requirements": [
[
"has_royal_steel_block",
"has_the_recipe"
]
],
"rewards": {
"recipes": [
"minecraft:cut_royal_steel_stairs_from_royal_steel_block_stonecutting"
]
},
"sends_telemetry_event": false
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
{
"parent": "minecraft:recipes/root",
"criteria": {
"has_royal_steel_block": {
"conditions": {
"items": [
{
"items": [
"anvilcraft:royal_steel_block"
]
}
]
},
"trigger": "minecraft:inventory_changed"
},
"has_the_recipe": {
"conditions": {
"recipe": "minecraft:smooth_royal_steel_block_from_royal_steel_block_stonecutting"
},
"trigger": "minecraft:recipe_unlocked"
}
},
"requirements": [
[
"has_royal_steel_block",
"has_the_recipe"
]
],
"rewards": {
"recipes": [
"minecraft:smooth_royal_steel_block_from_royal_steel_block_stonecutting"
]
},
"sends_telemetry_event": false
}
Loading
Loading