Skip to content

Commit

Permalink
Add an inverted iron button, which needs to be pulled to activate
Browse files Browse the repository at this point in the history
  • Loading branch information
legobmw99 committed Jan 14, 2024
1 parent c75c716 commit ad2a8a6
Show file tree
Hide file tree
Showing 16 changed files with 265 additions and 9 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,118 @@
{
"variants": {
"face=ceiling,facing=east,powered=false": {
"model": "allomancy:block/iron_button_pressed",
"x": 180,
"y": 270
},
"face=ceiling,facing=east,powered=true": {
"model": "allomancy:block/iron_button",
"x": 180,
"y": 270
},
"face=ceiling,facing=north,powered=false": {
"model": "allomancy:block/iron_button_pressed",
"x": 180,
"y": 180
},
"face=ceiling,facing=north,powered=true": {
"model": "allomancy:block/iron_button",
"x": 180,
"y": 180
},
"face=ceiling,facing=south,powered=false": {
"model": "allomancy:block/iron_button_pressed",
"x": 180
},
"face=ceiling,facing=south,powered=true": {
"model": "allomancy:block/iron_button",
"x": 180
},
"face=ceiling,facing=west,powered=false": {
"model": "allomancy:block/iron_button_pressed",
"x": 180,
"y": 90
},
"face=ceiling,facing=west,powered=true": {
"model": "allomancy:block/iron_button",
"x": 180,
"y": 90
},
"face=floor,facing=east,powered=false": {
"model": "allomancy:block/iron_button_pressed",
"y": 90
},
"face=floor,facing=east,powered=true": {
"model": "allomancy:block/iron_button",
"y": 90
},
"face=floor,facing=north,powered=false": {
"model": "allomancy:block/iron_button_pressed"
},
"face=floor,facing=north,powered=true": {
"model": "allomancy:block/iron_button"
},
"face=floor,facing=south,powered=false": {
"model": "allomancy:block/iron_button_pressed",
"y": 180
},
"face=floor,facing=south,powered=true": {
"model": "allomancy:block/iron_button",
"y": 180
},
"face=floor,facing=west,powered=false": {
"model": "allomancy:block/iron_button_pressed",
"y": 270
},
"face=floor,facing=west,powered=true": {
"model": "allomancy:block/iron_button",
"y": 270
},
"face=wall,facing=east,powered=false": {
"model": "allomancy:block/iron_button_pressed",
"uvlock": true,
"x": 90,
"y": 90
},
"face=wall,facing=east,powered=true": {
"model": "allomancy:block/iron_button",
"uvlock": true,
"x": 90,
"y": 90
},
"face=wall,facing=north,powered=false": {
"model": "allomancy:block/iron_button_pressed",
"uvlock": true,
"x": 90
},
"face=wall,facing=north,powered=true": {
"model": "allomancy:block/iron_button",
"uvlock": true,
"x": 90
},
"face=wall,facing=south,powered=false": {
"model": "allomancy:block/iron_button_pressed",
"uvlock": true,
"x": 90,
"y": 180
},
"face=wall,facing=south,powered=true": {
"model": "allomancy:block/iron_button",
"uvlock": true,
"x": 90,
"y": 180
},
"face=wall,facing=west,powered=false": {
"model": "allomancy:block/iron_button_pressed",
"uvlock": true,
"x": 90,
"y": 270
},
"face=wall,facing=west,powered=true": {
"model": "allomancy:block/iron_button",
"uvlock": true,
"x": 90,
"y": 270
}
}
}
1 change: 1 addition & 0 deletions src/generated/resources/assets/allomancy/lang/en_us.json
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@
"block.allomancy.deepslate_zinc_ore": "Deepslate Zinc Ore",
"block.allomancy.duralumin_block": "Duralumin Block",
"block.allomancy.electrum_block": "Electrum Block",
"block.allomancy.inverted_iron_button": "Inverted Iron Button",
"block.allomancy.iron_activation.lore": "This item seems too heavy to activate by ordinary means",
"block.allomancy.iron_button": "Iron Button",
"block.allomancy.iron_lever": "Iron Lever",
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
{
"parent": "allomancy:block/iron_button_inventory"
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
{
"type": "minecraft:block",
"pools": [
{
"bonus_rolls": 0.0,
"entries": [
{
"type": "minecraft:item",
"name": "allomancy:inverted_iron_button"
}
],
"name": "inverted_iron_button",
"rolls": 1.0
}
],
"random_sequence": "allomancy:blocks/inverted_iron_button"
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
{
"parent": "minecraft:recipes/root",
"criteria": {
"has_iron_button": {
"conditions": {
"items": [
{
"items": [
"allomancy:iron_button"
]
}
]
},
"trigger": "minecraft:inventory_changed"
},
"has_the_recipe": {
"conditions": {
"recipe": "minecraft:inverted_from_iron_button"
},
"trigger": "minecraft:recipe_unlocked"
}
},
"requirements": [
[
"has_the_recipe",
"has_iron_button"
]
],
"rewards": {
"recipes": [
"minecraft:inverted_from_iron_button"
]
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
{
"parent": "minecraft:recipes/root",
"criteria": {
"has_inverted_iron_button": {
"conditions": {
"items": [
{
"items": [
"allomancy:inverted_iron_button"
]
}
]
},
"trigger": "minecraft:inventory_changed"
},
"has_the_recipe": {
"conditions": {
"recipe": "minecraft:iron_button_from_inverted"
},
"trigger": "minecraft:recipe_unlocked"
}
},
"requirements": [
[
"has_the_recipe",
"has_inverted_iron_button"
]
],
"rewards": {
"recipes": [
"minecraft:iron_button_from_inverted"
]
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
{
"type": "minecraft:crafting_shapeless",
"category": "redstone",
"ingredients": [
{
"item": "allomancy:iron_button"
}
],
"result": {
"item": "allomancy:inverted_iron_button"
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
{
"type": "minecraft:crafting_shapeless",
"category": "redstone",
"ingredients": [
{
"item": "allomancy:inverted_iron_button"
}
],
"result": {
"item": "allomancy:iron_button"
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -71,6 +71,7 @@ public void generate(BiConsumer<ResourceLocation, LootTable.Builder> writer) {
}

addSimpleBlock(writer, "iron_button", ExtrasSetup.IRON_BUTTON.get());
addSimpleBlock(writer, "inverted_iron_button", ExtrasSetup.INVERTED_IRON_BUTTON.get());
addSimpleBlock(writer, "iron_lever", ExtrasSetup.IRON_LEVER.get());

for (Supplier<Block> rblock : MaterialsSetup.STORAGE_BLOCKS) {
Expand Down
13 changes: 7 additions & 6 deletions src/main/java/com/legobmw99/allomancy/datagen/BlockStates.java
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,8 @@ protected void registerStatesAndModels() {
}

createIronLeverBlock();
createIronButtonBlock();
createIronButtonBlock(ExtrasSetup.IRON_BUTTON.get());
createIronButtonBlock(ExtrasSetup.INVERTED_IRON_BUTTON.get());

}

Expand All @@ -61,23 +62,23 @@ private void singleTextureBlock(Block block, String model, String texture) {
}


private void createIronButtonBlock() {
private void createIronButtonBlock(IronButtonBlock block) {
Allomancy.LOGGER.debug("Creating Block Data for allomancy:iron_button");
ModelFile inventory = models().withExistingParent("allomancy:iron_button_inventory", mcLoc("block/button_inventory")).texture("texture", mcLoc("block/iron_block"));
ModelFile button = models().withExistingParent("allomancy:iron_button", mcLoc("block/button")).texture("texture", mcLoc("block/iron_block"));
ModelFile pressed = models().withExistingParent("allomancy:iron_button_pressed", mcLoc("block/button_pressed")).texture("texture", mcLoc("block/iron_block"));

VariantBlockStateBuilder builder = getVariantBuilder(ExtrasSetup.IRON_BUTTON.get());

VariantBlockStateBuilder builder = getVariantBuilder(block);
for (Boolean powered : IronButtonBlock.POWERED.getPossibleValues()) {
ModelFile model = powered ? pressed : button;
ModelFile model = powered == block.activatedOnPush() ? pressed : button;
for (AttachFace face : IronButtonBlock.FACE.getPossibleValues()) {
int xangle = (face == AttachFace.CEILING) ? 180 : (face == AttachFace.WALL) ? 90 : 0;
boolean uvlock = face == AttachFace.WALL;
for (Direction dir : IronButtonBlock.FACING.getPossibleValues()) {
int yangle = (int) dir.toYRot();
yangle = face != AttachFace.CEILING ? (yangle + 180) % 360 : yangle;
builder
.partialState()
builder.partialState()
.with(IronButtonBlock.POWERED, powered)
.with(IronButtonBlock.FACE, face)
.with(IronButtonBlock.FACING, dir)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ public ItemModels(PackOutput generator, ExistingFileHelper existingFileHelper) {
@Override
protected void registerModels() {
parentedBlock(ExtrasSetup.IRON_BUTTON.get(), "block/iron_button_inventory");
parentedBlock(ExtrasSetup.INVERTED_IRON_BUTTON.get(), "block/iron_button_inventory");
itemGenerated(ExtrasSetup.IRON_LEVER_ITEM.get(), "block/iron_lever");

itemGenerated(CombatSetup.MISTCLOAK.get());
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,7 @@ protected void addTranslations() {
}

add(ExtrasSetup.IRON_BUTTON.get(), "Iron Button");
add(ExtrasSetup.INVERTED_IRON_BUTTON.get(), "Inverted Iron Button");
add(ExtrasSetup.IRON_LEVER.get(), "Iron Lever");
add("block.allomancy.iron_activation.lore", "This item seems too heavy to activate by ordinary means");

Expand Down
6 changes: 6 additions & 0 deletions src/main/java/com/legobmw99/allomancy/datagen/Recipes.java
Original file line number Diff line number Diff line change
Expand Up @@ -133,6 +133,12 @@ protected void buildRecipes(RecipeOutput consumer) {
// Basic Shaped Recipes
buildShaped(consumer, RecipeCategory.REDSTONE, ExtrasSetup.IRON_LEVER.get(), Items.IRON_INGOT, "s", "I");
buildShaped(consumer, RecipeCategory.REDSTONE, ExtrasSetup.IRON_BUTTON.get(), Items.IRON_INGOT, "i", "I");
buildShapeless(consumer, RecipeCategory.REDSTONE, ExtrasSetup.INVERTED_IRON_BUTTON.get(), 1, ExtrasSetup.IRON_BUTTON_ITEM.get(), "inverted_from_iron_button",
ing(ExtrasSetup.IRON_BUTTON.get()));
buildShapeless(consumer, RecipeCategory.REDSTONE, ExtrasSetup.IRON_BUTTON.get(), 1, ExtrasSetup.INVERTED_IRON_BUTTON_ITEM.get(), "iron_button_from_inverted",
ing(ExtrasSetup.INVERTED_IRON_BUTTON.get()));


buildShaped(consumer, RecipeCategory.FOOD, ConsumeSetup.ALLOMANTIC_GRINDER.get(), Items.IRON_INGOT, "ggg", "iii", "ggg");
buildShaped(consumer, RecipeCategory.FOOD, ConsumeSetup.VIAL.get(), 4, Items.GLASS, " S ", "G G", " G ");
buildShaped(consumer, RecipeCategory.COMBAT, CombatSetup.MISTCLOAK.get(), ConsumeSetup.VIAL.get(), "W W", "WWW", "WWW");
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,8 +31,13 @@ public class ExtrasSetup {
public static final DeferredRegister<BannerPattern> BP = DeferredRegister.create(Registries.BANNER_PATTERN, Allomancy.MODID);


public static final DeferredBlock<IronButtonBlock> IRON_BUTTON = BLOCKS.register("iron_button", IronButtonBlock::new);
public static final DeferredBlock<IronButtonBlock> IRON_BUTTON = BLOCKS.register("iron_button", () -> new IronButtonBlock(true));

public static final DeferredItem<Item> IRON_BUTTON_ITEM = ITEMS.register("iron_button", () -> new BlockItem(IRON_BUTTON.get(), new Item.Properties()));
public static final DeferredBlock<IronButtonBlock> INVERTED_IRON_BUTTON = BLOCKS.register("inverted_iron_button", () -> new IronButtonBlock(false));

public static final DeferredItem<Item> INVERTED_IRON_BUTTON_ITEM = ITEMS.register("inverted_iron_button",
() -> new BlockItem(INVERTED_IRON_BUTTON.get(), new Item.Properties()));
public static final DeferredBlock<IronLeverBlock> IRON_LEVER = BLOCKS.register("iron_lever", IronLeverBlock::new);
public static final DeferredItem<Item> IRON_LEVER_ITEM = ITEMS.register("iron_lever", () -> new BlockItem(IRON_LEVER.get(), new Item.Properties()));

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,8 +26,12 @@

public class IronButtonBlock extends ButtonBlock implements IAllomanticallyUsableBlock {

public IronButtonBlock() {

private final boolean activatedOnPush;

public IronButtonBlock(boolean activatedOnPush) {
super(BlockSetType.IRON, 35, Block.Properties.of().noCollission().strength(1.0F));
this.activatedOnPush = activatedOnPush;
}

@Override
Expand All @@ -38,14 +42,18 @@ public boolean useAllomantically(BlockState state, Level level, BlockPos pos, Pl

if (state.getValue(POWERED) || level.isClientSide) {
return true;
} else if (isPush) {
} else if (isPush == this.activatedOnPush) {
this.press(state, level, pos);
return true;
} else {
return false;
}
}

public boolean activatedOnPush() {
return this.activatedOnPush;
}

@Override
public InteractionResult use(BlockState state, Level worldIn, BlockPos pos, Player player, InteractionHand handIn, BlockHitResult hit) {
return InteractionResult.FAIL;
Expand Down
2 changes: 2 additions & 0 deletions src/main/java/com/legobmw99/allomancy/util/ItemDisplay.java
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,7 @@ public class ItemDisplay {

output.accept(ExtrasSetup.IRON_LEVER.get());
output.accept(ExtrasSetup.IRON_BUTTON.get());
output.accept(ExtrasSetup.INVERTED_IRON_BUTTON.get());


for (var block : MaterialsSetup.STORAGE_BLOCKS) {
Expand Down Expand Up @@ -113,6 +114,7 @@ public static void addTabContents(BuildCreativeModeTabContentsEvent event) {
} else if (event.getTabKey() == CreativeModeTabs.REDSTONE_BLOCKS) {
event.accept(ExtrasSetup.IRON_LEVER);
event.accept(ExtrasSetup.IRON_BUTTON);
event.accept(ExtrasSetup.INVERTED_IRON_BUTTON);
}
}

Expand Down

0 comments on commit ad2a8a6

Please sign in to comment.