-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #198 from Gilly7CE/mcversion-gilly7ce-197-support-…
…1.21 Add support for 1.21.1
- Loading branch information
Showing
35 changed files
with
387 additions
and
546 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Binary file not shown.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,7 @@ | ||
distributionBase=GRADLE_USER_HOME | ||
distributionPath=wrapper/dists | ||
distributionUrl=https\://services.gradle.org/distributions/gradle-8.6-bin.zip | ||
distributionUrl=https\://services.gradle.org/distributions/gradle-8.10-bin.zip | ||
networkTimeout=10000 | ||
validateDistributionUrl=true | ||
zipStoreBase=GRADLE_USER_HOME | ||
zipStorePath=wrapper/dists |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
30 changes: 30 additions & 0 deletions
30
src/main/java/carpetaddonsnotfound/flowerpotrules/AlwaysPickFlowersFromPotsRule.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
package carpetaddonsnotfound.flowerpotrules; | ||
|
||
import net.minecraft.block.Block; | ||
import net.minecraft.block.BlockState; | ||
import net.minecraft.block.Blocks; | ||
import net.minecraft.block.FlowerPotBlock; | ||
import net.minecraft.entity.player.PlayerEntity; | ||
import net.minecraft.item.ItemStack; | ||
import net.minecraft.util.math.BlockPos; | ||
import net.minecraft.world.World; | ||
import net.minecraft.world.event.GameEvent; | ||
|
||
public class AlwaysPickFlowersFromPotsRule { | ||
public static boolean execute(BlockState blockState, World world, BlockPos blockPos, PlayerEntity player) { | ||
Block potBlock = blockState.getBlock(); | ||
Block content; | ||
if (!(potBlock instanceof FlowerPotBlock flowerPotBlock) || (content = flowerPotBlock.getContent()) == Blocks.AIR) { | ||
return false; | ||
} | ||
|
||
ItemStack itemStack = new ItemStack(content); | ||
if (!player.giveItemStack(itemStack)) { | ||
player.dropItem(itemStack, false); | ||
} | ||
|
||
world.setBlockState(blockPos, Blocks.FLOWER_POT.getDefaultState(), 3); | ||
world.emitGameEvent(player, GameEvent.BLOCK_CHANGE, blockPos); | ||
return true; | ||
} | ||
} |
32 changes: 32 additions & 0 deletions
32
src/main/java/carpetaddonsnotfound/flowerpotrules/FlowerPotRuleManager.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
package carpetaddonsnotfound.flowerpotrules; | ||
|
||
import carpetaddonsnotfound.CarpetAddonsNotFoundSettings; | ||
import net.minecraft.block.Block; | ||
import net.minecraft.block.BlockState; | ||
import net.minecraft.entity.player.PlayerEntity; | ||
import net.minecraft.util.Hand; | ||
import net.minecraft.util.math.BlockPos; | ||
import net.minecraft.world.World; | ||
|
||
import java.util.Map; | ||
|
||
public class FlowerPotRuleManager { | ||
public static boolean executeRule(Map<Block, Block> contentToPotted, | ||
PlayerEntity player, | ||
Hand hand, | ||
World world, | ||
BlockPos blockPos, | ||
BlockState blockState, | ||
|
||
Block currentContent) { | ||
if (CarpetAddonsNotFoundSettings.replaceFlowersInPots) { | ||
return ReplaceFlowersInPotsRule.execute(contentToPotted, player, hand, world, blockPos, currentContent); | ||
} | ||
|
||
if (CarpetAddonsNotFoundSettings.alwaysPickFlowersFromPots) { | ||
return AlwaysPickFlowersFromPotsRule.execute(blockState, world, blockPos, player); | ||
} | ||
|
||
return false; | ||
} | ||
} |
43 changes: 43 additions & 0 deletions
43
src/main/java/carpetaddonsnotfound/flowerpotrules/ReplaceFlowersInPotsRule.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,43 @@ | ||
package carpetaddonsnotfound.flowerpotrules; | ||
|
||
import net.minecraft.block.Block; | ||
import net.minecraft.block.BlockState; | ||
import net.minecraft.block.Blocks; | ||
import net.minecraft.block.FlowerPotBlock; | ||
import net.minecraft.entity.player.PlayerEntity; | ||
import net.minecraft.item.BlockItem; | ||
import net.minecraft.item.Item; | ||
import net.minecraft.item.ItemStack; | ||
import net.minecraft.stat.Stats; | ||
import net.minecraft.util.Hand; | ||
import net.minecraft.util.math.BlockPos; | ||
import net.minecraft.world.World; | ||
import net.minecraft.world.event.GameEvent; | ||
|
||
import java.util.Map; | ||
|
||
public class ReplaceFlowersInPotsRule { | ||
public static boolean execute(Map<Block, Block> contentToPotted, PlayerEntity player, Hand hand, World world, | ||
BlockPos blockPos, Block currentContent) { | ||
ItemStack playerStack = player.getStackInHand(hand); | ||
Item item = playerStack.getItem(); | ||
Block newPot = | ||
(item instanceof BlockItem ? contentToPotted.getOrDefault(((BlockItem) item).getBlock(), Blocks.AIR) | ||
: Blocks.AIR); | ||
if (!(newPot instanceof FlowerPotBlock) || ((FlowerPotBlock) newPot).getContent() == currentContent) { | ||
return false; | ||
} | ||
|
||
ItemStack dropStack = new ItemStack(currentContent.asItem(), 1); | ||
if (!player.giveItemStack(dropStack)) { | ||
player.dropStack(dropStack); | ||
} | ||
|
||
BlockState blockState = newPot.getDefaultState(); | ||
world.setBlockState(blockPos, blockState, 3); | ||
world.emitGameEvent(player, GameEvent.BLOCK_CHANGE, blockPos); | ||
player.incrementStat(Stats.POT_FLOWER); | ||
playerStack.decrementUnlessCreative(1, player); | ||
return true; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
29 changes: 29 additions & 0 deletions
29
.../java/carpetaddonsnotfound/mixins/ClientPlayerEntity_SpectatorPlayersUsePortalsMixin.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
package carpetaddonsnotfound.mixins; | ||
|
||
import carpetaddonsnotfound.mixins.invokers.EntityInvokerMixin; | ||
import carpetaddonsnotfound.spectatorplayersuseportals.SpectatorPlayersUsePortalsRule; | ||
import com.mojang.authlib.GameProfile; | ||
import net.minecraft.client.network.AbstractClientPlayerEntity; | ||
import net.minecraft.client.network.ClientPlayerEntity; | ||
import net.minecraft.client.world.ClientWorld; | ||
import net.minecraft.entity.MovementType; | ||
import net.minecraft.util.math.Vec3d; | ||
import org.spongepowered.asm.mixin.Mixin; | ||
import org.spongepowered.asm.mixin.injection.At; | ||
import org.spongepowered.asm.mixin.injection.Inject; | ||
import org.spongepowered.asm.mixin.injection.callback.CallbackInfo; | ||
|
||
@Mixin(ClientPlayerEntity.class) | ||
public abstract class ClientPlayerEntity_SpectatorPlayersUsePortalsMixin extends AbstractClientPlayerEntity implements | ||
EntityInvokerMixin { | ||
|
||
public ClientPlayerEntity_SpectatorPlayersUsePortalsMixin(ClientWorld world, | ||
GameProfile profile) { | ||
super(world, profile); | ||
} | ||
|
||
@Inject(method = "move", at = @At("TAIL")) | ||
private void movePlayerInSpectator(MovementType movementType, Vec3d movement, CallbackInfo ci) { | ||
SpectatorPlayersUsePortalsRule.movePlayerInSpectator(this); | ||
} | ||
} |
Oops, something went wrong.