Compare commits

..

27 Commits

Author SHA1 Message Date
Justi b266c561f1 Initial Release code 2021-10-27 23:31:08 -04:00
Justi b44c9abf8e first attempt to overwrite loottables 2021-10-25 00:31:25 -04:00
Justi 273de51797 addition of standard recipes 2021-10-24 22:51:17 -04:00
Justi 5a3510873b disallow disable brewing reccipe, added firestar 2021-10-24 22:37:06 -04:00
Justi 8aa8895c52 minor refactoring 2021-10-24 21:21:27 -04:00
Justi 9fc1ea35e8 reccipe fix 2021-10-24 20:42:06 -04:00
Justi f6af1add93 Addition of dynamic recipe additions 2021-10-24 20:23:33 -04:00
Justi 5d10610a1d addition of cloth config, removal of fiber 2021-10-24 19:14:06 -04:00
Justi 0ab7da3ff0 beginning of fiber config 2021-10-24 17:53:06 -04:00
Justi 047a7f3e72 addition of textures and lang 2021-10-23 23:21:02 -04:00
Justi 1ea3ac0c13 Modifications of id handling, add itemgroup 2021-10-23 21:52:14 -04:00
Justi 9c8b7ab315 Fixed hitboxes, fixed connection issues 2021-10-22 03:16:09 -04:00
Justi 833d815fd2 ref previous commit 2021-10-18 21:55:21 -04:00
Justi 9d187ec8ed sorta fix for up/down not connecting issue 2021-10-18 21:55:01 -04:00
Justi 855ec86383 textures work now lol 2021-05-07 15:05:20 -04:00
Justi 6beb4911ac voxel 2021-05-04 19:02:16 -04:00
Justi ead8d12c6e Working wireconnection w/ expected functionality 2021-04-30 19:17:05 -04:00
Justi cbfce1a065 implement custom property 2021-04-30 15:01:40 -04:00
Justi e12051bc8c change 2021-04-30 10:45:10 -04:00
Justi 282da8d903 Made wire connections work 2021-04-30 10:20:31 -04:00
Justi bafe5feca3 attempt to get lines to work 2021-04-29 09:52:08 -04:00
Justi 4360b0381a refactor 2021-04-27 21:34:27 -04:00
Justi 46e19769be did some stuff iunno 2021-04-27 21:34:20 -04:00
Justi a38a20d523 license and readme update 2021-04-27 19:38:14 -04:00
Justi a4a9a1f76d refactor 2021-04-27 19:33:47 -04:00
Justi ca452cbff9 refactoring 2021-04-27 19:33:33 -04:00
Justi 107c336d43 Delete '.project' 2021-04-27 19:23:20 -04:00
48 changed files with 828 additions and 429 deletions
-28
View File
@@ -1,28 +0,0 @@
<?xml version="1.0" encoding="UTF-8"?>
<projectDescription>
<name>GlowstoneDust</name>
<comment>Project GlowstoneDust created by Buildship.</comment>
<projects>
</projects>
<buildSpec>
<buildCommand>
<name>org.eclipse.buildship.core.gradleprojectbuilder</name>
<arguments>
</arguments>
</buildCommand>
</buildSpec>
<natures>
<nature>org.eclipse.buildship.core.gradleprojectnature</nature>
</natures>
<filteredResources>
<filter>
<id>1619529879268</id>
<name></name>
<type>30</type>
<matcher>
<id>org.eclipse.core.resources.regexFilterMatcher</id>
<arguments>node_modules|.git|__CREATED_BY_JAVA_LANGUAGE_SERVER__</arguments>
</matcher>
</filter>
</filteredResources>
</projectDescription>
+4 -118
View File
@@ -1,121 +1,7 @@
Creative Commons Legal Code
Copyright 2021 Justin (Alias: Ganku, Badjman)
CC0 1.0 Universal
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
CREATIVE COMMONS CORPORATION IS NOT A LAW FIRM AND DOES NOT PROVIDE
LEGAL SERVICES. DISTRIBUTION OF THIS DOCUMENT DOES NOT CREATE AN
ATTORNEY-CLIENT RELATIONSHIP. CREATIVE COMMONS PROVIDES THIS
INFORMATION ON AN "AS-IS" BASIS. CREATIVE COMMONS MAKES NO WARRANTIES
REGARDING THE USE OF THIS DOCUMENT OR THE INFORMATION OR WORKS
PROVIDED HEREUNDER, AND DISCLAIMS LIABILITY FOR DAMAGES RESULTING FROM
THE USE OF THIS DOCUMENT OR THE INFORMATION OR WORKS PROVIDED
HEREUNDER.
The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
Statement of Purpose
The laws of most jurisdictions throughout the world automatically confer
exclusive Copyright and Related Rights (defined below) upon the creator
and subsequent owner(s) (each and all, an "owner") of an original work of
authorship and/or a database (each, a "Work").
Certain owners wish to permanently relinquish those rights to a Work for
the purpose of contributing to a commons of creative, cultural and
scientific works ("Commons") that the public can reliably and without fear
of later claims of infringement build upon, modify, incorporate in other
works, reuse and redistribute as freely as possible in any form whatsoever
and for any purposes, including without limitation commercial purposes.
These owners may contribute to the Commons to promote the ideal of a free
culture and the further production of creative, cultural and scientific
works, or to gain reputation or greater distribution for their Work in
part through the use and efforts of others.
For these and/or other purposes and motivations, and without any
expectation of additional consideration or compensation, the person
associating CC0 with a Work (the "Affirmer"), to the extent that he or she
is an owner of Copyright and Related Rights in the Work, voluntarily
elects to apply CC0 to the Work and publicly distribute the Work under its
terms, with knowledge of his or her Copyright and Related Rights in the
Work and the meaning and intended legal effect of CC0 on those rights.
1. Copyright and Related Rights. A Work made available under CC0 may be
protected by copyright and related or neighboring rights ("Copyright and
Related Rights"). Copyright and Related Rights include, but are not
limited to, the following:
i. the right to reproduce, adapt, distribute, perform, display,
communicate, and translate a Work;
ii. moral rights retained by the original author(s) and/or performer(s);
iii. publicity and privacy rights pertaining to a person's image or
likeness depicted in a Work;
iv. rights protecting against unfair competition in regards to a Work,
subject to the limitations in paragraph 4(a), below;
v. rights protecting the extraction, dissemination, use and reuse of data
in a Work;
vi. database rights (such as those arising under Directive 96/9/EC of the
European Parliament and of the Council of 11 March 1996 on the legal
protection of databases, and under any national implementation
thereof, including any amended or successor version of such
directive); and
vii. other similar, equivalent or corresponding rights throughout the
world based on applicable law or treaty, and any national
implementations thereof.
2. Waiver. To the greatest extent permitted by, but not in contravention
of, applicable law, Affirmer hereby overtly, fully, permanently,
irrevocably and unconditionally waives, abandons, and surrenders all of
Affirmer's Copyright and Related Rights and associated claims and causes
of action, whether now known or unknown (including existing as well as
future claims and causes of action), in the Work (i) in all territories
worldwide, (ii) for the maximum duration provided by applicable law or
treaty (including future time extensions), (iii) in any current or future
medium and for any number of copies, and (iv) for any purpose whatsoever,
including without limitation commercial, advertising or promotional
purposes (the "Waiver"). Affirmer makes the Waiver for the benefit of each
member of the public at large and to the detriment of Affirmer's heirs and
successors, fully intending that such Waiver shall not be subject to
revocation, rescission, cancellation, termination, or any other legal or
equitable action to disrupt the quiet enjoyment of the Work by the public
as contemplated by Affirmer's express Statement of Purpose.
3. Public License Fallback. Should any part of the Waiver for any reason
be judged legally invalid or ineffective under applicable law, then the
Waiver shall be preserved to the maximum extent permitted taking into
account Affirmer's express Statement of Purpose. In addition, to the
extent the Waiver is so judged Affirmer hereby grants to each affected
person a royalty-free, non transferable, non sublicensable, non exclusive,
irrevocable and unconditional license to exercise Affirmer's Copyright and
Related Rights in the Work (i) in all territories worldwide, (ii) for the
maximum duration provided by applicable law or treaty (including future
time extensions), (iii) in any current or future medium and for any number
of copies, and (iv) for any purpose whatsoever, including without
limitation commercial, advertising or promotional purposes (the
"License"). The License shall be deemed effective as of the date CC0 was
applied by Affirmer to the Work. Should any part of the License for any
reason be judged legally invalid or ineffective under applicable law, such
partial invalidity or ineffectiveness shall not invalidate the remainder
of the License, and in such case Affirmer hereby affirms that he or she
will not (i) exercise any of his or her remaining Copyright and Related
Rights in the Work or (ii) assert any associated claims and causes of
action with respect to the Work, in either case contrary to Affirmer's
express Statement of Purpose.
4. Limitations and Disclaimers.
a. No trademark or patent rights held by Affirmer are waived, abandoned,
surrendered, licensed or otherwise affected by this document.
b. Affirmer offers the Work as-is and makes no representations or
warranties of any kind concerning the Work, express, implied,
statutory or otherwise, including without limitation warranties of
title, merchantability, fitness for a particular purpose, non
infringement, or the absence of latent or other defects, accuracy, or
the present or absence of errors, whether or not discoverable, all to
the greatest extent permissible under applicable law.
c. Affirmer disclaims responsibility for clearing rights of other persons
that may apply to the Work or any use thereof, including without
limitation any person's Copyright and Related Rights in the Work.
Further, Affirmer disclaims responsibility for obtaining any necessary
consents, permissions or other rights required for any use of the
Work.
d. Affirmer understands and acknowledges that Creative Commons is not a
party to this document and has no duty or obligation with respect to
this CC0 or use of the Work.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+5 -7
View File
@@ -1,9 +1,7 @@
# Fabric Example Mod
# Glowstone Wire
## Setup
Adds redstone-like dust for glowstone.
- Emit's light level 8 (Perfect for 2-wide path ways)
- Can be customized to look a little more stylized
For setup instructions please see the [fabric wiki page](https://fabricmc.net/wiki/tutorial:setup) that relates to the IDE that you are using.
## License
This template is available under the CC0 license. Feel free to learn from it and incorporate it in your own projects.
10/10, great mod.
+6
View File
@@ -16,6 +16,7 @@ repositories {
// Loom adds the essential maven repositories to download Minecraft and libraries from automatically.
// See https://docs.gradle.org/current/userguide/declaring_repositories.html
// for more information about repositories.
maven{url "https://maven.shedaniel.me/"}
}
dependencies {
@@ -27,6 +28,11 @@ dependencies {
// Fabric API. This is technically optional, but you probably want it anyway.
modImplementation "net.fabricmc.fabric-api:fabric-api:${project.fabric_version}"
// Custom API's
modApi ("me.shedaniel.cloth:cloth-config-fabric:4.11.26") {
exclude(group: "net.fabricmc.fabric-api")
}
// PSA: Some older mods, compiled on Loom 0.2.1, might have outdated Maven POMs.
// You may need to force-disable transitiveness on them.
}
+2 -2
View File
@@ -8,9 +8,9 @@ org.gradle.jvmargs=-Xmx1G
loader_version=0.11.3
# Mod Properties
mod_version = 0.0.1
mod_version = 1.0.0
maven_group = me.parsell
archives_base_name = glowstonedust
archives_base_name = glowstonewire
# Dependencies
# currently not on the main fabric site, check on the maven: https://maven.fabricmc.net/net/fabricmc/fabric-api/fabric-api
@@ -1,18 +0,0 @@
package me.parsell.glowstonedust;
import me.parsell.glowstonedust.core.glowBlocks;
import me.parsell.glowstonedust.core.glowItems;
import net.fabricmc.api.ModInitializer;
public class GlowstoneDust implements ModInitializer {
@Override
public void onInitialize() {
// This code runs as soon as Minecraft is in a mod-load-ready state.
// However, some things (like resources) may still be uninitialized.
// Proceed with mild caution.
System.out.println("Hello Fabric world!");
glowBlocks.init();
glowItems.init();
}
}
@@ -1,146 +0,0 @@
package me.parsell.glowstonedust.common;
import java.util.Map;
import com.google.common.collect.ImmutableMap;
import com.google.common.collect.Maps;
import net.minecraft.block.Block;
import net.minecraft.block.BlockState;
import net.minecraft.block.ShapeContext;
import net.minecraft.block.enums.WireConnection;
import net.minecraft.entity.player.PlayerEntity;
import net.minecraft.item.ItemPlacementContext;
import net.minecraft.state.StateManager;
import net.minecraft.state.property.EnumProperty;
import net.minecraft.state.property.Properties;
import net.minecraft.util.ActionResult;
import net.minecraft.util.BlockMirror;
import net.minecraft.util.BlockRotation;
import net.minecraft.util.Hand;
import net.minecraft.util.hit.BlockHitResult;
import net.minecraft.util.math.BlockPos;
import net.minecraft.util.math.Direction;
import net.minecraft.util.shape.VoxelShape;
import net.minecraft.world.BlockView;
import net.minecraft.world.World;
public class GlowstoneWireBlock extends Block{
// These are the states of the wires coming off our block
public static final net.minecraft.state.property.EnumProperty<net.minecraft.block.enums.WireConnection> WIRE_CONNECTION_NORTH;
public static final net.minecraft.state.property.EnumProperty<net.minecraft.block.enums.WireConnection> WIRE_CONNECTION_EAST;
public static final net.minecraft.state.property.EnumProperty<net.minecraft.block.enums.WireConnection> WIRE_CONNECTION_SOUTH;
public static final net.minecraft.state.property.EnumProperty<net.minecraft.block.enums.WireConnection> WIRE_CONNECTION_WEST;
// Locally defined DIRECTION <-> WIRE_CONNECTION_DIRECTION
public static final Map<Direction, EnumProperty<WireConnection>> DIRECTION_TO_WIRE_CONNECTION_PROPERTY;
// Determines the hitbox for our block
public static final VoxelShape DOT_SHAPE;
// Full sided state
private BlockState FULL_STATE;
public GlowstoneWireBlock(Settings settings) {
super(settings);
// Set these properties to be none as start, so we start with a dot
this.setDefaultState((BlockState)((BlockState)((BlockState)((BlockState)((BlockState)((BlockState)this.stateManager.getDefaultState()).with(WIRE_CONNECTION_NORTH, WireConnection.NONE)).with(WIRE_CONNECTION_EAST, WireConnection.NONE)).with(WIRE_CONNECTION_SOUTH, WireConnection.NONE)).with(WIRE_CONNECTION_WEST, WireConnection.NONE)));
this.FULL_STATE = (BlockState)((BlockState)((BlockState)((BlockState)this.getDefaultState().with(WIRE_CONNECTION_NORTH, WireConnection.SIDE)).with(WIRE_CONNECTION_EAST, WireConnection.SIDE)).with(WIRE_CONNECTION_SOUTH, WireConnection.SIDE)).with(WIRE_CONNECTION_WEST, WireConnection.SIDE);
}
// Make sure out block has the properties for us to manage
protected void appendProperties(StateManager.Builder<Block, BlockState> builder) {
builder.add(WIRE_CONNECTION_NORTH, WIRE_CONNECTION_EAST, WIRE_CONNECTION_SOUTH, WIRE_CONNECTION_WEST);
}
private static boolean isFullyConnected(BlockState state) {
return ((WireConnection)state.get(WIRE_CONNECTION_NORTH)).isConnected() &&
((WireConnection)state.get(WIRE_CONNECTION_SOUTH)).isConnected() &&
((WireConnection)state.get(WIRE_CONNECTION_EAST)).isConnected() &&
((WireConnection)state.get(WIRE_CONNECTION_WEST)).isConnected();
}
private static boolean isNotConnected(BlockState state) {
return !((WireConnection)state.get(WIRE_CONNECTION_NORTH)).isConnected() &&
!((WireConnection)state.get(WIRE_CONNECTION_SOUTH)).isConnected() &&
!((WireConnection)state.get(WIRE_CONNECTION_EAST)).isConnected() &&
!((WireConnection)state.get(WIRE_CONNECTION_WEST)).isConnected();
}
public VoxelShape getOutlineShape(BlockState state, BlockView world, BlockPos pos, ShapeContext context) {
return DOT_SHAPE;
}
public BlockState getPlacecmentState(ItemPlacementContext ctx){
return this.getDefaultState();
}
public BlockState rotate(BlockState state, BlockRotation rotation) {
switch(rotation) {
case CLOCKWISE_180:
return (BlockState)((BlockState)((BlockState)((BlockState)state.with(WIRE_CONNECTION_NORTH, state.get(WIRE_CONNECTION_SOUTH))).with(WIRE_CONNECTION_EAST, state.get(WIRE_CONNECTION_WEST))).with(WIRE_CONNECTION_SOUTH, state.get(WIRE_CONNECTION_NORTH))).with(WIRE_CONNECTION_WEST, state.get(WIRE_CONNECTION_EAST));
case COUNTERCLOCKWISE_90:
return (BlockState)((BlockState)((BlockState)((BlockState)state.with(WIRE_CONNECTION_NORTH, state.get(WIRE_CONNECTION_EAST))).with(WIRE_CONNECTION_EAST, state.get(WIRE_CONNECTION_SOUTH))).with(WIRE_CONNECTION_SOUTH, state.get(WIRE_CONNECTION_WEST))).with(WIRE_CONNECTION_WEST, state.get(WIRE_CONNECTION_NORTH));
case CLOCKWISE_90:
return (BlockState)((BlockState)((BlockState)((BlockState)state.with(WIRE_CONNECTION_NORTH, state.get(WIRE_CONNECTION_WEST))).with(WIRE_CONNECTION_EAST, state.get(WIRE_CONNECTION_NORTH))).with(WIRE_CONNECTION_SOUTH, state.get(WIRE_CONNECTION_EAST))).with(WIRE_CONNECTION_WEST, state.get(WIRE_CONNECTION_SOUTH));
default:
return state;
}
}
public BlockState mirror(BlockState state, BlockMirror mirror) {
switch(mirror) {
case LEFT_RIGHT:
return (BlockState)((BlockState)state.with(WIRE_CONNECTION_NORTH, state.get(WIRE_CONNECTION_SOUTH))).with(WIRE_CONNECTION_SOUTH, state.get(WIRE_CONNECTION_NORTH));
case FRONT_BACK:
return (BlockState)((BlockState)state.with(WIRE_CONNECTION_EAST, state.get(WIRE_CONNECTION_WEST))).with(WIRE_CONNECTION_WEST, state.get(WIRE_CONNECTION_EAST));
default:
return super.mirror(state, mirror);
}
}
public ActionResult onUse(BlockState state, World world, BlockPos pos, PlayerEntity player, Hand hand, BlockHitResult hit){
if(isNotConnected(state))
world.setBlockState(pos, FULL_STATE, 3);
else
world.setBlockState(pos, this.getDefaultState(), 3);
System.out.println("onUse");
return ActionResult.SUCCESS;
}
public void update(World world, BlockPos pos, BlockState state){
System.out.println("Update");
}
// isnt system.out BUT will update neighors?
public void updateNeighbors(World world, BlockPos pos){
System.out.println("Update neighbors");
if (world.getBlockState(pos).isOf(this)) {
world.updateNeighborsAlways(pos, this);
Direction[] var3 = Direction.values();
int var4 = var3.length;
for(int var5 = 0; var5 < var4; ++var5) {
Direction direction = var3[var5];
world.updateNeighborsAlways(pos.offset(direction), this);
}
}
}
public void neighborUpdate(BlockState state, World world, BlockPos pos, Block block, BlockPos fromPos, boolean notify){
System.out.println("Neighbor update");
}
static {
WIRE_CONNECTION_NORTH = Properties.NORTH_WIRE_CONNECTION;
WIRE_CONNECTION_EAST = Properties.EAST_WIRE_CONNECTION;
WIRE_CONNECTION_SOUTH = Properties.SOUTH_WIRE_CONNECTION;
WIRE_CONNECTION_WEST = Properties.WEST_WIRE_CONNECTION;
DIRECTION_TO_WIRE_CONNECTION_PROPERTY = Maps.newEnumMap((Map)ImmutableMap.of(Direction.NORTH, WIRE_CONNECTION_NORTH, Direction.EAST, WIRE_CONNECTION_EAST, Direction.SOUTH, WIRE_CONNECTION_SOUTH, Direction.WEST, WIRE_CONNECTION_WEST));
DOT_SHAPE = Block.createCuboidShape(3.0D, 0.0D, 3.0D, 13.0D, 1.0D, 13.0D);
}
}
@@ -1,13 +0,0 @@
package me.parsell.glowstonedust.core;
import net.fabricmc.fabric.api.item.v1.FabricItemSettings;
import net.minecraft.item.BlockItem;
import net.minecraft.item.ItemGroup;
import net.minecraft.util.Identifier;
import net.minecraft.util.registry.Registry;
public class glowItems {
public static void init(){
Registry.register(Registry.ITEM, new Identifier("glowstonedust", "glowstone_wire"), new BlockItem(glowBlocks.GLOWSTONEWIRE, new FabricItemSettings().group(ItemGroup.MISC)));
};
}
@@ -0,0 +1,25 @@
package me.parsell.glowstonewire;
import me.parsell.glowstonewire.core.glowBlocks;
import me.parsell.glowstonewire.core.glowItems;
import me.parsell.glowstonewire.core.glowLootTables;
import me.parsell.glowstonewire.core.glowRecipes;
import me.shedaniel.autoconfig.AutoConfig;
import me.shedaniel.autoconfig.serializer.GsonConfigSerializer;
import net.fabricmc.api.ModInitializer;
public class GlowstoneWire implements ModInitializer {
public static final String MODID = "glowstonewire";
public static GlowstoneWireConfig CONFIG;
@Override
public void onInitialize() {
AutoConfig.register(GlowstoneWireConfig.class, GsonConfigSerializer::new);
CONFIG = AutoConfig.getConfigHolder(GlowstoneWireConfig.class).getConfig();
glowBlocks.init();
glowItems.init();
glowRecipes.init();
glowLootTables.init();
}
}
@@ -1,17 +1,15 @@
package me.parsell.glowstonedust;
package me.parsell.glowstonewire;
import me.parsell.glowstonedust.core.glowBlocks;
import me.parsell.glowstonewire.core.glowBlocks;
import net.fabricmc.api.ClientModInitializer;
import net.fabricmc.fabric.api.blockrenderlayer.v1.BlockRenderLayerMap;
import net.fabricmc.fabric.api.client.rendering.v1.ColorProviderRegistry;
import net.minecraft.client.render.RenderLayer;
public class GlowstoneDustClient implements ClientModInitializer {
public class GlowstoneWireClient implements ClientModInitializer {
@Override
public void onInitializeClient(){
BlockRenderLayerMap.INSTANCE.putBlock(glowBlocks.GLOWSTONEWIRE, RenderLayer.getCutout());
ColorProviderRegistry.BLOCK.register((state, world, pos, tintIndex) -> {
return 0xFFFF00;
}, glowBlocks.GLOWSTONEWIRE);
ColorProviderRegistry.BLOCK.register((state, world, pos, tintIndex) -> {return 0xffbc5e;}, glowBlocks.GLOWSTONEWIRE);
}
}
@@ -0,0 +1,11 @@
package me.parsell.glowstonewire;
import me.shedaniel.autoconfig.ConfigData;
import me.shedaniel.autoconfig.annotation.Config;
@Config(name = "GlowstoneWire")
public class GlowstoneWireConfig implements ConfigData{
public String Description = "Changing this does nothing. Replacing glowstone drops is dirty, and will overwrite ALL loot tables that attempt to change minecraft's glowstone loot table. Disable this, and cocnsider using a datapack to achieve what you want.";
public boolean addConversionRecipes = true;
public boolean replaceGlowstoneDrop = true;
}
@@ -0,0 +1,36 @@
package me.parsell.glowstonewire.common;
import net.minecraft.util.StringIdentifiable;
public enum GlowWireConnection implements StringIdentifiable{
UP("up"),
SIDE("side"),
BROKE("broke"),
NONE("none");
private final String name;
private GlowWireConnection(String name){
this.name = name;
}
public String toString() {
return this.asString();
}
public String asString() {
return this.name;
}
public boolean isBroken() {
return this == BROKE;
}
public boolean isConnected() {
return this != NONE && this != BROKE;
}
public boolean isConnectedUp(){
return this == UP;
}
}
@@ -0,0 +1,254 @@
package me.parsell.glowstonewire.common;
import java.util.Map;
import com.google.common.collect.ImmutableMap;
import com.google.common.collect.Maps;
import com.google.common.collect.UnmodifiableIterator;
import org.jetbrains.annotations.Nullable;
import java.util.Iterator;
import net.minecraft.block.Block;
import net.minecraft.block.BlockState;
import net.minecraft.block.ShapeContext;
import net.minecraft.entity.EquipmentSlot;
import net.minecraft.entity.LivingEntity;
import net.minecraft.entity.player.PlayerEntity;
import net.minecraft.item.ItemPlacementContext;
import net.minecraft.item.ItemStack;
import net.minecraft.state.StateManager;
import net.minecraft.state.property.EnumProperty;
import net.minecraft.util.ActionResult;
import net.minecraft.util.BlockMirror;
import net.minecraft.util.BlockRotation;
import net.minecraft.util.Hand;
import net.minecraft.util.hit.BlockHitResult;
import net.minecraft.util.math.BlockPos;
import net.minecraft.util.math.Direction;
import net.minecraft.util.shape.VoxelShape;
import net.minecraft.util.shape.VoxelShapes;
import net.minecraft.world.BlockView;
import net.minecraft.world.World;
import net.minecraft.world.WorldAccess;
import net.minecraft.world.WorldView;
public class GlowstoneWireBlock extends Block{
// These are the states of the wires coming off our block
public static final EnumProperty<GlowWireConnection> WIRE_CONNECTION_NORTH;
public static final EnumProperty<GlowWireConnection> WIRE_CONNECTION_SOUTH;
public static final EnumProperty<GlowWireConnection> WIRE_CONNECTION_EAST;
public static final EnumProperty<GlowWireConnection> WIRE_CONNECTION_WEST;
// Locally defined DIRECTION <-> WIRE_CONNECTION_DIRECTION
public static final Map<Direction, EnumProperty<GlowWireConnection>> DIRECTION_TO_WIRE_CONNECTION;
// Determines the hitbox for our block
public static final VoxelShape DOT_VOXELSHAPE;
private static final Map<Direction, VoxelShape> DIRECTION_HITBOX, UP_HITBOX;
private final Map<BlockState, VoxelShape> STATE_TO_VOXELSHAPE = Maps.newHashMap();
public GlowstoneWireBlock(Settings settings) {
super(settings);
// Set these properties to be none as start, so we start with a dot
this.setDefaultState((BlockState)((BlockState)((BlockState)((BlockState)((BlockState)((BlockState)this.stateManager.getDefaultState()).with(WIRE_CONNECTION_NORTH, GlowWireConnection.NONE)).with(WIRE_CONNECTION_EAST, GlowWireConnection.NONE)).with(WIRE_CONNECTION_SOUTH, GlowWireConnection.NONE)).with(WIRE_CONNECTION_WEST, GlowWireConnection.NONE)));
UnmodifiableIterator stateItr = this.getStateManager().getStates().iterator();
while(stateItr.hasNext()) {
BlockState state = (BlockState)stateItr.next();
this.STATE_TO_VOXELSHAPE.put(state, determineVoxelShape(state));
}
}
// Make sure out block has the properties for us to manage
@Override
protected void appendProperties(StateManager.Builder<Block, BlockState> builder) {
builder.add(WIRE_CONNECTION_NORTH, WIRE_CONNECTION_EAST, WIRE_CONNECTION_SOUTH, WIRE_CONNECTION_WEST);
}
private static boolean hasConnection(BlockState state) {
return ((GlowWireConnection)state.get(WIRE_CONNECTION_NORTH)).isConnected() ||
((GlowWireConnection)state.get(WIRE_CONNECTION_SOUTH)).isConnected() ||
((GlowWireConnection)state.get(WIRE_CONNECTION_EAST)).isConnected() ||
((GlowWireConnection)state.get(WIRE_CONNECTION_WEST)).isConnected();
}
private BlockState determineState(WorldAccess world, BlockState state, BlockPos pos){
Iterator<Direction> dirItr = Direction.Type.HORIZONTAL.iterator();
while(dirItr.hasNext()){
Direction dir = dirItr.next();
state = state.with(DIRECTION_TO_WIRE_CONNECTION.get(dir), determineConnection(world, pos, dir));
}
return state;
}
private GlowWireConnection determineConnection(WorldAccess world, BlockPos pos, Direction direction){
BlockPos offsetPos = pos.offset(direction);
if((world.getBlockState(offsetPos.up()).isOf(this) && world.isAir(pos.up()))) // If offset+up is me && if up is air
if(!world.getBlockState(offsetPos.up()).get(DIRECTION_TO_WIRE_CONNECTION.get(direction.getOpposite())).isBroken()) //if offset+up is not broken
if(world.getBlockState(offsetPos).hasSidedTransparency())
return GlowWireConnection.SIDE;
else
return GlowWireConnection.UP;
if(world.getBlockState(offsetPos.down()).isOf(this) && world.isAir(offsetPos)) // if offset+down is me && if offset is air
if(!world.getBlockState(offsetPos.down()).get(DIRECTION_TO_WIRE_CONNECTION.get(direction.getOpposite())).isBroken()) //if offset+down is not broken
return GlowWireConnection.SIDE;
if(world.getBlockState(offsetPos).isOf(this)) // if offset is me
if(!world.getBlockState(offsetPos).get(DIRECTION_TO_WIRE_CONNECTION.get(direction.getOpposite())).isBroken()) // if offset is not broken
return GlowWireConnection.SIDE;
return GlowWireConnection.NONE;
}
@Override
public VoxelShape getOutlineShape(BlockState state, BlockView world, BlockPos pos, ShapeContext context) {
return STATE_TO_VOXELSHAPE.get(state);
}
public VoxelShape determineVoxelShape(BlockState state){
VoxelShape voxelShape = DOT_VOXELSHAPE;
Iterator dirItr = Direction.Type.HORIZONTAL.iterator();
while(dirItr.hasNext()) {
Direction direction = (Direction)dirItr.next();
GlowWireConnection wireConnection = state.get(DIRECTION_TO_WIRE_CONNECTION.get(direction));
if(state.equals(this.getDefaultState().with(DIRECTION_TO_WIRE_CONNECTION.get(direction), GlowWireConnection.SIDE))) {
voxelShape = VoxelShapes.union(voxelShape, (VoxelShape)DIRECTION_HITBOX.get(direction));
return VoxelShapes.union(voxelShape, DIRECTION_HITBOX.get(direction.getOpposite()));
} else if (state.equals(this.getDefaultState().with(DIRECTION_TO_WIRE_CONNECTION.get(direction), GlowWireConnection.UP))) {
voxelShape = VoxelShapes.union(voxelShape, (VoxelShape)UP_HITBOX.get(direction));
return VoxelShapes.union(voxelShape, DIRECTION_HITBOX.get(direction.getOpposite()));
} else if (wireConnection == GlowWireConnection.SIDE) {
voxelShape = VoxelShapes.union(voxelShape, (VoxelShape)DIRECTION_HITBOX.get(direction));
} else if (wireConnection == GlowWireConnection.UP) {
voxelShape = VoxelShapes.union(voxelShape, (VoxelShape)UP_HITBOX.get(direction));
}
}
return voxelShape;
}
public boolean canPlaceAt(BlockState state, WorldView world, BlockPos pos) {
BlockPos blockPos = pos.down();
BlockState blockState = world.getBlockState(blockPos);
return this.canRunOnTop(world, blockPos, blockState);
}
private boolean canRunOnTop(BlockView world, BlockPos pos, BlockState floor) {
return floor.isSideSolidFullSquare(world, pos, Direction.UP);
}
@Override
public BlockState rotate(BlockState state, BlockRotation rotation) {
switch(rotation) {
case CLOCKWISE_180:
return (BlockState)((BlockState)((BlockState)((BlockState)state.with(WIRE_CONNECTION_NORTH, state.get(WIRE_CONNECTION_SOUTH))).with(WIRE_CONNECTION_EAST, state.get(WIRE_CONNECTION_WEST))).with(WIRE_CONNECTION_SOUTH, state.get(WIRE_CONNECTION_NORTH))).with(WIRE_CONNECTION_WEST, state.get(WIRE_CONNECTION_EAST));
case COUNTERCLOCKWISE_90:
return (BlockState)((BlockState)((BlockState)((BlockState)state.with(WIRE_CONNECTION_NORTH, state.get(WIRE_CONNECTION_EAST))).with(WIRE_CONNECTION_EAST, state.get(WIRE_CONNECTION_SOUTH))).with(WIRE_CONNECTION_SOUTH, state.get(WIRE_CONNECTION_WEST))).with(WIRE_CONNECTION_WEST, state.get(WIRE_CONNECTION_NORTH));
case CLOCKWISE_90:
return (BlockState)((BlockState)((BlockState)((BlockState)state.with(WIRE_CONNECTION_NORTH, state.get(WIRE_CONNECTION_WEST))).with(WIRE_CONNECTION_EAST, state.get(WIRE_CONNECTION_NORTH))).with(WIRE_CONNECTION_SOUTH, state.get(WIRE_CONNECTION_EAST))).with(WIRE_CONNECTION_WEST, state.get(WIRE_CONNECTION_SOUTH));
default:
return state;
}
}
@Override
public BlockState mirror(BlockState state, BlockMirror mirror) {
switch(mirror) {
case LEFT_RIGHT:
return (BlockState)((BlockState)state.with(WIRE_CONNECTION_NORTH, state.get(WIRE_CONNECTION_SOUTH))).with(WIRE_CONNECTION_SOUTH, state.get(WIRE_CONNECTION_NORTH));
case FRONT_BACK:
return (BlockState)((BlockState)state.with(WIRE_CONNECTION_EAST, state.get(WIRE_CONNECTION_WEST))).with(WIRE_CONNECTION_WEST, state.get(WIRE_CONNECTION_EAST));
default:
return super.mirror(state, mirror);
}
}
// Place block check disconnect (if block block connection)
@Override // For each link, set to break and update the blocks around me (above and below)
public ActionResult onUse(BlockState state, World world, BlockPos pos, PlayerEntity player, Hand hand, BlockHitResult hit){
if(player.abilities.allowModifyWorld)
if(hasConnection(state) && !player.hasStackEquipped(EquipmentSlot.MAINHAND)) {
Iterator<Direction> dirItr = Direction.Type.HORIZONTAL.iterator();
while(dirItr.hasNext()){
Direction dir = dirItr.next();
if(state.get(DIRECTION_TO_WIRE_CONNECTION.get(dir)).isConnected())
state = state.with(DIRECTION_TO_WIRE_CONNECTION.get(dir), GlowWireConnection.BROKE);
}
world.setBlockState(pos, state);
// These call neighborUpdate not getStateForNeighborUpdate!!
//world.updateNeighborsAlways(pos, this); // Update those around me
world.updateNeighbors(pos.down(), this); // Update those below me
world.updateNeighbors(pos.up(), this); // Update those above me
return ActionResult.SUCCESS;
}
return ActionResult.PASS;
}
@Override // Get the state I should place in, and update those around me (above/below) as needed
public BlockState getPlacementState(ItemPlacementContext ctx){
return determineState(ctx.getWorld(), this.getDefaultState(), ctx.getBlockPos());
}
@Override
public void onPlaced(World world, BlockPos pos, BlockState state, @Nullable LivingEntity placer, ItemStack itemStack) {
world.updateNeighbors(pos.offset(Direction.UP), state.getBlock());
world.updateNeighbors(pos.offset(Direction.DOWN), state.getBlock());
}
@Override // This causes w/e issue that tracks deal with.
public void onBroken(WorldAccess world, BlockPos pos, BlockState state) {
world.updateNeighbors(pos.offset(Direction.UP), state.getBlock());
world.updateNeighbors(pos.offset(Direction.DOWN), state.getBlock());
}
@Override // Called when I get told to update, so I should see what/why I need to update. I also use this to determine if I need to be drop or not.
public void neighborUpdate(BlockState state, World world, BlockPos pos, Block block, BlockPos fromPos, boolean notify) {
if (!world.isClient) {
if(!state.canPlaceAt(world, pos)) {
dropStacks(state, world, pos);
world.removeBlock(pos, false);
this.onBroken(world, pos, state);
} else {
Iterator<Direction> dirItr = Direction.Type.HORIZONTAL.iterator();
while(dirItr.hasNext()){
Direction dir = dirItr.next();
if(!state.get(DIRECTION_TO_WIRE_CONNECTION.get(dir)).isBroken())
state = state.with(DIRECTION_TO_WIRE_CONNECTION.get(dir), determineConnection(world, pos, dir));
}
world.setBlockState(pos, state);
}
}
}
static {
WIRE_CONNECTION_NORTH = EnumProperty.of("north", GlowWireConnection.class);
WIRE_CONNECTION_EAST = EnumProperty.of("east", GlowWireConnection.class);
WIRE_CONNECTION_SOUTH = EnumProperty.of("south", GlowWireConnection.class);
WIRE_CONNECTION_WEST = EnumProperty.of("west", GlowWireConnection.class);
DIRECTION_TO_WIRE_CONNECTION = Maps.newEnumMap((Map)ImmutableMap.of(
Direction.NORTH, WIRE_CONNECTION_NORTH,
Direction.EAST, WIRE_CONNECTION_EAST,
Direction.SOUTH, WIRE_CONNECTION_SOUTH,
Direction.WEST, WIRE_CONNECTION_WEST)
);
DOT_VOXELSHAPE = Block.createCuboidShape(3.0D, 0.0D, 3.0D, 13.0D, 1.0D, 13.0D);
DIRECTION_HITBOX = Maps.newEnumMap((Map)ImmutableMap.of(
Direction.NORTH, Block.createCuboidShape(3.0D, 0.0D, 0.0D, 13.0D, 1.0D, 13.0D),
Direction.SOUTH, Block.createCuboidShape(3.0D, 0.0D, 3.0D, 13.0D, 1.0D, 16.0D),
Direction.EAST, Block.createCuboidShape(3.0D, 0.0D, 3.0D, 16.0D, 1.0D, 13.0D),
Direction.WEST, Block.createCuboidShape(0.0D, 0.0D, 3.0D, 13.0D, 1.0D, 13.0D))
);
UP_HITBOX = Maps.newEnumMap((Map)ImmutableMap.of(
Direction.NORTH, VoxelShapes.union((VoxelShape)DIRECTION_HITBOX.get(Direction.NORTH), Block.createCuboidShape(3.0D, 0.0D, 0.0D, 13.0D, 16.0D, 1.0D)),
Direction.SOUTH, VoxelShapes.union((VoxelShape)DIRECTION_HITBOX.get(Direction.SOUTH), Block.createCuboidShape(3.0D, 0.0D, 15.0D, 13.0D, 16.0D, 16.0D)),
Direction.EAST, VoxelShapes.union((VoxelShape)DIRECTION_HITBOX.get(Direction.EAST), Block.createCuboidShape(15.0D, 0.0D, 3.0D, 16.0D, 16.0D, 13.0D)),
Direction.WEST, VoxelShapes.union((VoxelShape)DIRECTION_HITBOX.get(Direction.WEST), Block.createCuboidShape(0.0D, 0.0D, 3.0D, 1.0D, 16.0D, 13.0D)))
);
}
}
@@ -1,6 +1,7 @@
package me.parsell.glowstonedust.core;
package me.parsell.glowstonewire.core;
import me.parsell.glowstonedust.common.GlowstoneWireBlock;
import me.parsell.glowstonewire.GlowstoneWire;
import me.parsell.glowstonewire.common.GlowstoneWireBlock;
import net.fabricmc.fabric.api.object.builder.v1.block.FabricBlockSettings;
import net.minecraft.block.Block;
import net.minecraft.block.Material;
@@ -11,7 +12,6 @@ public class glowBlocks {
public static final Block GLOWSTONEWIRE = new GlowstoneWireBlock(FabricBlockSettings.of(Material.SUPPORTED).breakInstantly().noCollision().luminance(8));
public static void init(){
Registry.register(Registry.BLOCK, new Identifier("glowstonedust", "glowstone_wire"), GLOWSTONEWIRE);
Registry.register(Registry.BLOCK, new Identifier(GlowstoneWire.MODID, "glowstone_wire"), GLOWSTONEWIRE);
}
}
@@ -0,0 +1,23 @@
package me.parsell.glowstonewire.core;
import me.parsell.glowstonewire.GlowstoneWire;
import me.parsell.glowstonewire.mixin.BrewingRecipeRegistryInvoker;
import net.fabricmc.fabric.api.client.itemgroup.FabricItemGroupBuilder;
import net.fabricmc.fabric.api.item.v1.FabricItemSettings;
import net.minecraft.item.BlockItem;
import net.minecraft.item.Item;
import net.minecraft.item.ItemGroup;
import net.minecraft.item.ItemStack;
import net.minecraft.item.Items;
import net.minecraft.potion.Potions;
import net.minecraft.util.Identifier;
import net.minecraft.util.registry.Registry;
public class glowItems {
public static final ItemGroup GLOWSTONEWIRE_CTAB = FabricItemGroupBuilder.build(new Identifier(GlowstoneWire.MODID, "general"), () -> new ItemStack(Items.GLOWSTONE_DUST));
public static final Item GLOWSTONE_DUST = new BlockItem(glowBlocks.GLOWSTONEWIRE, new FabricItemSettings().group(GLOWSTONEWIRE_CTAB));
public static void init(){
Registry.register(Registry.ITEM, new Identifier(GlowstoneWire.MODID, "glowstone_dust"), GLOWSTONE_DUST);
}
}
@@ -0,0 +1,125 @@
package me.parsell.glowstonewire.core;
import com.google.gson.JsonArray;
import com.google.gson.JsonObject;
import me.parsell.glowstonewire.GlowstoneWire;
public class glowLootTables {
public static JsonObject glowstonelootTable;
public static void init(){
if(GlowstoneWire.CONFIG.replaceGlowstoneDrop) {
JsonObject explosion;
JsonObject limitValues, limit;
JsonObject bonus, parametersValues;
JsonObject count, countValues;
JsonArray secondItemArray;
JsonObject secondItem;
JsonObject levelsValues, silktouch;
JsonArray enchantmentsArray;
JsonObject enchantments, match;
JsonArray firstItemArray;
JsonObject firstItem;
JsonArray alternativesArray;
JsonObject alternatives;
JsonArray rollsArray;
JsonObject rolls;
JsonArray lootPoolsArray;
explosion = new JsonObject();
explosion.addProperty("function", "minecraft:explosion_decay");
limit = new JsonObject();
limit.addProperty("function", "minecraft:limit_count");
limitValues = new JsonObject();
limitValues.addProperty("max", 4);
limitValues.addProperty("min", 1);
limit.add("limit", limitValues);
bonus = new JsonObject();
bonus.addProperty("function", "minecraft:apply_bonus");
bonus.addProperty("enchantment", "minecraft:fortune");
bonus.addProperty("formula", "minecraft:uniform_bonus_count");
parametersValues = new JsonObject();
parametersValues.addProperty("bonusMultiplier", 1);
bonus.add("parameters", parametersValues);
count = new JsonObject();
count.addProperty("function", "minecraft:set_count");
countValues = new JsonObject();
countValues.addProperty("min", 2.0);
countValues.addProperty("max", 4.0);
countValues.addProperty("type", "minecraft:uniform");
count.add("count", countValues);
secondItemArray = new JsonArray();
secondItemArray.add(count);
secondItemArray.add(bonus);
secondItemArray.add(limit);
secondItemArray.add(explosion);
secondItem = new JsonObject();
secondItem.addProperty("type", "minecraft:item");
secondItem.add("functions", secondItemArray);
secondItem.addProperty("name", "glowstonewire:glowstone_dust");
//
levelsValues = new JsonObject();
levelsValues.addProperty("min", 1);
silktouch = new JsonObject();
silktouch.addProperty("enchantment", "minecraft:silk_touch");
silktouch.add("levels", levelsValues);
enchantmentsArray = new JsonArray();
enchantmentsArray.add(silktouch);
enchantments = new JsonObject();
enchantments.add("enchantments", enchantmentsArray);
match = new JsonObject();
match.addProperty("condition", "minecraft:match_tool");
match.add("predicate", enchantments);
firstItemArray = new JsonArray();
firstItemArray.add(match);
firstItem = new JsonObject();
firstItem.addProperty("type", "minecraft:item");
firstItem.add("conditions", firstItemArray);
firstItem.addProperty("name", "minecraft:glowstone");
//
alternativesArray = new JsonArray();
alternativesArray.add(firstItem);
alternativesArray.add(secondItem);
alternatives = new JsonObject();
alternatives.addProperty("type", "minecraft:alternatives");
alternatives.add("children", alternativesArray);
//
rollsArray = new JsonArray();
rollsArray.add(alternatives);
rolls = new JsonObject();
rolls.addProperty("rolls", 1);
rolls.add("entries", rollsArray);
//
lootPoolsArray = new JsonArray();
lootPoolsArray.add(rolls);
glowstonelootTable = new JsonObject();
glowstonelootTable.addProperty("type", "minecraft:block");
glowstonelootTable.add("pools", lootPoolsArray);
}
}
}
@@ -0,0 +1,66 @@
package me.parsell.glowstonewire.core;
import com.google.gson.JsonArray;
import com.google.gson.JsonObject;
import me.parsell.glowstonewire.GlowstoneWire;
import me.parsell.glowstonewire.mixin.BrewingRecipeRegistryInvoker;
import me.parsell.glowstonewire.mixin.FireworkStarRecipeAccessor;
import net.minecraft.item.Items;
import net.minecraft.potion.Potions;
import net.minecraft.recipe.Ingredient;
public class glowRecipes {
public static JsonObject MODDED_TO_VANILLA;
public static JsonObject VANILLA_TO_MODDED;
public static void init(){
BrewingRecipeRegistryInvoker.registerPotionRecipe(Potions.WATER, glowItems.GLOWSTONE_DUST, Potions.THICK);
BrewingRecipeRegistryInvoker.registerPotionRecipe(Potions.LEAPING, glowItems.GLOWSTONE_DUST, Potions.STRONG_LEAPING);
BrewingRecipeRegistryInvoker.registerPotionRecipe(Potions.SLOWNESS, glowItems.GLOWSTONE_DUST, Potions.STRONG_SLOWNESS);
BrewingRecipeRegistryInvoker.registerPotionRecipe(Potions.TURTLE_MASTER, glowItems.GLOWSTONE_DUST, Potions.STRONG_TURTLE_MASTER);
BrewingRecipeRegistryInvoker.registerPotionRecipe(Potions.SWIFTNESS, glowItems.GLOWSTONE_DUST, Potions.STRONG_SWIFTNESS);
BrewingRecipeRegistryInvoker.registerPotionRecipe(Potions.HEALING, glowItems.GLOWSTONE_DUST, Potions.STRONG_HEALING);
BrewingRecipeRegistryInvoker.registerPotionRecipe(Potions.HARMING, glowItems.GLOWSTONE_DUST, Potions.STRONG_HARMING);
BrewingRecipeRegistryInvoker.registerPotionRecipe(Potions.POISON, glowItems.GLOWSTONE_DUST, Potions.STRONG_POISON);
BrewingRecipeRegistryInvoker.registerPotionRecipe(Potions.REGENERATION, glowItems.GLOWSTONE_DUST, Potions.STRONG_REGENERATION);
BrewingRecipeRegistryInvoker.registerPotionRecipe(Potions.STRENGTH, glowItems.GLOWSTONE_DUST, Potions.STRONG_STRENGTH);
// Manually reset the glowstone compability, since i cant find a way to read and reset.
Ingredient defaultFSFlickerModifier = FireworkStarRecipeAccessor.getFlickerModifier();
FireworkStarRecipeAccessor.setFlickerModifier(Ingredient.ofItems(Items.GLOWSTONE_DUST, glowItems.GLOWSTONE_DUST));
if(GlowstoneWire.CONFIG.addConversionRecipes) {
// Base JsonObjects
JsonObject cIngredientVanilla = new JsonObject();
JsonObject CIngredientModded = new JsonObject();
JsonArray cIngredientsList = new JsonArray();
cIngredientVanilla.addProperty("item", "minecraft:glowstone_dust");
CIngredientModded.addProperty("item", "glowstonewire:glowstone_dust");
// FOR VANILLA TO MODDED
VANILLA_TO_MODDED = new JsonObject();
// Header, defining what type of crafting recipe it is
VANILLA_TO_MODDED.addProperty("type", "minecraft:crafting_shapeless");
// Adding the ingredients
cIngredientsList.add(cIngredientVanilla);
VANILLA_TO_MODDED.add("ingredients", cIngredientsList);
// Adding the result
VANILLA_TO_MODDED.add("result", CIngredientModded);
// Clearing out the old array for new
cIngredientsList = new JsonArray();
// FOR MODDED TO VANILLA
MODDED_TO_VANILLA = new JsonObject();
// Define recipe type
MODDED_TO_VANILLA.addProperty("type", "minecraft:crafting_shapeless");
// Add ingredients
cIngredientsList.add(CIngredientModded);
MODDED_TO_VANILLA.add("ingredients", cIngredientsList);
// Add result
MODDED_TO_VANILLA.add("result", cIngredientVanilla);
}
}
}
@@ -0,0 +1,16 @@
package me.parsell.glowstonewire.mixin;
import org.spongepowered.asm.mixin.Mixin;
import org.spongepowered.asm.mixin.gen.Invoker;
import net.minecraft.item.Item;
import net.minecraft.potion.Potion;
import net.minecraft.recipe.BrewingRecipeRegistry;
@Mixin(BrewingRecipeRegistry.class)
public interface BrewingRecipeRegistryInvoker {
@Invoker("registerPotionRecipe")
public static void registerPotionRecipe(Potion input, Item item, Potion output) {
throw new AssertionError();
}
}
@@ -0,0 +1,20 @@
package me.parsell.glowstonewire.mixin;
import org.spongepowered.asm.mixin.Mixin;
import org.spongepowered.asm.mixin.gen.Accessor;
import net.minecraft.recipe.FireworkStarRecipe;
import net.minecraft.recipe.Ingredient;
@Mixin(FireworkStarRecipe.class)
public interface FireworkStarRecipeAccessor {
@Accessor("FLICKER_MODIFIER")
public static Ingredient getFlickerModifier(){
throw new AssertionError();
}
@Accessor("FLICKER_MODIFIER")
public static void setFlickerModifier(Ingredient FLICKER_MODIFIER){
throw new AssertionError();
}
}
@@ -0,0 +1,27 @@
package me.parsell.glowstonewire.mixin;
import java.util.Map;
import com.google.gson.JsonElement;
import org.spongepowered.asm.mixin.Mixin;
import org.spongepowered.asm.mixin.injection.At;
import org.spongepowered.asm.mixin.injection.Inject;
import org.spongepowered.asm.mixin.injection.callback.CallbackInfo;
import me.parsell.glowstonewire.GlowstoneWire;
import me.parsell.glowstonewire.core.glowLootTables;
import net.minecraft.loot.LootManager;
import net.minecraft.resource.ResourceManager;
import net.minecraft.util.Identifier;
import net.minecraft.util.profiler.Profiler;
@Mixin(LootManager.class)
public class LootManagerInjector {
@Inject(method = "apply", at = @At("HEAD"))
public void interceptApply(Map<Identifier, JsonElement> map, ResourceManager resourceManager, Profiler profiler, CallbackInfo info) {
if (GlowstoneWire.CONFIG.replaceGlowstoneDrop) {
map.put(new Identifier("minecraft", "blocks/glowstone"), glowLootTables.glowstonelootTable);
}
}
}
@@ -0,0 +1,28 @@
package me.parsell.glowstonewire.mixin;
import java.util.Map;
import com.google.gson.JsonElement;
import org.spongepowered.asm.mixin.Mixin;
import org.spongepowered.asm.mixin.injection.At;
import org.spongepowered.asm.mixin.injection.Inject;
import org.spongepowered.asm.mixin.injection.callback.CallbackInfo;
import me.parsell.glowstonewire.GlowstoneWire;
import me.parsell.glowstonewire.core.glowRecipes;
import net.minecraft.recipe.RecipeManager;
import net.minecraft.resource.ResourceManager;
import net.minecraft.util.Identifier;
import net.minecraft.util.profiler.Profiler;
@Mixin(RecipeManager.class)
public class RecipeManagerInjector {
@Inject(method = "apply", at = @At("HEAD"))
public void interceptApply(Map<Identifier, JsonElement> map, ResourceManager resourceManager, Profiler profiler, CallbackInfo info) {
if (GlowstoneWire.CONFIG.addConversionRecipes) {
map.put(new Identifier(GlowstoneWire.MODID, "glowstone_vanilla_modded"), glowRecipes.VANILLA_TO_MODDED);
map.put(new Identifier(GlowstoneWire.MODID, "glowstone_modded_vanilla"), glowRecipes.MODDED_TO_VANILLA);
}
}
}
@@ -1,6 +0,0 @@
{
"parent": "glowstonedust:block/glowstone_dust_side",
"textures": {
"line": "glowstonedust:block/glowstone_dust_line0"
}
}
@@ -1,6 +0,0 @@
{
"parent": "glowstonedust:block/glowstone_dust_side",
"textures": {
"line": "glowstonedust:block/glowstone_dust_line1"
}
}
@@ -1,6 +0,0 @@
{
"parent": "glowstonedust:block/glowstone_dust_side_alt",
"textures": {
"line": "glowstonedust:block/glowstone_dust_line0"
}
}
@@ -1,6 +0,0 @@
{
"parent": "glowstonedust:block/glowstone_dust_side_alt",
"textures": {
"line": "glowstonedust:block/glowstone_dust_line1"
}
}
@@ -4,10 +4,10 @@
"when": {
"OR": [
{
"south": "none",
"north": "none",
"west": "none",
"east": "none"
"south": "none|broke",
"north": "none|broke",
"west": "none|broke",
"east": "none|broke"
},
{
"north": "side|up",
@@ -28,7 +28,7 @@
]
},
"apply": {
"model": "glowstonedust:block/glowstone_dust_dot"
"model": "glowstonewire:block/glowstone_dust_dot"
}
},
{
@@ -39,14 +39,14 @@
},
{
"south": "side|up",
"north": "none",
"west": "none",
"east": "none"
"north": "none|broke",
"west": "none|broke",
"east": "none|broke"
}
]
},
"apply": {
"model": "glowstonedust:block/glowstone_dust_side0"
"model": "glowstonewire:block/glowstone_dust_side0"
}
},
{
@@ -56,15 +56,21 @@
"south": "side|up"
},
{
"south": "none",
"south": "none|broke",
"north": "side|up",
"west": "none",
"east": "none"
"west": "none|broke",
"east": "none|broke"
},
{
"south": "broke",
"north": "side|up",
"west": "broke",
"east": "broke"
}
]
},
"apply": {
"model": "glowstonedust:block/glowstone_dust_side_alt0"
"model": "glowstonewire:block/glowstone_dust_side_alt0"
}
},
{
@@ -74,16 +80,22 @@
"east": "side|up"
},
{
"south": "none",
"north": "none",
"south": "none|broke",
"north": "none|broke",
"west": "side|up",
"east": "none"
"east": "none|broke"
},
{
"south": "broke",
"north": "broke",
"west": "side|up",
"east": "broke"
}
]
},
"apply": {
"y": 270,
"model": "glowstonedust:block/glowstone_dust_side_alt1"
"model": "glowstonewire:block/glowstone_dust_side_alt1"
}
},
{
@@ -93,16 +105,22 @@
"west": "side|up"
},
{
"south": "none",
"north": "none",
"west": "none",
"south": "none|broke",
"north": "none|broke",
"west": "none|broke",
"east": "side|up"
},
{
"south": "broke",
"north": "broke",
"west": "broke",
"east": "side|up"
}
]
},
"apply": {
"y": 270,
"model": "glowstonedust:block/glowstone_dust_side1"
"model": "glowstonewire:block/glowstone_dust_side1"
}
},
{
@@ -110,7 +128,7 @@
"north": "up"
},
"apply": {
"model": "glowstonedust:block/glowstone_dust_up"
"model": "glowstonewire:block/glowstone_dust_up"
}
},
{
@@ -119,7 +137,7 @@
},
"apply": {
"y": 90,
"model": "glowstonedust:block/glowstone_dust_up"
"model": "glowstonewire:block/glowstone_dust_up"
}
},
{
@@ -128,7 +146,7 @@
},
"apply": {
"y": 180,
"model": "glowstonedust:block/glowstone_dust_up"
"model": "glowstonewire:block/glowstone_dust_up"
}
},
{
@@ -137,7 +155,7 @@
},
"apply": {
"y": 270,
"model": "glowstonedust:block/glowstone_dust_up"
"model": "glowstonewire:block/glowstone_dust_up"
}
}
]

Before

Width:  |  Height:  |  Size: 453 B

After

Width:  |  Height:  |  Size: 453 B

@@ -0,0 +1,4 @@
{
"itemGroup.glowstonewire.general": "Glowstone Wire",
"block.glowstonewire.glowstone_wire": "Glowstone Dust"
}
@@ -1,9 +1,9 @@
{
"ambientocclusion": false,
"textures": {
"particle": "glowstonedust:block/glowstone_dust_dot",
"line": "glowstonedust:block/glowstone_dust_dot",
"overlay": "glowstonedust:block/glowstone_dust_overlay"
"particle": "glowstonewire:block/glowstone_dust_dot",
"line": "glowstonewire:block/glowstone_dust_dot",
"overlay": "glowstonewire:block/glowstone_dust_overlay"
},
"elements": [
{ "from": [ 0, 0.25, 0 ],
@@ -1,8 +1,8 @@
{
"ambientocclusion": false,
"textures": {
"particle": "glowstonedust:block/glowstone_dust_dot",
"overlay": "glowstonedust:block/glowstone_dust_overlay"
"particle": "glowstonewire:block/glowstone_dust_dot",
"overlay": "glowstonewire:block/glowstone_dust_overlay"
},
"elements": [
{ "from": [ 0, 0.25, 0 ],
@@ -0,0 +1,6 @@
{
"parent": "glowstonewire:block/glowstone_dust_side",
"textures": {
"line": "glowstonewire:block/glowstone_dust_line0"
}
}
@@ -0,0 +1,6 @@
{
"parent": "glowstonewire:block/glowstone_dust_side",
"textures": {
"line": "glowstonewire:block/glowstone_dust_line1"
}
}
@@ -1,8 +1,8 @@
{
"ambientocclusion": false,
"textures": {
"particle": "glowstonedust:block/glowstone_dust_dot",
"overlay": "glowstonedust:block/glowstone_dust_overlay"
"particle": "glowstonewire:block/glowstone_dust_dot",
"overlay": "glowstonewire:block/glowstone_dust_overlay"
},
"elements": [
{ "from": [ 0, 0.25, 8 ],
@@ -0,0 +1,6 @@
{
"parent": "glowstonewire:block/glowstone_dust_side_alt",
"textures": {
"line": "glowstonewire:block/glowstone_dust_line0"
}
}
@@ -0,0 +1,6 @@
{
"parent": "glowstonewire:block/glowstone_dust_side_alt",
"textures": {
"line": "glowstonewire:block/glowstone_dust_line1"
}
}
@@ -1,9 +1,9 @@
{
"ambientocclusion": false,
"textures": {
"particle": "glowstonedust:block/glowstone_dust_dot",
"line": "glowstonedust:block/glowstone_dust_line0",
"overlay": "glowstonedust:block/glowstone_dust_overlay"
"particle": "glowstonewire:block/glowstone_dust_dot",
"line": "glowstonewire:block/glowstone_dust_line0",
"overlay": "glowstonewire:block/glowstone_dust_overlay"
},
"elements": [
{ "from": [ 0, 0, 0.25 ],
@@ -0,0 +1,6 @@
{
"parent": "item/generated",
"textures": {
"layer0": "glowstonewire:item/glowstone_dust"
}
}
Binary file not shown.

After

Width:  |  Height:  |  Size: 191 B

@@ -0,0 +1,19 @@
{
"type": "minecraft:block",
"pools": [
{
"rolls": 1,
"entries": [
{
"type": "minecraft:item",
"name": "glowstonewire:glowstone_dust"
}
],
"conditions": [
{
"condition": "minecraft:survives_explosion"
}
]
}
]
}
@@ -0,0 +1,15 @@
{
"type": "minecraft:crafting_shaped",
"pattern": [
"##",
"##"
],
"key": {
"#": {
"item": "glowstonewire:glowstone_dust"
}
},
"result": {
"item": "minecraft:glowstone"
}
}
@@ -0,0 +1,20 @@
{
"type": "minecraft:crafting_shaped",
"pattern": [
" # ",
"#X#",
" # "
],
"key": {
"#": {
"item": "glowstonewire:glowstone_dust"
},
"X": {
"item": "minecraft:arrow"
}
},
"result": {
"item": "minecraft:spectral_arrow",
"count": 2
}
}
+14 -14
View File
@@ -1,40 +1,40 @@
{
"schemaVersion": 1,
"id": "glowstonedust",
"version": "${version}",
"id": "glowstonewire",
"version": "1.0.0",
"name": "Glowstone Dust",
"description": "This is an example description! Tell everyone what your mod is about!",
"name": "Glowstone Wire",
"description": "Adds redstone like dust in the form of glowstone, used to emit a lower light level in a small form factor",
"authors": [
"Me!"
"Ganku (Badjman)"
],
"contact": {
"homepage": "https://fabricmc.net/",
"sources": "https://github.com/FabricMC/fabric-example-mod"
"homepage": "",
"sources": "https://git.parsell.me/Justi/GlowstoneWire/"
},
"license": "CC0-1.0",
"icon": "assets/glowstonedust/icon.png",
"license": "MIT",
"icon": "assets/glowstonewire/icon.png",
"environment": "*",
"entrypoints": {
"client": [
"me.parsell.glowstonedust.GlowstoneDustClient"
"me.parsell.glowstonewire.GlowstoneWireClient"
],
"main": [
"me.parsell.glowstonedust.GlowstoneDust"
"me.parsell.glowstonewire.GlowstoneWire"
]
},
"mixins": [
"glowstonedust.mixins.json"
"glowstonewire.mixins.json"
],
"depends": {
"fabricloader": ">=0.7.4",
"fabric": "*",
"minecraft": "1.16.x"
"minecraft": "1.16.x",
"cloth-config2": ">=4.11.26"
},
"suggests": {
"another-mod": "*"
}
}
@@ -1,14 +0,0 @@
{
"required": true,
"minVersion": "0.8",
"package": "me.parsell.glowstonedust.mixin",
"compatibilityLevel": "JAVA_8",
"mixins": [
],
"client": [
],
"injectors": {
"defaultRequire": 1
}
}
@@ -0,0 +1,17 @@
{
"required": true,
"minVersion": "0.8",
"package": "me.parsell.glowstonewire.mixin",
"compatibilityLevel": "JAVA_8",
"mixins": [
],
"client": [
"BrewingRecipeRegistryInvoker",
"RecipeManagerInjector",
"LootManagerInjector",
"FireworkStarRecipeAccessor"
],
"injectors": {
"defaultRequire": 1
}
}