Migrate the Carpet codebase to Mojang Mappings

This commit is contained in:
altrisi committed 2022-01-24 20:33:16 +01:00
1 parent a1a2488bc3
commit 06af9ce8b1
346 files changed
+8353 -8492

No files matched your search

+22 -22
View File
@@ -1,13 +1,6 @@
package carpet.mixins;
import carpet.CarpetSettings;
import net.minecraft.screen.slot.Slot;
import net.minecraft.screen.slot.SlotActionType;
import net.minecraft.entity.player.PlayerEntity;
import net.minecraft.item.Item;
import net.minecraft.item.ItemStack;
import net.minecraft.screen.ScreenHandler;
import net.minecraft.util.collection.DefaultedList;
import org.spongepowered.asm.mixin.Final;
import org.spongepowered.asm.mixin.Mixin;
import org.spongepowered.asm.mixin.Shadow;
@@ -17,39 +10,46 @@ import org.spongepowered.asm.mixin.injection.callback.CallbackInfo;
import org.spongepowered.asm.mixin.injection.callback.CallbackInfoReturnable;
import java.util.List;
import net.minecraft.core.NonNullList;
import net.minecraft.world.entity.player.Player;
import net.minecraft.world.inventory.AbstractContainerMenu;
import net.minecraft.world.inventory.ClickType;
import net.minecraft.world.inventory.Slot;
import net.minecraft.world.item.Item;
import net.minecraft.world.item.ItemStack;
@Mixin(ScreenHandler.class)
@Mixin(AbstractContainerMenu.class)
public abstract class ContainerMixin
{
@Shadow public abstract void onSlotClick(int int_1, int int_2, SlotActionType slotActionType_1, PlayerEntity playerEntity_1);
@Shadow public abstract void clicked(int int_1, int int_2, ClickType slotActionType_1, Player playerEntity_1);
@Shadow public abstract void sendContentUpdates();
@Shadow public abstract void broadcastChanges();
@Shadow @Final public DefaultedList<Slot> slots;
@Shadow @Final public NonNullList<Slot> slots;
@Shadow protected abstract void endQuickCraft();
@Shadow protected abstract void resetQuickCraft();
@Shadow public abstract ItemStack getCursorStack();
@Shadow public abstract ItemStack getCarried();
@Inject( method = "internalOnSlotClick", at = @At(value = "HEAD"), cancellable = true)
private void onThrowClick(int slotId, int clickData, SlotActionType actionType, PlayerEntity playerEntity, CallbackInfo ci)
@Inject( method = "doClick", at = @At(value = "HEAD"), cancellable = true)
private void onThrowClick(int slotId, int clickData, ClickType actionType, Player playerEntity, CallbackInfo ci)
{
if (actionType == SlotActionType.THROW && CarpetSettings.ctrlQCraftingFix && this.getCursorStack().isEmpty() && slotId >= 0)
if (actionType == ClickType.THROW && CarpetSettings.ctrlQCraftingFix && this.getCarried().isEmpty() && slotId >= 0)
{
ItemStack itemStack_1 = ItemStack.EMPTY;
Slot slot_4 = slots.get(slotId);
if (/*slot_4 != null && */slot_4.hasStack() && slot_4.canTakeItems(playerEntity))
if (/*slot_4 != null && */slot_4.hasItem() && slot_4.mayPickup(playerEntity))
{
if(slotId == 0 && clickData == 1)
{
Item craftedItem = slot_4.getStack().getItem();
while(slot_4.hasStack() && slot_4.getStack().getItem() == craftedItem)
Item craftedItem = slot_4.getItem().getItem();
while(slot_4.hasItem() && slot_4.getItem().getItem() == craftedItem)
{
this.onSlotClick(slotId, 0, SlotActionType.THROW, playerEntity);
this.clicked(slotId, 0, ClickType.THROW, playerEntity);
}
this.sendContentUpdates();
this.endQuickCraft();
this.broadcastChanges();
this.resetQuickCraft();
ci.cancel();
}
}