Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add CV support to wand recharge pedestal #32

Merged
merged 3 commits into from
Nov 11, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ repositories {
}
}

version = "1.6.11"
version = "1.6.12"
group = "com.mitchej123.hodgepodge"
archivesBaseName = "hodgepodge"
sourceCompatibility = 1.8
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -182,7 +182,10 @@ public enum MixinSets {
Collections.singletonList("fixFireSpread.MixinBlockFire")),
TILE_RENDERER_PROFILER("Shows renderer's impact on FPS in vanilla lagometer",
() -> config.enableTileRendererProfiler,
Arrays.asList("profiler.TileEntityRendererDispatcherMixin", "profiler.MinecraftMixin"))
Arrays.asList("profiler.TileEntityRendererDispatcherMixin", "profiler.MinecraftMixin")),
ADD_CV_SUPPORT_TO_WAND_PEDESTAL("Add CV support to Thaumcraft wand recharge pedestal",
()->config.addCVSupportToWandPedestal,
Collections.singletonList("wandPedestalCV.MixinTileWandPedestal"))
;


Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@ public class LoadingConfig {
public boolean fixGetBlockLightValue;
public boolean fixFireSpread;
public boolean fixPotionEffectRender;
public boolean addCVSupportToWandPedestal;
// ASM
public boolean pollutionAsm;
public boolean cofhWorldTransformer;
Expand Down Expand Up @@ -65,6 +66,7 @@ public LoadingConfig(File file) {
dropPickedLootOnDespawn = config.get("tweaks", "dropPickedLootOnDespawn", true, "Drop picked loot on entity despawn").getBoolean();
hideIc2ReactorSlots = config.get("tweaks", "hideIc2ReactorSlots", true, "Prevent IC2's reactor's coolant slots from being accessed by automations if not a fluid reactor").getBoolean();
enableTileRendererProfiler = config.get("tweaks", "enableTileRendererProfiler", true, "Shows renderer's impact on FPS in vanilla lagometer").getBoolean();
addCVSupportToWandPedestal = config.get("tweaks", "addCVSupportToWandPedestal", true, "Add CV support to Thaumcraft wand recharge pedestal").getBoolean();

speedupChunkCoordinatesHashCode = config.get("speedups", "speedupChunkCoordinatesHashCode", true, "Speedup ChunkCoordinates hashCode").getBoolean();

Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,53 @@
package com.mitchej123.hodgepodge.mixins.wandPedestalCV;

import java.util.ArrayList;
import java.util.HashMap;
import java.util.Map;

import net.minecraft.item.ItemStack;
import net.minecraft.tileentity.TileEntity;
import net.minecraft.util.ChunkCoordinates;
import net.minecraft.world.World;

import org.spongepowered.asm.mixin.Mixin;
import org.spongepowered.asm.mixin.Shadow;
import org.spongepowered.asm.mixin.injection.At;
import org.spongepowered.asm.mixin.injection.Redirect;
import thaumcraft.api.TileThaumcraft;
import thaumcraft.api.aspects.Aspect;
import thaumcraft.api.aspects.AspectList;
import thaumcraft.api.visnet.TileVisNode;
import thaumcraft.api.visnet.VisNetHandler;
import thaumcraft.common.items.wands.ItemWandCasting;
import thaumcraft.common.tiles.TileWandPedestal;

@Mixin(TileWandPedestal.class)
public class MixinTileWandPedestal extends TileThaumcraft {
@Shadow
ArrayList<ChunkCoordinates> nodes = null;
@Shadow int counter = 0;

@Redirect(method ="Lthaumcraft/common/tiles/TileWandPedestal;updateEntity()V",
at=@At(value = "INVOKE",target="Lthaumcraft/common/items/wands/ItemWandCasting;getAspectsWithRoom(Lnet/minecraft/item/ItemStack;)Lthaumcraft/api/aspects/AspectList;"))
AspectList getAspectsWithRoomReplacement(ItemWandCasting wand, ItemStack wandstack)
{
AspectList as = wand.getAspectsWithRoom(wandstack);
if (as != null && as.size() > 0) {
for(Aspect aspect : as.getAspects()) {
int drained = VisNetHandler.drainVis(worldObj, xCoord, yCoord, zCoord, aspect, 25); // Pedestal operates every 5 tick
if (drained > 0)
wand.addRealVis(wandstack, aspect, drained, true);
}
}
return as;
}

@Redirect(method="Lthaumcraft/common/tiles/TileWandPedestal;findNodes()V", at=@At(value="INVOKE", target="Lnet/minecraft/world/World;getTileEntity(III)Lnet/minecraft/tileentity/TileEntity;"))
TileEntity addCVNodes(World w, int x, int y, int z)
{
TileEntity te = this.worldObj.getTileEntity(x, y, z);
if (te instanceof TileVisNode)
nodes.add(new ChunkCoordinates(x, y, z));
return te;
}
}