Skip to content

Commit

Permalink
Update Forge and BWM Support.
Browse files Browse the repository at this point in the history
Fix Hopper Crate recipe impl (with a bug fix in BWM to make it easier)
Fix BWM Manual api, less hacks necessary now.
  • Loading branch information
primetoxinz committed Jun 27, 2018
1 parent 3134c0d commit e946bda
Show file tree
Hide file tree
Showing 4 changed files with 16 additions and 77 deletions.
4 changes: 2 additions & 2 deletions build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ sourceCompatibility = JavaVersion.VERSION_1_8
targetCompatibility = JavaVersion.VERSION_1_8

minecraft {
version = "1.12.2-14.23.2.2624"
version = "1.12.2-14.23.4.2705"
runDir = "run"
mappings = "snapshot_20171125"
replace "%VERSION%": "${project.version}"
Expand All @@ -38,7 +38,7 @@ repositories {
}

dependencies {
deobfCompile "betterwithmods:BetterWithMods:1.12-2.1.8-477"
deobfCompile "betterwithmods:BetterWithMods:1.12-2.1.24-720"
deobfCompile "mezz.jei:jei_1.12.2:4.8.3.128"
//deobfCompile "com.blamejared:MTLib:3.+"
compile files('libs/')
Expand Down
41 changes: 5 additions & 36 deletions src/main/java/betterwithaddons/ClientProxy.java
Original file line number Diff line number Diff line change
Expand Up @@ -18,15 +18,10 @@
import betterwithmods.manual.api.ManualAPI;
import betterwithmods.manual.api.manual.ImageRenderer;
import betterwithmods.manual.api.prefab.manual.ItemStackTabIconRenderer;
import betterwithmods.manual.api.prefab.manual.ResourceContentProvider;
import betterwithmods.manual.client.manual.Document;
import betterwithmods.manual.client.manual.provider.BlockImageProvider;
import betterwithmods.manual.client.manual.provider.ItemImageProvider;
import betterwithmods.manual.client.manual.provider.OreDictImageProvider;
import betterwithmods.manual.client.manual.provider.TextureImageProvider;
import betterwithmods.manual.client.manual.segment.JEIRenderSegment;
import betterwithmods.manual.client.manual.segment.JEISegment;
import betterwithmods.manual.client.manual.segment.Segment;
import betterwithmods.manual.common.DirectoryDefaultProvider;
import betterwithmods.manual.custom.JEIRenderSegment;
import betterwithmods.manual.custom.JEISegment;
import com.google.common.base.Strings;
import com.google.common.collect.Maps;
import net.minecraft.block.Block;
Expand Down Expand Up @@ -62,7 +57,6 @@ public class ClientProxy implements IProxy
public static ModelResourceLocation ropePostLocation = new ModelResourceLocation(new ResourceLocation(Reference.MOD_ID, "rope_post_knot"), "normal");

static ResourceProxy resourceProxy;
private static Pattern varPattern = Pattern.compile("var:([^\\)]+)");

static {
resourceProxy = new ResourceProxy();
Expand Down Expand Up @@ -97,35 +91,10 @@ public void init() {
registerColorable(ModItems.TEA_CUP);

MinecraftForge.EVENT_BUS.register(new ToolShardModelHandler());
//TODO definition provider
ManualAPI.addProvider(new ResourceContentProvider(Reference.MOD_ID, "docs/"));
ManualAPI.addProvider("", new TextureImageProvider());
ManualAPI.addProvider("item", new ItemImageProvider());
ManualAPI.addProvider("block", new BlockImageProvider());
ManualAPI.addProvider("oredict", new OreDictImageProvider());
ManualAPI.addTab(new ItemStackTabIconRenderer(new ItemStack(ModBlocks.CHUTE)), "bwm.manual.bwa", "%LANGUAGE%/bwa/index.md");
String imagePattern = "!\\[([^\\[]*)\\]\\(([^\\)]+)\\)";
Document.SEGMENT_TYPES.removeIf(mapping -> mapping.pattern.pattern().equals(imagePattern));
Document.SEGMENT_TYPES.add(1,new Document.PatternMapping(imagePattern, ClientProxy::JEIorVariableSegment));
ManualAPI.addProvider(new DirectoryDefaultProvider(new ResourceLocation(Reference.MOD_ID, "docs/")));
ManualAPI.addTab(new ItemStackTabIconRenderer(new ItemStack(ModBlocks.CHUTE)),"bwm.manual.bwa", "%LANGUAGE%/bwa/index.md");
}

private static Segment JEIorVariableSegment(final Segment s, final Matcher m) {
Matcher varMatch = varPattern.matcher(m.group(2));
if(varMatch.matches()) {
return new VariableSegment(s,varMatch.group(1));
}

try {
final ImageRenderer renderer = ManualAPI.imageFor(m.group(2));
if (renderer != null) {
return new JEIRenderSegment(s, m.group(1), m.group(2), renderer);
} else {
return new JEISegment(s, "No renderer found for: " + m.group(2));
}
} catch (final Throwable t) {
return new JEISegment(s, Strings.isNullOrEmpty(t.toString()) ? "Unknown error." : t.toString(), m.group(2));
}
}

@Override
public void postInit() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,75 +5,45 @@
import betterwithmods.common.blocks.tile.SimpleStackHandler;
import betterwithmods.common.registry.HopperFilter;
import betterwithmods.common.registry.HopperInteractions.HopperRecipe;
import betterwithmods.util.InvUtils;
import betterwithmods.util.StackIngredient;
import com.google.common.collect.Lists;
import net.minecraft.block.state.IBlockState;
import net.minecraft.entity.item.EntityItem;
import net.minecraft.item.ItemStack;
import net.minecraft.item.crafting.Ingredient;
import net.minecraft.util.NonNullList;
import net.minecraft.util.math.BlockPos;
import net.minecraft.world.World;

import java.util.List;
import java.util.stream.Collectors;

public class HopperCratingRecipe extends HopperRecipe {
StackIngredient testIngredient;

public HopperCratingRecipe(Ingredient input, ItemStack output) {
super(HopperFilter.NONE.getName(), input, output);
testIngredient = StackIngredient.fromIngredient(7,input);
super(HopperFilter.NONE.getName(), StackIngredient.fromIngredient(8, input), output);
}

@Override
public List<ItemStack> getContainers() {
public List<ItemStack> getInputContainer() {
return Lists.newArrayList(new ItemStack(ModBlocks.BOX));
}

@Override
public List<ItemStack> getInputs() {
return super.getInputs().stream().map(stack -> {
ItemStack newStack = stack.copy();
newStack.setCount(8);
return newStack;
}).collect(Collectors.toList());
}

public boolean isCrate(IBlockState state)
{
public boolean isCrate(IBlockState state) {
return state.getBlock() == ModBlocks.BOX;
}

@Override
public boolean canCraft(World world, BlockPos pos) {
IBlockState crateState = world.getBlockState(pos.down());
TileEntityFilteredHopper tile = (TileEntityFilteredHopper)world.getTileEntity(pos);
SimpleStackHandler inventory = tile.inventory;
if(!isCrate(crateState)) {
if (!isCrate(crateState)) {
return false;
}
return InvUtils.consumeItemsInInventory(inventory, testIngredient, true, NonNullList.create());
return super.canCraft(world, pos);
}

@Override
public void craft(EntityItem entity, World world, BlockPos pos) {
TileEntityFilteredHopper tile = (TileEntityFilteredHopper)world.getTileEntity(pos);
SimpleStackHandler inventory = tile.inventory;
if(!InvUtils.consumeItemsInInventory(inventory, entity.getItem(), 7, false)) {
return;
}

InvUtils.ejectStackWithOffset(world, pos.down(1), secondaryOutputs);

this.onCraft(world, pos, entity);
}

@Override
public void onCraft(World world, BlockPos pos, EntityItem item) {
public void onCraft(World world, BlockPos pos, EntityItem item, TileEntityFilteredHopper tile) {
world.setBlockToAir(pos.down());

super.onCraft(world, pos, item);
super.onCraft(world, pos, item, tile);
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -234,7 +234,7 @@ public void init() {
String[] dyeOredictTags = new String[]{"White", "Orange", "Magenta", "LightBlue", "Yellow", "Lime", "Pink", "Gray", "LightGray", "Cyan", "Purple", "Blue", "Brown", "Green", "Red", "Black"};

if (HARDCORE_SHEARING) {
BlockBDispenser.ENTITY_COLLECT_REGISTRY.putObject(EntitySheep.class, (world, pos, entity, itemStack) -> {
BlockBDispenser.ENTITY_COLLECT_REGISTRY.putObject(new ResourceLocation("sheep"), (world, pos, entity, itemStack) -> {
EntitySheep sheep = (EntitySheep) entity;
if (sheep.isShearable(new ItemStack(Items.SHEARS), world, pos)) {
return convertShearedWool(sheep.onSheared(new ItemStack(Items.SHEARS), world, pos, 0));
Expand Down

0 comments on commit e946bda

Please sign in to comment.