Skip to content

Commit

Permalink
Added Mixer
Browse files Browse the repository at this point in the history
Added Mixer
Added UU Mixer
Added RBMK Partial meltdowns
Added JSON Bedrock Ore Dimension config
Added more info to Fluid tooltips
Added ethanol, fishoil, sunfloweroil, nitroglycering, colloid and their recipes
Added logarithmic fluid display
Added creative bedrock ore changing
Added fluid rendering to crystallizer render

Changed S.A.F.E reactor to have a button instead of a fuse
Changed biofuel recipe to include ethanol
Changed upgrade tooltips to have indentations
Changed S.A.F.E reactor power output by x40
Changed DFC rendering scales and off look
Changed name of coated red copper cable to red copper cable block as both are coated
Changed Silex texture to reflect that it has a bottom port

Fixed Crash when setting fluid types of fraction tower on a server
Fixed RBMK redstone control not working on a server
Fixed flashing when having [blinding] item and spider milks
Fixed missing shift click of chemfactory
Fixed barrel info render pos
Fixed dickmask bug
Fixed DFC negative power bug
Fixed DFC injector not inputting fluids

Removed unused interface
  • Loading branch information
Alcatergit committed Jun 25, 2023
1 parent eacccc0 commit 0f139dd
Show file tree
Hide file tree
Showing 80 changed files with 3,181 additions and 429 deletions.
2 changes: 2 additions & 0 deletions src/main/java/com/hbm/blocks/ModBlocks.java
Original file line number Diff line number Diff line change
Expand Up @@ -1083,6 +1083,8 @@ public SoundEvent getBreakSound() {
public static final Block machine_chemfac = new MachineChemfac(Material.IRON, "machine_chemfac").setHardness(5.0F).setResistance(30.0F).setCreativeTab(MainRegistry.machineTab);
public static final int guiID_machine_chemplant = 49;

public static final Block machine_mixer = new MachineMixer(Material.IRON, "machine_mixer").setHardness(5.0F).setResistance(30.0F).setCreativeTab(MainRegistry.machineTab);

public static final Block machine_rtg_grey = new MachineRTG(Material.IRON, "machine_rtg_grey").setHardness(5.0F).setResistance(10.0F).setCreativeTab(MainRegistry.machineTab);
public static final int guiID_machine_rtg = 42;

Expand Down
21 changes: 14 additions & 7 deletions src/main/java/com/hbm/blocks/machine/MachineFractionTower.java
Original file line number Diff line number Diff line change
Expand Up @@ -74,25 +74,32 @@ public boolean onBlockActivated(World world, BlockPos pos1, IBlockState state, E
TileEntityMachineFractionTower frac = (TileEntityMachineFractionTower) te;

if(player.getHeldItem(hand).isEmpty()) {

player.sendMessage(new TextComponentString(TextFormatting.YELLOW + "=== FRACTIONING TOWER Y:" + pos[1] + " ==="));
if(world.isRemote){
player.sendMessage(new TextComponentString(TextFormatting.YELLOW + "=== FRACTIONING TOWER Y:" + pos[1] + " ==="));

for(int i = 0; i < frac.tanks.length; i++)
player.sendMessage(new TextComponentTranslation(frac.types[i].getUnlocalizedName()).appendSibling(new TextComponentString(": " + frac.tanks[i].getFluidAmount() + "/" + frac.tanks[i].getCapacity() + "mB")));
for(int i = 0; i < frac.tanks.length; i++)
player.sendMessage(new TextComponentTranslation(frac.types[i].getUnlocalizedName()).appendSibling(new TextComponentString(": " + frac.tanks[i].getFluidAmount() + "/" + frac.tanks[i].getCapacity() + "mB")));
}
} else {

if(world.getTileEntity(new BlockPos(pos[0], pos[1] - 3, pos[2])) instanceof TileEntityMachineFractionTower) {
player.sendMessage(new TextComponentString(TextFormatting.RED + "You can only change the type in the bottom segment!"));
if(world.isRemote){
player.sendMessage(new TextComponentString(TextFormatting.RED + "You can only change the type in the bottom segment!"));
}
} else {
Fluid type = ItemForgeFluidIdentifier.getType(player.getHeldItem(hand));
if(RefineryRecipes.getFractions(type) == null){
player.sendMessage(new TextComponentString("§cNo recipe found for §e"+type.getLocalizedName(new FluidStack(type, 1))));
if(world.isRemote){
player.sendMessage(new TextComponentString("§cNo recipe found for §e"+type.getLocalizedName(new FluidStack(type, 1))));
}
return false;
}

frac.setTankType(0, type);
frac.markDirty();
player.sendMessage(new TextComponentString(TextFormatting.YELLOW + "Changed type to §a" + I18n.format(type.getUnlocalizedName())));
if(world.isRemote){
player.sendMessage(new TextComponentString(TextFormatting.YELLOW + "Changed type to §a" + I18n.format(type.getUnlocalizedName())));
}
}
}

Expand Down
44 changes: 44 additions & 0 deletions src/main/java/com/hbm/blocks/machine/MachineMixer.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
package com.hbm.blocks.machine;

import com.hbm.blocks.BlockDummyable;
import com.hbm.tileentity.machine.TileEntityMachineMixer;

import net.minecraft.block.material.Material;
import net.minecraft.block.state.IBlockState;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.tileentity.TileEntity;
import net.minecraft.util.math.BlockPos;
import net.minecraft.util.EnumFacing;
import net.minecraft.util.EnumHand;
import net.minecraft.world.World;

public class MachineMixer extends BlockDummyable {

public MachineMixer(Material mat, String s) {
super(mat, s);
}

@Override
public TileEntity createNewTileEntity(World world, int meta) {

if(meta >= 12)
return new TileEntityMachineMixer();

return null;
}

@Override
public int[] getDimensions() {
return new int[] {2, 0, 0, 0, 0, 0};
}

@Override
public int getOffset() {
return 0;
}

@Override
public boolean onBlockActivated(World world, BlockPos pos, IBlockState state, EntityPlayer player, EnumHand hand, EnumFacing facing, float hitX, float hitY, float hitZ) {
return standardOpenBehavior(world, pos.getX(), pos.getY(), pos.getZ(), player, 0);
}
}
26 changes: 14 additions & 12 deletions src/main/java/com/hbm/blocks/machine/rbmk/RBMKConsole.java
Original file line number Diff line number Diff line change
Expand Up @@ -51,19 +51,21 @@ public TileEntity createNewTileEntity(World world, int meta) {
@Override
public void neighborChanged(IBlockState state, World world, BlockPos pos, Block blockIn, BlockPos fromPos) {
super.neighborChanged(state, world, pos, blockIn, fromPos);
if(state.getValue(META) >= offset){
int power = world.isBlockIndirectlyGettingPowered(pos);
if(power > 0 && power <= 15){
TileEntityRBMKConsole console = (TileEntityRBMKConsole) world.getTileEntity(pos);
NBTTagCompound control = new NBTTagCompound();
control.setDouble("level", (15D-power)/14D);

for(int j = 0; j < console.columns.length; j++) {
if(console.columns[j] != null && console.columns[j].type == ColumnType.CONTROL)
control.setInteger("sel_" + j, j);
if(!world.isRemote){
if(state.getValue(META) >= offset){
int power = world.isBlockIndirectlyGettingPowered(pos);
if(power > 0 && power <= 15){
TileEntityRBMKConsole console = (TileEntityRBMKConsole) world.getTileEntity(pos);
NBTTagCompound control = new NBTTagCompound();
control.setDouble("level", (15D-power)/14D);

for(int j = 0; j < console.columns.length; j++) {
if(console.columns[j] != null && console.columns[j].type == ColumnType.CONTROL)
control.setInteger("sel_" + j, j);
}

console.receiveControl(control);
}

PacketDispatcher.wrapper.sendToServer(new NBTControlPacket(control, console.getPos()));
}
}
}
Expand Down
120 changes: 120 additions & 0 deletions src/main/java/com/hbm/config/BedrockOreJsonConfig.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,120 @@
package com.hbm.config;

import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;
import java.util.HashMap;
import java.util.HashSet;

import com.google.gson.Gson;
import com.google.gson.JsonElement;
import com.google.gson.JsonArray;
import com.google.gson.JsonObject;
import com.google.gson.stream.JsonWriter;

import com.hbm.main.MainRegistry;

public class BedrockOreJsonConfig {

public static final String bedrockOreJsonConfigFile = "hbm_bedrock_ores.json";

public static HashMap<Integer, HashSet<String>> dimOres = new HashMap();
public static HashMap<Integer, Boolean> dimWhiteList = new HashMap();
public static HashMap<Integer, Integer> dimOreRarity = new HashMap();

public static void init(){
if(!loadFromJson()){
clear();
setDefaults();
writeToJson();
}
}

public static void clear(){
dimOres.clear();
dimWhiteList.clear();
dimOreRarity.clear();
}

public static boolean isOreAllowed(int dimID, String ore){
HashSet<String> ores = dimOres.get(dimID);
boolean isInList = ores.contains(ore);
if(!dimWhiteList.get(dimID)) isInList = !isInList;
return isInList;
}

public static void setDefaults() {
addEntry(0, 30, Arrays.asList("orePlutonium", "oreQuartz", "oreRedPhosphorus", "oreSchrabidium"), false);
addEntry(-1, 60, Arrays.asList("orePlutonium", "oreQuartz", "oreRedPhosphorus", "oreSchrabidium"), true);
}

public static void addEntry(int dimID, int rarity, List<String> ores, Boolean isWhiteList){
HashSet<String> set = new HashSet();
for(String ore : ores)
set.add(ore);
dimOres.put(dimID, set);
dimOreRarity.put(dimID, rarity);
dimWhiteList.put(dimID, isWhiteList);
}

public static void writeToJson(){
try {
JsonWriter writer = JsonConfig.startWriting(bedrockOreJsonConfigFile);
writer.name("dimConfig").beginArray();
for(Integer dimID : dimOres.keySet()){
writer.beginObject();
writer.name("dimID").value(dimID);
writer.name("oreRarity").value(dimOreRarity.get(dimID));
writer.name("isWhiteList").value(dimWhiteList.get(dimID));
writer.name("bedrockOres").beginArray();
for(String line : dimOres.get(dimID))
writer.value(line);
writer.endArray();
writer.endObject();
}
writer.endArray();
JsonConfig.stopWriting(writer);
} catch(Exception ex) {
ex.printStackTrace();
}
}

public static boolean loadFromJson() {
try {
JsonObject reader = JsonConfig.startReading(bedrockOreJsonConfigFile);

if(reader == null || !reader.has("dimConfig")) return false;

JsonArray entries = reader.getAsJsonArray("dimConfig");
for(JsonElement entry : entries){

if(entry == null || !entry.isJsonObject()) continue;
JsonObject dimEntry = entry.getAsJsonObject();

if(!dimEntry.has("dimID")) return false;
int dimID = dimEntry.get("dimID").getAsInt();

if(!dimEntry.has("oreRarity")) return false;
int oreRarity = dimEntry.get("oreRarity").getAsInt();

if(!dimEntry.has("isWhiteList")) continue;
boolean isWhiteList = dimEntry.get("isWhiteList").getAsBoolean();

if(!dimEntry.has("bedrockOres") || !dimEntry.get("bedrockOres").isJsonArray()) continue;
JsonArray jbedrockOres = dimEntry.get("bedrockOres").getAsJsonArray();
List<String> bedrockOres = new ArrayList<String>();
for(JsonElement ore : jbedrockOres){
bedrockOres.add(ore.getAsString());
}

addEntry(dimID, oreRarity, bedrockOres, isWhiteList);
}

return true;
} catch(Exception ex) {
MainRegistry.logger.error("Loading the bedrock ore config resulted in an error");
ex.printStackTrace();
return false;
}
}
}
2 changes: 0 additions & 2 deletions src/main/java/com/hbm/config/CompatibilityConfig.java
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,6 @@ public class CompatibilityConfig {
public static HashMap endTixiteSpawn;

public static HashMap bedrockOilSpawn;
public static HashMap bedrockOreSpawn;

public static HashMap radioStructure;
public static HashMap antennaStructure;
Expand Down Expand Up @@ -151,7 +150,6 @@ public static void loadFromConfig(Configuration config) {
daffergonSpawn = CommonConfig.createConfigHashMap(config, CATEGORY_DIMORE, "01.30_daffergonSpawnRate", "Amount of daffergon ore veins per chunk - <dimID:amount> (Int:Int)", "Int", "Int", new String[]{ "-30:1" }, ":");

bedrockOilSpawn = CommonConfig.createConfigHashMap(config, CATEGORY_DIMORE, "01.31_bedrockOilSpawnRate", "Spawn bedrock oil every nTH chunk - <dimID:amount> (Int:Int)", "Int", "Int", new String[]{ "0:200" }, ":");
bedrockOreSpawn = CommonConfig.createConfigHashMap(config, CATEGORY_DIMORE, "01.32_bedrockOreSpawnRate", "Spawn bedrock ore every nTH chunk - <dimID:amount> (Int:Int)", "Int", "Int", new String[]{ "0:30", "-1:60" }, ":");

netherUraniumSpawn = CommonConfig.createConfigHashMap(config, CATEGORY_DIMORE, "02.N00_uraniumSpawnrate", "Amount of nether uranium per chunk - <dimID:amount> (Int:Int)", "Int", "Int", new String[]{ "-1:8" }, ":");
netherTungstenSpawn = CommonConfig.createConfigHashMap(config, CATEGORY_DIMORE, "02.N01_tungstenSpawnrate", "Amount of nether tungsten per chunk - <dimID:amount> (Int:Int)", "Int", "Int", new String[]{ "-1:10" }, ":");
Expand Down
47 changes: 47 additions & 0 deletions src/main/java/com/hbm/config/JsonConfig.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
package com.hbm.config;

import java.io.File;
import java.io.FileReader;
import java.io.FileWriter;

import com.google.gson.Gson;
import com.google.gson.JsonObject;
import com.google.gson.stream.JsonWriter;

import com.hbm.main.MainRegistry;

public class JsonConfig {

public static final Gson gson = new Gson();

private static File getFile(String filename){
return new File(MainRegistry.proxy.getDataDir().getPath() + "/config/hbm" + File.separatorChar + filename);
}

public static JsonWriter startWriting(String filename){
try{
JsonWriter writer = new JsonWriter(new FileWriter(getFile(filename)));
writer.setIndent(" ");
writer.beginObject();
return writer;
} catch(Exception ex) { }
return null;
}

public static void stopWriting(JsonWriter writer){
try{
writer.endObject();
writer.close();
} catch(Exception ex) { }
}

public static JsonObject startReading(String filename){
try{
File file = getFile(filename);
if(file.exists())
return gson.fromJson(new FileReader(file), JsonObject.class);
return null;
} catch(Exception ex) { }
return null;
}
}
Loading

0 comments on commit 0f139dd

Please sign in to comment.