Skip to content

Commit

Permalink
Merge branch '1.19' of https://github.com/McJtyMods/FancyTrinkets int…
Browse files Browse the repository at this point in the history
…o 1.19
  • Loading branch information
McJty committed Jun 21, 2023
2 parents 7807003 + 434e015 commit b20efd7
Show file tree
Hide file tree
Showing 14 changed files with 33 additions and 37 deletions.
2 changes: 1 addition & 1 deletion build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ apply plugin: 'maven-publish'
if (project.file('../gradletools.gradle').exists()) {
apply from: '../gradletools.gradle'
} else {
apply from: 'https://raw.githubusercontent.com/McJtyMods/MultiWorkspace/1.19_tech/gradletools.gradle'
apply from: 'https://raw.githubusercontent.com/McJtyMods/MultiWorkspace/1.20_tech/gradletools.gradle'
}

group = "com.github.mcjty"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
import mezz.jei.api.recipe.RecipeIngredientRole;
import mezz.jei.api.recipe.RecipeType;
import mezz.jei.api.recipe.category.IRecipeCategory;
import net.minecraft.client.gui.GuiGraphics;
import net.minecraft.network.chat.Component;
import net.minecraft.world.item.ItemStack;

Expand Down Expand Up @@ -51,13 +52,13 @@ public IDrawable getIcon() {
}

@Override
public void draw(XpRecipe recipe, IRecipeSlotsView recipeSlotsView, PoseStack stack, double mouseX, double mouseY) {
public void draw(XpRecipe recipe, IRecipeSlotsView recipeSlotsView, GuiGraphics graphics, double mouseX, double mouseY) {
for (int y = 0 ; y < XpRecipe.RECIPE_DIMENSION ; y++) {
for (int x = 0 ; x < XpRecipe.RECIPE_DIMENSION ; x++) {
slot.draw(stack, 4 + x*18, 4 + y*18);
slot.draw(graphics, 4 + x*18, 4 + y*18);
}
}
slot.draw(stack, 4+6*18, 4);
slot.draw(graphics, 4+6*18, 4);
}

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -90,8 +90,8 @@ private static AttributeModifierEffect getAttributeEffect(IEffectParameters para
Supplier<Attribute> attributeSupplier = switch (effName) {
case "step_assist" -> ForgeMod.STEP_HEIGHT_ADDITION;
case "swim_speed" -> ForgeMod.SWIM_SPEED;
case "attack_range" -> ForgeMod.ATTACK_RANGE;
case "reach_distance" -> ForgeMod.REACH_DISTANCE;
case "attack_range" -> ForgeMod.ENTITY_REACH;
case "reach_distance" -> ForgeMod.BLOCK_REACH;
case "max_health" -> () -> Attributes.MAX_HEALTH;
case "knockback_resistance" -> () -> Attributes.KNOCKBACK_RESISTANCE;
case "movement_speed" -> () -> Attributes.MOVEMENT_SPEED;
Expand Down
21 changes: 9 additions & 12 deletions src/main/java/com/mcjty/fancytrinkets/keys/PacketSendKey.java
Original file line number Diff line number Diff line change
Expand Up @@ -30,18 +30,15 @@ public PacketSendKey(int key) {

public void handle(Supplier<NetworkEvent.Context> supplier) {
NetworkEvent.Context ctx = supplier.get();
ctx.enqueueWork(() -> {
for (SlotResult slot : CuriosApi.getCuriosHelper().findCurios(ctx.getSender(), stack -> stack.getCapability(Registration.TRINKET_ITEM_CAPABILITY).isPresent())) {
ItemStack stack = slot.stack();
stack.getCapability(Registration.TRINKET_ITEM_CAPABILITY).ifPresent(trinket -> {
SlotContext context = slot.slotContext();
String slotId = context.identifier() + context.index() + "_";
trinket.forAllEffects(ctx.getSender().level, stack, (effect, idx) -> {
effect.onHotkey(stack, ctx.getSender(), slotId + idx, key);
});
for (SlotResult slot : CuriosApi.getCuriosHelper().findCurios(ctx.getSender(), stack -> stack.getCapability(Registration.TRINKET_ITEM_CAPABILITY).isPresent())) {
ItemStack stack = slot.stack();
stack.getCapability(Registration.TRINKET_ITEM_CAPABILITY).ifPresent(trinket -> {
SlotContext context = slot.slotContext();
String slotId = context.identifier() + context.index() + "_";
trinket.forAllEffects(ctx.getSender().level(), stack, (effect, idx) -> {
effect.onHotkey(stack, ctx.getSender(), slotId + idx, key);
});
}
});
ctx.setPacketHandled(true);
});
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ public void tick(ItemStack stack, ServerPlayer player, String slotId) {
int dy = random.nextInt(3 * 2) - 3;
int dz = random.nextInt(maxdist * 2) - maxdist;
BlockPos dest = blockPos.offset(dx, dy, dz);
player.level.getBlockState(dest).randomTick((ServerLevel) player.level, dest, random);
player.level().getBlockState(dest).randomTick((ServerLevel) player.level(), dest, random);
}
});
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ public MobEffectEffect(Integer hotkey, String toggle, MobEffect effect, int stre
@Override
public void tick(ItemStack stack, ServerPlayer player, String slotId) {
executeIfEnabled(player, playerEffects -> {
long gameTime = player.level.getGameTime();
long gameTime = player.level().getGameTime();
playerEffects.registerEffect(slotId, this, gameTime + 14*20);
});
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -62,14 +62,14 @@ public void onHotkey(ItemStack stack, ServerPlayer player, String slotId, int ke

Vec3 end = start.add(lookVec.x * distance, lookVec.y * distance, lookVec.z * distance);
ClipContext context = new ClipContext(start, end, ClipContext.Block.COLLIDER, ClipContext.Fluid.NONE, player);
HitResult position = player.level.clip(context);
HitResult position = player.level().clip(context);
safeTeleport(player, (BlockHitResult) position);
});
}
}

private void safeTeleport(ServerPlayer player, BlockHitResult position) {
Level level = player.level;
Level level = player.level();
BlockPos blockPos = position.getBlockPos();
int x = blockPos.getX();
int y = blockPos.getY();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -46,23 +46,23 @@ public ItemStack getStack() {
public void curioTick(SlotContext slotContext) {
if (slotContext.entity() instanceof ServerPlayer player) {
String slotId = slotContext.identifier() + slotContext.index() + "_";
trinketItem.forAllEffects(player.level, itemStack, (effect, idx) -> effect.tick(itemStack, player, slotId + idx));
trinketItem.forAllEffects(player.level(), itemStack, (effect, idx) -> effect.tick(itemStack, player, slotId + idx));
}
}

@Override
public void onEquip(SlotContext slotContext, ItemStack prevStack) {
if (slotContext.entity() instanceof ServerPlayer player) {
String slotId = slotContext.identifier() + slotContext.index() + "_";
trinketItem.forAllEffects(player.level, itemStack, (effect, idx) -> effect.onEquip(itemStack, player, slotId + idx));
trinketItem.forAllEffects(player.level(), itemStack, (effect, idx) -> effect.onEquip(itemStack, player, slotId + idx));
}
}

@Override
public void onUnequip(SlotContext slotContext, ItemStack newStack) {
if (slotContext.entity() instanceof ServerPlayer player) {
String slotId = slotContext.identifier() + slotContext.index() + "_";
trinketItem.forAllEffects(player.level, itemStack, (effect, idx) -> effect.onUnequip(itemStack, player, slotId + idx));
trinketItem.forAllEffects(player.level(), itemStack, (effect, idx) -> effect.onUnequip(itemStack, player, slotId + idx));
}
}
};
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@
import net.minecraft.world.entity.player.Player;
import net.minecraft.world.inventory.AbstractContainerMenu;
import net.minecraft.world.inventory.CraftingContainer;
import net.minecraft.world.inventory.TransientCraftingContainer;
import net.minecraft.world.item.ItemStack;
import net.minecraft.world.level.block.state.BlockState;
import net.minecraftforge.common.util.Lazy;
Expand Down Expand Up @@ -70,7 +71,7 @@ public class ExperienceCrafterBE extends GenericTileEntity {
@ServerCommand
public static final Command<?> CMD_CRAFT = Command.<ExperienceCrafterBE>create("craft", (te, player, params) -> te.craft());

private final CraftingContainer inv = new CraftingContainer(new AbstractContainerMenu(null, -1) {
private final CraftingContainer inv = new TransientCraftingContainer(new AbstractContainerMenu(null, -1) {
@Override
public boolean stillValid(@Nonnull Player playerIn) {
return false;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
import mcjty.lib.gui.widgets.Button;
import mcjty.lib.gui.widgets.EnergyBar;
import mcjty.lib.gui.widgets.Panel;
import net.minecraft.client.gui.GuiGraphics;
import net.minecraft.resources.ResourceLocation;
import net.minecraft.world.entity.player.Inventory;

Expand Down Expand Up @@ -71,8 +72,8 @@ public void init() {


@Override
protected void renderBg(@Nonnull PoseStack matrixStack, float partialTicks, int x, int y) {
drawWindow(matrixStack);
protected void renderBg(@Nonnull GuiGraphics graphics, float partialTicks, int x, int y) {
drawWindow(graphics);
xpbar.value(tileEntity.getExperience());
craftButton.enabled(!tileEntity.getPreviewOutput().isEmpty());
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,10 +32,6 @@ public PacketSyncPlayerEffects(PlayerEffects effects) {
}

public void handle(Supplier<NetworkEvent.Context> supplier) {
NetworkEvent.Context ctx = supplier.get();
ctx.enqueueWork(() -> {
TrinketItem.toggles = toggles;
});
ctx.setPacketHandled(true);
TrinketItem.toggles = toggles;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ public Set<String> getToggles() {
}

public void tick(ServerPlayer player) {
long time = player.level.getGameTime();
long time = player.level().getGameTime();
Counter<IEffect> collectedEffects = new Counter<>();
List<String> toDelete = new ArrayList<>();
for (Map.Entry<String, EffectHolder> entry : effectMap.entrySet()) {
Expand Down
4 changes: 2 additions & 2 deletions src/main/java/com/mcjty/fancytrinkets/setup/Messages.java
Original file line number Diff line number Diff line change
Expand Up @@ -37,12 +37,12 @@ public static void registerMessages(String name) {
net.messageBuilder(PacketSendKey.class, id())
.encoder(PacketSendKey::toBytes)
.decoder(PacketSendKey::new)
.consumer(PacketSendKey::handle)
.consumerMainThread(PacketSendKey::handle)
.add();
net.messageBuilder(PacketSyncPlayerEffects.class, id())
.encoder(PacketSyncPlayerEffects::toBytes)
.decoder(PacketSyncPlayerEffects::new)
.consumer(PacketSyncPlayerEffects::handle)
.consumerMainThread(PacketSyncPlayerEffects::handle)
.add();

PacketHandler.registerStandardMessages(id(), net);
Expand Down
2 changes: 1 addition & 1 deletion src/main/resources/META-INF/accesstransformer.cfg
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ public net.minecraft.world.level.BaseSpawner m_45475_()Lnet/minecraft/resources/

# For McJtyLib
public net.minecraft.world.inventory.AbstractContainerMenu f_38848_ # listeners
public net.minecraft.client.gui.screens.inventory.AbstractContainerScreen m_97799_(Lcom/mojang/blaze3d/vertex/PoseStack;Lnet/minecraft/world/inventory/Slot;)V # moveItems
public net.minecraft.client.gui.screens.inventory.AbstractContainerScreen m_280092_(Lnet/minecraft/client/gui/GuiGraphics;Lnet/minecraft/world/inventory/Slot;)V # renderSlot

# For RFToolsStorage
public net.minecraft.client.gui.screens.inventory.AbstractContainerScreen m_97774_(Lnet/minecraft/world/inventory/Slot;DD)Z # isSlotSelected
Expand Down

0 comments on commit b20efd7

Please sign in to comment.