Skip to content

Commit

Permalink
Colored beacons work with modded glass
Browse files Browse the repository at this point in the history
  • Loading branch information
Roadhog360 committed Sep 2, 2023
1 parent 9e1c9f2 commit ae26502
Show file tree
Hide file tree
Showing 2 changed files with 48 additions and 20 deletions.
13 changes: 13 additions & 0 deletions src/main/java/ganymedes01/etfuturum/recipes/ModRecipes.java
Original file line number Diff line number Diff line change
Expand Up @@ -239,6 +239,19 @@ private static void registerOreDictionary() {
for (String waxString : IDegradable.waxStrings) {
registerOre(waxString, ModItems.HONEYCOMB.get());
}

if (ConfigBlocksItems.enableColourfulBeacons && EtFuturum.hasTConstruct) { //TCon lacks proper tagging for their glass; let's add the right tags so beacons can see it
for (int i = 0; i < ore_dyes.length; i++) {
String capitalizedColor = ore_dyes[15 - i].substring(3);
ItemStack glassBlock = new ItemStack(GameRegistry.findBlock("TConstruct", "GlassBlock.StainedClear"), 1, i);
ItemStack glassPane = new ItemStack(GameRegistry.findBlock("TConstruct", "GlassPaneClearStained"), 1, i);

OreDictionary.registerOre("blockGlass" + capitalizedColor, glassBlock);
OreDictionary.registerOre("blockGlass", glassBlock);
OreDictionary.registerOre("paneGlass" + capitalizedColor, glassPane);
OreDictionary.registerOre("paneGlass", glassPane);
}
}
}

private static void registerRecipes() {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,18 +1,20 @@
package ganymedes01.etfuturum.tileentities;

import java.util.Arrays;
import java.util.List;

import com.google.common.collect.Lists;

import cpw.mods.fml.relauncher.Side;
import cpw.mods.fml.relauncher.SideOnly;
import ganymedes01.etfuturum.EtFuturum;
import ganymedes01.etfuturum.recipes.ModRecipes;
import net.minecraft.block.Block;
import net.minecraft.entity.passive.EntitySheep;
import net.minecraft.init.Blocks;
import net.minecraft.item.Item;
import net.minecraft.item.ItemStack;
import net.minecraft.tileentity.TileEntityBeacon;
import net.minecraft.util.AxisAlignedBB;

import java.util.Arrays;
import java.util.List;

public class TileEntityNewBeacon extends TileEntityBeacon {

private final List<BeamSegment> segments = Lists.newArrayList();
Expand Down Expand Up @@ -42,31 +44,44 @@ private void updateSegments() {

for (int i = y + 1; i < worldObj.getActualHeight(); i++) {
Block iblockstate = worldObj.getBlock(x, i, z);
float[] colours;

if (iblockstate == Blocks.stained_glass)
colours = EntitySheep.fleeceColorTable[worldObj.getBlockMetadata(x, i, z)];
else {
if (iblockstate != Blocks.stained_glass_pane) {
if (iblockstate.getLightOpacity() >= 15) {
segments.clear();
break;
float[] colors = null;

Item itemBlock = Item.getItemFromBlock(iblockstate);
if (itemBlock != null) {
for (String tag : EtFuturum.getOreStrings(new ItemStack(itemBlock, 1, worldObj.getBlockMetadata(x, i, z)))) {
if (colors != null) break;
String tagLower = tag.toLowerCase();
for (int j = 0; j < 16; j++) {
String oreDye = ModRecipes.ore_dyes[15 - j].substring(3).toLowerCase();
if (tagLower.contains("glass") && tagLower.contains(oreDye)) {
if (!oreDye.contains("light") && tagLower.contains("light")) {
//Prevents Light Gray glass from getting the regular Gray color
continue;
}
colors = EntitySheep.fleeceColorTable[j];
break;
}
}
}
}

beamsegment.func_177262_a();
continue;
if (colors == null) {
if (iblockstate.getLightOpacity() >= 15) {
segments.clear();
break;
}

colours = EntitySheep.fleeceColorTable[worldObj.getBlockMetadata(x, i, z)];
beamsegment.func_177262_a();
continue;
}

if (!flag)
colours = new float[] { (beamsegment.getColor()[0] + colours[0]) / 2.0F, (beamsegment.getColor()[1] + colours[1]) / 2.0F, (beamsegment.getColor()[2] + colours[2]) / 2.0F };
colors = new float[]{(beamsegment.getColor()[0] + colors[0]) / 2.0F, (beamsegment.getColor()[1] + colors[1]) / 2.0F, (beamsegment.getColor()[2] + colors[2]) / 2.0F};

if (Arrays.equals(colours, beamsegment.getColor()))
if (Arrays.equals(colors, beamsegment.getColor()))
beamsegment.func_177262_a();
else {
beamsegment = new TileEntityNewBeacon.BeamSegment(colours);
beamsegment = new TileEntityNewBeacon.BeamSegment(colors);
segments.add(beamsegment);
}

Expand Down

0 comments on commit ae26502

Please sign in to comment.