diff --git a/gradle.properties b/gradle.properties index f8f3fa5..e1c12ff 100644 --- a/gradle.properties +++ b/gradle.properties @@ -6,7 +6,7 @@ minecraft_version=1.16.5 yarn_mappings=1.16.5+build.5 loader_version=0.11.2 # Mod Properties -mod_version=ALPHA.8 +mod_version=ALPHA.9 maven_group=azzy.ttlg archives_base_name=TTLG libgui_version=3.3.3+1.16.5 diff --git a/src/main/java/azzy/fabric/lookingglass/blockentity/PoweredFurnaceEntity.java b/src/main/java/azzy/fabric/lookingglass/blockentity/PoweredFurnaceEntity.java index 8fd4bfa..adb0ca0 100644 --- a/src/main/java/azzy/fabric/lookingglass/blockentity/PoweredFurnaceEntity.java +++ b/src/main/java/azzy/fabric/lookingglass/blockentity/PoweredFurnaceEntity.java @@ -37,7 +37,7 @@ public void tick() { tickRecipeProgression(); } else { - if(trackedRecipe.matches(this, world)) { + if(trackedRecipe.matches(this, world) && trackedRecipe.getType() == getRecipeType()) { tickRecipeProgression(); if(!getCachedState().get(LIT)) world.setBlockState(pos, getCachedState().with(LIT, true)); diff --git a/src/main/java/azzy/fabric/lookingglass/item/GoldenLassoItem.java b/src/main/java/azzy/fabric/lookingglass/item/GoldenLassoItem.java index 6693a86..f576292 100644 --- a/src/main/java/azzy/fabric/lookingglass/item/GoldenLassoItem.java +++ b/src/main/java/azzy/fabric/lookingglass/item/GoldenLassoItem.java @@ -19,8 +19,11 @@ import net.minecraft.util.registry.Registry; import net.minecraft.world.World; +import static azzy.fabric.lookingglass.LookingGlassCommon.FFLog; + @SuppressWarnings("rawtypes") public class GoldenLassoItem extends ToolItem { + public GoldenLassoItem(ToolMaterial toolMaterial, FabricItemSettings goldenLassoSettings) { super(toolMaterial, goldenLassoSettings); } @@ -36,15 +39,13 @@ public ActionResult useOnBlock(ItemUsageContext context) { // Spawn the mob above the clicked block position. BlockPos usedPosition = context.getBlockPos().up(); - CompoundTag tmpMobKey = context.getStack().getSubTag("MOB_KEY"); - System.out.println(tmpMobKey); - // Don't bother playing on the client side. We live on the server side. if (genericWorld.isClient) return ActionResult.PASS; ServerWorld world = (ServerWorld) genericWorld; ItemStack itemStack = context.getStack(); + FFLog.error(itemStack.getTag()); CompoundTag stackTag = itemStack.getSubTag("MOB_KEY"); if (stackTag == null) { @@ -56,7 +57,7 @@ public ActionResult useOnBlock(ItemUsageContext context) { Identifier mobTypeId = Identifier.tryParse(mobType); if (mobTypeId == null) { // Some issue with this mob. Reset the lasso. - LookingGlassCommon.FFLog.warn("Unable to spawn mob: '" + mobType + "'."); + FFLog.warn("Unable to spawn mob: '" + mobType + "'."); itemStack.removeSubTag("MOB_KEY"); // TODO: Reset the render for the lasso to make it empty again. return ActionResult.FAIL; @@ -69,6 +70,7 @@ public ActionResult useOnBlock(ItemUsageContext context) { return ActionResult.FAIL; spawnedEntity.fromTag(mobTag); + itemStack.removeSubTag("MOB_KEY"); return ActionResult.PASS; } @@ -90,7 +92,7 @@ public ActionResult useOnEntity(ItemStack stack, PlayerEntity user, LivingEntity if (user.getEntityWorld().isClient) return ActionResult.PASS; - CompoundTag stackTag = stack.getOrCreateSubTag("MOB_KEY"); + CompoundTag stackTag = user.getStackInHand(hand).getOrCreateSubTag("MOB_KEY"); CompoundTag mobTag = new CompoundTag(); entity.saveSelfToTag(mobTag); EntityType entityType = entity.getType(); @@ -103,4 +105,15 @@ public ActionResult useOnEntity(ItemStack stack, PlayerEntity user, LivingEntity // TODO: Change the lasso's notification to show the captured mob details (type, health, max health, etc.) return ActionResult.SUCCESS; } + + /** + * Determines whether or not the lasso should glow, this is determined by whether or not it contains an entity. + * + * @param stack The lasso + * @return Should the lasso shine + */ + @Override + public boolean hasGlint(ItemStack stack) { + return stack.getOrCreateTag().contains("MOB_KEY"); + } } \ No newline at end of file diff --git a/src/main/java/azzy/fabric/lookingglass/item/LookingGlassItems.java b/src/main/java/azzy/fabric/lookingglass/item/LookingGlassItems.java index d6e3c8b..eb60b6b 100644 --- a/src/main/java/azzy/fabric/lookingglass/item/LookingGlassItems.java +++ b/src/main/java/azzy/fabric/lookingglass/item/LookingGlassItems.java @@ -57,7 +57,7 @@ private static FabricItemSettings eldenmetalSettings() { public static final Item BASIC_SPEED_UPGRADE = registerGeneratedItem("basic_speed_upgrade", new GenericUpgradeItem(defaultSettings(), 1.2, 0, 0.95, ModifierProvider.AdditivityType.ADD, ModifierProvider.AdditivityType.ADD, LookingGlassMachine.MachineTier.BASIC)); public static final Item BASIC_ENERGY_STORAGE_UPGRADE = registerGeneratedItem("basic_energy_storage_upgrade", new GenericUpgradeItem(defaultSettings(), 1, 0.5, 1, ModifierProvider.AdditivityType.ADD, ModifierProvider.AdditivityType.ADD, LookingGlassMachine.MachineTier.BASIC)); public static final Item BASIC_ENERGY_USAGE_UPGRADE = registerGeneratedItem("basic_energy_usage_upgrade", new GenericUpgradeItem(defaultSettings(), 0.9, 0, 1.05, ModifierProvider.AdditivityType.ADD, ModifierProvider.AdditivityType.ADD, LookingGlassMachine.MachineTier.BASIC)); - public static final Item FREEZER_UPGRADE_ITEM = registerGeneratedItem("freezer_upgrade", new RecipeConvertingUpgradeItem<>(defaultSettings(), LookingGlassRecipes.FREEZING_RECIPE, PoweredFurnaceGuiDescription.class, 2.0, 0, 0.5, ModifierProvider.AdditivityType.ADD, ModifierProvider.AdditivityType.ADD)); + public static final Item FREEZER_UPGRADE_ITEM = registerGeneratedItem("freezer_upgrade", new RecipeConvertingUpgradeItem<>(defaultSettings(), LookingGlassRecipes.FREEZING_RECIPE, PoweredFurnaceGuiDescription.class, 2.0, 0, 4.0, ModifierProvider.AdditivityType.ADD, ModifierProvider.AdditivityType.ADD)); //Materials public static final Item FISH_FEED = registerItem("fish_feed", new Item(defaultSettings().food(BAD_NOMS))); diff --git a/src/main/java/azzy/fabric/lookingglass/mixin/LithiumBlockEntityListMixin.java b/src/main/java/azzy/fabric/lookingglass/mixin/LithiumBlockEntityListMixin.java index e2e3234..c432020 100644 --- a/src/main/java/azzy/fabric/lookingglass/mixin/LithiumBlockEntityListMixin.java +++ b/src/main/java/azzy/fabric/lookingglass/mixin/LithiumBlockEntityListMixin.java @@ -4,8 +4,10 @@ import it.unimi.dsi.fastutil.objects.ReferenceLinkedOpenHashSet; import me.jellysquid.mods.lithium.common.util.collections.BlockEntityList; import net.minecraft.block.entity.BlockEntity; +import net.minecraft.block.entity.CommandBlockBlockEntity; import org.spongepowered.asm.mixin.Final; import org.spongepowered.asm.mixin.Mixin; +import org.spongepowered.asm.mixin.Overwrite; import org.spongepowered.asm.mixin.Shadow; import org.spongepowered.asm.mixin.injection.At; import org.spongepowered.asm.mixin.injection.Inject; @@ -17,9 +19,40 @@ @Mixin(BlockEntityList.class) public abstract class LithiumBlockEntityListMixin { - @Inject(method = {"addNoDoubleAdd"}, at = {@At("HEAD")}, remap = false) - private void addNoDoubleAdd(BlockEntity blockEntity, boolean exceptionOnDoubleAdd, CallbackInfoReturnable cir) { - exceptionOnDoubleAdd = false; + @Shadow @Final private ReferenceLinkedOpenHashSet allBlockEntities; + + @Shadow @Final private Long2ReferenceOpenHashMap posMap; + + @Shadow + private static long getEntityPos(BlockEntity e) { + return 0; + } + + @Shadow @Final private Long2ReferenceOpenHashMap> posMapMulti; + + /** + * @author Azazelthedemonlord + * @reason Prevents a crash when moving block entities. + */ + @Overwrite(remap = false) + private boolean addNoDoubleAdd(BlockEntity blockEntity, boolean exceptionOnDoubleAdd) { + boolean added = this.allBlockEntities.add(blockEntity); + if (added && this.posMap != null) { + long pos = getEntityPos(blockEntity); + BlockEntity prev = (BlockEntity)this.posMap.putIfAbsent(pos, blockEntity); + if (prev != null) { + List multiEntry = this.posMapMulti.computeIfAbsent(pos, (l) -> { + return new ArrayList<>(); + }); + if (multiEntry.size() == 0) { + multiEntry.add(prev); + } + + multiEntry.add(blockEntity); + } + } + + return added; } } diff --git a/src/main/resources/assets/lookingglass/models/item/golden_lasso.json b/src/main/resources/assets/lookingglass/models/item/golden_lasso.json index 540526a..be14555 100644 --- a/src/main/resources/assets/lookingglass/models/item/golden_lasso.json +++ b/src/main/resources/assets/lookingglass/models/item/golden_lasso.json @@ -1,3 +1,6 @@ { - "parent": "lookingglass:block/golden_lasso" + "parent": "item/generated", + "textures": { + "layer0": "lookingglass:item/golden_lasso" + } } \ No newline at end of file diff --git a/src/main/resources/fabric.mod.json b/src/main/resources/fabric.mod.json index 3fbea71..acc5483 100644 --- a/src/main/resources/fabric.mod.json +++ b/src/main/resources/fabric.mod.json @@ -1,7 +1,7 @@ { "schemaVersion": 1, "id": "lookingglass", - "version": "2.0.0-alpha.8", + "version": "2.0.0-alpha.9", "name": "Through The Looking Glass", "description": "Not a mod about glass working",