mirror of
https://github.com/GTNewHorizons/Mantle.git
synced 2026-11-22 12:59:49 +00:00
Move Tinker's Construct register wood objects to Mantle for use in other mods.
This commit is contained in:
1 parent
a13d1046d2
commit
983c21184d
7 files changed
+291
No files matched your search
@@ -0,0 +1,28 @@
|
||||
package slimeknights.mantle.block;
|
||||
|
||||
import net.minecraft.block.Block;
|
||||
import net.minecraft.block.BlockState;
|
||||
import net.minecraft.block.RotatedPillarBlock;
|
||||
import net.minecraft.entity.player.PlayerEntity;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.util.math.BlockPos;
|
||||
import net.minecraft.world.World;
|
||||
import net.minecraftforge.common.ToolType;
|
||||
|
||||
import javax.annotation.Nullable;
|
||||
import java.util.function.Supplier;
|
||||
|
||||
/** Log block that can be stripped */
|
||||
public class StrippableLogBlock extends RotatedPillarBlock {
|
||||
private final Supplier<? extends Block> stripped;
|
||||
public StrippableLogBlock(Supplier<? extends Block> stripped, Properties properties) {
|
||||
super(properties);
|
||||
this.stripped = stripped;
|
||||
}
|
||||
|
||||
@Nullable
|
||||
@Override
|
||||
public BlockState getToolModifiedState(BlockState state, World world, BlockPos pos, PlayerEntity player, ItemStack stack, ToolType toolType) {
|
||||
return stripped.get().getDefaultState().with(AXIS, state.get(AXIS));
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,22 @@
|
||||
package slimeknights.mantle.block;
|
||||
|
||||
import net.minecraft.block.BlockState;
|
||||
import net.minecraft.block.DoorBlock;
|
||||
import net.minecraft.entity.MobEntity;
|
||||
import net.minecraft.pathfinding.PathNodeType;
|
||||
import net.minecraft.util.math.BlockPos;
|
||||
import net.minecraft.world.IBlockReader;
|
||||
|
||||
import javax.annotation.Nullable;
|
||||
|
||||
public class WoodenDoorBlock extends DoorBlock {
|
||||
public WoodenDoorBlock(Properties builder) {
|
||||
super(builder);
|
||||
}
|
||||
|
||||
@Nullable
|
||||
@Override
|
||||
public PathNodeType getAiPathNodeType(BlockState state, IBlockReader world, BlockPos pos, @Nullable MobEntity entity) {
|
||||
return state.get(OPEN) ? PathNodeType.DOOR_OPEN : PathNodeType.DOOR_WOOD_CLOSED;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,18 @@
|
||||
package slimeknights.mantle.item;
|
||||
|
||||
import net.minecraft.block.Block;
|
||||
import net.minecraft.item.BlockItem;
|
||||
import net.minecraft.item.ItemStack;
|
||||
|
||||
public class BurnableBlockItem extends BlockItem {
|
||||
private final int burnTime;
|
||||
public BurnableBlockItem(Block blockIn, Properties builder, int burnTime) {
|
||||
super(blockIn, builder);
|
||||
this.burnTime = burnTime;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getBurnTime(ItemStack itemStack) {
|
||||
return burnTime;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,18 @@
|
||||
package slimeknights.mantle.item;
|
||||
|
||||
import net.minecraft.block.Block;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.item.TallBlockItem;
|
||||
|
||||
public class BurnableTallBlockItem extends TallBlockItem {
|
||||
private final int burnTime;
|
||||
public BurnableTallBlockItem(Block blockIn, Properties builder, int burnTime) {
|
||||
super(blockIn, builder);
|
||||
this.burnTime = burnTime;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getBurnTime(ItemStack itemStack) {
|
||||
return burnTime;
|
||||
}
|
||||
}
|
||||
@@ -2,22 +2,41 @@ package slimeknights.mantle.registration.deferred;
|
||||
|
||||
import net.minecraft.block.AbstractBlock;
|
||||
import net.minecraft.block.Block;
|
||||
import net.minecraft.block.Blocks;
|
||||
import net.minecraft.block.DoorBlock;
|
||||
import net.minecraft.block.FenceBlock;
|
||||
import net.minecraft.block.FenceGateBlock;
|
||||
import net.minecraft.block.PressurePlateBlock;
|
||||
import net.minecraft.block.RotatedPillarBlock;
|
||||
import net.minecraft.block.SlabBlock;
|
||||
import net.minecraft.block.SoundType;
|
||||
import net.minecraft.block.StairsBlock;
|
||||
import net.minecraft.block.TrapDoorBlock;
|
||||
import net.minecraft.block.WallBlock;
|
||||
import net.minecraft.block.WoodButtonBlock;
|
||||
import net.minecraft.block.material.Material;
|
||||
import net.minecraft.block.material.MaterialColor;
|
||||
import net.minecraft.item.BlockItem;
|
||||
import net.minecraft.item.Item;
|
||||
import net.minecraft.item.ItemGroup;
|
||||
import net.minecraft.item.TallBlockItem;
|
||||
import net.minecraft.util.Direction;
|
||||
import net.minecraft.util.IStringSerializable;
|
||||
import net.minecraftforge.common.ToolType;
|
||||
import net.minecraftforge.eventbus.api.IEventBus;
|
||||
import net.minecraftforge.fml.RegistryObject;
|
||||
import net.minecraftforge.registries.DeferredRegister;
|
||||
import net.minecraftforge.registries.ForgeRegistries;
|
||||
import slimeknights.mantle.block.StrippableLogBlock;
|
||||
import slimeknights.mantle.block.WoodenDoorBlock;
|
||||
import slimeknights.mantle.item.BurnableBlockItem;
|
||||
import slimeknights.mantle.item.BurnableTallBlockItem;
|
||||
import slimeknights.mantle.registration.object.BuildingBlockObject;
|
||||
import slimeknights.mantle.registration.object.EnumObject;
|
||||
import slimeknights.mantle.registration.object.FenceBuildingBlockObject;
|
||||
import slimeknights.mantle.registration.object.ItemObject;
|
||||
import slimeknights.mantle.registration.object.WallBuildingBlockObject;
|
||||
import slimeknights.mantle.registration.object.WoodBlockObject;
|
||||
|
||||
import java.util.function.Function;
|
||||
import java.util.function.Supplier;
|
||||
@@ -176,6 +195,61 @@ public class BlockDeferredRegister extends DeferredRegisterWrapper<Block> {
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* Registers everything needed to make a new wood type, including a wood type
|
||||
* @param name Wood name
|
||||
* @param planksColor Color of the planks
|
||||
* @param barkColor Bark color
|
||||
* @param plankSound Sound for the wood
|
||||
* @param group Item group for the wood
|
||||
* @return Wood object
|
||||
*/
|
||||
public WoodBlockObject registerWood(String name, Material planksMaterial, MaterialColor planksColor, SoundType plankSound, ToolType planksTool, Material barkMaterial, MaterialColor barkColor, SoundType barkSound, ItemGroup group) {
|
||||
//WoodType woodType = WoodType.create(resourceName(name));
|
||||
Item.Properties itemProps = new Item.Properties().group(group);
|
||||
|
||||
// many of these are already burnable via tags, but simplier to set them all here
|
||||
Function<Integer, Function<? super Block, ? extends BlockItem>> burnableItem;
|
||||
Function<Integer, Function<? super Block, ? extends BlockItem>> burnableTallItem;
|
||||
if (barkMaterial.isFlammable()) {
|
||||
burnableItem = burnTime -> block -> new BurnableBlockItem(block, itemProps, burnTime);
|
||||
burnableTallItem = burnTime -> block -> new BurnableTallBlockItem(block, itemProps, burnTime);
|
||||
} else {
|
||||
Function<? super Block, ? extends BlockItem> defaultItemBlock = block -> new BlockItem(block, itemProps);
|
||||
burnableItem = burnTime -> defaultItemBlock;
|
||||
burnableTallItem = burnTime -> block -> new TallBlockItem(block, itemProps);
|
||||
}
|
||||
|
||||
// planks
|
||||
Function<? super Block, ? extends BlockItem> burnable300 = burnableItem.apply(300);
|
||||
AbstractBlock.Properties planksProps = AbstractBlock.Properties.create(planksMaterial, planksColor).harvestTool(planksTool).hardnessAndResistance(2.0f, 3.0f).sound(plankSound);
|
||||
BuildingBlockObject planks = registerBuilding(name + "_planks", planksProps, burnable300);
|
||||
ItemObject<FenceBlock> fence = register(name + "_fence", () -> new FenceBlock(AbstractBlock.Properties.from(planks.get())), burnable300);
|
||||
// logs and wood
|
||||
Supplier<? extends RotatedPillarBlock> stripped = () -> new RotatedPillarBlock(AbstractBlock.Properties.create(planksMaterial, planksColor).harvestTool(planksTool).hardnessAndResistance(2.0f).sound(plankSound));
|
||||
ItemObject<RotatedPillarBlock> strippedLog = register("stripped_" + name + "_log", stripped, burnable300);
|
||||
ItemObject<RotatedPillarBlock> strippedWood = register("stripped_" + name + "_wood", stripped, burnable300);
|
||||
ItemObject<RotatedPillarBlock> log = register(name + "_log", () -> new StrippableLogBlock(strippedLog,
|
||||
AbstractBlock.Properties.create(barkMaterial, state -> state.get(RotatedPillarBlock.AXIS) == Direction.Axis.Y ? planksColor : barkColor)
|
||||
.harvestTool(ToolType.AXE).hardnessAndResistance(2.0f).sound(barkSound)), burnable300);
|
||||
ItemObject<RotatedPillarBlock> wood = register(name + "_wood", () -> new StrippableLogBlock(strippedWood, AbstractBlock.Properties.create(barkMaterial, barkColor).harvestTool(ToolType.AXE).hardnessAndResistance(2.0f).sound(barkSound)), burnable300);
|
||||
|
||||
// doors
|
||||
ItemObject<DoorBlock> door = register(name + "_door", () -> new WoodenDoorBlock(AbstractBlock.Properties.create(planksMaterial, planksColor).harvestTool(planksTool).hardnessAndResistance(3.0F).sound(plankSound).notSolid()), burnableTallItem.apply(200));
|
||||
ItemObject<TrapDoorBlock> trapdoor = register(name + "_trapdoor", () -> new TrapDoorBlock(AbstractBlock.Properties.create(planksMaterial, planksColor).harvestTool(planksTool).hardnessAndResistance(3.0F).sound(SoundType.WOOD).notSolid().setAllowsSpawn(Blocks::neverAllowSpawn)), burnable300);
|
||||
ItemObject<FenceGateBlock> fenceGate = register(name + "_fence_gate", () -> new FenceGateBlock(planksProps), burnable300);
|
||||
// redstone
|
||||
AbstractBlock.Properties redstoneProps = AbstractBlock.Properties.create(planksMaterial, planksColor).harvestTool(planksTool).doesNotBlockMovement().hardnessAndResistance(0.5F).sound(plankSound);
|
||||
ItemObject<PressurePlateBlock> pressurePlate = register(name + "_pressure_plate", () -> new PressurePlateBlock(PressurePlateBlock.Sensitivity.EVERYTHING, redstoneProps), burnable300);
|
||||
ItemObject<WoodButtonBlock> button = register(name + "_button", () -> new WoodButtonBlock(redstoneProps), burnableItem.apply(100));
|
||||
// signs
|
||||
//RegistryObject<StandingSignBlock> standingSign = registerNoItem(name + "_sign", () -> new StandingSignBlock(AbstractBlock.Properties.create(material, planksColor).doesNotBlockMovement().hardnessAndResistance(1.0F).sound(sound), woodType));
|
||||
//RegistryObject<WallSignBlock> wallSign = registerNoItem(name + "_wall_sign", () -> new WallSignBlock(AbstractBlock.Properties.create(material, planksColor).doesNotBlockMovement().hardnessAndResistance(1.0F).sound(sound).lootFrom(standingSign), woodType));
|
||||
//RegistryObject<SignItem> signItem = this.itemRegister.register(name + "_sign", () -> new SignItem(new Item.Properties().maxStackSize(16).group(group), standingSign.get(), wallSign.get()));
|
||||
// finally, return
|
||||
return new WoodBlockObject(resource(name), /*woodType,*/ planks, log, strippedLog, wood, strippedWood, fence, fenceGate, door, trapdoor, pressurePlate, button/*, standingSign, wallSign*/);
|
||||
}
|
||||
|
||||
/**
|
||||
* Registers an item with multiple variants, prefixing the name with the value name
|
||||
* @param values Enum values to use for this block
|
||||
|
||||
@@ -0,0 +1,128 @@
|
||||
package slimeknights.mantle.registration.object;
|
||||
|
||||
import lombok.Getter;
|
||||
import net.minecraft.block.Block;
|
||||
import net.minecraft.block.DoorBlock;
|
||||
import net.minecraft.block.FenceBlock;
|
||||
import net.minecraft.block.FenceGateBlock;
|
||||
import net.minecraft.block.PressurePlateBlock;
|
||||
import net.minecraft.block.TrapDoorBlock;
|
||||
import net.minecraft.block.WoodButtonBlock;
|
||||
import net.minecraft.item.Item;
|
||||
import net.minecraft.tags.BlockTags;
|
||||
import net.minecraft.tags.ItemTags;
|
||||
import net.minecraft.util.ResourceLocation;
|
||||
import net.minecraftforge.common.Tags.IOptionalNamedTag;
|
||||
|
||||
import java.util.function.Supplier;
|
||||
|
||||
/** Extension of the fence object with all other wood blocks */
|
||||
@SuppressWarnings("unused")
|
||||
public class WoodBlockObject extends FenceBuildingBlockObject {
|
||||
//@Getter
|
||||
//private final WoodType woodType;
|
||||
// basic
|
||||
private final Supplier<? extends Block> log;
|
||||
private final Supplier<? extends Block> strippedLog;
|
||||
private final Supplier<? extends Block> wood;
|
||||
private final Supplier<? extends Block> strippedWood;
|
||||
// doors
|
||||
private final Supplier<? extends FenceGateBlock> fenceGate;
|
||||
private final Supplier<? extends DoorBlock> door;
|
||||
private final Supplier<? extends TrapDoorBlock> trapdoor;
|
||||
// redstone
|
||||
private final Supplier<? extends PressurePlateBlock> pressurePlate;
|
||||
private final Supplier<? extends WoodButtonBlock> button;
|
||||
// signs
|
||||
//private final Supplier<? extends StandingSignBlock> sign;
|
||||
//private final Supplier<? extends WallSignBlock> wallSign;
|
||||
// tags
|
||||
@Getter
|
||||
private final IOptionalNamedTag<Block> logBlockTag;
|
||||
@Getter
|
||||
private final IOptionalNamedTag<Item> logItemTag;
|
||||
|
||||
public WoodBlockObject(ResourceLocation name, /*WoodType woodType,*/ BuildingBlockObject planks,
|
||||
Supplier<? extends Block> log, Supplier<? extends Block> strippedLog, Supplier<? extends Block> wood, Supplier<? extends Block> strippedWood,
|
||||
Supplier<? extends FenceBlock> fence, Supplier<? extends FenceGateBlock> fenceGate, Supplier<? extends DoorBlock> door, Supplier<? extends TrapDoorBlock> trapdoor,
|
||||
Supplier<? extends PressurePlateBlock> pressurePlate, Supplier<? extends WoodButtonBlock> button/*,
|
||||
Supplier<? extends StandingSignBlock> sign, Supplier<? extends WallSignBlock> wallSign*/) {
|
||||
super(planks, fence);
|
||||
//this.woodType = woodType;
|
||||
this.log = log;
|
||||
this.strippedLog = strippedLog;
|
||||
this.wood = wood;
|
||||
this.strippedWood = strippedWood;
|
||||
this.fenceGate = fenceGate;
|
||||
this.door = door;
|
||||
this.trapdoor = trapdoor;
|
||||
this.pressurePlate = pressurePlate;
|
||||
this.button = button;
|
||||
//this.sign = sign;
|
||||
//this.wallSign = wallSign;
|
||||
ResourceLocation tagName = new ResourceLocation(name.getNamespace(), name.getPath() + "_logs");
|
||||
this.logBlockTag = BlockTags.createOptional(tagName);
|
||||
this.logItemTag = ItemTags.createOptional(tagName);
|
||||
}
|
||||
|
||||
/** Gets the log for this wood type */
|
||||
public Block getLog() {
|
||||
return log.get();
|
||||
}
|
||||
|
||||
/** Gets the stripped log for this wood type */
|
||||
public Block getStrippedLog() {
|
||||
return strippedLog.get();
|
||||
}
|
||||
|
||||
/** Gets the wood for this wood type */
|
||||
public Block getWood() {
|
||||
return wood.get();
|
||||
}
|
||||
|
||||
/** Gets the stripped wood for this wood type */
|
||||
public Block getStrippedWood() {
|
||||
return strippedWood.get();
|
||||
}
|
||||
|
||||
/* Doors */
|
||||
|
||||
/** Gets the fence gate for this wood type */
|
||||
public FenceGateBlock getFenceGate() {
|
||||
return fenceGate.get();
|
||||
}
|
||||
|
||||
/** Gets the door for this wood type */
|
||||
public DoorBlock getDoor() {
|
||||
return door.get();
|
||||
}
|
||||
|
||||
/** Gets the trapdoor for this wood type */
|
||||
public TrapDoorBlock getTrapdoor() {
|
||||
return trapdoor.get();
|
||||
}
|
||||
|
||||
/* Redstone */
|
||||
|
||||
/** Gets the pressure plate for this wood type */
|
||||
public PressurePlateBlock getPressurePlate() {
|
||||
return pressurePlate.get();
|
||||
}
|
||||
|
||||
/** Gets the button for this wood type */
|
||||
public WoodButtonBlock getButton() {
|
||||
return button.get();
|
||||
}
|
||||
|
||||
/* Signs */
|
||||
|
||||
/* Gets the sign for this wood type, can also be used to get the item /
|
||||
public StandingSignBlock getSign() {
|
||||
return sign.get();
|
||||
}*/
|
||||
|
||||
/* Gets the wall sign for this wood type /
|
||||
public WallSignBlock getWallSign() {
|
||||
return wallSign.get();
|
||||
}*/
|
||||
}
|
||||
@@ -53,3 +53,6 @@ protected net.minecraft.util.IntReferenceHolder field_221498_a # lastKnownValue
|
||||
|
||||
# Fix hand swinging animations resetting cooldown
|
||||
public net.minecraft.entity.LivingEntity func_82166_i()I # getArmSwingAnimationEnd
|
||||
|
||||
# Block properties
|
||||
public net.minecraft.block.Blocks func_235427_a_(Lnet/minecraft/block/BlockState;Lnet/minecraft/world/IBlockReader;Lnet/minecraft/util/math/BlockPos;Lnet/minecraft/entity/EntityType;)Ljava/lang/Boolean; # neverAllowSpawn
|
||||
Reference in new issue
Block a user