Skip to content

Commit

Permalink
porting
Browse files Browse the repository at this point in the history
  • Loading branch information
IThundxr committed Nov 15, 2023
1 parent 66f8b32 commit dabe660
Show file tree
Hide file tree
Showing 31 changed files with 233 additions and 252 deletions.
Original file line number Diff line number Diff line change
@@ -1,10 +1,5 @@
package org.violetmoon.quark.addons.oddities.block.pipe;

import java.util.HashSet;
import java.util.Set;

import javax.annotation.Nonnull;

import net.minecraft.core.BlockPos;
import net.minecraft.core.Direction;
import net.minecraft.world.InteractionHand;
Expand All @@ -17,18 +12,15 @@
import net.minecraft.world.item.context.BlockPlaceContext;
import net.minecraft.world.level.Level;
import net.minecraft.world.level.LevelAccessor;
import net.minecraft.world.level.block.Block;
import net.minecraft.world.level.block.EntityBlock;
import net.minecraft.world.level.block.Mirror;
import net.minecraft.world.level.block.Rotation;
import net.minecraft.world.level.block.SoundType;
import net.minecraft.world.level.block.*;
import net.minecraft.world.level.block.entity.BlockEntity;
import net.minecraft.world.level.block.entity.BlockEntityTicker;
import net.minecraft.world.level.block.entity.BlockEntityType;
import net.minecraft.world.level.block.state.BlockState;
import net.minecraft.world.level.block.state.StateDefinition.Builder;
import net.minecraft.world.level.block.state.properties.BlockStateProperties;
import net.minecraft.world.level.block.state.properties.BooleanProperty;
import net.minecraft.world.level.block.state.properties.NoteBlockInstrument;
import net.minecraft.world.level.material.Material;
import net.minecraft.world.phys.BlockHitResult;
import org.jetbrains.annotations.Nullable;
Expand All @@ -38,6 +30,10 @@
import org.violetmoon.zeta.module.ZetaModule;
import org.violetmoon.zeta.registry.RenderLayerRegistry;

import javax.annotation.Nonnull;
import java.util.HashSet;
import java.util.Set;

import static org.violetmoon.quark.base.handler.MiscUtil.directionProperty;

public abstract class BasePipeBlock extends ZetaBlock implements EntityBlock {
Expand All @@ -62,7 +58,8 @@ protected static BooleanProperty property(Direction direction) {

protected BasePipeBlock(String name, ZetaModule module) {
super(name, module, CreativeModeTab.TAB_REDSTONE,
Block.Properties.of(Material.GLASS)
Block.Properties.of()
.instrument(NoteBlockInstrument.HAT)
.strength(3F, 10F)
.sound(SoundType.GLASS)
.noOcclusion());
Expand Down
Original file line number Diff line number Diff line change
@@ -1,10 +1,11 @@
package org.violetmoon.quark.addons.oddities.client.screen;

import com.mojang.blaze3d.systems.RenderSystem;
import com.mojang.blaze3d.vertex.PoseStack;
import net.minecraft.client.gui.GuiGraphics;
import net.minecraft.client.gui.components.AbstractWidget;
import net.minecraft.client.gui.components.Button;
import net.minecraft.client.gui.components.ImageButton;
import net.minecraft.client.gui.components.Widget;
import net.minecraft.client.gui.components.Renderable;
import net.minecraft.client.gui.screens.inventory.InventoryScreen;
import net.minecraft.client.renderer.GameRenderer;
import net.minecraft.network.chat.Component;
Expand All @@ -13,14 +14,10 @@
import net.minecraft.world.entity.player.Player;
import net.minecraft.world.inventory.InventoryMenu;
import net.minecraft.world.item.ItemStack;

import javax.annotation.Nonnull;

import org.violetmoon.quark.addons.oddities.inventory.BackpackMenu;
import org.violetmoon.quark.addons.oddities.module.BackpackModule;
import org.violetmoon.quark.base.Quark;
import org.violetmoon.quark.base.QuarkClient;
import org.violetmoon.quark.base.network.QuarkNetwork;
import org.violetmoon.quark.base.network.message.oddities.HandleBackpackMessage;

import java.util.HashMap;
Expand Down Expand Up @@ -57,20 +54,20 @@ public void init() {

buttonYs.clear();

for(Widget widget : renderables)
if(widget instanceof Button b)
if(b.getClass().getName().contains("GuiButtonInventoryBook")) { // class check for Patchouli
if(!buttonYs.containsKey(b)) {
b.y -= 29;
buttonYs.put(b, b.y);
for (Renderable renderable : renderables)
if (renderable instanceof Button b)
if (b.getClass().getName().contains("GuiButtonInventoryBook")) { // class check for Patchouli
if (!buttonYs.containsKey(b)) {
b.setY(b.getY() - 29);
buttonYs.put(b, b.getY());
}
}

}

@Override
public void containerTick() {
buttonYs.forEach((button, y) -> button.y = y);
buttonYs.forEach(AbstractWidget::setY);

super.containerTick();

Expand All @@ -95,23 +92,22 @@ public void removed() {
}

@Override
protected void renderBg(@Nonnull PoseStack stack, float partialTicks, int mouseX, int mouseY) {
protected void renderBg(GuiGraphics guiGraphics, float partialTicks, int mouseX, int mouseY) {
RenderSystem.setShader(GameRenderer::getPositionTexShader);
RenderSystem.setShaderColor(1.0F, 1.0F, 1.0F, 1.0F);
RenderSystem.setShaderTexture(0, BACKPACK_INVENTORY_BACKGROUND);
int i = leftPos;
int j = topPos;
blit(stack, i, j, 0, 0, imageWidth, imageHeight);
renderEntityInInventory(i + 51, j + 75, 30, i + 51 - mouseX, j + 75 - 50 - mouseY, minecraft.player);
guiGraphics.blit(BACKPACK_INVENTORY_BACKGROUND, i, j, 0, 0, imageWidth, imageHeight);
renderEntityInInventoryFollowsMouse(guiGraphics, i + 51, j + 75, 30, i + 51 - mouseX, j + 75 - 50 - mouseY, minecraft.player);
moveCharmsButtons();
}

private void moveCharmsButtons() {
for(Widget widget : renderables) {
for (Renderable renderable : renderables) {
//Charms buttons have a static Y pos, so use that to only focus on them.
if(widget instanceof ImageButton img) {
if(img.y == height / 2 - 22)
img.setPosition(img.x, img.y - 29);
if (renderable instanceof ImageButton img) {
if (img.getY() == height / 2 - 22)
img.setPosition(img.getX(), img.getY() - 29);
}
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,18 +8,17 @@
import net.minecraft.world.entity.player.Player;
import net.minecraft.world.inventory.*;
import net.minecraft.world.item.ItemStack;

import javax.annotation.Nonnull;

import org.violetmoon.quark.addons.oddities.inventory.slot.BackpackSlot;
import org.violetmoon.quark.addons.oddities.inventory.slot.CachedItemHandlerSlot;
import org.violetmoon.quark.addons.oddities.module.BackpackModule;
import org.violetmoon.quark.base.util.InventoryIIH;

import javax.annotation.Nonnull;

public class BackpackMenu extends InventoryMenu {

public BackpackMenu(int windowId, Player player) {
super(player.getInventory(), !player.level.isClientSide, player);
super(player.getInventory(), !player.getCommandSenderWorld().isClientSide, player);
this.containerId = windowId;

Inventory inventory = player.getInventory();
Expand Down Expand Up @@ -138,7 +137,7 @@ public boolean moveItemStackTo(ItemStack stack, int start, int length, boolean r
int maxStack = Math.min(stack.getMaxStackSize(), slot.getMaxStackSize());
int rmv = Math.min(maxStack, stack.getCount());

if (slot.mayPlace(cloneStack(stack, rmv)) && existingStack.getItem().equals(stack.getItem()) && ItemStack.tagMatches(stack, existingStack)) {
if (slot.mayPlace(cloneStack(stack, rmv)) && existingStack.getItem().equals(stack.getItem()) && ItemStack.isSameItemSameTags(stack, existingStack)) {
int existingSize = existingStack.getCount() + stack.getCount();

if (existingSize <= maxStack) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -173,7 +173,7 @@ public void inventoryTick(@Nonnull ItemStack stack, Level worldIn, @Nonnull Enti

@Override
public boolean onEntityItemUpdateZeta(ItemStack stack, ItemEntity entityItem) {
if(BackpackModule.superOpMode || entityItem.level.isClientSide)
if(BackpackModule.superOpMode || entityItem.getCommandSenderWorld().isClientSide)
return false;

if (!ItemNBTHelper.detectNBT(stack))
Expand All @@ -190,7 +190,7 @@ public boolean onEntityItemUpdateZeta(ItemStack stack, ItemEntity entityItem) {
ItemStack stackAt = handler.getStackInSlot(i);
if(!stackAt.isEmpty()) {
ItemStack copy = stackAt.copy();
Containers.dropItemStack(entityItem.level, entityItem.getX(), entityItem.getY(), entityItem.getZ(), copy);
Containers.dropItemStack(entityItem.getCommandSenderWorld(), entityItem.getX(), entityItem.getY(), entityItem.getZ(), copy);
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,8 @@
import net.minecraft.client.gui.screens.Screen;
import net.minecraft.client.gui.screens.inventory.InventoryScreen;
import net.minecraft.client.renderer.item.ItemProperties;
import net.minecraft.core.Registry;
import net.minecraft.core.cauldron.CauldronInteraction;
import net.minecraft.core.registries.Registries;
import net.minecraft.resources.ResourceLocation;
import net.minecraft.tags.ItemTags;
import net.minecraft.tags.TagKey;
Expand All @@ -18,15 +18,10 @@
import net.minecraft.world.entity.item.ItemEntity;
import net.minecraft.world.entity.player.Player;
import net.minecraft.world.inventory.MenuType;
import net.minecraft.world.item.CreativeModeTab;
import net.minecraft.world.item.DyeColor;
import net.minecraft.world.item.DyeableArmorItem;
import net.minecraft.world.item.Item;
import net.minecraft.world.item.ItemStack;
import net.minecraft.world.item.Rarity;
import net.minecraft.world.item.*;
import net.minecraft.world.level.block.Block;
import net.minecraft.world.level.block.SoundType;
import net.minecraft.world.level.material.Material;
import net.minecraft.world.level.block.state.properties.NoteBlockInstrument;
import net.minecraftforge.common.extensions.IForgeMenuType;
import org.violetmoon.quark.addons.oddities.client.screen.BackpackInventoryScreen;
import org.violetmoon.quark.addons.oddities.inventory.BackpackMenu;
Expand Down Expand Up @@ -82,11 +77,14 @@ public final void register(ZRegister event) {
ravager_hide = new ZetaItem("ravager_hide", this, new Item.Properties().rarity(Rarity.RARE).tab(CreativeModeTab.TAB_MATERIALS)).setCondition(() -> enableRavagerHide);

menyType = IForgeMenuType.create(BackpackMenu::fromNetwork);
Quark.ZETA.registry.register(menyType, "backpack", Registry.MENU_REGISTRY);
Quark.ZETA.registry.register(menyType, "backpack", Registries.MENU);

bonded_ravager_hide = new ZetaBlock("bonded_ravager_hide", this, CreativeModeTab.TAB_BUILDING_BLOCKS, Block.Properties.of(Material.WOOL, DyeColor.BLACK)
bonded_ravager_hide = new ZetaBlock("bonded_ravager_hide", this, CreativeModeTab.TAB_BUILDING_BLOCKS, Block.Properties.of()
.mapColor(DyeColor.BLACK)
.instrument(NoteBlockInstrument.GUITAR)
.strength(1F)
.sound(SoundType.WOOL))
.sound(SoundType.WOOL)
.ignitedByLava())
.setCondition(() -> enableRavagerHide);

CauldronInteraction.WATER.put(backpack, CauldronInteraction.DYED_ITEM);
Expand All @@ -107,10 +105,10 @@ public void onDrops(ZLivingDrops event) {
chance--;
amount++;
}
if(chance > 0 && entity.level.random.nextDouble() < chance)
if(chance > 0 && entity.getCommandSenderWorld().random.nextDouble() < chance)
amount++;

event.getDrops().add(new ItemEntity(entity.level, entity.getX(), entity.getY(), entity.getZ(), new ItemStack(ravager_hide, amount)));
event.getDrops().add(new ItemEntity(entity.getCommandSenderWorld(), entity.getX(), entity.getY(), entity.getZ(), new ItemStack(ravager_hide, amount)));
}
}

Expand Down
4 changes: 4 additions & 0 deletions src/main/java/org/violetmoon/quark/base/Quark.java
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
package org.violetmoon.quark.base;

import net.minecraft.resources.ResourceLocation;
import net.minecraftforge.fml.DistExecutor;
import net.minecraftforge.fml.common.Mod;

Expand Down Expand Up @@ -32,4 +33,7 @@ public Quark() {
proxy.start();
}

public static ResourceLocation asResource(String name) {
return new ResourceLocation(MOD_ID, name);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@
import net.minecraft.world.level.block.state.BlockBehaviour;
import net.minecraft.world.level.block.state.BlockBehaviour.Properties;
import net.minecraft.world.level.block.state.properties.WoodType;
import net.minecraft.world.level.material.MapColor;
import net.minecraft.world.level.material.Material;
import net.minecraft.world.level.material.MaterialColor;
import net.minecraftforge.common.ToolActions;
Expand Down Expand Up @@ -104,11 +105,11 @@ public static void setup(ZCommonSetup event) {
});
}

public static WoodSet addWoodSet(ZRegister event, ZetaModule module, String name, MaterialColor color, MaterialColor barkColor, boolean flammable) {
public static WoodSet addWoodSet(ZRegister event, ZetaModule module, String name, MapColor color, MapColor barkColor, boolean flammable) {
return addWoodSet(event, module, name, color, barkColor, true, true, flammable);
}

public static WoodSet addWoodSet(ZRegister event, ZetaModule module, String name, MaterialColor color, MaterialColor barkColor, boolean hasLog, boolean hasBoat, boolean flammable) {
public static WoodSet addWoodSet(ZRegister event, ZetaModule module, String name, MapColor color, MapColor barkColor, boolean hasLog, boolean hasBoat, boolean flammable) {
WoodType type = WoodType.register(WoodType.create(Quark.MOD_ID + ":" + name));
WoodSet set = new WoodSet(name, module, type);

Expand Down Expand Up @@ -185,7 +186,7 @@ public static void makeSignWork(Block sign, Block wallSign) {
BlockEntityType.SIGN.validBlocks = ImmutableSet.copyOf(validBlocks);
}

private static RotatedPillarBlock log(String name, ZetaModule module, MaterialColor topColor, MaterialColor sideColor) {
private static RotatedPillarBlock log(String name, ZetaModule module, MapColor topColor, MapColor sideColor) {
return new ZetaPillarBlock(name, module, CreativeModeTab.TAB_BUILDING_BLOCKS,
BlockBehaviour.Properties.of(Material.WOOD, s -> s.getValue(RotatedPillarBlock.AXIS) == Direction.Axis.Y ? topColor : sideColor)
.strength(2.0F).sound(SoundType.WOOD));
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
package org.violetmoon.quark.content.client.module;

import net.minecraft.client.gui.GuiGraphics;
import org.violetmoon.quark.base.QuarkClient;
import org.violetmoon.quark.base.config.Config;
import org.violetmoon.zeta.client.event.load.ZKeyMapping;
Expand Down Expand Up @@ -56,6 +57,8 @@ public void drawHUD(ZRenderGuiOverlay.Hotbar event) {
if(drawHud && autorunning) {
String message = I18n.get("quark.misc.autowalking");

GuiGraphics guiGraphics = event.getGuiGraphics();

Minecraft mc = Minecraft.getInstance();
int w = mc.font.width("OoO" + message + "oOo");

Expand All @@ -70,7 +73,7 @@ public void drawHUD(ZRenderGuiOverlay.Hotbar event) {
case 1 -> displayMessage = "oOo " + message + " OoO";
}

mc.font.drawShadow(event.getPoseStack(), displayMessage, x, y, 0xFFFFFFFF);
guiGraphics.drawString(mc.font, displayMessage, x, y, 0xFFFFFFFF, true);
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
import net.minecraft.client.KeyMapping;
import net.minecraft.client.Minecraft;
import net.minecraft.client.Screenshot;
import net.minecraft.client.gui.GuiGraphics;
import net.minecraft.client.gui.screens.Screen;
import net.minecraft.client.renderer.GameRenderer;
import net.minecraft.client.resources.language.I18n;
Expand Down
Loading

0 comments on commit dabe660

Please sign in to comment.