Skip to content

Commit

Permalink
Backport 0.2.1 for 1.18.2
Browse files Browse the repository at this point in the history
  • Loading branch information
AbdElAziz333 committed May 23, 2023
1 parent 52d2dbb commit d5d8e17
Show file tree
Hide file tree
Showing 10 changed files with 40 additions and 108 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@
import it.unimi.dsi.fastutil.objects.Reference2ReferenceOpenHashMap;
import com.abdelaziz.canary.common.world.interests.PointOfInterestSetExtended;
import com.abdelaziz.canary.common.world.interests.iterator.SinglePointOfInterestTypeFilter;
import net.minecraft.core.Holder;
import net.minecraft.world.entity.ai.village.poi.PoiManager;
import net.minecraft.world.entity.ai.village.poi.PoiRecord;
import net.minecraft.world.entity.ai.village.poi.PoiSection;
Expand Down

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -96,6 +96,9 @@ public HopperBlockEntityMixin(BlockEntityType<?> type, BlockPos pos, BlockState
@Nullable
private static native Container getSourceContainer(Level world, Hopper hopper);

@Shadow
private static native boolean canTakeItemFromContainer(Container inv, ItemStack stack, int slot, Direction facing);

@Shadow
public abstract boolean isOnCustomCooldown();

Expand All @@ -105,9 +108,6 @@ public HopperBlockEntityMixin(BlockEntityType<?> type, BlockPos pos, BlockState
@Shadow
protected abstract boolean isOnCooldown();

@Shadow
private static native boolean canTakeItemFromContainer(Container p_273433_, Container p_273542_, ItemStack p_273400_, int p_273519_, Direction p_273088_);

/**
* Effectively overwrites {@link HopperBlockEntity#insert(Level, BlockPos, BlockState, Container)} (only usage redirect)
* [VanillaCopy] general hopper insert logic, modified for optimizations
Expand Down Expand Up @@ -221,7 +221,7 @@ private static void canaryExtract(Level world, Hopper to, CallbackInfoReturnable
for (int i = 0; i < fromSize; i++) {
int fromSlot = availableSlots != null ? availableSlots[i] : i;
ItemStack itemStack = fromStackList.get(fromSlot);
if (!itemStack.isEmpty() && canTakeItemFromContainer(to, from, itemStack, fromSlot, Direction.DOWN)) {
if (!itemStack.isEmpty() && canTakeItemFromContainer(from, itemStack, fromSlot, Direction.DOWN)) {
//calling removeStack is necessary due to its side effects (setChanged in LootableContainerBlockEntity)
ItemStack takenItem = from.removeItem(fromSlot, 1);
assert !takenItem.isEmpty();
Expand Down Expand Up @@ -306,20 +306,6 @@ private static Container nullify(Level world, BlockPos pos, BlockState state) {
return null;
}

/*@ModifyVariable(
method = "ejectItems",
at = @At(
value = "INVOKE_ASSIGN",
target = "Lnet/minecraft/world/level/block/entity/HopperBlockEntity;getAttachedContainer(Lnet/minecraft/world/level/Level;Lnet/minecraft/core/BlockPos;Lnet/minecraft/world/level/block/state/BlockState;)Lnet/minecraft/world/Container;"
),
ordinal = 1
)//Inventory inventory, Level world, BlockPos pos, BlockState hopperState, Inventory hopper
//Lnet/minecraft/world/Container;Lnet/minecraft/world/level/Level;Lnet/minecraft/core/BlockPos;Lnet/minecraft/world/level/block/state/BlockState;Lnet/minecraft/world/level/block/entity/HopperBlockEntity;)
private static Container getCanaryOutputInventory(Container inventory, Level world, BlockPos pos, BlockState hopperState, HopperBlockEntity hopper) {
HopperBlockEntityMixin hopperBlockEntity = (HopperBlockEntityMixin) inventory;
return hopperBlockEntity.getInsertInventory(world, hopperState);
}*/

@Redirect(method = "suckInItems(Lnet/minecraft/world/level/Level;Lnet/minecraft/world/level/block/entity/Hopper;)Z", at = @At(value = "INVOKE", target = "Lnet/minecraft/world/level/block/entity/HopperBlockEntity;getItemsAtAndAbove(Lnet/minecraft/world/level/Level;Lnet/minecraft/world/level/block/entity/Hopper;)Ljava/util/List;"))
private static List<ItemEntity> canaryGetInputItemEntities(Level world, Hopper hopper) {
if (!(hopper instanceof HopperBlockEntityMixin hopperBlockEntity)) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
import net.minecraft.world.level.block.entity.BrewingStandBlockEntity;
import net.minecraft.world.level.block.state.BlockState;
import net.minecraftforge.common.util.LazyOptional;
import net.minecraftforge.items.CapabilityItemHandler;
import net.minecraftforge.items.IItemHandler;
import org.spongepowered.asm.mixin.Mixin;
import org.spongepowered.asm.mixin.Overwrite;
Expand All @@ -30,7 +31,7 @@ protected BrewingStandBlockEntityMixin(BlockEntityType<?> blockEntityType, Block
* */
@Overwrite (remap = false)
public <T> LazyOptional<T> getCapability(net.minecraftforge.common.capabilities.Capability<T> capability, @Nullable Direction facing) {
if (!this.remove && facing != null && capability == net.minecraftforge.common.capabilities.ForgeCapabilities.ITEM_HANDLER) {
if (!this.remove && facing != null && capability == CapabilityItemHandler.ITEM_HANDLER_CAPABILITY) {
switch(facing) {
case UP -> {
return handlers[0].cast();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
import net.minecraft.world.level.block.entity.BlockEntityType;
import net.minecraft.world.level.block.state.BlockState;
import net.minecraftforge.common.util.LazyOptional;
import net.minecraftforge.items.CapabilityItemHandler;
import net.minecraftforge.items.IItemHandler;
import org.spongepowered.asm.mixin.Mixin;
import org.spongepowered.asm.mixin.Overwrite;
Expand All @@ -30,7 +31,7 @@ protected AbstractFurnaceBlockEntityMixin(BlockEntityType<?> blockEntityType, Bl
* */
@Overwrite (remap = false)
public <T> LazyOptional<T> getCapability(net.minecraftforge.common.capabilities.Capability<T> capability, @Nullable Direction facing) {
if (!this.remove && facing != null && capability == net.minecraftforge.common.capabilities.ForgeCapabilities.ITEM_HANDLER) {
if (!this.remove && facing != null && capability == CapabilityItemHandler.ITEM_HANDLER_CAPABILITY) {
switch(facing) {
case UP -> {
return handlers[0].cast();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,6 @@ public void handleEntityEvent(byte b) {
case 59: {
this.isLoweringHead = false;
break;

}
default: {
super.handleEntityEvent(b);
Expand Down

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -54,15 +54,18 @@ public void setItemSlot(EquipmentSlot equipmentSlot, ItemStack itemStack) {

switch(equipmentSlot) {
case MAINHAND: {
this.onEquipItem(equipmentSlot, this.inventory.items.set(this.inventory.selected, itemStack), itemStack);
this.equipEventAndSound(itemStack);
this.inventory.items.set(this.inventory.selected, itemStack);
break;
}
case OFFHAND : {
this.onEquipItem(equipmentSlot, this.inventory.offhand.set(0, itemStack), itemStack);
this.equipEventAndSound(itemStack);
this.inventory.offhand.set(0, itemStack);
break;
}
default : {
this.onEquipItem(equipmentSlot, this.inventory.armor.set(equipmentSlot.getIndex(), itemStack), itemStack);
this.equipEventAndSound(itemStack);
this.inventory.armor.set(equipmentSlot.getIndex(), itemStack);
break;
}
}
Expand Down
1 change: 0 additions & 1 deletion src/main/resources/META-INF/accesstransformer.cfg
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,6 @@ public net.minecraft.world.level.border.WorldBorder$BorderExtent
public net.minecraft.world.level.pathfinder.WalkNodeEvaluator m_77643_(Lnet/minecraft/world/level/BlockGetter;Lnet/minecraft/core/BlockPos;)Lnet/minecraft/world/level/pathfinder/BlockPathTypes; # getBlockPathTypeRaw
public net.minecraft.world.entity.ai.village.poi.PoiSection m_27273_(Lnet/minecraft/world/entity/ai/village/poi/PoiRecord;)Z # add

public net.minecraftforge.client.ChunkRenderTypeSet$None
public net.minecraft.world.level.block.state.BlockBehaviour$BlockStateBase
public net.minecraft.world.level.material.Fluid m_6759_()Z # isEmpty
public net.minecraft.world.level.material.Fluid m_6685_()Z # isRandomlyTicking
Expand Down
31 changes: 26 additions & 5 deletions src/main/resources/canary.mixins.json
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,6 @@
"ai.nearby_entity_tracking.goals.AvoidEntityGoalMixin",
"ai.nearby_entity_tracking.goals.LookAtPlayerGoalMixin",
"ai.pathing.BlockStateBaseMixin",
"ai.pathing.FlyNodeEvaluatorMixin",
"ai.pathing.PathNavigationRegionMixin",
"ai.pathing.WalkNodeEvaluatorMixin",
"ai.poi.PoiManagerMixin",
Expand All @@ -43,6 +42,9 @@
"alloc.composter.ComposterMixin$ComposterBlockInputContainerMixin",
"alloc.composter.ComposterMixin$ComposterBlockOutputContainerMixin",
"alloc.deep_passengers.EntityMixin",
"alloc.empty_chunk.EmptyLevelChunkMixin",
"alloc.empty_iterator.ClassInstanceMultiMapMixin",
"alloc.empty_list.WorldGenRegionMixin",
"alloc.entity_tracker.TrackedEntityMixin",
"alloc.enum_values.living_entity.LivingEntityMixin",
"alloc.enum_values.piston_block.PistonBaseBlockMixin",
Expand All @@ -61,6 +63,7 @@
"block.hopper.EntityAccessor",
"block.hopper.EntityDataAccessorMixin",
"block.hopper.EntitySectionAccessor",
"block.hopper.HopperBlockEntityMixin",
"block.hopper.HopperBlockMixin",
"block.hopper.InventoryAccessors$InventoryAccessorAbstractFurnaceBlockEntity",
"block.hopper.InventoryAccessors$InventoryAccessorAbstractMinecartEntity",
Expand All @@ -71,13 +74,34 @@
"block.hopper.InventoryAccessors$InventoryAccessorHopperBlockEntity",
"block.hopper.InventoryAccessors$InventoryAccessorShulkerBoxBlockEntity",
"block.hopper.ItemStackMixin",
"block.hopper.LevelMixin",
"block.hopper.NonNullListAccessor",
"block.hopper.ScreenHandlerMixin",
"block.hopper.world_edit_compat.LevelChunkMixin",
"block.moving_block_shapes.PistonMovingBlockEntityMixin",
"block.moving_block_shapes.VoxelShapeMixin",
"block.redstone_wire.RedStoneWireBlockMixin",
"cached_hashcode.BlockStatePairKeyMixin",
"calc.deduplicate.player_statistics.PlayerMixin",
"calc.if_else.ai.evaluator.FlyNodeEvaluatorMixin",
"calc.if_else.ai.evaluator.WalkNodeEvaluatorMixin",
"calc.if_else.block_entity.can_place_item.brewing_stand.BrewingStandBlockEntityMixin",
"calc.if_else.block_entity.composter.ComposterBlockMixin",
"calc.if_else.block_entity.get_capability.brewing_stand.BrewingStandBlockEntityMixin",
"calc.if_else.block_entity.get_capability.furnace.AbstractFurnaceBlockEntityMixin",
"calc.if_else.block_entity.get_slots_for_face.brewing_stand.BrewingStandBlockEntityMixin",
"calc.if_else.block_entity.get_slots_for_face.furnace.AbstractFurnaceBlockEntityMixin",
"calc.if_else.dripstone_shape.PointedDripstoneBlockMixin",
"calc.if_else.entity.handle_entity_event.goat.GoatMixin",
"calc.if_else.entity.handle_entity_event.horse.AbstractHorseMixin",
"calc.if_else.entity.handle_entity_event.iron_golem.IronGolemMixin",
"calc.if_else.entity.handle_entity_event.ocelot.OcelotMixin",
"calc.if_else.entity.handle_entity_event.player.PlayerMixin",
"calc.if_else.entity.handle_entity_event.tamable_animal.TamableAnimalMixin",
"calc.if_else.entity.handle_entity_event.villager.VillagerMixin",
"calc.if_else.entity.handle_entity_event.wolf.WolfMixin",
"calc.if_else.player_slot.PlayerMixin",
"calc.if_else.raid_odds.RaidMixin",
"chunk.entity_class_groups.ClassInstanceMultiMapMixin",
"chunk.entity_class_groups.EntitySectionAccessor",
"chunk.entity_class_groups.PersistentEntitySectionManagerAccessor",
Expand Down Expand Up @@ -150,11 +174,7 @@
"shapes.shape_merging.ShapesMixin",
"shapes.specialized_shapes.ShapesMixin",
"shapes.specialized_shapes.VoxelShapeMixin",
"util.block_counting.BlockStateBaseMixin",
"util.block_counting.LevelChunkSectionMixin",
"util.block_entity_retrieval.LevelMixin",
"util.chunk_access.LevelReaderMixin",
"util.chunk_access.PathNavigationRegionMixin",
"util.entity_movement_tracking.EntitySectionMixin",
"util.entity_movement_tracking.EntitySectionStorageMixin",
"util.entity_movement_tracking.PersistentEntitySectionManagerAccessor",
Expand All @@ -174,6 +194,7 @@
"util.inventory_comparator_tracking.BlockEntityMixin",
"util.inventory_comparator_tracking.ComparatorBlockMixin",
"util.world_border_listener.WorldBorderMixin",
"world.block_entity_ticking.sleeping.LevelChunkMixin",
"world.block_entity_ticking.sleeping.LevelMixin",
"world.block_entity_ticking.sleeping.RebindableTickingBlockEntityWrapperAccessor",
"world.block_entity_ticking.sleeping.brewing_stand.BrewingStandBlockEntityMixin",
Expand Down

0 comments on commit d5d8e17

Please sign in to comment.