-
-
Notifications
You must be signed in to change notification settings - Fork 62
Expand file tree
/
Copy pathHeatRegistry.java
More file actions
57 lines (49 loc) · 2.09 KB
/
HeatRegistry.java
File metadata and controls
57 lines (49 loc) · 2.09 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
package com.blamejared.compat.betterwithmods;
import betterwithmods.common.registry.block.recipe.BlockIngredient;
import betterwithmods.common.registry.heat.BWMHeatRegistry;
import com.blamejared.mtlib.helpers.InputHelper;
import com.blamejared.mtlib.helpers.LogHelper;
import com.blamejared.mtlib.utils.BaseAction;
import crafttweaker.CraftTweakerAPI;
import crafttweaker.annotations.ModOnly;
import crafttweaker.annotations.ZenRegister;
import crafttweaker.api.item.IItemStack;
import crafttweaker.api.minecraft.CraftTweakerMC;
import net.minecraft.block.Block;
import net.minecraft.block.state.IBlockState;
import net.minecraft.item.ItemStack;
import stanhebben.zenscript.annotations.ZenClass;
import stanhebben.zenscript.annotations.ZenMethod;
@ZenClass("mods.betterwithmods.HeatRegistry")
@ModOnly("betterwithmods")
@ZenRegister
public class HeatRegistry {
@ZenMethod
public static void addHeatSource(crafttweaker.api.block.IBlockState state, int heat) {
CraftTweakerAPI.apply(new AddHeatSource(CraftTweakerMC.getBlockState(state), heat));
}
@SuppressWarnings("deprecation")
@ZenMethod
public static void addHeatSource(IItemStack stack, int heat) {
if (InputHelper.isABlock(stack)) {
Block block = CraftTweakerMC.getBlock(stack);
IBlockState state = block.getStateFromMeta(stack.getMetadata());
CraftTweakerAPI.apply(new AddHeatSource(state, heat));
} else {
LogHelper.logError(String.format("%s input must create a valid BlockState", stack.getDisplayName()), new IllegalArgumentException(String.format("%s input must create a valid BlockState", stack.getDisplayName())));
}
}
public static class AddHeatSource extends BaseAction {
private IBlockState state;
private int heat;
AddHeatSource(IBlockState state, int heat) {
super("Add Heat");
this.state = state;
this.heat = heat;
}
@Override
public void apply() {
BWMHeatRegistry.addHeatSource(new BlockIngredient(new ItemStack(state.getBlock())), heat);
}
}
}