mod for the islanders smp
0
fork

Configure Feed

Select the types of activity you want to include in your feed.

1.0.3-rc2 - fix: ender eggs being able to be placed - fix: item frames staying glowing after taking out special item

+73 -74
+1 -1
gradle.properties
··· 10 10 fabric_kotlin_version=1.13.4+kotlin.2.2.0 11 11 12 12 # Mod Properties 13 - mod_version=1.0.3-rc1 13 + mod_version=1.0.3-rc2 14 14 maven_group=net.radsteve.islanders 15 15 archives_base_name=islanders-smp 16 16
+26
src/main/java/net/radsteve/islanders/mixin/AbstractDecorationEntityMixin.java
··· 1 + package net.radsteve.islanders.mixin; 2 + 3 + import com.llamalad7.mixinextras.sugar.Local; 4 + import net.minecraft.entity.ItemEntity; 5 + import net.minecraft.entity.decoration.AbstractDecorationEntity; 6 + import net.minecraft.item.ItemStack; 7 + import net.minecraft.server.world.ServerWorld; 8 + import net.radsteve.islanders.SpecialItem; 9 + import org.spongepowered.asm.mixin.Mixin; 10 + import org.spongepowered.asm.mixin.injection.At; 11 + import org.spongepowered.asm.mixin.injection.Inject; 12 + import org.spongepowered.asm.mixin.injection.callback.CallbackInfoReturnable; 13 + 14 + @Mixin(AbstractDecorationEntity.class) 15 + public class AbstractDecorationEntityMixin { 16 + @Inject(method = "dropStack", at = @At(value = "INVOKE", target = "Lnet/minecraft/world/World;spawnEntity(Lnet/minecraft/entity/Entity;)Z")) 17 + private void islanders$dropStack(ServerWorld world, ItemStack stack, float yOffset, CallbackInfoReturnable<ItemEntity> cir, @Local ItemEntity entity) { 18 + final SpecialItem item = SpecialItem.Companion.find(stack); 19 + if (item == null) { 20 + return; 21 + } 22 + 23 + entity.getWorld().getScoreboard().addScoreHolderToTeam(entity.getNameForScoreboard(), item.getTeam()); 24 + entity.setGlowing(true); 25 + } 26 + }
+1 -1
src/main/java/net/radsteve/islanders/mixin/AnvilScreenHandlerMixin.java
··· 13 13 public class AnvilScreenHandlerMixin { 14 14 @Inject(method = "onTakeOutput", at = @At("HEAD"), cancellable = true) 15 15 private void islanders$onTakeOutput(PlayerEntity player, ItemStack stack, CallbackInfo ci) { 16 - if (stack.getItem().equals(Items.POPPED_CHORUS_FRUIT) || stack.getItem().equals(Items.MACE)) { 16 + if (stack.isOf(Items.POPPED_CHORUS_FRUIT) || stack.isOf(Items.MACE)) { 17 17 ci.cancel(); 18 18 } 19 19 }
+4 -4
src/main/java/net/radsteve/islanders/mixin/BlockItemMixin.java
··· 12 12 public class BlockItemMixin { 13 13 @WrapMethod(method = "getPlacementState") 14 14 private BlockState islanders$getPlacementState(ItemPlacementContext context, Operation<BlockState> original) { 15 - if (context.getStack().getItem().equals(Items.DRAGON_EGG)) { 16 - return null; 17 - } else { 15 + // if (context.getStack().getItem().equals(Items.DRAGON_EGG)) { 16 + // return null; 17 + // } else { 18 18 return original.call(context); 19 - } 19 + // } 20 20 } 21 21 }
+1 -1
src/main/java/net/radsteve/islanders/mixin/DecoratedPotBlockMixin.java
··· 24 24 return; 25 25 } 26 26 27 - cir.cancel(); 27 + cir.setReturnValue(ActionResult.FAIL); 28 28 } 29 29 }
-2
src/main/java/net/radsteve/islanders/mixin/ItemFrameEntityMixin.java
··· 1 1 package net.radsteve.islanders.mixin; 2 2 3 3 import net.minecraft.entity.Entity; 4 - import net.minecraft.entity.LivingEntity; 5 4 import net.minecraft.entity.damage.DamageSource; 6 5 import net.minecraft.entity.decoration.ItemFrameEntity; 7 6 import net.minecraft.entity.player.PlayerEntity; ··· 50 49 } 51 50 52 51 entity.setGlowing(false); 53 - item.pickedUp((ServerPlayerEntity) source.getAttacker()); 54 52 } 55 53 }
-20
src/main/java/net/radsteve/islanders/mixin/ItemPlacementContextMixin.java
··· 1 - package net.radsteve.islanders.mixin; 2 - 3 - import com.llamalad7.mixinextras.injector.wrapmethod.WrapMethod; 4 - import com.llamalad7.mixinextras.injector.wrapoperation.Operation; 5 - import net.minecraft.item.ItemPlacementContext; 6 - import net.minecraft.item.ItemUsageContext; 7 - import net.minecraft.item.Items; 8 - import org.spongepowered.asm.mixin.Mixin; 9 - 10 - @Mixin(ItemPlacementContext.class) 11 - public class ItemPlacementContextMixin { 12 - @WrapMethod(method = "canPlace") 13 - private boolean islanders$canPlace(Operation<Boolean> original) { 14 - // if (ItemUsageContext.class.cast(this).getStack().getItem().equals(Items.DRAGON_EGG)) { 15 - // return false; 16 - // } else { 17 - return original.call(); 18 - // } 19 - } 20 - }
-11
src/main/java/net/radsteve/islanders/mixin/PlayerEntityMixin.java
··· 7 7 import net.minecraft.entity.player.PlayerEntity; 8 8 import net.minecraft.entity.player.PlayerInventory; 9 9 import net.minecraft.item.ItemStack; 10 - import net.minecraft.item.Items; 11 10 import net.minecraft.scoreboard.Scoreboard; 12 11 import net.minecraft.server.world.ServerWorld; 13 - import net.minecraft.util.math.BlockPos; 14 - import net.minecraft.util.math.Direction; 15 12 import net.radsteve.islanders.Islanders; 16 13 import net.radsteve.islanders.ItemEffects; 17 14 import net.radsteve.islanders.SpecialItem; ··· 21 18 import org.spongepowered.asm.mixin.injection.At; 22 19 import org.spongepowered.asm.mixin.injection.Inject; 23 20 import org.spongepowered.asm.mixin.injection.callback.CallbackInfo; 24 - import org.spongepowered.asm.mixin.injection.callback.CallbackInfoReturnable; 25 21 26 22 @Mixin(PlayerEntity.class) 27 23 public abstract class PlayerEntityMixin { ··· 65 61 getScoreboard().removeScoreHolderFromTeam(getNameForScoreboard(), item.getTeam()); 66 62 } 67 63 }); 68 - } 69 - 70 - @Inject(method = "canPlaceOn", at = @At("HEAD"), cancellable = true) 71 - private void islanders$canPlaceOn(BlockPos pos, Direction facing, ItemStack stack, CallbackInfoReturnable<Boolean> cir) { 72 - if (stack.getItem().equals(Items.DRAGON_EGG)) { 73 - cir.setReturnValue(false); 74 - } 75 64 } 76 65 }
-27
src/main/java/net/radsteve/islanders/mixin/ServerPlayerInteractionManagerMixin.java
··· 1 - package net.radsteve.islanders.mixin; 2 - 3 - import com.llamalad7.mixinextras.injector.wrapoperation.Operation; 4 - import com.llamalad7.mixinextras.injector.wrapoperation.WrapOperation; 5 - import net.minecraft.item.ItemStack; 6 - import net.minecraft.item.ItemUsageContext; 7 - import net.minecraft.item.Items; 8 - import net.minecraft.server.network.ServerPlayerEntity; 9 - import net.minecraft.server.network.ServerPlayerInteractionManager; 10 - import net.minecraft.util.ActionResult; 11 - import net.minecraft.util.Hand; 12 - import net.minecraft.util.hit.BlockHitResult; 13 - import net.minecraft.world.World; 14 - import org.spongepowered.asm.mixin.Mixin; 15 - import org.spongepowered.asm.mixin.injection.At; 16 - import org.spongepowered.asm.mixin.injection.Inject; 17 - import org.spongepowered.asm.mixin.injection.callback.CallbackInfoReturnable; 18 - 19 - @Mixin(ServerPlayerInteractionManager.class) 20 - public class ServerPlayerInteractionManagerMixin { 21 - @Inject(method = "interactBlock", at = @At(value = "INVOKE", target = "Lnet/minecraft/item/ItemStack;useOnBlock(Lnet/minecraft/item/ItemUsageContext;)Lnet/minecraft/util/ActionResult;", ordinal = 1), cancellable = true) 22 - private void islanders$interactBlock(ServerPlayerEntity player, World world, ItemStack stack, Hand hand, BlockHitResult hitResult, CallbackInfoReturnable<ActionResult> cir) { 23 - // if (stack.getItem().equals(Items.DRAGON_EGG)) { 24 - // cir.setReturnValue(ActionResult.FAIL); 25 - // } 26 - } 27 - }
+6
src/main/kotlin/net/radsteve/islanders/Helpers.kt
··· 2 2 3 3 import net.minecraft.component.DataComponentTypes 4 4 import net.minecraft.component.type.LoreComponent 5 + import net.minecraft.component.type.TooltipDisplayComponent 5 6 import net.minecraft.enchantment.Enchantment 6 7 import net.minecraft.item.ItemStack 7 8 import net.minecraft.registry.RegistryKey ··· 16 17 17 18 public fun ItemStack.withName(name: MutableText): ItemStack { 18 19 set(DataComponentTypes.CUSTOM_NAME, name.styled { style -> style.withItalic(false) }) 20 + return this 21 + } 22 + 23 + public fun ItemStack.withHideEnchantments(): ItemStack { 24 + set(DataComponentTypes.TOOLTIP_DISPLAY, TooltipDisplayComponent(false, LinkedHashSet(setOf(DataComponentTypes.ENCHANTMENTS)))) 19 25 return this 20 26 } 21 27
+22 -1
src/main/kotlin/net/radsteve/islanders/Islanders.kt
··· 4 4 import net.fabricmc.fabric.api.command.v2.CommandRegistrationCallback 5 5 import net.fabricmc.fabric.api.event.lifecycle.v1.ServerLifecycleEvents 6 6 import net.fabricmc.fabric.api.event.lifecycle.v1.ServerTickEvents 7 + import net.fabricmc.fabric.api.event.player.UseBlockCallback 8 + import net.fabricmc.fabric.api.event.player.UseItemCallback 7 9 import net.mcbrawls.scheduler.AbsoluteScheduler 8 10 import net.mcbrawls.scheduler.Scheduler 11 + import net.mcbrawls.scheduler.duration.TickDuration.ticks 12 + import net.minecraft.entity.player.PlayerEntity 13 + import net.minecraft.item.Items 9 14 import net.minecraft.server.MinecraftServer 15 + import net.minecraft.util.ActionResult 16 + import net.minecraft.util.Hand 17 + import net.minecraft.util.hit.BlockHitResult 18 + import net.minecraft.world.World 10 19 import net.radsteve.islanders.command.animationCommand 11 20 import net.radsteve.islanders.crown.CrownAnimation 12 21 import net.radsteve.islanders.mace.MaceAnimation ··· 16 25 import org.slf4j.Logger 17 26 import org.slf4j.LoggerFactory 18 27 19 - public object Islanders : ModInitializer, ServerTickEvents.EndTick { 28 + public object Islanders : ModInitializer, ServerTickEvents.EndTick, UseBlockCallback { 20 29 @JvmStatic 21 30 public val logger: Logger = LoggerFactory.getLogger("islanders") 22 31 public lateinit var server: MinecraftServer ··· 33 42 ServerLifecycleEvents.SERVER_STARTED.register { server -> Islanders.server = server } 34 43 35 44 ServerTickEvents.END_SERVER_TICK.register(this) 45 + UseBlockCallback.EVENT.register(this) 36 46 37 47 RuleHandlers 38 48 ItemEffects ··· 48 58 49 59 override fun onEndTick(server: MinecraftServer) { 50 60 scheduler.processTick() 61 + } 62 + 63 + override fun interact(player: PlayerEntity, world: World, hand: Hand, hitResult: BlockHitResult): ActionResult { 64 + return if (player.getStackInHand(hand).isOf(Items.DRAGON_EGG)) { 65 + scheduler.schedule(1.ticks) { 66 + player.playerScreenHandler.syncState() // thank you ebic 67 + } 68 + ActionResult.FAIL 69 + } else { 70 + ActionResult.PASS 71 + } 51 72 } 52 73 }
+11 -4
src/main/kotlin/net/radsteve/islanders/SpecialItem.kt
··· 192 192 } 193 193 194 194 public fun decorateItemStack(itemStack: ItemStack): ItemStack { 195 + val effectLines = listOf( 196 + Text.literal("Effect:").formatted(Formatting.GRAY), 197 + Text.literal(" $description").formatted(color) 198 + ) 199 + val lines = if (this != DragonEgg) { 200 + listOf(Text.empty()) + effectLines // cursed 201 + } else { 202 + effectLines 203 + } 204 + 195 205 return itemStack 196 206 .withName(Text.literal(displayName).formatted(color)) 197 - .withLore( 198 - Text.literal("Effect:").formatted(Formatting.GRAY), 199 - Text.literal(" $description").formatted(color) 200 - ) 207 + .withLore(*lines.toTypedArray()) 201 208 } 202 209 203 210 public companion object {
+1 -2
src/main/resources/islanders.mixins.json
··· 14 14 "CraftingScreenHandlerAccessor", 15 15 "CraftingScreenHandlerMixin", 16 16 "DecoratedPotBlockMixin", 17 + "AbstractDecorationEntityMixin", 17 18 "GrindstoneScreenHandlerMixin", 18 19 "HopperBlockEntityMixin", 19 20 "ItemEntityMixin", 20 21 "ItemFrameEntityMixin", 21 - "ItemPlacementContextMixin", 22 22 "ItemStackMixin", 23 23 "LivingEntityAccessor", 24 24 "LivingEntityMixin", ··· 26 26 "PlayerInventoryAccessor", 27 27 "PlayerInventoryMixin", 28 28 "ScreenHandlerMixin", 29 - "ServerPlayerInteractionManagerMixin", 30 29 "ShapelessRecipeAccessor" 31 30 ], 32 31 "injectors": {