-
-
Notifications
You must be signed in to change notification settings - Fork 1
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 #5 from udu3324/master
Add BlockLobbyMapAds & Fix BlockLobbyWelcome
- Loading branch information
Showing
7 changed files
with
121 additions
and
29 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
package com.udu3324.poinpow.mixin; | ||
|
||
import com.udu3324.poinpow.utils.BlockLobbyMapAds; | ||
import net.minecraft.client.render.VertexConsumerProvider; | ||
import net.minecraft.client.render.entity.ItemFrameEntityRenderer; | ||
import net.minecraft.client.util.math.MatrixStack; | ||
import net.minecraft.entity.Entity; | ||
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(ItemFrameEntityRenderer.class) | ||
public class MapartMixin { | ||
@Inject(method = "render(Lnet/minecraft/entity/Entity;FFLnet/minecraft/client/util/math/MatrixStack;Lnet/minecraft/client/render/VertexConsumerProvider;I)V", at = @At("HEAD")) | ||
private void onRender(Entity entity, float yaw, float tickDelta, MatrixStack matrices, VertexConsumerProvider vertexConsumers, int light, CallbackInfo ci) { | ||
BlockLobbyMapAds.block(entity); | ||
} | ||
} |
48 changes: 48 additions & 0 deletions
48
src/main/java/com/udu3324/poinpow/utils/BlockLobbyMapAds.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,48 @@ | ||
package com.udu3324.poinpow.utils; | ||
|
||
import com.udu3324.poinpow.Poinpow; | ||
import net.minecraft.client.MinecraftClient; | ||
import net.minecraft.entity.Entity; | ||
import net.minecraft.entity.decoration.ItemFrameEntity; | ||
import net.minecraft.item.ItemStack; | ||
import net.minecraft.item.Items; | ||
import net.minecraft.scoreboard.Scoreboard; | ||
import net.minecraft.scoreboard.ScoreboardObjective; | ||
import net.minecraft.text.Text; | ||
|
||
import java.util.ArrayList; | ||
import java.util.concurrent.atomic.AtomicBoolean; | ||
import java.util.stream.Collectors; | ||
|
||
public class BlockLobbyMapAds { | ||
public static String name = "block_lobby_map_ads"; | ||
public static String description = "Removes the humungous map art that advertises things in lobby."; | ||
public static AtomicBoolean toggled = new AtomicBoolean(true); | ||
private static final ItemStack item = new ItemStack(Items.DIAMOND, 1).setCustomName(Text.of("Poinpow by udu3324")); | ||
|
||
public static void block(Entity entity) { | ||
// return if toggled off (no need for bool) | ||
if (!toggled.get()) return; | ||
|
||
// return if not on minehut | ||
if (!Poinpow.onMinehut) return; | ||
|
||
if (MinecraftClient.getInstance().player == null) return; | ||
|
||
// check for scoreboard | ||
Scoreboard scoreboard = MinecraftClient.getInstance().player.getScoreboard(); | ||
ArrayList<String> objectivesList = scoreboard.getObjectives().stream().map(ScoreboardObjective::getName).collect(Collectors.toCollection(ArrayList::new)); | ||
|
||
if (!objectivesList.contains("Minehut")) return; | ||
|
||
// remove if item frame has a map in it | ||
ItemFrameEntity itemFrame = (ItemFrameEntity) entity; | ||
|
||
if (!itemFrame.containsMap()) return; | ||
|
||
Poinpow.log.info("Blocked: Lobby Map Ad (" + itemFrame.getBlockX() + ", " + itemFrame.getBlockY() + ", " + itemFrame.getBlockZ() + ")"); | ||
|
||
itemFrame.setHeldItemStack(item); | ||
itemFrame.setRotation(1); | ||
} | ||
} |
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