Skip to content

Commit 5755419

Browse files
committed
Added support for fluids and multipart in Too Many Blocks.
Removed the old energy API. All modules now have their own options category. Added a way to control ItemStack sizes. Block network fixes. Added a way of rendering block networks for debugging purposes.
1 parent 7e19e36 commit 5755419

File tree

21 files changed

+331
-27
lines changed

21 files changed

+331
-27
lines changed

all/CHANGELOG.md

+6-1
Original file line numberDiff line numberDiff line change
@@ -1 +1,6 @@
1-
- Various bugfixes
1+
- Added support for fluids and multipart in Too Many Blocks.
2+
- Removed the old energy API.
3+
- All modules now have their own options category.
4+
- Added a way to control ItemStack sizes.
5+
- Block network fixes.
6+
Added a way of rendering block networks for debugging purposes.

effects/gradle.properties

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
org.gradle.jvmargs=-Xmx2G
22

33
# Mod
4-
mod_version=1.2.1
4+
mod_version=1.2.2
55
mod_group=sunsetsatellite
66
mod_name=catalyst-effects

effects/src/main/java/sunsetsatellite/catalyst/CatalystEffectsClient.java

+1-7
Original file line numberDiff line numberDiff line change
@@ -2,9 +2,6 @@
22

33
import net.minecraft.client.Minecraft;
44
import net.minecraft.client.gui.options.components.ToggleableOptionComponent;
5-
import net.minecraft.client.gui.options.data.OptionsPage;
6-
import net.minecraft.client.gui.options.data.OptionsPages;
7-
import net.minecraft.core.item.Item;
85
import sunsetsatellite.catalyst.effects.interfaces.mixins.IKeybinds;
96
import turniplabs.halplibe.util.ClientStartEntrypoint;
107

@@ -17,9 +14,6 @@ public void beforeClientStart() {
1714
@Override
1815
public void afterClientStart() {
1916
CatalystEffects.keybinds = ((IKeybinds) Minecraft.getMinecraft(Minecraft.class).gameSettings);
20-
OptionsPage optionsPage = new OptionsPage("gui.options.page.catalyst-effect", Item.bucketWater.getDefaultStack());
21-
optionsPage
22-
.withComponent(new ToggleableOptionComponent<>(CatalystEffects.keybinds.getEffectDisplayPlaceEnumOption()));
23-
OptionsPages.register(optionsPage);
17+
CatalystClient.effectsCategory.withComponent(new ToggleableOptionComponent<>(CatalystEffects.keybinds.getEffectDisplayPlaceEnumOption()));
2418
}
2519
}

energy/src/main/java/sunsetsatellite/catalyst/energy/simple/impl/TileEntityEnergyBase.java

+19
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
package sunsetsatellite.catalyst.energy.simple.impl;
22

3+
import com.mojang.nbt.CompoundTag;
34
import net.minecraft.core.block.entity.TileEntity;
45
import sunsetsatellite.catalyst.core.util.Direction;
56
import sunsetsatellite.catalyst.core.util.Vec3i;
@@ -64,6 +65,24 @@ public boolean isConnected(Direction direction) {
6465
return direction.getTileEntity(worldObj,this) instanceof TileEntityEnergyConductor;
6566
}
6667

68+
@Override
69+
public void writeToNBT(CompoundTag tag) {
70+
super.writeToNBT(tag);
71+
tag.putLong("Energy", energy);
72+
tag.putLong("Capacity", capacity);
73+
tag.putLong("MaxReceive", maxReceive);
74+
tag.putLong("MaxProvide", maxProvide);
75+
}
76+
77+
@Override
78+
public void readFromNBT(CompoundTag tag) {
79+
super.readFromNBT(tag);
80+
energy = tag.getLong("Energy");
81+
capacity = tag.getLong("Capacity");
82+
maxReceive = tag.getLong("MaxReceive");
83+
maxProvide = tag.getLong("MaxProvide");
84+
}
85+
6786
@Override
6887
public void networkChanged(Network network) {
6988
this.energyNet = network;

fluids/gradle.properties

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
org.gradle.jvmargs=-Xmx2G
22

33
# Mod
4-
mod_version=1.4.0
4+
mod_version=1.4.1
55
mod_group=sunsetsatellite
66
mod_name=catalyst-fluids

gradle.properties

+1-1
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,6 @@ mod_menu_version=2.0.6
1111
halplibe_version=4.1.3
1212

1313
# Mod
14-
core_mod_version=1.8.2
14+
core_mod_version=1.9.0
1515
core_mod_group=sunsetsatellite
1616
core_mod_name=catalyst-core

multipart/gradle.properties

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
org.gradle.jvmargs=-Xmx2G
22

33
# Mod
4-
mod_version=1.0.1
4+
mod_version=1.0.2
55
mod_group=sunsetsatellite
66
mod_name=catalyst-multipart
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,53 @@
1+
package sunsetsatellite.catalyst;
2+
3+
import net.fabricmc.api.EnvType;
4+
import net.fabricmc.api.Environment;
5+
import net.minecraft.client.Minecraft;
6+
import net.minecraft.client.gui.options.components.BooleanOptionComponent;
7+
import net.minecraft.client.gui.options.components.OptionsCategory;
8+
import net.minecraft.client.gui.options.data.OptionsPage;
9+
import net.minecraft.client.gui.options.data.OptionsPages;
10+
import net.minecraft.core.Global;
11+
import net.minecraft.core.item.Item;
12+
import sunsetsatellite.catalyst.core.interfaces.mixins.IKeybinds;
13+
import turniplabs.halplibe.util.GameStartEntrypoint;
14+
15+
@Environment(EnvType.CLIENT)
16+
public class CatalystClient implements GameStartEntrypoint {
17+
18+
public static OptionsPage optionsPage;
19+
public static OptionsCategory coreCategory;
20+
public static OptionsCategory fluidsCategory;
21+
public static OptionsCategory energyCategory;
22+
public static OptionsCategory multiblocksCategory;
23+
public static OptionsCategory effectsCategory;
24+
public static OptionsCategory multipartCategory;
25+
26+
@Override
27+
public void beforeGameStart() {
28+
29+
}
30+
31+
@Override
32+
public void afterGameStart() {
33+
if(!Global.isServer){
34+
optionsPage = new OptionsPage("gui.options.page.catalyst", Item.dustRedstone.getDefaultStack());
35+
IKeybinds gameSettings = (IKeybinds) Minecraft.getMinecraft(this).gameSettings;
36+
coreCategory = new OptionsCategory("gui.options.page.catalyst.category.core");
37+
coreCategory.withComponent(new BooleanOptionComponent(gameSettings.getNetworkRenderOption()));
38+
fluidsCategory = new OptionsCategory("gui.options.page.catalyst.category.fluids");
39+
energyCategory = new OptionsCategory("gui.options.page.catalyst.category.energy");
40+
multiblocksCategory = new OptionsCategory("gui.options.page.catalyst.category.multiblocks");
41+
effectsCategory = new OptionsCategory("gui.options.page.catalyst.category.effects");
42+
multipartCategory = new OptionsCategory("gui.options.page.catalyst.category.multipart");
43+
optionsPage
44+
.withComponent(coreCategory)
45+
.withComponent(fluidsCategory)
46+
.withComponent(energyCategory)
47+
.withComponent(multiblocksCategory)
48+
.withComponent(effectsCategory)
49+
.withComponent(multipartCategory);
50+
OptionsPages.register(optionsPage);
51+
}
52+
}
53+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
package sunsetsatellite.catalyst.core.interfaces.mixins;
2+
3+
import net.minecraft.client.option.BooleanOption;
4+
5+
public interface IKeybinds {
6+
7+
BooleanOption getNetworkRenderOption();
8+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
package sunsetsatellite.catalyst.core.mixin;
2+
3+
4+
import net.minecraft.client.option.BooleanOption;
5+
import net.minecraft.client.option.GameSettings;
6+
import org.spongepowered.asm.mixin.Mixin;
7+
import org.spongepowered.asm.mixin.Unique;
8+
import sunsetsatellite.catalyst.core.interfaces.mixins.IKeybinds;
9+
10+
@Mixin(
11+
value = GameSettings.class,
12+
remap = false
13+
)
14+
public class GameSettingsMixin implements IKeybinds
15+
{
16+
private final GameSettings thisAs = ((GameSettings)(Object)this);
17+
18+
@Unique
19+
BooleanOption networkRenderOption = new BooleanOption(thisAs,"catalyst-core.showNetworkRender",false);
20+
21+
@Override
22+
public BooleanOption getNetworkRenderOption() {
23+
return networkRenderOption;
24+
}
25+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,46 @@
1+
package sunsetsatellite.catalyst.core.mixin;
2+
3+
import net.minecraft.core.item.ItemStack;
4+
import org.spongepowered.asm.mixin.Mixin;
5+
import org.spongepowered.asm.mixin.Unique;
6+
import org.spongepowered.asm.mixin.injection.At;
7+
import org.spongepowered.asm.mixin.injection.Inject;
8+
import org.spongepowered.asm.mixin.injection.callback.CallbackInfoReturnable;
9+
import sunsetsatellite.catalyst.core.util.mixin.interfaces.UnlimitedItemStack;
10+
11+
@Mixin(value = ItemStack.class, remap = false)
12+
public class ItemStackMixin implements UnlimitedItemStack {
13+
@Unique
14+
public boolean unlimited = false;
15+
@Unique
16+
public boolean customMaxSizeEnabled = false;
17+
18+
@Unique
19+
public int customMaxSize = 64;
20+
21+
@Override
22+
@Unique
23+
public void setUnlimited(boolean unlimited) {
24+
this.unlimited = unlimited;
25+
}
26+
27+
@Override
28+
public void enableCustomMaxSize(int maxSize) {
29+
customMaxSizeEnabled = true;
30+
customMaxSize = maxSize;
31+
}
32+
33+
@Override
34+
public void disableCustomMaxSize() {
35+
customMaxSizeEnabled = false;
36+
}
37+
38+
@Inject(method = "getMaxStackSize()I", at = @At("HEAD"), cancellable = true)
39+
public void getMaxStackSize(CallbackInfoReturnable<Integer> cir) {
40+
if (unlimited) {
41+
cir.setReturnValue(Integer.MAX_VALUE);
42+
} else if (customMaxSizeEnabled) {
43+
cir.setReturnValue(customMaxSize);
44+
}
45+
}
46+
}

src/main/java/sunsetsatellite/catalyst/core/mixin/RenderGlobalMixin.java

+75-1
Original file line numberDiff line numberDiff line change
@@ -2,23 +2,41 @@
22

33
import com.llamalad7.mixinextras.sugar.Local;
44
import net.minecraft.client.Minecraft;
5+
import net.minecraft.client.render.RenderBlocks;
56
import net.minecraft.client.render.RenderGlobal;
7+
import net.minecraft.client.render.block.model.BlockModel;
8+
import net.minecraft.client.render.block.model.BlockModelDispatcher;
9+
import net.minecraft.client.render.camera.ICamera;
10+
import net.minecraft.client.render.stitcher.TextureRegistry;
611
import net.minecraft.client.render.tessellator.Tessellator;
712
import net.minecraft.core.block.Block;
813
import net.minecraft.core.util.phys.AABB;
14+
import net.minecraft.core.world.World;
915
import org.lwjgl.opengl.GL11;
1016
import org.spongepowered.asm.mixin.Mixin;
1117
import org.spongepowered.asm.mixin.Shadow;
18+
import org.spongepowered.asm.mixin.Unique;
1219
import org.spongepowered.asm.mixin.injection.At;
20+
import org.spongepowered.asm.mixin.injection.Inject;
1321
import org.spongepowered.asm.mixin.injection.Redirect;
14-
import sunsetsatellite.catalyst.core.util.ISideInteractable;
22+
import org.spongepowered.asm.mixin.injection.callback.CallbackInfo;
23+
import sunsetsatellite.catalyst.core.interfaces.mixins.IKeybinds;
24+
import sunsetsatellite.catalyst.core.util.*;
25+
import sunsetsatellite.catalyst.core.util.network.Network;
26+
import sunsetsatellite.catalyst.core.util.network.NetworkManager;
27+
28+
import java.util.ArrayList;
29+
import java.util.Set;
1530

1631
@Mixin(value = RenderGlobal.class,remap = false)
1732
public class RenderGlobalMixin {
1833

1934
@Shadow
2035
private Minecraft mc;
2136

37+
@Shadow
38+
private World worldObj;
39+
2240
@Redirect(method = "drawSelectionBox",at = @At(value = "INVOKE", target = "Lnet/minecraft/client/render/RenderGlobal;drawOutlinedBoundingBox(Lnet/minecraft/core/util/phys/AABB;)V"))
2341
public void drawOutlinedSectionedBoundingBox(RenderGlobal instance, AABB aabb, @Local int j)
2442
{
@@ -246,5 +264,61 @@ public void drawOutlinedSectionedBoundingBox(RenderGlobal instance, AABB aabb, @
246264
}
247265
}
248266

267+
@Unique
268+
private RenderBlocks blockRenderer;
269+
270+
@Inject(method = "renderEntities", at = @At("TAIL"))
271+
public void renderWorld(ICamera camera, float partialTick, CallbackInfo ci){
272+
if(((IKeybinds) mc.gameSettings).getNetworkRenderOption().value){
273+
double x = camera.getX(partialTick);
274+
double y = camera.getY(partialTick);
275+
double z = camera.getZ(partialTick);
276+
Set<Network> nets = NetworkManager.getNetsForDimension(worldObj.dimension.id);
277+
ArrayList<BlockInstance> list = new ArrayList<>();
278+
for (Network net : nets) {
279+
for (Vec3i position : net.getPositions()) {
280+
list.add(new BlockInstance(Block.sand,position,null));
281+
}
282+
}
283+
blockRenderer = new RenderBlocks(new HologramWorld(list));
284+
for (Network net : nets) {
285+
for (Vec3i position : net.getPositions()) {
286+
GL11.glPushMatrix();
287+
GL11.glDisable(GL11.GL_LIGHTING);
288+
//GL11.glDisable(GL11.GL_DEPTH_TEST);
289+
BlockModel<?> model = BlockModelDispatcher.getInstance().getDispatch(Block.sand);
290+
GL11.glTranslated(position.x - x + 0.5f , position.y - y + 0.5f, position.z - z + 0.5f);
291+
((IFullbright)model).enableFullbright();
292+
((IColorOverride)model).enableColorOverride();
293+
((IColorOverride)model).overrideColor(net.getColor().getRed() / 255f,net.getColor().getGreen() / 255f,net.getColor().getBlue() / 255f,0.5f);
294+
GL11.glScalef(1.01f,1.01f,1.01f);
295+
drawBlock(Tessellator.instance,
296+
model
297+
);
298+
((IColorOverride)model).disableColorOverride();
299+
((IFullbright)model).disableFullbright();
300+
GL11.glEnable(GL11.GL_LIGHTING);
301+
//GL11.glEnable(GL11.GL_DEPTH_TEST);
302+
GL11.glPopMatrix();
303+
304+
}
305+
}
306+
}
307+
}
308+
309+
@Unique
310+
private void drawBlock(Tessellator tessellator, BlockModel<?> model) {
311+
TextureRegistry.blockAtlas.bindTexture();
312+
GL11.glPushMatrix();
313+
RenderBlocks renderBlocks = BlockModel.renderBlocks;
314+
BlockModel.setRenderBlocks(blockRenderer);
315+
GL11.glEnable(GL11.GL_BLEND);
316+
GL11.glBlendFunc(GL11.GL_SRC_ALPHA, GL11.GL_ONE_MINUS_SRC_ALPHA);
317+
model.renderBlockOnInventory(tessellator, 0,1,null);
318+
BlockModel.setRenderBlocks(renderBlocks);
319+
GL11.glDisable(GL11.GL_BLEND);
320+
GL11.glPopMatrix();
321+
GL11.glEnable(GL11.GL_CULL_FACE);
322+
}
249323

250324
}

src/main/java/sunsetsatellite/catalyst/core/util/ConduitCapability.java

+1-1
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ public enum ConduitCapability {
44
FLUID,
55
SIGNALUM,
66
ITEM,
7-
NETWORK,
7+
RES_NETWORK,
88
CATALYST_ENERGY,
99
ELECTRIC
1010
}

multiblocks/src/main/java/sunsetsatellite/catalyst/multiblocks/HologramWorld.java src/main/java/sunsetsatellite/catalyst/core/util/HologramWorld.java

+1-3
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
package sunsetsatellite.catalyst.multiblocks;
1+
package sunsetsatellite.catalyst.core.util;
22

33
import net.minecraft.client.render.LightmapHelper;
44
import net.minecraft.core.block.Block;
@@ -8,8 +8,6 @@
88
import net.minecraft.core.world.WorldSource;
99
import net.minecraft.core.world.biome.Biome;
1010
import net.minecraft.core.world.season.SeasonManager;
11-
import sunsetsatellite.catalyst.core.util.BlockInstance;
12-
import sunsetsatellite.catalyst.core.util.Vec3i;
1311

1412
import java.util.ArrayList;
1513
import java.util.HashMap;
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
package sunsetsatellite.catalyst.core.util.mixin.interfaces;
2+
3+
public interface UnlimitedItemStack {
4+
void setUnlimited(boolean unlimited);
5+
6+
void enableCustomMaxSize(int maxSize);
7+
8+
void disableCustomMaxSize();
9+
}

0 commit comments

Comments
 (0)