upgrade to 1.21.3
This commit is contained in:
parent
0079c721cc
commit
4c5dea1756
@ -1,5 +1,5 @@
|
||||
plugins {
|
||||
id 'fabric-loom' version '1.6-SNAPSHOT'
|
||||
id 'fabric-loom' version '1.8-SNAPSHOT'
|
||||
id 'maven-publish'
|
||||
}
|
||||
|
||||
|
@ -4,14 +4,14 @@ org.gradle.parallel=true
|
||||
|
||||
# Fabric Properties
|
||||
# check these on https://fabricmc.net/develop
|
||||
minecraft_version=1.21.1
|
||||
yarn_mappings=1.21.1+build.3
|
||||
loader_version=0.15.11
|
||||
minecraft_version=1.21.3
|
||||
yarn_mappings=1.21.3+build.2
|
||||
loader_version=0.16.9
|
||||
|
||||
# Mod Properties
|
||||
mod_version=1.21.1.0
|
||||
mod_version=1.21.3.1
|
||||
maven_group=de.jottyfan.quickiemod
|
||||
archives_base_name=quickiemod
|
||||
|
||||
# Dependencies
|
||||
fabric_version=0.102.1+1.21.1
|
||||
fabric_version=0.108.0+1.21.3
|
2
gradle/wrapper/gradle-wrapper.properties
vendored
2
gradle/wrapper/gradle-wrapper.properties
vendored
@ -1,6 +1,6 @@
|
||||
distributionBase=GRADLE_USER_HOME
|
||||
distributionPath=wrapper/dists
|
||||
distributionUrl=https\://services.gradle.org/distributions/gradle-8.7-bin.zip
|
||||
distributionUrl=https\://services.gradle.org/distributions/gradle-8.10.2-bin.zip
|
||||
networkTimeout=10000
|
||||
validateDistributionUrl=true
|
||||
zipStoreBase=GRADLE_USER_HOME
|
||||
|
7
gradlew
vendored
7
gradlew
vendored
@ -15,6 +15,8 @@
|
||||
# See the License for the specific language governing permissions and
|
||||
# limitations under the License.
|
||||
#
|
||||
# SPDX-License-Identifier: Apache-2.0
|
||||
#
|
||||
|
||||
##############################################################################
|
||||
#
|
||||
@ -55,7 +57,7 @@
|
||||
# Darwin, MinGW, and NonStop.
|
||||
#
|
||||
# (3) This script is generated from the Groovy template
|
||||
# https://github.com/gradle/gradle/blob/HEAD/subprojects/plugins/src/main/resources/org/gradle/api/internal/plugins/unixStartScript.txt
|
||||
# https://github.com/gradle/gradle/blob/HEAD/platforms/jvm/plugins-application/src/main/resources/org/gradle/api/internal/plugins/unixStartScript.txt
|
||||
# within the Gradle project.
|
||||
#
|
||||
# You can find Gradle at https://github.com/gradle/gradle/.
|
||||
@ -84,7 +86,8 @@ done
|
||||
# shellcheck disable=SC2034
|
||||
APP_BASE_NAME=${0##*/}
|
||||
# Discard cd standard output in case $CDPATH is set (https://github.com/gradle/gradle/issues/25036)
|
||||
APP_HOME=$( cd "${APP_HOME:-./}" > /dev/null && pwd -P ) || exit
|
||||
APP_HOME=$( cd -P "${APP_HOME:-./}" > /dev/null && printf '%s
|
||||
' "$PWD" ) || exit
|
||||
|
||||
# Use the maximum available, or set MAX_FD != -1 to use that value.
|
||||
MAX_FD=maximum
|
||||
|
2
gradlew.bat
vendored
2
gradlew.bat
vendored
@ -13,6 +13,8 @@
|
||||
@rem See the License for the specific language governing permissions and
|
||||
@rem limitations under the License.
|
||||
@rem
|
||||
@rem SPDX-License-Identifier: Apache-2.0
|
||||
@rem
|
||||
|
||||
@if "%DEBUG%"=="" @echo off
|
||||
@rem ##########################################################################
|
||||
|
@ -1,31 +0,0 @@
|
||||
package de.jottyfan.quickiemod;
|
||||
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
|
||||
import de.jottyfan.quickiemod.init.RegistryManager;
|
||||
import net.fabricmc.api.ModInitializer;
|
||||
|
||||
/**
|
||||
*
|
||||
* @author jotty
|
||||
*
|
||||
*/
|
||||
public class QuickieMod implements ModInitializer {
|
||||
public static final String MODID = "quickiemod";
|
||||
|
||||
public static final Logger LOGGER = LoggerFactory.getLogger(MODID);
|
||||
|
||||
@Override
|
||||
public void onInitialize() {
|
||||
LOGGER.info("loading {}", MODID);
|
||||
|
||||
RegistryManager.registerBlockEntityTypes();
|
||||
RegistryManager.registerScreenHandlerTypes();
|
||||
RegistryManager.registerItems();
|
||||
RegistryManager.registerEvents();
|
||||
RegistryManager.registerBlocks();
|
||||
RegistryManager.registerFeatures();
|
||||
RegistryManager.registerItemGroup();
|
||||
}
|
||||
}
|
@ -1,26 +0,0 @@
|
||||
package de.jottyfan.quickiemod;
|
||||
|
||||
import de.jottyfan.quickiemod.blocks.QuickieBlocks;
|
||||
import de.jottyfan.quickiemod.container.BlockStackerScreen;
|
||||
import de.jottyfan.quickiemod.container.ScreenHandlerTypes;
|
||||
import net.fabricmc.api.ClientModInitializer;
|
||||
import net.fabricmc.api.EnvType;
|
||||
import net.fabricmc.api.Environment;
|
||||
import net.fabricmc.fabric.api.blockrenderlayer.v1.BlockRenderLayerMap;
|
||||
import net.minecraft.client.gui.screen.ingame.HandledScreens;
|
||||
import net.minecraft.client.render.RenderLayer;
|
||||
|
||||
/**
|
||||
*
|
||||
* @author jotty
|
||||
*
|
||||
*/
|
||||
@Environment(EnvType.CLIENT)
|
||||
public class QuickieModClient implements ClientModInitializer {
|
||||
@Override
|
||||
public void onInitializeClient() {
|
||||
// HandledScreens.register(ScreenHandlerTypes.BLOCKSTACKER_SCREEN_HANDLER, BlockStackerScreen::new);
|
||||
BlockRenderLayerMap.INSTANCE.putBlock(QuickieBlocks.COTTONPLANT.getBlock(), RenderLayer.getCutout());
|
||||
BlockRenderLayerMap.INSTANCE.putBlock(QuickieBlocks.CANOLAPLANT.getBlock(), RenderLayer.getCutout());
|
||||
}
|
||||
}
|
73
src/main/java/de/jottyfan/quickiemod/Quickiemod.java
Normal file
73
src/main/java/de/jottyfan/quickiemod/Quickiemod.java
Normal file
@ -0,0 +1,73 @@
|
||||
package de.jottyfan.quickiemod;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
|
||||
import de.jottyfan.quickiemod.block.ModBlocks;
|
||||
import de.jottyfan.quickiemod.blockentity.ModBlockentity;
|
||||
import de.jottyfan.quickiemod.event.EventBlockBreak;
|
||||
import de.jottyfan.quickiemod.feature.ModFeatures;
|
||||
import de.jottyfan.quickiemod.item.ModItems;
|
||||
import de.jottyfan.quickiemod.itemgroup.ModItemGroup;
|
||||
import net.fabricmc.api.ModInitializer;
|
||||
import net.fabricmc.fabric.api.event.player.PlayerBlockBreakEvents;
|
||||
import net.fabricmc.fabric.api.loot.v3.LootTableEvents;
|
||||
import net.fabricmc.fabric.api.registry.CompostingChanceRegistry;
|
||||
import net.minecraft.block.Block;
|
||||
import net.minecraft.item.Item;
|
||||
import net.minecraft.item.Items;
|
||||
import net.minecraft.loot.LootPool;
|
||||
import net.minecraft.loot.condition.SurvivesExplosionLootCondition;
|
||||
import net.minecraft.loot.entry.ItemEntry;
|
||||
|
||||
/**
|
||||
*
|
||||
* @author jotty
|
||||
*
|
||||
*/
|
||||
public class Quickiemod implements ModInitializer {
|
||||
public static final String MOD_ID = "quickiemod";
|
||||
public static final Logger LOGGER = LoggerFactory.getLogger(MOD_ID);
|
||||
|
||||
private void registerComposterItems() {
|
||||
CompostingChanceRegistry.INSTANCE.add(ModItems.ITEM_COTTONSEED, 0.5f);
|
||||
CompostingChanceRegistry.INSTANCE.add(ModItems.ITEM_COTTON, 0.75f);
|
||||
CompostingChanceRegistry.INSTANCE.add(ModItems.ITEM_CANOLASEED, 0.5f);
|
||||
CompostingChanceRegistry.INSTANCE.add(ModItems.ITEM_CANOLA, 0.75f);
|
||||
}
|
||||
|
||||
private void registerLootTableChanges() {
|
||||
LootTableEvents.MODIFY.register((key, tableBuilder, source, registries) -> {
|
||||
if (source.isBuiltin()) {
|
||||
if ("minecraft:blocks/short_grass".equals(key.getValue().toString())) {
|
||||
tableBuilder.pool(LootPool.builder()
|
||||
.with(ItemEntry.builder(ModItems.ITEM_COTTONSEED).weight(1))
|
||||
.with(ItemEntry.builder(Items.AIR).weight(4))
|
||||
.conditionally(SurvivesExplosionLootCondition.builder()));
|
||||
} else if ("minecraft:blocks/tall_grass".equals(key.getValue().toString())) {
|
||||
tableBuilder.pool(LootPool.builder()
|
||||
.with(ItemEntry.builder(ModItems.ITEM_CANOLASEED).weight(1))
|
||||
.with(ItemEntry.builder(Items.AIR).weight(7))
|
||||
.conditionally(SurvivesExplosionLootCondition.builder()));
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onInitialize() {
|
||||
ModBlockentity.registerModBlockentities();
|
||||
List<Item> items = ModItems.registerModItems();
|
||||
List<Block> blocks = ModBlocks.registerModBlocks();
|
||||
ModFeatures.registerFeatures();
|
||||
registerComposterItems();
|
||||
registerLootTableChanges();
|
||||
ModItemGroup.registerItemGroup(items, blocks);
|
||||
PlayerBlockBreakEvents.AFTER.register((world, player, pos, state, blockEntity) -> {
|
||||
Block oldBlock = state.getBlock();
|
||||
new EventBlockBreak().doBreakBlock(world, pos, state, player, oldBlock);
|
||||
});
|
||||
}
|
||||
}
|
20
src/main/java/de/jottyfan/quickiemod/QuickiemodClient.java
Normal file
20
src/main/java/de/jottyfan/quickiemod/QuickiemodClient.java
Normal file
@ -0,0 +1,20 @@
|
||||
package de.jottyfan.quickiemod;
|
||||
|
||||
import de.jottyfan.quickiemod.block.ModBlocks;
|
||||
import net.fabricmc.api.ClientModInitializer;
|
||||
import net.fabricmc.fabric.api.blockrenderlayer.v1.BlockRenderLayerMap;
|
||||
import net.minecraft.client.render.RenderLayer;
|
||||
|
||||
/**
|
||||
*
|
||||
* @author jotty
|
||||
*
|
||||
*/
|
||||
public class QuickiemodClient implements ClientModInitializer {
|
||||
|
||||
@Override
|
||||
public void onInitializeClient() {
|
||||
BlockRenderLayerMap.INSTANCE.putBlock(ModBlocks.BLOCK_COTTONPLANT, RenderLayer.getCutout());
|
||||
BlockRenderLayerMap.INSTANCE.putBlock(ModBlocks.BLOCK_CANOLAPLANT, RenderLayer.getCutout());
|
||||
}
|
||||
}
|
@ -1,8 +1,5 @@
|
||||
package de.jottyfan.quickiemod;
|
||||
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
|
||||
import net.fabricmc.fabric.api.datagen.v1.DataGeneratorEntrypoint;
|
||||
import net.fabricmc.fabric.api.datagen.v1.FabricDataGenerator;
|
||||
|
||||
@ -11,13 +8,10 @@ import net.fabricmc.fabric.api.datagen.v1.FabricDataGenerator;
|
||||
* @author jotty
|
||||
*
|
||||
*/
|
||||
public class QuickieModDataGenerator implements DataGeneratorEntrypoint {
|
||||
private static final Logger LOGGER = LoggerFactory.getLogger(QuickieMod.MODID);
|
||||
|
||||
public class QuickiemodDataGenerator implements DataGeneratorEntrypoint {
|
||||
|
||||
@Override
|
||||
public void onInitializeDataGenerator(FabricDataGenerator fabricDataGenerator) {
|
||||
// TODO: implement
|
||||
LOGGER.debug("initializing data generator");
|
||||
|
||||
}
|
||||
}
|
@ -1,84 +0,0 @@
|
||||
package de.jottyfan.quickiemod.api;
|
||||
|
||||
import java.util.HashSet;
|
||||
import java.util.Iterator;
|
||||
import java.util.Set;
|
||||
import java.util.function.BiFunction;
|
||||
|
||||
import net.minecraft.util.math.BlockPos;
|
||||
import net.minecraft.world.World;
|
||||
|
||||
/**
|
||||
*
|
||||
* @author jotty
|
||||
*
|
||||
*/
|
||||
public class Neighborhood {
|
||||
|
||||
/**
|
||||
* find the same blocks that is next to the current position pos
|
||||
*
|
||||
* @param world the world to look for the blocks
|
||||
* @param pos the starting position
|
||||
* @param seekLimit the limit of seek operations
|
||||
* @param checkLambda check functionality
|
||||
* @return a set of found block positions
|
||||
*/
|
||||
public static final Set<BlockPos> findEqualBlock(World world, BlockPos pos, int seekLimit,
|
||||
BiFunction<World, BlockPos, Boolean> checkLambda) {
|
||||
Set<NeighborhoodBean> found = new HashSet<>();
|
||||
found.add(new NeighborhoodBean(pos, true));
|
||||
|
||||
while (pos != null && found.size() < seekLimit) {
|
||||
findNewNeihgbor(world, pos.east(), found, checkLambda);
|
||||
findNewNeihgbor(world, pos.south(), found, checkLambda);
|
||||
findNewNeihgbor(world, pos.west(), found, checkLambda);
|
||||
findNewNeihgbor(world, pos.north(), found, checkLambda);
|
||||
pos = findNextUncheckedField(found);
|
||||
}
|
||||
|
||||
Set<BlockPos> finals = new HashSet<>();
|
||||
for (NeighborhoodBean bean : found) {
|
||||
finals.add(bean.getPos());
|
||||
}
|
||||
return finals;
|
||||
}
|
||||
|
||||
private static final BlockPos findNextUncheckedField(Set<NeighborhoodBean> found) {
|
||||
Iterator<NeighborhoodBean> i = found.iterator();
|
||||
while (i.hasNext()) {
|
||||
NeighborhoodBean bean = i.next();
|
||||
if (!bean.isChecked()) {
|
||||
bean.setChecked(true);
|
||||
return bean.getPos();
|
||||
}
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
/**
|
||||
* find new neighbor at pos
|
||||
*
|
||||
* @param world the world
|
||||
* @param pos the position
|
||||
* @param found the set with all already found positions
|
||||
* @return true or false
|
||||
*/
|
||||
private static final boolean findNewNeihgbor(World world, BlockPos pos, Set<NeighborhoodBean> found,
|
||||
BiFunction<World, BlockPos, Boolean> checkLambda) {
|
||||
NeighborhoodBean bean = new NeighborhoodBean(pos);
|
||||
if (found.contains(bean) || found.contains(bean.over()) || found.contains(bean.below())) {
|
||||
return false;
|
||||
} else if (checkLambda.apply(world, pos).booleanValue()) {
|
||||
found.add(bean);
|
||||
return true;
|
||||
} else if (checkLambda.apply(world, pos.up()).booleanValue()) {
|
||||
found.add(new NeighborhoodBean(pos.up()));
|
||||
return true;
|
||||
} else if (checkLambda.apply(world, pos.down()).booleanValue()) {
|
||||
found.add(new NeighborhoodBean(pos.down()));
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
}
|
@ -1,77 +0,0 @@
|
||||
package de.jottyfan.quickiemod.api;
|
||||
|
||||
import java.util.Objects;
|
||||
|
||||
import net.minecraft.util.math.BlockPos;
|
||||
|
||||
/**
|
||||
*
|
||||
* @author jotty
|
||||
*
|
||||
*/
|
||||
public class NeighborhoodBean {
|
||||
private final BlockPos pos;
|
||||
private boolean checked;
|
||||
|
||||
public NeighborhoodBean(BlockPos pos, boolean checked) {
|
||||
super();
|
||||
this.pos = pos;
|
||||
this.checked = checked;
|
||||
}
|
||||
|
||||
public NeighborhoodBean(BlockPos pos) {
|
||||
super();
|
||||
this.pos = pos;
|
||||
this.checked = false;
|
||||
}
|
||||
|
||||
public NeighborhoodBean over() {
|
||||
return new NeighborhoodBean(pos.up(), checked);
|
||||
}
|
||||
|
||||
public NeighborhoodBean below() {
|
||||
return new NeighborhoodBean(pos.down(), checked);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int hashCode() {
|
||||
return Objects.hash(pos);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean equals(Object obj) {
|
||||
Boolean result = null;
|
||||
if (this == obj) {
|
||||
result = true;
|
||||
} else if (obj == null) {
|
||||
result = false;
|
||||
} else if (getClass() != obj.getClass()) {
|
||||
result = false;
|
||||
} else {
|
||||
NeighborhoodBean other = (NeighborhoodBean) obj;
|
||||
result = Objects.equals(pos, other.pos);
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return the checked
|
||||
*/
|
||||
public boolean isChecked() {
|
||||
return checked;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param checked the checked to set
|
||||
*/
|
||||
public void setChecked(boolean checked) {
|
||||
this.checked = checked;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return the pos
|
||||
*/
|
||||
public BlockPos getPos() {
|
||||
return pos;
|
||||
}
|
||||
}
|
@ -0,0 +1,25 @@
|
||||
package de.jottyfan.quickiemod.block;
|
||||
|
||||
import net.minecraft.block.AbstractBlock;
|
||||
import net.minecraft.block.Block;
|
||||
import net.minecraft.registry.RegistryKey;
|
||||
import net.minecraft.registry.RegistryKeys;
|
||||
import net.minecraft.util.Identifier;
|
||||
|
||||
/**
|
||||
*
|
||||
* @author jotty
|
||||
*
|
||||
*/
|
||||
public abstract class AbstractIdentifiedBlock extends Block {
|
||||
|
||||
public AbstractIdentifiedBlock(Identifier identifier) {
|
||||
super(AbstractBlock.Settings.create().registryKey(RegistryKey.of(RegistryKeys.BLOCK, identifier)));
|
||||
}
|
||||
|
||||
public AbstractIdentifiedBlock(Identifier identifier, float strength, float hardness) {
|
||||
super(AbstractBlock.Settings.create().strength(strength).hardness(hardness).requiresTool()
|
||||
.registryKey(RegistryKey.of(RegistryKeys.BLOCK, identifier)));
|
||||
}
|
||||
|
||||
}
|
@ -1,16 +1,15 @@
|
||||
package de.jottyfan.quickiemod.blocks;
|
||||
package de.jottyfan.quickiemod.block;
|
||||
|
||||
import java.util.Arrays;
|
||||
import java.util.List;
|
||||
|
||||
import com.mojang.serialization.MapCodec;
|
||||
|
||||
import de.jottyfan.quickiemod.items.QuickieItems;
|
||||
import net.minecraft.block.AbstractBlock;
|
||||
import net.minecraft.block.BlockState;
|
||||
import net.minecraft.block.FallingBlock;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.loot.context.LootContextParameterSet.Builder;
|
||||
import net.minecraft.loot.context.LootWorldContext.Builder;
|
||||
import net.minecraft.util.Identifier;
|
||||
import net.minecraft.world.explosion.Explosion;
|
||||
|
||||
/**
|
||||
@ -18,15 +17,19 @@ import net.minecraft.world.explosion.Explosion;
|
||||
* @author jotty
|
||||
*
|
||||
*/
|
||||
public class BlockSpeedpowder extends FallingBlock {
|
||||
public class BlockBreakByTool extends AbstractIdentifiedBlock {
|
||||
|
||||
public BlockSpeedpowder() {
|
||||
super(AbstractBlock.Settings.create().luminance(state -> 12));
|
||||
private final ItemStack[] drops;
|
||||
|
||||
public BlockBreakByTool(Identifier identifier, float strength, float hardness, ItemStack[] drops) {
|
||||
super(identifier, strength, hardness);
|
||||
|
||||
this.drops = drops;
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<ItemStack> getDroppedStacks(BlockState state, Builder builder) {
|
||||
return Arrays.asList(new ItemStack[] { new ItemStack(QuickieItems.SPEEDPOWDER.getItem(), 9) });
|
||||
return Arrays.asList(drops);
|
||||
}
|
||||
|
||||
@Override
|
@ -1,4 +1,4 @@
|
||||
package de.jottyfan.quickiemod.blocks;
|
||||
package de.jottyfan.quickiemod.block;
|
||||
|
||||
import java.util.Arrays;
|
||||
import java.util.List;
|
||||
@ -6,14 +6,17 @@ import java.util.Random;
|
||||
|
||||
import com.mojang.serialization.MapCodec;
|
||||
|
||||
import de.jottyfan.quickiemod.items.QuickieItems;
|
||||
import de.jottyfan.quickiemod.item.ModItems;
|
||||
import net.minecraft.block.AbstractBlock;
|
||||
import net.minecraft.block.BlockState;
|
||||
import net.minecraft.block.Blocks;
|
||||
import net.minecraft.block.FallingBlock;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.item.Items;
|
||||
import net.minecraft.loot.context.LootContextParameterSet.Builder;
|
||||
import net.minecraft.loot.context.LootWorldContext.Builder;
|
||||
import net.minecraft.registry.RegistryKey;
|
||||
import net.minecraft.registry.RegistryKeys;
|
||||
import net.minecraft.util.Identifier;
|
||||
|
||||
/**
|
||||
*
|
||||
@ -22,8 +25,8 @@ import net.minecraft.loot.context.LootContextParameterSet.Builder;
|
||||
*/
|
||||
public class BlockDirtSalpeter extends FallingBlock {
|
||||
|
||||
public BlockDirtSalpeter() {
|
||||
super(AbstractBlock.Settings.create().hardness(3.1f));
|
||||
public BlockDirtSalpeter(Identifier identifier) {
|
||||
super(AbstractBlock.Settings.create().hardness(3.1f).registryKey(RegistryKey.of(RegistryKeys.BLOCK, identifier)));
|
||||
}
|
||||
|
||||
@Override
|
||||
@ -31,7 +34,7 @@ public class BlockDirtSalpeter extends FallingBlock {
|
||||
Integer count = (Double.valueOf(new Random().nextDouble() * 10).intValue() / 4) + 1;
|
||||
boolean spawnBoneMeal = new Random().nextDouble() > 0.5f;
|
||||
ItemStack boneMealStack = new ItemStack(Items.BONE_MEAL);
|
||||
ItemStack salpeterStack = new ItemStack(QuickieItems.SALPETER.getItem(), count);
|
||||
ItemStack salpeterStack = new ItemStack(ModItems.ITEM_SALPETER, count);
|
||||
ItemStack dirtStack = new ItemStack(Blocks.DIRT);
|
||||
ItemStack[] spawnies = spawnBoneMeal ? new ItemStack[] { boneMealStack, salpeterStack, dirtStack }
|
||||
: new ItemStack[] { salpeterStack, dirtStack };
|
||||
@ -40,7 +43,6 @@ public class BlockDirtSalpeter extends FallingBlock {
|
||||
|
||||
@Override
|
||||
protected MapCodec<? extends FallingBlock> getCodec() {
|
||||
// TODO Auto-generated method stub
|
||||
return null;
|
||||
}
|
||||
}
|
112
src/main/java/de/jottyfan/quickiemod/block/BlockDrill.java
Normal file
112
src/main/java/de/jottyfan/quickiemod/block/BlockDrill.java
Normal file
@ -0,0 +1,112 @@
|
||||
package de.jottyfan.quickiemod.block;
|
||||
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
|
||||
import com.mojang.serialization.MapCodec;
|
||||
|
||||
import de.jottyfan.quickiemod.blockentity.DrillBlockEntity;
|
||||
import de.jottyfan.quickiemod.item.ModItems;
|
||||
import net.minecraft.block.AbstractBlock;
|
||||
import net.minecraft.block.Block;
|
||||
import net.minecraft.block.BlockEntityProvider;
|
||||
import net.minecraft.block.BlockState;
|
||||
import net.minecraft.block.FallingBlock;
|
||||
import net.minecraft.block.entity.BlockEntity;
|
||||
import net.minecraft.block.entity.BlockEntityTicker;
|
||||
import net.minecraft.block.entity.BlockEntityType;
|
||||
import net.minecraft.entity.ItemEntity;
|
||||
import net.minecraft.entity.player.PlayerEntity;
|
||||
import net.minecraft.item.Item;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.item.Items;
|
||||
import net.minecraft.registry.RegistryKey;
|
||||
import net.minecraft.registry.RegistryKeys;
|
||||
import net.minecraft.state.StateManager.Builder;
|
||||
import net.minecraft.state.property.EnumProperty;
|
||||
import net.minecraft.state.property.IntProperty;
|
||||
import net.minecraft.text.Text;
|
||||
import net.minecraft.util.ActionResult;
|
||||
import net.minecraft.util.Identifier;
|
||||
import net.minecraft.util.hit.BlockHitResult;
|
||||
import net.minecraft.util.math.BlockPos;
|
||||
import net.minecraft.util.math.Direction;
|
||||
import net.minecraft.world.World;
|
||||
|
||||
/**
|
||||
*
|
||||
* @author jotty
|
||||
*
|
||||
*/
|
||||
public class BlockDrill extends FallingBlock implements BlockEntityProvider {
|
||||
private static final Integer MAX_FUEL = 255;
|
||||
public static final IntProperty FUEL = IntProperty.of("fuel", 0, MAX_FUEL);
|
||||
public static final EnumProperty<Direction> DIRECTION = EnumProperty.of("direction", Direction.class, Direction.values());
|
||||
|
||||
public BlockDrill(Identifier identifier, Direction direction) {
|
||||
super(AbstractBlock.Settings.create().hardness(2.5f).registryKey(RegistryKey.of(RegistryKeys.BLOCK, identifier)));
|
||||
setDefaultState(getDefaultState().with(FUEL, 0).with(DIRECTION, direction));
|
||||
}
|
||||
|
||||
@Override
|
||||
public BlockEntity createBlockEntity(BlockPos pos, BlockState blockState) {
|
||||
return new DrillBlockEntity(pos, blockState);
|
||||
}
|
||||
|
||||
@Override
|
||||
public <T extends BlockEntity> BlockEntityTicker<T> getTicker(World world, BlockState state,
|
||||
BlockEntityType<T> type) {
|
||||
return (world1, pos, state1, be) -> DrillBlockEntity.tick(world1, pos, state1, be);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected MapCodec<? extends FallingBlock> getCodec() {
|
||||
// TODO Auto-generated method stub
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public BlockState onBreak(World world, BlockPos pos, BlockState state, PlayerEntity player) {
|
||||
Integer fuelLeft = state.get(FUEL);
|
||||
world.spawnEntity(
|
||||
new ItemEntity(world, pos.getX(), pos.getY(), pos.getZ(), new ItemStack(ModItems.ITEM_CANOLABOTTLE, fuelLeft)));
|
||||
return super.onBreak(world, pos, state, player);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void appendProperties(Builder<Block, BlockState> builder) {
|
||||
builder.add(FUEL).add(DIRECTION);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected ActionResult onUse(BlockState state, World world, BlockPos pos, PlayerEntity player, BlockHitResult hit) {
|
||||
Map<Item, Integer> loadings = new HashMap<>();
|
||||
loadings.put(ModItems.ITEM_CANOLABOTTLE, 8);
|
||||
loadings.put(ModItems.ITEM_CANOLABOTTLESTACK, 72);
|
||||
ItemStack stack = player.getStackInHand(player.getActiveHand());
|
||||
Item item = stack.getItem();
|
||||
if (stack.isEmpty() || !loadings.containsKey(item)) {
|
||||
if (world.isClient()) {
|
||||
player.sendMessage(Text.translatable("msg.drill.fuelinfo", state.get(FUEL)), false);
|
||||
}
|
||||
} else {
|
||||
Integer fuelWeight = loadings.get(item);
|
||||
if (fuelWeight != null) {
|
||||
Integer load = MAX_FUEL - state.get(FUEL);
|
||||
if (load < fuelWeight) {
|
||||
fuelWeight = load;
|
||||
}
|
||||
world.setBlockState(pos, state.with(FUEL, state.get(FUEL) + fuelWeight));
|
||||
if (item.equals(ModItems.ITEM_CANOLABOTTLE)) {
|
||||
world.spawnEntity(
|
||||
new ItemEntity(world, pos.getX(), pos.getY(), pos.getZ(), new ItemStack(Items.GLASS_BOTTLE, 1)));
|
||||
} else if (item.equals(ModItems.ITEM_CANOLABOTTLESTACK)) {
|
||||
world.spawnEntity(
|
||||
new ItemEntity(world, pos.getX(), pos.getY(), pos.getZ(), new ItemStack(Items.GLASS_BOTTLE, 9)));
|
||||
}
|
||||
stack.decrement(1);
|
||||
}
|
||||
}
|
||||
return ActionResult.PASS;
|
||||
}
|
||||
}
|
@ -1,4 +1,4 @@
|
||||
package de.jottyfan.quickiemod.blocks;
|
||||
package de.jottyfan.quickiemod.block;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.HashSet;
|
||||
@ -6,50 +6,57 @@ import java.util.List;
|
||||
import java.util.Random;
|
||||
import java.util.Set;
|
||||
|
||||
import de.jottyfan.quickiemod.blockentity.EmptyLavaHoarderBlockEntity;
|
||||
import net.minecraft.block.AbstractBlock;
|
||||
import net.minecraft.block.Block;
|
||||
import net.minecraft.block.BlockEntityProvider;
|
||||
import net.minecraft.block.BlockState;
|
||||
import net.minecraft.block.Blocks;
|
||||
import net.minecraft.block.entity.BlockEntity;
|
||||
import net.minecraft.block.entity.BlockEntityTicker;
|
||||
import net.minecraft.block.entity.BlockEntityType;
|
||||
import net.minecraft.entity.ExperienceOrbEntity;
|
||||
import net.minecraft.entity.LivingEntity;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.loot.context.LootContextParameterSet.Builder;
|
||||
import net.minecraft.loot.context.LootWorldContext.Builder;
|
||||
import net.minecraft.registry.RegistryKey;
|
||||
import net.minecraft.registry.RegistryKeys;
|
||||
import net.minecraft.server.world.ServerWorld;
|
||||
import net.minecraft.util.Identifier;
|
||||
import net.minecraft.util.math.BlockPos;
|
||||
import net.minecraft.world.World;
|
||||
import net.minecraft.world.tick.OrderedTick;
|
||||
|
||||
/**
|
||||
*
|
||||
* @author jotty
|
||||
*
|
||||
*/
|
||||
public class BlockEmptyLavahoarder extends Block implements BlockEntityProvider {
|
||||
public class BlockEmptyLavahoarder extends Block {
|
||||
|
||||
public BlockEmptyLavahoarder() {
|
||||
super(AbstractBlock.Settings.create().hardness(2.5f));
|
||||
}
|
||||
|
||||
@Override
|
||||
public BlockEntity createBlockEntity(BlockPos pos, BlockState blockState) {
|
||||
return new EmptyLavaHoarderBlockEntity(pos, blockState);
|
||||
}
|
||||
|
||||
@Override
|
||||
public <T extends BlockEntity> BlockEntityTicker<T> getTicker(World world, BlockState state, BlockEntityType<T> type){
|
||||
return (world1, pos, state1, be) -> EmptyLavaHoarderBlockEntity.tick(world1, pos, state1, be);
|
||||
public BlockEmptyLavahoarder(Identifier identifier) {
|
||||
super(AbstractBlock.Settings.create().hardness(2.5f).registryKey(RegistryKey.of(RegistryKeys.BLOCK, identifier)));
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<ItemStack> getDroppedStacks(BlockState state, Builder builder) {
|
||||
List<ItemStack> list = new ArrayList<>();
|
||||
list.add(new ItemStack(QuickieBlocks.EMPTYLAVAHOARDER.getBlock()));
|
||||
list.add(new ItemStack(ModBlocks.BLOCK_EMPTYLAVAHOARDER));
|
||||
return list;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void scheduledTick(BlockState state, ServerWorld world, BlockPos pos,
|
||||
net.minecraft.util.math.random.Random random) {
|
||||
boolean found = BlockLavahoarder.suckLava(world, pos.north());
|
||||
found = found || BlockLavahoarder.suckLava(world, pos.south());
|
||||
found = found || BlockLavahoarder.suckLava(world, pos.east());
|
||||
found = found || BlockLavahoarder.suckLava(world, pos.west());
|
||||
found = found || BlockLavahoarder.suckLava(world, pos.up());
|
||||
found = found || BlockLavahoarder.suckLava(world, pos.down());
|
||||
if (found) {
|
||||
world.setBlockState(pos, ModBlocks.BLOCK_LAVAHOARDER.getDefaultState());
|
||||
world.getBlockTickScheduler().scheduleTick(OrderedTick.create(ModBlocks.BLOCK_LAVAHOARDER, pos));
|
||||
} else {
|
||||
world.getBlockTickScheduler().scheduleTick(OrderedTick.create(this, pos));
|
||||
}
|
||||
}
|
||||
|
||||
private static final String stringOf(BlockPos pos) {
|
||||
StringBuilder buf = new StringBuilder();
|
||||
buf.append(pos.getX()).append(":");
|
||||
@ -106,7 +113,8 @@ public class BlockEmptyLavahoarder extends Block implements BlockEntityProvider
|
||||
world.setBlockState(blockPosOf(p), Blocks.AIR.getDefaultState());
|
||||
}
|
||||
if (amount > 0) {
|
||||
world.setBlockState(pos, QuickieBlocks.LAVAHOARDER.getBlock().getDefaultState());
|
||||
world.setBlockState(pos, ModBlocks.BLOCK_LAVAHOARDER.getDefaultState());
|
||||
world.getBlockTickScheduler().scheduleTick(OrderedTick.create(ModBlocks.BLOCK_LAVAHOARDER, pos));
|
||||
int count = 0;
|
||||
Random random = new Random();
|
||||
for (int i = 0; i < amount; i++) {
|
||||
@ -116,9 +124,12 @@ public class BlockEmptyLavahoarder extends Block implements BlockEntityProvider
|
||||
}
|
||||
BlockPos up = pos.up();
|
||||
if (count > 0) {
|
||||
EmptyLavaHoarderBlockEntity.spawnRandomItems(world, up, count);
|
||||
world.spawnEntity(new ExperienceOrbEntity(world, (double) pos.getX() + 0.5D, (double) pos.getY() + 0.5D, (double) pos.getZ() + 0.5D, count));
|
||||
BlockLavahoarder.spawnRandomItems(world, up, count);
|
||||
world.spawnEntity(new ExperienceOrbEntity(world, (double) pos.getX() + 0.5D, (double) pos.getY() + 0.5D,
|
||||
(double) pos.getZ() + 0.5D, count));
|
||||
}
|
||||
} else {
|
||||
world.getBlockTickScheduler().scheduleTick(OrderedTick.create(this, pos));
|
||||
}
|
||||
}
|
||||
}
|
@ -1,4 +1,4 @@
|
||||
package de.jottyfan.quickiemod.blocks;
|
||||
package de.jottyfan.quickiemod.block;
|
||||
|
||||
import java.text.SimpleDateFormat;
|
||||
import java.util.ArrayList;
|
||||
@ -16,11 +16,14 @@ import net.minecraft.block.entity.BlockEntityTicker;
|
||||
import net.minecraft.block.entity.BlockEntityType;
|
||||
import net.minecraft.entity.player.PlayerEntity;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.loot.context.LootContextParameterSet.Builder;
|
||||
import net.minecraft.loot.context.LootWorldContext.Builder;
|
||||
import net.minecraft.registry.RegistryKey;
|
||||
import net.minecraft.registry.RegistryKeys;
|
||||
import net.minecraft.text.Style;
|
||||
import net.minecraft.text.Text;
|
||||
import net.minecraft.util.ActionResult;
|
||||
import net.minecraft.util.Formatting;
|
||||
import net.minecraft.util.Identifier;
|
||||
import net.minecraft.util.ItemScatterer;
|
||||
import net.minecraft.util.hit.BlockHitResult;
|
||||
import net.minecraft.util.math.BlockPos;
|
||||
@ -33,8 +36,8 @@ import net.minecraft.world.World;
|
||||
*/
|
||||
public class BlockItemhoarder extends Block implements BlockEntityProvider {
|
||||
|
||||
public BlockItemhoarder() {
|
||||
super(AbstractBlock.Settings.create().hardness(2.5f));
|
||||
public BlockItemhoarder(Identifier identifier) {
|
||||
super(AbstractBlock.Settings.create().hardness(2.5f).registryKey(RegistryKey.of(RegistryKeys.BLOCK, identifier)));
|
||||
}
|
||||
|
||||
@Override
|
||||
@ -56,7 +59,7 @@ public class BlockItemhoarder extends Block implements BlockEntityProvider {
|
||||
@Override
|
||||
public List<ItemStack> getDroppedStacks(BlockState state, Builder builder) {
|
||||
List<ItemStack> list = new ArrayList<>();
|
||||
list.add(new ItemStack(QuickieBlocks.ITEMHOARDER.getBlock()));
|
||||
list.add(new ItemStack(ModBlocks.BLOCK_ITEMHOARDER));
|
||||
return list;
|
||||
}
|
||||
|
135
src/main/java/de/jottyfan/quickiemod/block/BlockLavahoarder.java
Normal file
135
src/main/java/de/jottyfan/quickiemod/block/BlockLavahoarder.java
Normal file
@ -0,0 +1,135 @@
|
||||
package de.jottyfan.quickiemod.block;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.Random;
|
||||
|
||||
import de.jottyfan.quickiemod.item.ModItems;
|
||||
import net.minecraft.block.AbstractBlock;
|
||||
import net.minecraft.block.Block;
|
||||
import net.minecraft.block.BlockState;
|
||||
import net.minecraft.block.Blocks;
|
||||
import net.minecraft.entity.ItemEntity;
|
||||
import net.minecraft.entity.LivingEntity;
|
||||
import net.minecraft.entity.player.PlayerEntity;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.item.Items;
|
||||
import net.minecraft.loot.context.LootWorldContext.Builder;
|
||||
import net.minecraft.registry.RegistryKey;
|
||||
import net.minecraft.registry.RegistryKeys;
|
||||
import net.minecraft.server.world.ServerWorld;
|
||||
import net.minecraft.util.ActionResult;
|
||||
import net.minecraft.util.Hand;
|
||||
import net.minecraft.util.Identifier;
|
||||
import net.minecraft.util.hit.BlockHitResult;
|
||||
import net.minecraft.util.math.BlockPos;
|
||||
import net.minecraft.world.World;
|
||||
import net.minecraft.world.tick.OrderedTick;
|
||||
|
||||
/**
|
||||
*
|
||||
* @author jotty
|
||||
*
|
||||
*/
|
||||
public class BlockLavahoarder extends Block {
|
||||
|
||||
public BlockLavahoarder(Identifier identifier) {
|
||||
super(AbstractBlock.Settings.create().hardness(2.5f).luminance(state -> 15)
|
||||
.registryKey(RegistryKey.of(RegistryKeys.BLOCK, identifier)));
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<ItemStack> getDroppedStacks(BlockState state, Builder builder) {
|
||||
List<ItemStack> list = new ArrayList<>();
|
||||
list.add(new ItemStack(ModBlocks.BLOCK_LAVAHOARDER));
|
||||
return list;
|
||||
}
|
||||
|
||||
public static final void spawnRandomItems(World world, BlockPos pos, Integer count) {
|
||||
Integer which = new Random().nextInt(10);
|
||||
if (which < 1) {
|
||||
world.spawnEntity(new ItemEntity(world, pos.getX(), pos.getY(), pos.getZ(),
|
||||
new ItemStack(Items.DIAMOND, new Random().nextInt(count + 2))));
|
||||
} else if (which < 2) {
|
||||
world.spawnEntity(new ItemEntity(world, pos.getX(), pos.getY(), pos.getZ(),
|
||||
new ItemStack(Items.EMERALD, new Random().nextInt(count + 1))));
|
||||
} else if (which < 3) {
|
||||
world.spawnEntity(new ItemEntity(world, pos.getX(), pos.getY(), pos.getZ(),
|
||||
new ItemStack(Items.RAW_GOLD, new Random().nextInt(count))));
|
||||
} else if (which < 4) {
|
||||
world.spawnEntity(new ItemEntity(world, pos.getX(), pos.getY(), pos.getZ(),
|
||||
new ItemStack(Items.RAW_IRON, new Random().nextInt(count + 1))));
|
||||
} else if (which < 5) {
|
||||
world.spawnEntity(new ItemEntity(world, pos.getX(), pos.getY(), pos.getZ(),
|
||||
new ItemStack(Items.RAW_COPPER, new Random().nextInt(count + 2))));
|
||||
} else if (which < 6) {
|
||||
world.spawnEntity(new ItemEntity(world, pos.getX(), pos.getY(), pos.getZ(), new ItemStack(Items.OBSIDIAN)));
|
||||
} else if (which < 7) {
|
||||
world.spawnEntity(new ItemEntity(world, pos.getX(), pos.getY(), pos.getZ(), new ItemStack(Items.LAPIS_LAZULI)));
|
||||
} else if (which < 8) {
|
||||
world.spawnEntity(new ItemEntity(world, pos.getX(), pos.getY(), pos.getZ(), new ItemStack(ModItems.ITEM_SULFOR)));
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* sucks the lava that touches the block
|
||||
*
|
||||
* @param world the world
|
||||
* @param pos the pos
|
||||
* @return true if lava was found
|
||||
*/
|
||||
public static final boolean suckLava(World world, BlockPos pos) {
|
||||
if (world == null) {
|
||||
return false;
|
||||
} else if (Blocks.LAVA.equals(world.getBlockState(pos).getBlock())) {
|
||||
world.setBlockState(pos, Blocks.AIR.getDefaultState());
|
||||
BlockPos up = pos.up();
|
||||
Random random = new Random();
|
||||
if (random.nextFloat() > 0.9f) {
|
||||
spawnRandomItems(world, up, 2);
|
||||
}
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void scheduledTick(BlockState state, ServerWorld world, BlockPos pos,
|
||||
net.minecraft.util.math.random.Random random) {
|
||||
suckLava(world, pos.north());
|
||||
suckLava(world, pos.south());
|
||||
suckLava(world, pos.east());
|
||||
suckLava(world, pos.west());
|
||||
suckLava(world, pos.up());
|
||||
suckLava(world, pos.down());
|
||||
world.getBlockTickScheduler().scheduleTick(OrderedTick.create(this, pos));
|
||||
}
|
||||
|
||||
@Override
|
||||
protected ActionResult onUse(BlockState state, World world, BlockPos pos, PlayerEntity player, BlockHitResult hit) {
|
||||
if (!world.isClient) {
|
||||
Hand hand = player.getActiveHand();
|
||||
ItemStack handStack = player.getStackInHand(hand);
|
||||
if (handStack != null && Items.BUCKET.equals(handStack.getItem())) {
|
||||
Integer amount = handStack.getCount();
|
||||
ItemStack lavaBucketStack = new ItemStack(Items.LAVA_BUCKET, 1);
|
||||
ItemStack emptyBucketStack = new ItemStack(Items.BUCKET, amount - 1);
|
||||
if (emptyBucketStack.getCount() < 1) {
|
||||
player.setStackInHand(hand, lavaBucketStack);
|
||||
} else {
|
||||
player.setStackInHand(hand, emptyBucketStack);
|
||||
world.spawnEntity(new ItemEntity(world, pos.getX(), pos.getY(), pos.getZ(), lavaBucketStack));
|
||||
}
|
||||
spawnRandomItems(world, pos, 2);
|
||||
world.setBlockState(pos, ModBlocks.BLOCK_EMPTYLAVAHOARDER.getDefaultState());
|
||||
world.getBlockTickScheduler().scheduleTick(OrderedTick.create(ModBlocks.BLOCK_EMPTYLAVAHOARDER, pos));
|
||||
}
|
||||
}
|
||||
return ActionResult.SUCCESS; // forbid to empty the just filled lava bucket
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onPlaced(World world, BlockPos pos, BlockState state, LivingEntity placer, ItemStack itemStack) {
|
||||
world.getBlockTickScheduler().scheduleTick(OrderedTick.create(this, pos));
|
||||
}
|
||||
}
|
@ -0,0 +1,89 @@
|
||||
package de.jottyfan.quickiemod.block;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import net.minecraft.block.AbstractBlock;
|
||||
import net.minecraft.block.Block;
|
||||
import net.minecraft.block.BlockState;
|
||||
import net.minecraft.entity.Entity;
|
||||
import net.minecraft.entity.LivingEntity;
|
||||
import net.minecraft.entity.mob.HostileEntity;
|
||||
import net.minecraft.entity.player.PlayerEntity;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.registry.RegistryKey;
|
||||
import net.minecraft.registry.RegistryKeys;
|
||||
import net.minecraft.server.world.ServerWorld;
|
||||
import net.minecraft.sound.SoundCategory;
|
||||
import net.minecraft.sound.SoundEvents;
|
||||
import net.minecraft.state.StateManager.Builder;
|
||||
import net.minecraft.state.property.IntProperty;
|
||||
import net.minecraft.text.Text;
|
||||
import net.minecraft.util.ActionResult;
|
||||
import net.minecraft.util.Identifier;
|
||||
import net.minecraft.util.hit.BlockHitResult;
|
||||
import net.minecraft.util.math.BlockPos;
|
||||
import net.minecraft.util.math.Box;
|
||||
import net.minecraft.util.math.random.Random;
|
||||
import net.minecraft.world.World;
|
||||
import net.minecraft.world.tick.OrderedTick;
|
||||
|
||||
/**
|
||||
*
|
||||
* @author jotty
|
||||
*
|
||||
*/
|
||||
public class BlockMonsterhoarder extends Block {
|
||||
|
||||
private static final IntProperty SUCKRADIUS = IntProperty.of("suckradius", 1, 15);
|
||||
|
||||
public BlockMonsterhoarder(Identifier identifier) {
|
||||
super(AbstractBlock.Settings.create().hardness(2.5f).luminance(state -> state.get(BlockMonsterhoarder.SUCKRADIUS))
|
||||
.registryKey(RegistryKey.of(RegistryKeys.BLOCK, identifier)));
|
||||
setDefaultState(getDefaultState().with(SUCKRADIUS, 8));
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void appendProperties(Builder<Block, BlockState> builder) {
|
||||
builder.add(SUCKRADIUS);
|
||||
super.appendProperties(builder);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected ActionResult onUse(BlockState state, World world, BlockPos pos, PlayerEntity player, BlockHitResult hit) {
|
||||
if (!world.isClient()) {
|
||||
world.setBlockState(pos, state.cycle(SUCKRADIUS));
|
||||
} else {
|
||||
player.sendMessage(Text.translatable("msg.monsterhoarder.size", state.get(SUCKRADIUS)), false);
|
||||
}
|
||||
return ActionResult.SUCCESS;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void scheduledTick(BlockState state, ServerWorld world, BlockPos pos, Random random) {
|
||||
if (!world.isClient) {
|
||||
Box box = new Box(pos).expand(Double.valueOf(state.get(SUCKRADIUS)));
|
||||
List<Entity> entities = world.getOtherEntities(null, box);
|
||||
for (Entity entity : entities) {
|
||||
if (entity instanceof HostileEntity hostile) {
|
||||
if (hostile.isFireImmune()) {
|
||||
if (world instanceof ServerWorld serverWorld) {
|
||||
hostile.kill(serverWorld);
|
||||
}
|
||||
} else {
|
||||
hostile.setOnFireFor(90);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
world.getBlockTickScheduler().scheduleTick(OrderedTick.create(this, pos));
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onPlaced(World world, BlockPos pos, BlockState state, LivingEntity placer, ItemStack itemStack) {
|
||||
if (!world.isClient) {
|
||||
world.getBlockTickScheduler().scheduleTick(OrderedTick.create(this, pos));
|
||||
world.playSound(null, pos, SoundEvents.UI_TOAST_CHALLENGE_COMPLETE, SoundCategory.PLAYERS, 1f, 1f);
|
||||
}
|
||||
super.onPlaced(world, pos, state, placer, itemStack);
|
||||
}
|
||||
}
|
@ -0,0 +1,33 @@
|
||||
package de.jottyfan.quickiemod.block;
|
||||
|
||||
import java.util.Arrays;
|
||||
import java.util.List;
|
||||
|
||||
import de.jottyfan.quickiemod.block.help.IntProviderHelper;
|
||||
import de.jottyfan.quickiemod.item.ModItems;
|
||||
import net.minecraft.block.BlockState;
|
||||
import net.minecraft.block.ExperienceDroppingBlock;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.loot.context.LootWorldContext.Builder;
|
||||
import net.minecraft.registry.RegistryKey;
|
||||
import net.minecraft.registry.RegistryKeys;
|
||||
import net.minecraft.sound.BlockSoundGroup;
|
||||
import net.minecraft.util.Identifier;
|
||||
|
||||
/**
|
||||
*
|
||||
* @author jotty
|
||||
*
|
||||
*/
|
||||
public class BlockOreDeepslateSulphor extends ExperienceDroppingBlock {
|
||||
|
||||
public BlockOreDeepslateSulphor(Identifier identifier) {
|
||||
super(IntProviderHelper.of(0, 2), Settings.create().strength(2.5f).hardness(1.9f).sounds(BlockSoundGroup.SOUL_SAND)
|
||||
.requiresTool().registryKey(RegistryKey.of(RegistryKeys.BLOCK, identifier)));
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<ItemStack> getDroppedStacks(BlockState state, Builder builder) {
|
||||
return Arrays.asList(new ItemStack[] { new ItemStack(ModItems.ITEM_SULFOR, 4) });
|
||||
}
|
||||
}
|
@ -0,0 +1,33 @@
|
||||
package de.jottyfan.quickiemod.block;
|
||||
|
||||
import java.util.Arrays;
|
||||
import java.util.List;
|
||||
|
||||
import de.jottyfan.quickiemod.block.help.IntProviderHelper;
|
||||
import de.jottyfan.quickiemod.item.ModItems;
|
||||
import net.minecraft.block.BlockState;
|
||||
import net.minecraft.block.ExperienceDroppingBlock;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.loot.context.LootWorldContext.Builder;
|
||||
import net.minecraft.registry.RegistryKey;
|
||||
import net.minecraft.registry.RegistryKeys;
|
||||
import net.minecraft.sound.BlockSoundGroup;
|
||||
import net.minecraft.util.Identifier;
|
||||
|
||||
/**
|
||||
*
|
||||
* @author jotty
|
||||
*
|
||||
*/
|
||||
public class BlockOreNetherSulphor extends ExperienceDroppingBlock {
|
||||
|
||||
public BlockOreNetherSulphor(Identifier identifier) {
|
||||
super(IntProviderHelper.of(0, 2), Settings.create().strength(2.5f).hardness(2.1f).sounds(BlockSoundGroup.SOUL_SAND)
|
||||
.requiresTool().registryKey(RegistryKey.of(RegistryKeys.BLOCK, identifier)));
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<ItemStack> getDroppedStacks(BlockState state, Builder builder) {
|
||||
return Arrays.asList(new ItemStack[] { new ItemStack(ModItems.ITEM_SULFOR) });
|
||||
}
|
||||
}
|
@ -0,0 +1,34 @@
|
||||
package de.jottyfan.quickiemod.block;
|
||||
|
||||
import java.util.Arrays;
|
||||
import java.util.List;
|
||||
|
||||
import de.jottyfan.quickiemod.block.help.IntProviderHelper;
|
||||
import de.jottyfan.quickiemod.item.ModItems;
|
||||
import net.minecraft.block.BlockState;
|
||||
import net.minecraft.block.ExperienceDroppingBlock;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.loot.context.LootWorldContext.Builder;
|
||||
import net.minecraft.registry.RegistryKey;
|
||||
import net.minecraft.registry.RegistryKeys;
|
||||
import net.minecraft.sound.BlockSoundGroup;
|
||||
import net.minecraft.util.Identifier;
|
||||
import net.minecraft.util.math.random.Random;
|
||||
|
||||
/**
|
||||
*
|
||||
* @author jotty
|
||||
*
|
||||
*/
|
||||
public class BlockOreSalpeter extends ExperienceDroppingBlock {
|
||||
|
||||
public BlockOreSalpeter(Identifier identifier) {
|
||||
super(IntProviderHelper.of(0, 2), Settings.create().strength(2.5f).hardness(3.1f).sounds(BlockSoundGroup.SOUL_SAND)
|
||||
.requiresTool().registryKey(RegistryKey.of(RegistryKeys.BLOCK, identifier)));
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<ItemStack> getDroppedStacks(BlockState state, Builder builder) {
|
||||
return Arrays.asList(new ItemStack[] { new ItemStack(ModItems.ITEM_SALPETER, 2 + Random.create().nextInt(3)) });
|
||||
}
|
||||
}
|
@ -1,16 +1,19 @@
|
||||
package de.jottyfan.quickiemod.blocks;
|
||||
package de.jottyfan.quickiemod.block;
|
||||
|
||||
import java.util.Arrays;
|
||||
import java.util.List;
|
||||
|
||||
import de.jottyfan.quickiemod.blocks.help.IntProviderHelper;
|
||||
import de.jottyfan.quickiemod.items.QuickieItems;
|
||||
import de.jottyfan.quickiemod.block.help.IntProviderHelper;
|
||||
import de.jottyfan.quickiemod.item.ModItems;
|
||||
import net.minecraft.block.BlockState;
|
||||
import net.minecraft.block.Blocks;
|
||||
import net.minecraft.block.ExperienceDroppingBlock;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.loot.context.LootContextParameterSet.Builder;
|
||||
import net.minecraft.loot.context.LootWorldContext.Builder;
|
||||
import net.minecraft.registry.RegistryKey;
|
||||
import net.minecraft.registry.RegistryKeys;
|
||||
import net.minecraft.sound.BlockSoundGroup;
|
||||
import net.minecraft.util.Identifier;
|
||||
import net.minecraft.util.math.random.Random;
|
||||
|
||||
/**
|
||||
@ -20,12 +23,12 @@ import net.minecraft.util.math.random.Random;
|
||||
*/
|
||||
public class BlockOreSandSalpeter extends ExperienceDroppingBlock {
|
||||
|
||||
public BlockOreSandSalpeter() {
|
||||
super(IntProviderHelper.of(0, 2), Settings.create().strength(2.5f).hardness(2.9f).sounds(BlockSoundGroup.SOUL_SAND).requiresTool());
|
||||
public BlockOreSandSalpeter(Identifier identifier) {
|
||||
super(IntProviderHelper.of(0, 2), Settings.create().strength(2.5f).hardness(2.9f).sounds(BlockSoundGroup.SOUL_SAND).requiresTool().registryKey(RegistryKey.of(RegistryKeys.BLOCK, identifier)));
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<ItemStack> getDroppedStacks(BlockState state, Builder builder) {
|
||||
return Arrays.asList(new ItemStack[] { new ItemStack(QuickieItems.SALPETER.getItem(), 7 + Random.create().nextInt(4)), new ItemStack(Blocks.SAND) });
|
||||
return Arrays.asList(new ItemStack[] { new ItemStack(ModItems.ITEM_SALPETER, 7 + Random.create().nextInt(4)), new ItemStack(Blocks.SAND) });
|
||||
}
|
||||
}
|
@ -0,0 +1,33 @@
|
||||
package de.jottyfan.quickiemod.block;
|
||||
|
||||
import java.util.Arrays;
|
||||
import java.util.List;
|
||||
|
||||
import de.jottyfan.quickiemod.block.help.IntProviderHelper;
|
||||
import de.jottyfan.quickiemod.item.ModItems;
|
||||
import net.minecraft.block.BlockState;
|
||||
import net.minecraft.block.ExperienceDroppingBlock;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.loot.context.LootWorldContext.Builder;
|
||||
import net.minecraft.registry.RegistryKey;
|
||||
import net.minecraft.registry.RegistryKeys;
|
||||
import net.minecraft.sound.BlockSoundGroup;
|
||||
import net.minecraft.util.Identifier;
|
||||
|
||||
/**
|
||||
*
|
||||
* @author jotty
|
||||
*
|
||||
*/
|
||||
public class BlockOreSulphor extends ExperienceDroppingBlock {
|
||||
|
||||
public BlockOreSulphor(Identifier identifier) {
|
||||
super(IntProviderHelper.of(0, 2), Settings.create().strength(2.5f).hardness(1.9f).sounds(BlockSoundGroup.SOUL_SAND)
|
||||
.requiresTool().registryKey(RegistryKey.of(RegistryKeys.BLOCK, identifier)));
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<ItemStack> getDroppedStacks(BlockState state, Builder builder) {
|
||||
return Arrays.asList(new ItemStack[] { new ItemStack(ModItems.ITEM_SULFOR) });
|
||||
}
|
||||
}
|
@ -1,28 +1,41 @@
|
||||
package de.jottyfan.quickiemod.blocks;
|
||||
package de.jottyfan.quickiemod.block;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.Random;
|
||||
|
||||
import de.jottyfan.quickiemod.items.QuickieItems;
|
||||
import net.minecraft.block.AbstractBlock;
|
||||
import net.minecraft.block.BlockState;
|
||||
import net.minecraft.block.Blocks;
|
||||
import net.minecraft.block.CropBlock;
|
||||
import net.minecraft.entity.player.PlayerEntity;
|
||||
import net.minecraft.item.Item;
|
||||
import net.minecraft.item.ItemConvertible;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.loot.context.LootContextParameterSet.Builder;
|
||||
import net.minecraft.loot.context.LootWorldContext.Builder;
|
||||
import net.minecraft.registry.RegistryKey;
|
||||
import net.minecraft.registry.RegistryKeys;
|
||||
import net.minecraft.util.ActionResult;
|
||||
import net.minecraft.util.Identifier;
|
||||
import net.minecraft.util.ItemScatterer;
|
||||
import net.minecraft.util.collection.DefaultedList;
|
||||
import net.minecraft.util.hit.BlockHitResult;
|
||||
import net.minecraft.util.math.BlockPos;
|
||||
import net.minecraft.world.World;
|
||||
|
||||
public class BlockCottonplant extends CropBlock {
|
||||
/**
|
||||
*
|
||||
* @author jotty
|
||||
*
|
||||
*/
|
||||
public class BlockPlant extends CropBlock {
|
||||
|
||||
public BlockCottonplant() {
|
||||
super(AbstractBlock.Settings.copy(Blocks.WHEAT));
|
||||
private Item seed;
|
||||
private Item fruit;
|
||||
|
||||
public BlockPlant(Identifier identifier, Item seed, Item fruit) {
|
||||
super(AbstractBlock.Settings.copy(Blocks.WHEAT).registryKey(RegistryKey.of(RegistryKeys.BLOCK, identifier)));
|
||||
this.seed = seed;
|
||||
this.fruit = fruit;
|
||||
}
|
||||
|
||||
@Override
|
||||
@ -31,7 +44,7 @@ public class BlockCottonplant extends CropBlock {
|
||||
list.add(new ItemStack(getSeedsItem())); // the one from the seed
|
||||
if (isMature(state)) {
|
||||
list.add(new ItemStack(getSeedsItem(), new Random().nextInt(2)));
|
||||
list.add(new ItemStack(QuickieItems.COTTON.getItem(), new Random().nextFloat() > 0.9f ? 2 : 1));
|
||||
list.add(new ItemStack(fruit, new Random().nextFloat() > 0.9f ? 2 : 1));
|
||||
}
|
||||
return list;
|
||||
}
|
||||
@ -52,7 +65,7 @@ public class BlockCottonplant extends CropBlock {
|
||||
|
||||
@Override
|
||||
protected ItemConvertible getSeedsItem() {
|
||||
return QuickieItems.COTTONSEED.getItem();
|
||||
return seed;
|
||||
}
|
||||
|
||||
@Override
|
@ -1,16 +1,18 @@
|
||||
package de.jottyfan.quickiemod.blocks;
|
||||
package de.jottyfan.quickiemod.block;
|
||||
|
||||
import java.util.Arrays;
|
||||
import java.util.List;
|
||||
|
||||
import com.mojang.serialization.MapCodec;
|
||||
|
||||
import de.jottyfan.quickiemod.items.QuickieItems;
|
||||
import net.minecraft.block.AbstractBlock;
|
||||
import net.minecraft.block.BlockState;
|
||||
import net.minecraft.block.FallingBlock;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.loot.context.LootContextParameterSet.Builder;
|
||||
import net.minecraft.loot.context.LootWorldContext.Builder;
|
||||
import net.minecraft.registry.RegistryKey;
|
||||
import net.minecraft.registry.RegistryKeys;
|
||||
import net.minecraft.util.Identifier;
|
||||
import net.minecraft.world.explosion.Explosion;
|
||||
|
||||
/**
|
||||
@ -18,15 +20,18 @@ import net.minecraft.world.explosion.Explosion;
|
||||
* @author jotty
|
||||
*
|
||||
*/
|
||||
public class BlockQuickiepowder extends FallingBlock {
|
||||
public class BlockPowder extends FallingBlock {
|
||||
|
||||
public BlockQuickiepowder() {
|
||||
super(AbstractBlock.Settings.create().luminance(state -> 12));
|
||||
private final ItemStack[] drops;
|
||||
|
||||
public BlockPowder(Identifier identifier, ItemStack[] drops) {
|
||||
super(AbstractBlock.Settings.create().luminance(state -> 12).registryKey(RegistryKey.of(RegistryKeys.BLOCK, identifier)));
|
||||
this.drops = drops;
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<ItemStack> getDroppedStacks(BlockState state, Builder builder) {
|
||||
return Arrays.asList(new ItemStack[] { new ItemStack(QuickieItems.QUICKIEPOWDER.getItem(), 9) });
|
||||
return Arrays.asList(drops);
|
||||
}
|
||||
|
||||
@Override
|
@ -1,17 +1,20 @@
|
||||
package de.jottyfan.quickiemod.blocks;
|
||||
package de.jottyfan.quickiemod.block;
|
||||
|
||||
import java.util.Arrays;
|
||||
import java.util.List;
|
||||
|
||||
import com.mojang.serialization.MapCodec;
|
||||
|
||||
import de.jottyfan.quickiemod.items.QuickieItems;
|
||||
import de.jottyfan.quickiemod.item.ModItems;
|
||||
import net.minecraft.block.BlockState;
|
||||
import net.minecraft.block.Blocks;
|
||||
import net.minecraft.block.FallingBlock;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.loot.context.LootContextParameterSet.Builder;
|
||||
import net.minecraft.loot.context.LootWorldContext.Builder;
|
||||
import net.minecraft.registry.RegistryKey;
|
||||
import net.minecraft.registry.RegistryKeys;
|
||||
import net.minecraft.sound.BlockSoundGroup;
|
||||
import net.minecraft.util.Identifier;
|
||||
import net.minecraft.util.math.random.Random;
|
||||
|
||||
/**
|
||||
@ -21,13 +24,15 @@ import net.minecraft.util.math.random.Random;
|
||||
*/
|
||||
public class BlockSandSalpeter extends FallingBlock {
|
||||
|
||||
public BlockSandSalpeter() {
|
||||
super(Settings.create().strength(2.5f).hardness(3.1f).sounds(BlockSoundGroup.SOUL_SAND).requiresTool());
|
||||
public BlockSandSalpeter(Identifier identifier) {
|
||||
super(Settings.create().strength(2.5f).hardness(3.1f).sounds(BlockSoundGroup.SOUL_SAND).requiresTool()
|
||||
.registryKey(RegistryKey.of(RegistryKeys.BLOCK, identifier)));
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<ItemStack> getDroppedStacks(BlockState state, Builder builder) {
|
||||
return Arrays.asList(new ItemStack[] { new ItemStack(QuickieItems.SALPETER.getItem(), 3 + Random.create().nextInt(2)), new ItemStack(Blocks.SAND) });
|
||||
return Arrays.asList(new ItemStack[] { new ItemStack(ModItems.ITEM_SALPETER, 3 + Random.create().nextInt(2)),
|
||||
new ItemStack(Blocks.SAND) });
|
||||
}
|
||||
|
||||
@Override
|
@ -0,0 +1,22 @@
|
||||
package de.jottyfan.quickiemod.block;
|
||||
|
||||
import net.minecraft.block.AbstractBlock;
|
||||
import net.minecraft.block.Block;
|
||||
import net.minecraft.registry.RegistryKey;
|
||||
import net.minecraft.registry.RegistryKeys;
|
||||
import net.minecraft.sound.BlockSoundGroup;
|
||||
import net.minecraft.util.Identifier;
|
||||
|
||||
/**
|
||||
*
|
||||
* @author jotty
|
||||
*
|
||||
*/
|
||||
public class BlockSlippery extends Block {
|
||||
|
||||
public BlockSlippery(Identifier identifier, float hardness, float slipperiness, BlockSoundGroup soundGroup) {
|
||||
super(AbstractBlock.Settings.create().hardness(hardness).slipperiness(slipperiness).breakInstantly()
|
||||
.sounds(soundGroup).registryKey(RegistryKey.of(RegistryKeys.BLOCK, identifier)));
|
||||
}
|
||||
|
||||
}
|
@ -1,13 +1,11 @@
|
||||
package de.jottyfan.quickiemod.blocks;
|
||||
|
||||
import java.util.List;
|
||||
package de.jottyfan.quickiemod.block;
|
||||
|
||||
import com.mojang.serialization.MapCodec;
|
||||
|
||||
import de.jottyfan.quickiemod.blockentity.BlockEntityTypes;
|
||||
import de.jottyfan.quickiemod.blockentity.BlockStackerEntity;
|
||||
import de.jottyfan.quickiemod.blocks.help.BlockStacker;
|
||||
import de.jottyfan.quickiemod.blockentity.ModBlockentity;
|
||||
import net.minecraft.block.AbstractBlock;
|
||||
import net.minecraft.block.BlockEntityProvider;
|
||||
import net.minecraft.block.BlockRenderType;
|
||||
import net.minecraft.block.BlockState;
|
||||
import net.minecraft.block.BlockWithEntity;
|
||||
@ -15,11 +13,11 @@ import net.minecraft.block.entity.BlockEntity;
|
||||
import net.minecraft.block.entity.BlockEntityTicker;
|
||||
import net.minecraft.block.entity.BlockEntityType;
|
||||
import net.minecraft.entity.player.PlayerEntity;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.loot.context.LootContextParameterSet.Builder;
|
||||
import net.minecraft.screen.NamedScreenHandlerFactory;
|
||||
import net.minecraft.registry.RegistryKey;
|
||||
import net.minecraft.registry.RegistryKeys;
|
||||
import net.minecraft.screen.ScreenHandler;
|
||||
import net.minecraft.util.ActionResult;
|
||||
import net.minecraft.util.Identifier;
|
||||
import net.minecraft.util.ItemScatterer;
|
||||
import net.minecraft.util.hit.BlockHitResult;
|
||||
import net.minecraft.util.math.BlockPos;
|
||||
@ -31,20 +29,38 @@ import net.minecraft.world.World;
|
||||
* @author jotty
|
||||
*
|
||||
*/
|
||||
public class BlockStackerDown extends BlockWithEntity implements BlockStacker {
|
||||
public class BlockStacker extends BlockWithEntity implements BlockEntityProvider {
|
||||
|
||||
public BlockStackerDown() {
|
||||
super(AbstractBlock.Settings.create().hardness(2.5f));
|
||||
private final Direction source;
|
||||
private final Direction dest;
|
||||
|
||||
public BlockStacker(Identifier identifier, Direction source, Direction dest) {
|
||||
super(AbstractBlock.Settings.create().hardness(2.5f).registryKey(RegistryKey.of(RegistryKeys.BLOCK, identifier)));
|
||||
this.source = source;
|
||||
this.dest = dest;
|
||||
}
|
||||
|
||||
@Override
|
||||
public BlockRenderType getRenderType(BlockState state) {
|
||||
return BlockRenderType.MODEL;
|
||||
}
|
||||
|
||||
/**
|
||||
* define the source offset
|
||||
*
|
||||
* @return the direction of the source offset (1 block beside)
|
||||
*/
|
||||
public Direction getSourceOffset() {
|
||||
return Direction.UP;
|
||||
return source;
|
||||
}
|
||||
|
||||
@Override
|
||||
/**
|
||||
* define the dest offset
|
||||
*
|
||||
* @return the direction of the dest offset (1 block beside)
|
||||
*/
|
||||
public Direction getDestOffset() {
|
||||
return Direction.DOWN;
|
||||
return dest;
|
||||
}
|
||||
|
||||
@Override
|
||||
@ -53,19 +69,15 @@ public class BlockStackerDown extends BlockWithEntity implements BlockStacker {
|
||||
}
|
||||
|
||||
@Override
|
||||
public BlockRenderType getRenderType(BlockState state) {
|
||||
return BlockRenderType.MODEL;
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<ItemStack> getDroppedStacks(BlockState state, Builder builder) {
|
||||
return List.of(new ItemStack(QuickieBlocks.BLOCKSTACKERDOWN.getBlock()));
|
||||
protected MapCodec<? extends BlockWithEntity> getCodec() {
|
||||
// TODO Auto-generated method stub
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public <T extends BlockEntity> BlockEntityTicker<T> getTicker(World world, BlockState state,
|
||||
BlockEntityType<T> type) {
|
||||
return validateTicker(type, BlockEntityTypes.BLOCKSTACKER_ENTITY,
|
||||
return validateTicker(type, ModBlockentity.BLOCKSTACKER_BLOCKENTITY,
|
||||
(world1, pos, state1, be) -> BlockStackerEntity.tick(world1, pos, state1, be));
|
||||
}
|
||||
|
||||
@ -102,10 +114,4 @@ public class BlockStackerDown extends BlockWithEntity implements BlockStacker {
|
||||
public int getComparatorOutput(BlockState state, World world, BlockPos pos) {
|
||||
return ScreenHandler.calculateComparatorOutput(world.getBlockEntity(pos));
|
||||
}
|
||||
|
||||
@Override
|
||||
protected MapCodec<? extends BlockWithEntity> getCodec() {
|
||||
// TODO Auto-generated method stub
|
||||
return null;
|
||||
}
|
||||
}
|
132
src/main/java/de/jottyfan/quickiemod/block/ModBlocks.java
Normal file
132
src/main/java/de/jottyfan/quickiemod/block/ModBlocks.java
Normal file
@ -0,0 +1,132 @@
|
||||
package de.jottyfan.quickiemod.block;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
import de.jottyfan.quickiemod.Quickiemod;
|
||||
import de.jottyfan.quickiemod.identifier.ModIdentifiers;
|
||||
import de.jottyfan.quickiemod.item.ModItems;
|
||||
import net.minecraft.block.Block;
|
||||
import net.minecraft.item.BlockItem;
|
||||
import net.minecraft.item.Item;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.registry.Registries;
|
||||
import net.minecraft.registry.Registry;
|
||||
import net.minecraft.registry.RegistryKey;
|
||||
import net.minecraft.registry.RegistryKeys;
|
||||
import net.minecraft.sound.BlockSoundGroup;
|
||||
import net.minecraft.util.Identifier;
|
||||
import net.minecraft.util.math.Direction;
|
||||
|
||||
/**
|
||||
*
|
||||
* @author jotty
|
||||
*
|
||||
*/
|
||||
public class ModBlocks {
|
||||
|
||||
public static final Block BLOCK_QUICKIEPOWDER = registerBlock(ModIdentifiers.BLOCK_QUICKIEPOWDER, new BlockPowder(
|
||||
ModIdentifiers.BLOCK_QUICKIEPOWDER, new ItemStack[] { new ItemStack(ModItems.ITEM_QUICKIEPOWDER, 9) }));
|
||||
public static final Block BLOCK_SPEEDPOWDER = registerBlock(ModIdentifiers.BLOCK_SPEEDPOWDER, new BlockPowder(
|
||||
ModIdentifiers.BLOCK_SPEEDPOWDER, new ItemStack[] { new ItemStack(ModItems.ITEM_SPEEDPOWDER, 9) }));
|
||||
public static final Block BLOCK_SALPETER = registerBlock(ModIdentifiers.BLOCK_SALPETER, new BlockBreakByTool(
|
||||
ModIdentifiers.BLOCK_SALPETER, 1.5f, 1.5f, new ItemStack[] { new ItemStack(ModItems.ITEM_SALPETER, 9) }));
|
||||
public static final Block BLOCK_SULFOR = registerBlock(ModIdentifiers.BLOCK_SULFOR, new BlockBreakByTool(
|
||||
ModIdentifiers.BLOCK_SULFOR, 1.5f, 1.5f, new ItemStack[] { new ItemStack(ModItems.ITEM_SULFOR, 9) }));
|
||||
public static final Block BLOCK_MONSTERHOARDER = registerBlock(ModIdentifiers.BLOCK_MONSTERHOARDER,
|
||||
new BlockMonsterhoarder(ModIdentifiers.BLOCK_MONSTERHOARDER));
|
||||
public static final Block BLOCK_LAVAHOARDER = registerBlock(ModIdentifiers.BLOCK_LAVAHOARDER,
|
||||
new BlockLavahoarder(ModIdentifiers.BLOCK_LAVAHOARDER));
|
||||
public static final Block BLOCK_EMPTYLAVAHOARDER = registerBlock(ModIdentifiers.BLOCK_EMPTYLAVAHOARDER,
|
||||
new BlockEmptyLavahoarder(ModIdentifiers.BLOCK_EMPTYLAVAHOARDER));
|
||||
public static final Block BLOCK_ITEMHOARDER = registerBlock(ModIdentifiers.BLOCK_ITEMHOARDER,
|
||||
new BlockItemhoarder(ModIdentifiers.BLOCK_ITEMHOARDER));
|
||||
public static final Block BLOCK_DIRTSALPETER = registerBlock(ModIdentifiers.BLOCK_DIRTSALPETER,
|
||||
new BlockDirtSalpeter(ModIdentifiers.BLOCK_DIRTSALPETER));
|
||||
public static final Block BLOCK_OREDEEPSLATESULFOR = registerBlock(ModIdentifiers.BLOCK_OREDEEPSLATESULFOR,
|
||||
new BlockOreDeepslateSulphor(ModIdentifiers.BLOCK_OREDEEPSLATESULFOR));
|
||||
public static final Block BLOCK_ORENETHERSULFOR = registerBlock(ModIdentifiers.BLOCK_ORENETHERSULFOR,
|
||||
new BlockOreNetherSulphor(ModIdentifiers.BLOCK_ORENETHERSULFOR));
|
||||
public static final Block BLOCK_ORESALPETER = registerBlock(ModIdentifiers.BLOCK_ORESALPETER,
|
||||
new BlockOreSalpeter(ModIdentifiers.BLOCK_ORESALPETER));
|
||||
public static final Block BLOCK_ORESANDSALPETER = registerBlock(ModIdentifiers.BLOCK_ORESANDSALPETER,
|
||||
new BlockOreSandSalpeter(ModIdentifiers.BLOCK_ORESANDSALPETER));
|
||||
public static final Block BLOCK_ORESULFOR = registerBlock(ModIdentifiers.BLOCK_ORESULFOR,
|
||||
new BlockOreSulphor(ModIdentifiers.BLOCK_ORESULFOR));
|
||||
public static final Block BLOCK_SANDSALPETER = registerBlock(ModIdentifiers.BLOCK_SANDSALPETER,
|
||||
new BlockSandSalpeter(ModIdentifiers.BLOCK_SANDSALPETER));
|
||||
public static final Block BLOCK_KELPSTACK = registerBlock(ModIdentifiers.BLOCK_KELPSTACK,
|
||||
new BlockSlippery(ModIdentifiers.BLOCK_KELPSTACK, 0.1f, 1.0f, BlockSoundGroup.WET_GRASS));
|
||||
public static final Block BLOCK_COTTONPLANT = registerBlock(ModIdentifiers.BLOCK_COTTONPLANT,
|
||||
new BlockPlant(ModIdentifiers.BLOCK_COTTONPLANT, ModItems.ITEM_COTTONSEED, ModItems.ITEM_COTTON), false);
|
||||
public static final Block BLOCK_CANOLAPLANT = registerBlock(ModIdentifiers.BLOCK_CANOLAPLANT,
|
||||
new BlockPlant(ModIdentifiers.BLOCK_CANOLAPLANT, ModItems.ITEM_CANOLASEED, ModItems.ITEM_CANOLA), false);
|
||||
public static final Block BLOCK_DRILL_DOWN = registerBlock(ModIdentifiers.BLOCK_DRILLDOWN,
|
||||
new BlockDrill(ModIdentifiers.BLOCK_DRILLDOWN, Direction.DOWN));
|
||||
public static final Block BLOCK_DRILL_EAST = registerBlock(ModIdentifiers.BLOCK_DRILLEAST,
|
||||
new BlockDrill(ModIdentifiers.BLOCK_DRILLEAST, Direction.EAST));
|
||||
public static final Block BLOCK_DRILL_SOUTH = registerBlock(ModIdentifiers.BLOCK_DRILLSOUTH,
|
||||
new BlockDrill(ModIdentifiers.BLOCK_DRILLSOUTH, Direction.SOUTH));
|
||||
public static final Block BLOCK_DRILL_WEST = registerBlock(ModIdentifiers.BLOCK_DRILLWEST,
|
||||
new BlockDrill(ModIdentifiers.BLOCK_DRILLWEST, Direction.WEST));
|
||||
public static final Block BLOCK_DRILL_NORTH = registerBlock(ModIdentifiers.BLOCK_DRILLNORTH,
|
||||
new BlockDrill(ModIdentifiers.BLOCK_DRILLNORTH, Direction.NORTH));
|
||||
public static final Block BLOCK_STACKER_DOWN = registerBlock(ModIdentifiers.BLOCK_STACKERDOWN,
|
||||
new BlockStacker(ModIdentifiers.BLOCK_STACKERDOWN, Direction.UP, Direction.DOWN));
|
||||
public static final Block BLOCK_STACKER_EAST = registerBlock(ModIdentifiers.BLOCK_STACKEREAST,
|
||||
new BlockStacker(ModIdentifiers.BLOCK_STACKEREAST, Direction.WEST, Direction.EAST));
|
||||
public static final Block BLOCK_STACKER_SOUTH = registerBlock(ModIdentifiers.BLOCK_STACKERSOUTH,
|
||||
new BlockStacker(ModIdentifiers.BLOCK_STACKERSOUTH, Direction.NORTH, Direction.SOUTH));
|
||||
public static final Block BLOCK_STACKER_WEST = registerBlock(ModIdentifiers.BLOCK_STACKERWEST,
|
||||
new BlockStacker(ModIdentifiers.BLOCK_STACKERWEST, Direction.EAST, Direction.WEST));
|
||||
public static final Block BLOCK_STACKER_NORTH = registerBlock(ModIdentifiers.BLOCK_STACKERNORTH,
|
||||
new BlockStacker(ModIdentifiers.BLOCK_STACKERNORTH, Direction.SOUTH, Direction.NORTH));
|
||||
public static final Block BLOCK_STACKER_UP = registerBlock(ModIdentifiers.BLOCK_STACKERUP,
|
||||
new BlockStacker(ModIdentifiers.BLOCK_STACKERUP, Direction.DOWN, Direction.UP));
|
||||
|
||||
private static final Block registerBlock(Identifier identifier, Block block) {
|
||||
return registerBlock(identifier, block, true);
|
||||
}
|
||||
|
||||
private static final Block registerBlock(Identifier identifier, Block block, boolean registerAsItem) {
|
||||
if (registerAsItem) {
|
||||
Registry.register(Registries.ITEM, identifier, new BlockItem(block, new Item.Settings()
|
||||
.registryKey(RegistryKey.of(RegistryKeys.ITEM, identifier)).useBlockPrefixedTranslationKey()));
|
||||
}
|
||||
return Registry.register(Registries.BLOCK, identifier, block);
|
||||
}
|
||||
|
||||
public static final List<Block> registerModBlocks() {
|
||||
Quickiemod.LOGGER.info(String.format("registering blocks for %s", Quickiemod.MOD_ID));
|
||||
|
||||
List<Block> blocks = new ArrayList<>();
|
||||
blocks.add(BLOCK_QUICKIEPOWDER);
|
||||
blocks.add(BLOCK_SPEEDPOWDER);
|
||||
blocks.add(BLOCK_SALPETER);
|
||||
blocks.add(BLOCK_SULFOR);
|
||||
blocks.add(BLOCK_MONSTERHOARDER);
|
||||
blocks.add(BLOCK_EMPTYLAVAHOARDER);
|
||||
blocks.add(BLOCK_LAVAHOARDER);
|
||||
blocks.add(BLOCK_ITEMHOARDER);
|
||||
blocks.add(BLOCK_DIRTSALPETER);
|
||||
blocks.add(BLOCK_OREDEEPSLATESULFOR);
|
||||
blocks.add(BLOCK_ORENETHERSULFOR);
|
||||
blocks.add(BLOCK_ORESALPETER);
|
||||
blocks.add(BLOCK_ORESANDSALPETER);
|
||||
blocks.add(BLOCK_ORESULFOR);
|
||||
blocks.add(BLOCK_SANDSALPETER);
|
||||
blocks.add(BLOCK_KELPSTACK);
|
||||
blocks.add(BLOCK_DRILL_DOWN);
|
||||
blocks.add(BLOCK_DRILL_EAST);
|
||||
blocks.add(BLOCK_DRILL_SOUTH);
|
||||
blocks.add(BLOCK_DRILL_WEST);
|
||||
blocks.add(BLOCK_DRILL_NORTH);
|
||||
blocks.add(BLOCK_STACKER_DOWN);
|
||||
blocks.add(BLOCK_STACKER_EAST);
|
||||
blocks.add(BLOCK_STACKER_SOUTH);
|
||||
blocks.add(BLOCK_STACKER_WEST);
|
||||
blocks.add(BLOCK_STACKER_NORTH);
|
||||
blocks.add(BLOCK_STACKER_UP);
|
||||
return blocks;
|
||||
}
|
||||
}
|
@ -0,0 +1,16 @@
|
||||
package de.jottyfan.quickiemod.block;
|
||||
|
||||
import net.minecraft.util.Identifier;
|
||||
|
||||
/**
|
||||
*
|
||||
* @author jotty
|
||||
*
|
||||
*/
|
||||
public class StandardBlock extends AbstractIdentifiedBlock {
|
||||
|
||||
public StandardBlock(Identifier identifier) {
|
||||
super(identifier);
|
||||
}
|
||||
|
||||
}
|
@ -1,4 +1,4 @@
|
||||
package de.jottyfan.quickiemod.blocks.help;
|
||||
package de.jottyfan.quickiemod.block.help;
|
||||
|
||||
import net.minecraft.util.math.intprovider.IntProvider;
|
||||
import net.minecraft.util.math.intprovider.IntProviderType;
|
@ -1,37 +0,0 @@
|
||||
package de.jottyfan.quickiemod.blockentity;
|
||||
|
||||
import de.jottyfan.quickiemod.blocks.QuickieBlocks;
|
||||
import de.jottyfan.quickiemod.init.BlockEntityIdentity;
|
||||
import net.minecraft.block.entity.BlockEntityType;
|
||||
import net.minecraft.registry.Registries;
|
||||
import net.minecraft.registry.Registry;
|
||||
|
||||
/**
|
||||
*
|
||||
* @author jotty
|
||||
*
|
||||
*/
|
||||
public class BlockEntityTypes {
|
||||
public static final BlockEntityType<EmptyLavaHoarderBlockEntity> EMPTYLAVAHOARDER = Registry.register(Registries.BLOCK_ENTITY_TYPE,
|
||||
BlockEntityIdentity.EMPTYLAVALHOARDER, BlockEntityType.Builder
|
||||
.create(EmptyLavaHoarderBlockEntity::new, QuickieBlocks.EMPTYLAVAHOARDER.getBlock(), QuickieBlocks.LAVAHOARDER.getBlock()).build(null));
|
||||
public static final BlockEntityType<ItemHoarderBlockEntity> ITEMHOARDER = Registry.register(Registries.BLOCK_ENTITY_TYPE, BlockEntityIdentity.ITEMHOARDER,
|
||||
BlockEntityType.Builder.create(ItemHoarderBlockEntity::new, QuickieBlocks.ITEMHOARDER.getBlock()).build(null));
|
||||
public static final BlockEntityType<MonsterHoarderBlockEntity> MONSTERHOARDER = Registry.register(Registries.BLOCK_ENTITY_TYPE,
|
||||
BlockEntityIdentity.MONSTERHOARDER, BlockEntityType.Builder.create(MonsterHoarderBlockEntity::new, QuickieBlocks.MONSTERHOARDER.getBlock()).build(null));
|
||||
public static final BlockEntityType<DrillBlockDownEntity> DRILL_DOWN = Registry.register(Registries.BLOCK_ENTITY_TYPE, BlockEntityIdentity.DRILL_DOWN,
|
||||
BlockEntityType.Builder.create(DrillBlockDownEntity::new, QuickieBlocks.DRILL_DOWN.getBlock()).build(null));
|
||||
public static final BlockEntityType<DrillBlockEastEntity> DRILL_EAST = Registry.register(Registries.BLOCK_ENTITY_TYPE, BlockEntityIdentity.DRILL_EAST,
|
||||
BlockEntityType.Builder.create(DrillBlockEastEntity::new, QuickieBlocks.DRILL_EAST.getBlock()).build(null));
|
||||
public static final BlockEntityType<DrillBlockSouthEntity> DRILL_SOUTH = Registry.register(Registries.BLOCK_ENTITY_TYPE, BlockEntityIdentity.DRILL_SOUTH,
|
||||
BlockEntityType.Builder.create(DrillBlockSouthEntity::new, QuickieBlocks.DRILL_SOUTH.getBlock()).build(null));
|
||||
public static final BlockEntityType<DrillBlockWestEntity> DRILL_WEST = Registry.register(Registries.BLOCK_ENTITY_TYPE, BlockEntityIdentity.DRILL_WEST,
|
||||
BlockEntityType.Builder.create(DrillBlockWestEntity::new, QuickieBlocks.DRILL_WEST.getBlock()).build(null));
|
||||
public static final BlockEntityType<DrillBlockNorthEntity> DRILL_NORTH = Registry.register(Registries.BLOCK_ENTITY_TYPE, BlockEntityIdentity.DRILL_NORTH,
|
||||
BlockEntityType.Builder.create(DrillBlockNorthEntity::new, QuickieBlocks.DRILL_NORTH.getBlock()).build(null));
|
||||
public static final BlockEntityType<BlockStackerEntity> BLOCKSTACKER_ENTITY = Registry.register(Registries.BLOCK_ENTITY_TYPE,
|
||||
BlockEntityIdentity.BLOCKSTACKERUP,
|
||||
BlockEntityType.Builder.create(BlockStackerEntity::new, QuickieBlocks.BLOCKSTACKERUP.getBlock(), QuickieBlocks.BLOCKSTACKERDOWN.getBlock(),
|
||||
QuickieBlocks.BLOCKSTACKEREAST.getBlock(), QuickieBlocks.BLOCKSTACKERWEST.getBlock(), QuickieBlocks.BLOCKSTACKERNORTH.getBlock(),
|
||||
QuickieBlocks.BLOCKSTACKERSOUTH.getBlock()).build(null));
|
||||
}
|
@ -1,64 +0,0 @@
|
||||
package de.jottyfan.quickiemod.blockentity;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
import de.jottyfan.quickiemod.blocks.QuickieBlocks;
|
||||
import net.minecraft.block.AbstractBlock;
|
||||
import net.minecraft.block.Block;
|
||||
import net.minecraft.block.BlockEntityProvider;
|
||||
import net.minecraft.block.BlockRenderType;
|
||||
import net.minecraft.block.BlockState;
|
||||
import net.minecraft.block.entity.BlockEntity;
|
||||
import net.minecraft.block.entity.BlockEntityTicker;
|
||||
import net.minecraft.block.entity.BlockEntityType;
|
||||
import net.minecraft.entity.LivingEntity;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.loot.context.LootContextParameterSet.Builder;
|
||||
import net.minecraft.sound.SoundCategory;
|
||||
import net.minecraft.sound.SoundEvents;
|
||||
import net.minecraft.util.math.BlockPos;
|
||||
import net.minecraft.world.World;
|
||||
|
||||
/**
|
||||
*
|
||||
* @author jotty
|
||||
*
|
||||
*/
|
||||
public class BlockMonsterhoarder extends Block implements BlockEntityProvider {
|
||||
|
||||
|
||||
public BlockMonsterhoarder() {
|
||||
super(AbstractBlock.Settings.create().hardness(2.5f).luminance(state -> 15));
|
||||
}
|
||||
|
||||
@Override
|
||||
public BlockEntity createBlockEntity(BlockPos pos, BlockState blockState) {
|
||||
return new MonsterHoarderBlockEntity(pos, blockState);
|
||||
}
|
||||
|
||||
@Override
|
||||
public BlockRenderType getRenderType(BlockState state) {
|
||||
return BlockRenderType.MODEL;
|
||||
}
|
||||
|
||||
@Override
|
||||
public <T extends BlockEntity> BlockEntityTicker<T> getTicker(World world, BlockState state, BlockEntityType<T> type){
|
||||
return (world1, pos, state1, be) -> MonsterHoarderBlockEntity.tick(world1, pos, state1, be);
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<ItemStack> getDroppedStacks(BlockState state, Builder builder) {
|
||||
List<ItemStack> list = new ArrayList<>();
|
||||
list.add(new ItemStack(QuickieBlocks.MONSTERHOARDER.getBlock()));
|
||||
return list;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onPlaced(World world, BlockPos pos, BlockState state, LivingEntity placer, ItemStack itemStack) {
|
||||
if (!world.isClient) {
|
||||
world.playSound(null, pos, SoundEvents.UI_TOAST_CHALLENGE_COMPLETE, SoundCategory.PLAYERS, 1f, 1f);
|
||||
}
|
||||
super.onPlaced(world, pos, state, placer, itemStack);
|
||||
}
|
||||
}
|
@ -3,11 +3,8 @@ package de.jottyfan.quickiemod.blockentity;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
|
||||
import de.jottyfan.quickiemod.QuickieMod;
|
||||
import de.jottyfan.quickiemod.blocks.help.BlockStacker;
|
||||
import de.jottyfan.quickiemod.Quickiemod;
|
||||
import de.jottyfan.quickiemod.block.BlockStacker;
|
||||
import de.jottyfan.quickiemod.container.BlockStackerScreenHandler;
|
||||
import de.jottyfan.quickiemod.container.ImplementedInventory;
|
||||
import net.minecraft.block.BlockState;
|
||||
@ -34,12 +31,11 @@ import net.minecraft.world.World;
|
||||
*
|
||||
*/
|
||||
public class BlockStackerEntity extends BlockEntity implements NamedScreenHandlerFactory, ImplementedInventory {
|
||||
private static final Logger LOGGER = LoggerFactory.getLogger(QuickieMod.MODID);
|
||||
|
||||
private final DefaultedList<ItemStack> inventory = DefaultedList.ofSize(BlockStackerScreenHandler.SLOTSIZE, ItemStack.EMPTY);
|
||||
|
||||
public BlockStackerEntity(BlockPos blockPos, BlockState blockState) {
|
||||
super(BlockEntityTypes.BLOCKSTACKER_ENTITY, blockPos, blockState);
|
||||
super(ModBlockentity.BLOCKSTACKER_BLOCKENTITY, blockPos, blockState);
|
||||
}
|
||||
|
||||
@Override
|
||||
@ -165,7 +161,7 @@ public class BlockStackerEntity extends BlockEntity implements NamedScreenHandle
|
||||
Integer candidates = source.getStack(sourceSlot).getCount();
|
||||
Integer travellers = candidates > free ? free : candidates;
|
||||
if (travellers > 0) {
|
||||
LOGGER.debug("transfer {}/{} of {} from slot {} to slot {} on top of {} ones", travellers, candidates,
|
||||
Quickiemod.LOGGER.debug("transfer {}/{} of {} from slot {} to slot {} on top of {} ones", travellers, candidates,
|
||||
source.getStack(sourceSlot).getItem().toString(), sourceSlot, destSlot, occupied);
|
||||
source.getStack(sourceSlot).decrement(travellers);
|
||||
if (source.getStack(sourceSlot).getCount() < 1) {
|
||||
@ -177,7 +173,7 @@ public class BlockStackerEntity extends BlockEntity implements NamedScreenHandle
|
||||
} else {
|
||||
Integer destFreeSlot = findItemStackPos(dest, true);
|
||||
if (destFreeSlot != null) {
|
||||
LOGGER.debug("transfer all of {} from slot {} to slot {}", source.getStack(sourceSlot).getItem().toString(),
|
||||
Quickiemod.LOGGER.debug("transfer all of {} from slot {} to slot {}", source.getStack(sourceSlot).getItem().toString(),
|
||||
sourceSlot, destSlot);
|
||||
dest.setStack(destFreeSlot, source.removeStack(sourceSlot));
|
||||
result = true;
|
||||
@ -236,7 +232,7 @@ public class BlockStackerEntity extends BlockEntity implements NamedScreenHandle
|
||||
private static final Integer findItemStackPos(LootableContainerBlockEntity lcbe, List<Item> filterItems, Boolean whitelist) {
|
||||
if (whitelist == null) {
|
||||
whitelist = true;
|
||||
LOGGER.error("whitelist is null");
|
||||
Quickiemod.LOGGER.error("whitelist is null");
|
||||
}
|
||||
if (filterItems == null || filterItems.size() < 1) {
|
||||
if (whitelist) {
|
||||
|
@ -1,62 +0,0 @@
|
||||
package de.jottyfan.quickiemod.blockentity;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
import net.minecraft.block.BlockState;
|
||||
import net.minecraft.block.entity.BlockEntity;
|
||||
import net.minecraft.util.math.BlockPos;
|
||||
import net.minecraft.world.World;
|
||||
|
||||
/**
|
||||
*
|
||||
* @author jotty
|
||||
*
|
||||
*/
|
||||
public class DrillBlockDownEntity extends DrillBlockEntity {
|
||||
|
||||
private static final Integer MAXDRILLSTEP = 20;
|
||||
|
||||
public DrillBlockDownEntity(BlockPos pos, BlockState state) {
|
||||
super(BlockEntityTypes.DRILL_DOWN, pos, state, MAXDRILLSTEP);
|
||||
}
|
||||
|
||||
public static void tick(World world, BlockPos pos, BlockState state, BlockEntity be) {
|
||||
if (be instanceof DrillBlockDownEntity) {
|
||||
DrillBlockDownEntity dbe = (DrillBlockDownEntity) be;
|
||||
DrillBlockEntity.tick(world, pos, state, dbe, MAXDRILLSTEP, generateBlockPos(pos));
|
||||
}
|
||||
}
|
||||
|
||||
public static final List<BlockPos> generateBlockPos(BlockPos pos) {
|
||||
List<BlockPos> list = new ArrayList<>();
|
||||
Integer tracesMod = pos.getY() % 8;
|
||||
tracesMod = tracesMod < 0 ? tracesMod * -1 : tracesMod; // lower that 0 makes it negative
|
||||
if (tracesMod != 0) {
|
||||
list.add(pos.north());
|
||||
}
|
||||
if (tracesMod != 1) {
|
||||
list.add(pos.north().west());
|
||||
}
|
||||
if (tracesMod != 2) {
|
||||
list.add(pos.west());
|
||||
}
|
||||
if (tracesMod != 3) {
|
||||
list.add(pos.south().west());
|
||||
}
|
||||
if (tracesMod != 4) {
|
||||
list.add(pos.south());
|
||||
}
|
||||
if (tracesMod != 5) {
|
||||
list.add(pos.south().east());
|
||||
}
|
||||
if (tracesMod != 6) {
|
||||
list.add(pos.east());
|
||||
}
|
||||
if (tracesMod != 7) {
|
||||
list.add(pos.north().east());
|
||||
}
|
||||
list.add(pos.down()); // must be last position
|
||||
return list;
|
||||
}
|
||||
}
|
@ -1,36 +0,0 @@
|
||||
package de.jottyfan.quickiemod.blockentity;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
import net.minecraft.block.BlockState;
|
||||
import net.minecraft.block.entity.BlockEntity;
|
||||
import net.minecraft.util.math.BlockPos;
|
||||
import net.minecraft.world.World;
|
||||
|
||||
/**
|
||||
*
|
||||
* @author jotty
|
||||
*
|
||||
*/
|
||||
public class DrillBlockEastEntity extends DrillBlockEntity {
|
||||
|
||||
private static final Integer MAXDRILLSTEP = 24;
|
||||
|
||||
public DrillBlockEastEntity(BlockPos pos, BlockState state) {
|
||||
super(BlockEntityTypes.DRILL_EAST, pos, state, MAXDRILLSTEP);
|
||||
}
|
||||
|
||||
public static void tick(World world, BlockPos pos, BlockState state, BlockEntity be) {
|
||||
if (be instanceof DrillBlockEastEntity) {
|
||||
DrillBlockEastEntity dbe = (DrillBlockEastEntity) be;
|
||||
List<BlockPos> list = new ArrayList<>();
|
||||
list.add(pos.east());
|
||||
list.add(pos.east().up());
|
||||
list.add(pos.east().up().up());
|
||||
list.add(pos.east().up().up().up());
|
||||
list.add(pos.east().down()); // must be last position
|
||||
DrillBlockEntity.tick(world, pos, state, dbe, MAXDRILLSTEP, list);
|
||||
}
|
||||
}
|
||||
}
|
@ -1,23 +1,94 @@
|
||||
package de.jottyfan.quickiemod.blockentity;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
import de.jottyfan.quickiemod.blocks.QuickieBlocks;
|
||||
import de.jottyfan.quickiemod.blocks.help.DrillBlock;
|
||||
import de.jottyfan.quickiemod.block.BlockDrill;
|
||||
import net.minecraft.block.BlockState;
|
||||
import net.minecraft.block.Blocks;
|
||||
import net.minecraft.block.entity.BlockEntity;
|
||||
import net.minecraft.block.entity.BlockEntityType;
|
||||
import net.minecraft.util.math.BlockPos;
|
||||
import net.minecraft.util.math.Direction;
|
||||
import net.minecraft.world.World;
|
||||
|
||||
public abstract class DrillBlockEntity extends BlockEntity {
|
||||
/**
|
||||
*
|
||||
* @author jotty
|
||||
*
|
||||
*/
|
||||
public class DrillBlockEntity extends BlockEntity {
|
||||
|
||||
private static final Integer MAXDRILLSTEP = 20;
|
||||
|
||||
private Integer drillstep;
|
||||
private final Integer maxDrillStep;
|
||||
|
||||
public DrillBlockEntity(BlockEntityType<?> type, BlockPos pos, BlockState state, Integer maxDrillStep) {
|
||||
super(type, pos, state);
|
||||
this.maxDrillStep = maxDrillStep;
|
||||
public DrillBlockEntity(BlockPos pos, BlockState state) {
|
||||
super(ModBlockentity.DRILL_BLOCKENTITY, pos, state);
|
||||
this.maxDrillStep = MAXDRILLSTEP;
|
||||
}
|
||||
|
||||
public static void tick(World world, BlockPos pos, BlockState state, BlockEntity be) {
|
||||
if (be instanceof DrillBlockEntity dbe) {
|
||||
Direction dir = state.get(BlockDrill.DIRECTION);
|
||||
List<BlockPos> list = new ArrayList<>();
|
||||
if (Direction.DOWN.equals(dir)) {
|
||||
list = downFrom(pos);
|
||||
} else if (Direction.EAST.equals(dir)) {
|
||||
list = directedFrom(pos.east());
|
||||
} else if (Direction.SOUTH.equals(dir)) {
|
||||
list = directedFrom(pos.south());
|
||||
} else if (Direction.WEST.equals(dir)) {
|
||||
list = directedFrom(pos.west());
|
||||
} else if (Direction.NORTH.equals(dir)) {
|
||||
list = directedFrom(pos.north());
|
||||
}
|
||||
DrillBlockEntity.tick(world, pos, state, dbe, MAXDRILLSTEP, list);
|
||||
}
|
||||
}
|
||||
|
||||
public static final List<BlockPos> directedFrom(BlockPos pos) {
|
||||
// Quickiemod.LOGGER.info("directed");
|
||||
List<BlockPos> list = new ArrayList<>();
|
||||
list.add(pos);
|
||||
list.add(pos.up());
|
||||
list.add(pos.up().up());
|
||||
list.add(pos.up().up().up());
|
||||
list.add(pos.down()); // must be last position
|
||||
return list;
|
||||
}
|
||||
|
||||
public static final List<BlockPos> downFrom(BlockPos pos) {
|
||||
// Quickiemod.LOGGER.info("down");
|
||||
List<BlockPos> list = new ArrayList<>();
|
||||
Integer tracesMod = pos.getY() % 8;
|
||||
tracesMod = tracesMod < 0 ? tracesMod * -1 : tracesMod; // lower that 0 makes it negative
|
||||
if (tracesMod != 0) {
|
||||
list.add(pos.north());
|
||||
}
|
||||
if (tracesMod != 1) {
|
||||
list.add(pos.north().west());
|
||||
}
|
||||
if (tracesMod != 2) {
|
||||
list.add(pos.west());
|
||||
}
|
||||
if (tracesMod != 3) {
|
||||
list.add(pos.south().west());
|
||||
}
|
||||
if (tracesMod != 4) {
|
||||
list.add(pos.south());
|
||||
}
|
||||
if (tracesMod != 5) {
|
||||
list.add(pos.south().east());
|
||||
}
|
||||
if (tracesMod != 6) {
|
||||
list.add(pos.east());
|
||||
}
|
||||
if (tracesMod != 7) {
|
||||
list.add(pos.north().east());
|
||||
}
|
||||
list.add(pos.down()); // must be last position
|
||||
return list;
|
||||
}
|
||||
|
||||
protected static final void moveBlockWithEntity(BlockPos from, BlockPos to, World world) {
|
||||
@ -25,9 +96,8 @@ public abstract class DrillBlockEntity extends BlockEntity {
|
||||
BlockState bs = world.getBlockState(from);
|
||||
if (be != null) {
|
||||
world.setBlockState(from, Blocks.AIR.getDefaultState());
|
||||
Integer newFuel = bs.get(DrillBlock.FUEL) - 1;
|
||||
world.setBlockState(to, bs.with(DrillBlock.FUEL, newFuel));
|
||||
world.addBlockEntity(be);
|
||||
Integer newFuel = bs.get(BlockDrill.FUEL) - 1;
|
||||
world.setBlockState(to, bs.with(BlockDrill.FUEL, newFuel));
|
||||
world.removeBlockEntity(from);
|
||||
}
|
||||
}
|
||||
@ -35,11 +105,11 @@ public abstract class DrillBlockEntity extends BlockEntity {
|
||||
protected static final Boolean drill(BlockPos pos, List<BlockPos> toList, World world) {
|
||||
Boolean lastSuccess = false;
|
||||
for (BlockPos to : toList) {
|
||||
if (!world.getBlockState(to).isOf(Blocks.BEDROCK) && !world.getBlockState(to).isOf(QuickieBlocks.DRILLSTOP.getBlock())) {
|
||||
if (!world.getBlockState(to).isOf(Blocks.BEDROCK)) {
|
||||
world.breakBlock(to, true);
|
||||
lastSuccess = pos.down() != to; // no need for the falling one
|
||||
} else {
|
||||
lastSuccess = false; // in case that the last one is a bedrock or a drillstop
|
||||
lastSuccess = false; // in case that the last one is a bedrock
|
||||
}
|
||||
}
|
||||
return lastSuccess;
|
||||
@ -47,7 +117,7 @@ public abstract class DrillBlockEntity extends BlockEntity {
|
||||
|
||||
public static void tick(World world, BlockPos pos, BlockState state, DrillBlockEntity be, Integer maxDrillStep,
|
||||
List<BlockPos> drillPosition) {
|
||||
if (state.get(DrillBlock.FUEL) > 0) {
|
||||
if (state.get(BlockDrill.FUEL) > 0) {
|
||||
if (be.getDrillstep() < 1) {
|
||||
be.setDrillstep(maxDrillStep);
|
||||
if (drill(pos, drillPosition, world)) {
|
||||
|
@ -1,36 +0,0 @@
|
||||
package de.jottyfan.quickiemod.blockentity;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
import net.minecraft.block.BlockState;
|
||||
import net.minecraft.block.entity.BlockEntity;
|
||||
import net.minecraft.util.math.BlockPos;
|
||||
import net.minecraft.world.World;
|
||||
|
||||
/**
|
||||
*
|
||||
* @author jotty
|
||||
*
|
||||
*/
|
||||
public class DrillBlockNorthEntity extends DrillBlockEntity {
|
||||
|
||||
private static final Integer MAXDRILLSTEP = 24;
|
||||
|
||||
public DrillBlockNorthEntity(BlockPos pos, BlockState state) {
|
||||
super(BlockEntityTypes.DRILL_NORTH, pos, state, MAXDRILLSTEP);
|
||||
}
|
||||
|
||||
public static void tick(World world, BlockPos pos, BlockState state, BlockEntity be) {
|
||||
if (be instanceof DrillBlockNorthEntity) {
|
||||
DrillBlockNorthEntity dbe = (DrillBlockNorthEntity) be;
|
||||
List<BlockPos> list = new ArrayList<>();
|
||||
list.add(pos.north());
|
||||
list.add(pos.north().up());
|
||||
list.add(pos.north().up().up());
|
||||
list.add(pos.north().up().up().up());
|
||||
list.add(pos.north().down()); // must be last position
|
||||
DrillBlockEntity.tick(world, pos, state, dbe, MAXDRILLSTEP, list);
|
||||
}
|
||||
}
|
||||
}
|
@ -1,35 +0,0 @@
|
||||
package de.jottyfan.quickiemod.blockentity;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
import net.minecraft.block.BlockState;
|
||||
import net.minecraft.block.entity.BlockEntity;
|
||||
import net.minecraft.util.math.BlockPos;
|
||||
import net.minecraft.world.World;
|
||||
|
||||
/**
|
||||
*
|
||||
* @author jotty
|
||||
*
|
||||
*/
|
||||
public class DrillBlockSouthEntity extends DrillBlockEntity {
|
||||
private static final Integer MAXDRILLSTEP = 24;
|
||||
|
||||
public DrillBlockSouthEntity(BlockPos pos, BlockState state) {
|
||||
super(BlockEntityTypes.DRILL_SOUTH, pos, state, MAXDRILLSTEP);
|
||||
}
|
||||
|
||||
public static void tick(World world, BlockPos pos, BlockState state, BlockEntity be) {
|
||||
if (be instanceof DrillBlockSouthEntity) {
|
||||
DrillBlockSouthEntity dbe = (DrillBlockSouthEntity) be;
|
||||
List<BlockPos> list = new ArrayList<>();
|
||||
list.add(pos.south());
|
||||
list.add(pos.south().up());
|
||||
list.add(pos.south().up().up());
|
||||
list.add(pos.south().up().up().up());
|
||||
list.add(pos.south().down()); // must be last position
|
||||
DrillBlockEntity.tick(world, pos, state, dbe, MAXDRILLSTEP, list);
|
||||
}
|
||||
}
|
||||
}
|
@ -1,36 +0,0 @@
|
||||
package de.jottyfan.quickiemod.blockentity;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
import net.minecraft.block.BlockState;
|
||||
import net.minecraft.block.entity.BlockEntity;
|
||||
import net.minecraft.util.math.BlockPos;
|
||||
import net.minecraft.world.World;
|
||||
|
||||
/**
|
||||
*
|
||||
* @author jotty
|
||||
*
|
||||
*/
|
||||
public class DrillBlockWestEntity extends DrillBlockEntity {
|
||||
|
||||
private static final Integer MAXDRILLSTEP = 24;
|
||||
|
||||
public DrillBlockWestEntity(BlockPos pos, BlockState state) {
|
||||
super(BlockEntityTypes.DRILL_WEST, pos, state, MAXDRILLSTEP);
|
||||
}
|
||||
|
||||
public static void tick(World world, BlockPos pos, BlockState state, BlockEntity be) {
|
||||
if (be instanceof DrillBlockWestEntity) {
|
||||
DrillBlockWestEntity dbe = (DrillBlockWestEntity) be;
|
||||
List<BlockPos> list = new ArrayList<>();
|
||||
list.add(pos.west());
|
||||
list.add(pos.west().up());
|
||||
list.add(pos.west().up().up());
|
||||
list.add(pos.west().up().up().up());
|
||||
list.add(pos.west().down()); // must be last position
|
||||
DrillBlockEntity.tick(world, pos, state, dbe, MAXDRILLSTEP, list);
|
||||
}
|
||||
}
|
||||
}
|
@ -1,84 +0,0 @@
|
||||
package de.jottyfan.quickiemod.blockentity;
|
||||
|
||||
import java.util.Random;
|
||||
|
||||
import de.jottyfan.quickiemod.blocks.QuickieBlocks;
|
||||
import de.jottyfan.quickiemod.items.QuickieItems;
|
||||
import net.minecraft.block.BlockState;
|
||||
import net.minecraft.block.Blocks;
|
||||
import net.minecraft.block.entity.BlockEntity;
|
||||
import net.minecraft.entity.ItemEntity;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.item.Items;
|
||||
import net.minecraft.util.math.BlockPos;
|
||||
import net.minecraft.world.World;
|
||||
|
||||
/**
|
||||
*
|
||||
* @author jotty
|
||||
*
|
||||
*/
|
||||
public class EmptyLavaHoarderBlockEntity extends BlockEntity {
|
||||
|
||||
public EmptyLavaHoarderBlockEntity(BlockPos pos, BlockState state) {
|
||||
super(BlockEntityTypes.EMPTYLAVAHOARDER, pos, state);
|
||||
}
|
||||
|
||||
public static final void spawnRandomItems(World world, BlockPos pos, Integer count) {
|
||||
Integer which = new Random().nextInt(10);
|
||||
if (which < 1) {
|
||||
world.spawnEntity(new ItemEntity(world, pos.getX(), pos.getY(), pos.getZ(), new ItemStack(Items.DIAMOND, new Random().nextInt(count + 2))));
|
||||
} else if (which < 2) {
|
||||
world.spawnEntity(new ItemEntity(world, pos.getX(), pos.getY(), pos.getZ(), new ItemStack(Items.EMERALD, new Random().nextInt(count + 1))));
|
||||
} else if (which < 3) {
|
||||
world.spawnEntity(new ItemEntity(world, pos.getX(), pos.getY(), pos.getZ(), new ItemStack(Items.RAW_GOLD, new Random().nextInt(count))));
|
||||
} else if (which < 4) {
|
||||
world.spawnEntity(new ItemEntity(world, pos.getX(), pos.getY(), pos.getZ(), new ItemStack(Items.RAW_IRON, new Random().nextInt(count + 1))));
|
||||
} else if (which < 5) {
|
||||
world.spawnEntity(new ItemEntity(world, pos.getX(), pos.getY(), pos.getZ(), new ItemStack(Items.RAW_COPPER, new Random().nextInt(count + 2))));
|
||||
} else if (which < 6) {
|
||||
world.spawnEntity(new ItemEntity(world, pos.getX(), pos.getY(), pos.getZ(), new ItemStack(Items.OBSIDIAN)));
|
||||
} else if (which < 7) {
|
||||
world.spawnEntity(new ItemEntity(world, pos.getX(), pos.getY(), pos.getZ(), new ItemStack(Items.LAPIS_LAZULI)));
|
||||
} else if (which < 8) {
|
||||
world.spawnEntity(new ItemEntity(world, pos.getX(), pos.getY(), pos.getZ(), new ItemStack(QuickieItems.SULPHOR.getItem())));
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* sucks the lava that touches the block
|
||||
*
|
||||
* @param world the world
|
||||
* @param pos the pos
|
||||
* @return true if lava was found
|
||||
*/
|
||||
private boolean suckLava(World world, BlockPos pos) {
|
||||
if (world == null) {
|
||||
return false;
|
||||
} else if (Blocks.LAVA.equals(world.getBlockState(pos).getBlock())) {
|
||||
world.setBlockState(pos, Blocks.AIR.getDefaultState());
|
||||
BlockPos up = pos.up();
|
||||
Random random = new Random();
|
||||
if (random.nextFloat() > 0.9f) {
|
||||
spawnRandomItems(world, up, 2);
|
||||
}
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
public static void tick(World world, BlockPos pos, BlockState state, BlockEntity be) {
|
||||
if (be instanceof EmptyLavaHoarderBlockEntity) {
|
||||
EmptyLavaHoarderBlockEntity elhbe = (EmptyLavaHoarderBlockEntity) be;
|
||||
boolean found = elhbe.suckLava(world, pos.north());
|
||||
found = found || elhbe.suckLava(world, pos.south());
|
||||
found = found || elhbe.suckLava(world, pos.east());
|
||||
found = found || elhbe.suckLava(world, pos.west());
|
||||
found = found || elhbe.suckLava(world, pos.up());
|
||||
found = found || elhbe.suckLava(world, pos.down());
|
||||
if (found) {
|
||||
world.setBlockState(pos, QuickieBlocks.LAVAHOARDER.getBlock().getDefaultState());
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
@ -3,7 +3,6 @@ package de.jottyfan.quickiemod.blockentity;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
import de.jottyfan.quickiemod.text.PrefixedText;
|
||||
import net.minecraft.block.BlockState;
|
||||
import net.minecraft.block.entity.BlockEntity;
|
||||
import net.minecraft.block.entity.LootableContainerBlockEntity;
|
||||
@ -30,13 +29,15 @@ import net.minecraft.world.World;
|
||||
*
|
||||
*/
|
||||
public class ItemHoarderBlockEntity extends LootableContainerBlockEntity {
|
||||
|
||||
|
||||
private DefaultedList<ItemStack> stacks;
|
||||
private float suckradius;
|
||||
|
||||
public ItemHoarderBlockEntity(BlockPos pos, BlockState state) {
|
||||
super(BlockEntityTypes.ITEMHOARDER, pos, state);
|
||||
super(ModBlockentity.ITEM_HOARDER_BLOCKENTITY, pos, state);
|
||||
stacks = DefaultedList.ofSize(54, ItemStack.EMPTY);
|
||||
setSuckradius(4f); // TODO: make it level up - able and start with 2
|
||||
setSuckradius(4f);
|
||||
}
|
||||
|
||||
// TODO: see https://fabricmc.net/wiki/tutorial:containers for a real chest
|
||||
@ -136,8 +137,7 @@ public class ItemHoarderBlockEntity extends LootableContainerBlockEntity {
|
||||
for (ItemStack stack : stacks) {
|
||||
Item item = stack.getItem();
|
||||
if (item != Items.AIR) {
|
||||
Text text = PrefixedText.instance(String.format("%dx ", stack.getCount()).concat("%s"),
|
||||
Text.translatable(stack.getTranslationKey()));
|
||||
Text text = Text.of(String.format("%dx %s", stack.getCount(), Text.translatable(stack.getItem().getTranslationKey())));
|
||||
list.add(text);
|
||||
}
|
||||
}
|
||||
|
@ -0,0 +1,31 @@
|
||||
package de.jottyfan.quickiemod.blockentity;
|
||||
|
||||
import de.jottyfan.quickiemod.block.ModBlocks;
|
||||
import de.jottyfan.quickiemod.identifier.ModIdentifiers;
|
||||
import net.fabricmc.fabric.api.object.builder.v1.block.entity.FabricBlockEntityTypeBuilder;
|
||||
import net.minecraft.block.entity.BlockEntityType;
|
||||
import net.minecraft.registry.Registries;
|
||||
import net.minecraft.registry.Registry;
|
||||
|
||||
/**
|
||||
*
|
||||
* @author jotty
|
||||
*
|
||||
*/
|
||||
public class ModBlockentity {
|
||||
public static final BlockEntityType<ItemHoarderBlockEntity> ITEM_HOARDER_BLOCKENTITY = Registry.register(
|
||||
Registries.BLOCK_ENTITY_TYPE, ModIdentifiers.BLOCKENTITY_ITEMHOARDER,
|
||||
FabricBlockEntityTypeBuilder.create(ItemHoarderBlockEntity::new, ModBlocks.BLOCK_ITEMHOARDER).build());
|
||||
public static final BlockEntityType<DrillBlockEntity> DRILL_BLOCKENTITY = Registry.register(
|
||||
Registries.BLOCK_ENTITY_TYPE, ModIdentifiers.BLOCKENTITY_DRILL,
|
||||
FabricBlockEntityTypeBuilder.create(DrillBlockEntity::new, ModBlocks.BLOCK_DRILL_DOWN, ModBlocks.BLOCK_DRILL_EAST,
|
||||
ModBlocks.BLOCK_DRILL_SOUTH, ModBlocks.BLOCK_DRILL_WEST, ModBlocks.BLOCK_DRILL_NORTH).build());
|
||||
public static final BlockEntityType<BlockStackerEntity> BLOCKSTACKER_BLOCKENTITY = Registry.register(
|
||||
Registries.BLOCK_ENTITY_TYPE, ModIdentifiers.BLOCKENTITY_BLOCKSTACKER,
|
||||
FabricBlockEntityTypeBuilder.create(BlockStackerEntity::new, ModBlocks.BLOCK_STACKER_DOWN,
|
||||
ModBlocks.BLOCK_STACKER_EAST, ModBlocks.BLOCK_STACKER_SOUTH, ModBlocks.BLOCK_STACKER_WEST,
|
||||
ModBlocks.BLOCK_STACKER_NORTH, ModBlocks.BLOCK_STACKER_UP).build());
|
||||
|
||||
public static final void registerModBlockentities() {
|
||||
};
|
||||
}
|
@ -1,51 +0,0 @@
|
||||
package de.jottyfan.quickiemod.blockentity;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import net.minecraft.block.BlockState;
|
||||
import net.minecraft.block.entity.BlockEntity;
|
||||
import net.minecraft.entity.Entity;
|
||||
import net.minecraft.entity.mob.HostileEntity;
|
||||
import net.minecraft.util.math.BlockPos;
|
||||
import net.minecraft.util.math.Box;
|
||||
import net.minecraft.world.World;
|
||||
|
||||
/**
|
||||
*
|
||||
* @author jotty
|
||||
*
|
||||
*/
|
||||
public class MonsterHoarderBlockEntity extends BlockEntity {
|
||||
|
||||
private float suckradius;
|
||||
|
||||
public MonsterHoarderBlockEntity(BlockPos pos, BlockState state) {
|
||||
super(BlockEntityTypes.MONSTERHOARDER, pos, state);
|
||||
setSuckradius(8f); // TODO: make it level up - able and start with 2
|
||||
}
|
||||
|
||||
public static void tick(World world, BlockPos pos, BlockState state, BlockEntity be) {
|
||||
if (be instanceof MonsterHoarderBlockEntity) {
|
||||
MonsterHoarderBlockEntity mhbe = (MonsterHoarderBlockEntity) be;
|
||||
Box box = new Box(pos).expand(mhbe.getSuckradius());
|
||||
List<Entity> entities = world.getOtherEntities(null, box);
|
||||
for (Entity entity : entities) {
|
||||
if (entity instanceof HostileEntity) {
|
||||
if (entity.isFireImmune()) {
|
||||
entity.kill();
|
||||
} else {
|
||||
entity.setOnFireFor(90);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public float getSuckradius() {
|
||||
return suckradius;
|
||||
}
|
||||
|
||||
public void setSuckradius(float suckradius) {
|
||||
this.suckradius = suckradius;
|
||||
}
|
||||
}
|
@ -1,66 +0,0 @@
|
||||
package de.jottyfan.quickiemod.blocks;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.Random;
|
||||
|
||||
import de.jottyfan.quickiemod.items.QuickieItems;
|
||||
import net.minecraft.block.AbstractBlock;
|
||||
import net.minecraft.block.BlockState;
|
||||
import net.minecraft.block.Blocks;
|
||||
import net.minecraft.block.CropBlock;
|
||||
import net.minecraft.entity.player.PlayerEntity;
|
||||
import net.minecraft.item.ItemConvertible;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.loot.context.LootContextParameterSet.Builder;
|
||||
import net.minecraft.util.ActionResult;
|
||||
import net.minecraft.util.ItemScatterer;
|
||||
import net.minecraft.util.collection.DefaultedList;
|
||||
import net.minecraft.util.hit.BlockHitResult;
|
||||
import net.minecraft.util.math.BlockPos;
|
||||
import net.minecraft.world.World;
|
||||
|
||||
public class BlockCanolaplant extends CropBlock {
|
||||
|
||||
public BlockCanolaplant() {
|
||||
super(AbstractBlock.Settings.copy(Blocks.WHEAT));
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<ItemStack> getDroppedStacks(BlockState state, Builder builder) {
|
||||
DefaultedList<ItemStack> list = DefaultedList.of();
|
||||
list.add(new ItemStack(getSeedsItem())); // the one from the seed
|
||||
if (isMature(state)) {
|
||||
list.add(new ItemStack(getSeedsItem(), new Random().nextInt(2)));
|
||||
list.add(new ItemStack(QuickieItems.CANOLA.getItem(), new Random().nextFloat() > 0.9f ? 2 : 1));
|
||||
}
|
||||
return list;
|
||||
}
|
||||
|
||||
private void spawnHarvested(World world, BlockPos pos, BlockState state) {
|
||||
DefaultedList<ItemStack> list = DefaultedList.of();
|
||||
getDroppedStacks(state, null).forEach(itemStack -> {
|
||||
list.add(itemStack);
|
||||
});
|
||||
ItemScatterer.spawn(world, pos, list);
|
||||
}
|
||||
|
||||
@Override
|
||||
public BlockState onBreak(World world, BlockPos pos, BlockState state, PlayerEntity player) {
|
||||
spawnHarvested(world, pos, state);
|
||||
return super.onBreak(world, pos, state, player);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected ItemConvertible getSeedsItem() {
|
||||
return QuickieItems.CANOLASEED.getItem();
|
||||
}
|
||||
|
||||
@Override
|
||||
protected ActionResult onUse(BlockState state, World world, BlockPos pos, PlayerEntity player, BlockHitResult hit) {
|
||||
if (!world.isClient && isMature(state)) {
|
||||
spawnHarvested(world, pos, state);
|
||||
world.setBlockState(pos, state.with(AGE, 0));
|
||||
}
|
||||
return ActionResult.PASS;
|
||||
}
|
||||
}
|
@ -1,61 +0,0 @@
|
||||
package de.jottyfan.quickiemod.blocks;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
import com.mojang.serialization.MapCodec;
|
||||
|
||||
import de.jottyfan.quickiemod.blockentity.DrillBlockDownEntity;
|
||||
import de.jottyfan.quickiemod.blocks.help.DrillBlock;
|
||||
import net.minecraft.block.AbstractBlock;
|
||||
import net.minecraft.block.BlockEntityProvider;
|
||||
import net.minecraft.block.BlockRenderType;
|
||||
import net.minecraft.block.BlockState;
|
||||
import net.minecraft.block.FallingBlock;
|
||||
import net.minecraft.block.entity.BlockEntity;
|
||||
import net.minecraft.block.entity.BlockEntityTicker;
|
||||
import net.minecraft.block.entity.BlockEntityType;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.loot.context.LootContextParameterSet.Builder;
|
||||
import net.minecraft.util.math.BlockPos;
|
||||
import net.minecraft.world.World;
|
||||
|
||||
/**
|
||||
*
|
||||
* @author jotty
|
||||
*
|
||||
*/
|
||||
public class BlockDrillDown extends DrillBlock implements BlockEntityProvider {
|
||||
|
||||
public BlockDrillDown() {
|
||||
super(AbstractBlock.Settings.create().hardness(2.5f));
|
||||
}
|
||||
|
||||
@Override
|
||||
public BlockEntity createBlockEntity(BlockPos pos, BlockState blockState) {
|
||||
return new DrillBlockDownEntity(pos, blockState);
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<ItemStack> getDroppedStacks(BlockState state, Builder builder) {
|
||||
List<ItemStack> list = new ArrayList<>();
|
||||
list.add(new ItemStack(QuickieBlocks.DRILL_DOWN.getBlock()));
|
||||
return list;
|
||||
}
|
||||
|
||||
@Override
|
||||
public BlockRenderType getRenderType(BlockState state) {
|
||||
return BlockRenderType.MODEL;
|
||||
}
|
||||
|
||||
@Override
|
||||
public <T extends BlockEntity> BlockEntityTicker<T> getTicker(World world, BlockState state,
|
||||
BlockEntityType<T> type) {
|
||||
return (world1, pos, state1, be) -> DrillBlockDownEntity.tick(world1, pos, state1, be);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected MapCodec<? extends FallingBlock> getCodec() {
|
||||
return null; // TODO: what to return here?
|
||||
}
|
||||
}
|
@ -1,61 +0,0 @@
|
||||
package de.jottyfan.quickiemod.blocks;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
import com.mojang.serialization.MapCodec;
|
||||
|
||||
import de.jottyfan.quickiemod.blockentity.DrillBlockEastEntity;
|
||||
import de.jottyfan.quickiemod.blocks.help.DrillBlock;
|
||||
import net.minecraft.block.AbstractBlock;
|
||||
import net.minecraft.block.BlockEntityProvider;
|
||||
import net.minecraft.block.BlockRenderType;
|
||||
import net.minecraft.block.BlockState;
|
||||
import net.minecraft.block.FallingBlock;
|
||||
import net.minecraft.block.entity.BlockEntity;
|
||||
import net.minecraft.block.entity.BlockEntityTicker;
|
||||
import net.minecraft.block.entity.BlockEntityType;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.loot.context.LootContextParameterSet.Builder;
|
||||
import net.minecraft.util.math.BlockPos;
|
||||
import net.minecraft.world.World;
|
||||
|
||||
/**
|
||||
*
|
||||
* @author jotty
|
||||
*
|
||||
*/
|
||||
public class BlockDrillEast extends DrillBlock implements BlockEntityProvider {
|
||||
|
||||
public BlockDrillEast() {
|
||||
super(AbstractBlock.Settings.create().hardness(2.5f));
|
||||
}
|
||||
|
||||
@Override
|
||||
public BlockEntity createBlockEntity(BlockPos pos, BlockState blockState) {
|
||||
return new DrillBlockEastEntity(pos, blockState);
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<ItemStack> getDroppedStacks(BlockState state, Builder builder) {
|
||||
List<ItemStack> list = new ArrayList<>();
|
||||
list.add(new ItemStack(QuickieBlocks.DRILL_EAST.getBlock()));
|
||||
return list;
|
||||
}
|
||||
|
||||
@Override
|
||||
public BlockRenderType getRenderType(BlockState state) {
|
||||
return BlockRenderType.MODEL;
|
||||
}
|
||||
|
||||
@Override
|
||||
public <T extends BlockEntity> BlockEntityTicker<T> getTicker(World world, BlockState state, BlockEntityType<T> type){
|
||||
return (world1, pos, state1, be) -> DrillBlockEastEntity.tick(world1, pos, state1, be);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected MapCodec<? extends FallingBlock> getCodec() {
|
||||
// TODO Auto-generated method stub
|
||||
return null;
|
||||
}
|
||||
}
|
@ -1,61 +0,0 @@
|
||||
package de.jottyfan.quickiemod.blocks;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
import com.mojang.serialization.MapCodec;
|
||||
|
||||
import de.jottyfan.quickiemod.blockentity.DrillBlockNorthEntity;
|
||||
import de.jottyfan.quickiemod.blocks.help.DrillBlock;
|
||||
import net.minecraft.block.AbstractBlock;
|
||||
import net.minecraft.block.BlockEntityProvider;
|
||||
import net.minecraft.block.BlockRenderType;
|
||||
import net.minecraft.block.BlockState;
|
||||
import net.minecraft.block.FallingBlock;
|
||||
import net.minecraft.block.entity.BlockEntity;
|
||||
import net.minecraft.block.entity.BlockEntityTicker;
|
||||
import net.minecraft.block.entity.BlockEntityType;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.loot.context.LootContextParameterSet.Builder;
|
||||
import net.minecraft.util.math.BlockPos;
|
||||
import net.minecraft.world.World;
|
||||
|
||||
/**
|
||||
*
|
||||
* @author jotty
|
||||
*
|
||||
*/
|
||||
public class BlockDrillNorth extends DrillBlock implements BlockEntityProvider {
|
||||
|
||||
public BlockDrillNorth() {
|
||||
super(AbstractBlock.Settings.create().hardness(2.5f));
|
||||
}
|
||||
|
||||
@Override
|
||||
public BlockEntity createBlockEntity(BlockPos pos, BlockState blockState) {
|
||||
return new DrillBlockNorthEntity(pos, blockState);
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<ItemStack> getDroppedStacks(BlockState state, Builder builder) {
|
||||
List<ItemStack> list = new ArrayList<>();
|
||||
list.add(new ItemStack(QuickieBlocks.DRILL_NORTH.getBlock()));
|
||||
return list;
|
||||
}
|
||||
|
||||
@Override
|
||||
public BlockRenderType getRenderType(BlockState state) {
|
||||
return BlockRenderType.MODEL;
|
||||
}
|
||||
|
||||
@Override
|
||||
public <T extends BlockEntity> BlockEntityTicker<T> getTicker(World world, BlockState state, BlockEntityType<T> type){
|
||||
return (world1, pos, state1, be) -> DrillBlockNorthEntity.tick(world1, pos, state1, be);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected MapCodec<? extends FallingBlock> getCodec() {
|
||||
// TODO Auto-generated method stub
|
||||
return null;
|
||||
}
|
||||
}
|
@ -1,61 +0,0 @@
|
||||
package de.jottyfan.quickiemod.blocks;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
import com.mojang.serialization.MapCodec;
|
||||
|
||||
import de.jottyfan.quickiemod.blockentity.DrillBlockSouthEntity;
|
||||
import de.jottyfan.quickiemod.blocks.help.DrillBlock;
|
||||
import net.minecraft.block.AbstractBlock;
|
||||
import net.minecraft.block.BlockEntityProvider;
|
||||
import net.minecraft.block.BlockRenderType;
|
||||
import net.minecraft.block.BlockState;
|
||||
import net.minecraft.block.FallingBlock;
|
||||
import net.minecraft.block.entity.BlockEntity;
|
||||
import net.minecraft.block.entity.BlockEntityTicker;
|
||||
import net.minecraft.block.entity.BlockEntityType;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.loot.context.LootContextParameterSet.Builder;
|
||||
import net.minecraft.util.math.BlockPos;
|
||||
import net.minecraft.world.World;
|
||||
|
||||
/**
|
||||
*
|
||||
* @author jotty
|
||||
*
|
||||
*/
|
||||
public class BlockDrillSouth extends DrillBlock implements BlockEntityProvider {
|
||||
|
||||
public BlockDrillSouth() {
|
||||
super(AbstractBlock.Settings.create().hardness(2.5f));
|
||||
}
|
||||
|
||||
@Override
|
||||
public BlockEntity createBlockEntity(BlockPos pos, BlockState blockState) {
|
||||
return new DrillBlockSouthEntity(pos, blockState);
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<ItemStack> getDroppedStacks(BlockState state, Builder builder) {
|
||||
List<ItemStack> list = new ArrayList<>();
|
||||
list.add(new ItemStack(QuickieBlocks.DRILL_SOUTH.getBlock()));
|
||||
return list;
|
||||
}
|
||||
|
||||
@Override
|
||||
public BlockRenderType getRenderType(BlockState state) {
|
||||
return BlockRenderType.MODEL;
|
||||
}
|
||||
|
||||
@Override
|
||||
public <T extends BlockEntity> BlockEntityTicker<T> getTicker(World world, BlockState state, BlockEntityType<T> type){
|
||||
return (world1, pos, state1, be) -> DrillBlockSouthEntity.tick(world1, pos, state1, be);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected MapCodec<? extends FallingBlock> getCodec() {
|
||||
// TODO Auto-generated method stub
|
||||
return null;
|
||||
}
|
||||
}
|
@ -1,61 +0,0 @@
|
||||
package de.jottyfan.quickiemod.blocks;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
import com.mojang.serialization.MapCodec;
|
||||
|
||||
import de.jottyfan.quickiemod.blockentity.DrillBlockWestEntity;
|
||||
import de.jottyfan.quickiemod.blocks.help.DrillBlock;
|
||||
import net.minecraft.block.AbstractBlock;
|
||||
import net.minecraft.block.BlockEntityProvider;
|
||||
import net.minecraft.block.BlockRenderType;
|
||||
import net.minecraft.block.BlockState;
|
||||
import net.minecraft.block.FallingBlock;
|
||||
import net.minecraft.block.entity.BlockEntity;
|
||||
import net.minecraft.block.entity.BlockEntityTicker;
|
||||
import net.minecraft.block.entity.BlockEntityType;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.loot.context.LootContextParameterSet.Builder;
|
||||
import net.minecraft.util.math.BlockPos;
|
||||
import net.minecraft.world.World;
|
||||
|
||||
/**
|
||||
*
|
||||
* @author jotty
|
||||
*
|
||||
*/
|
||||
public class BlockDrillWest extends DrillBlock implements BlockEntityProvider {
|
||||
|
||||
public BlockDrillWest() {
|
||||
super(AbstractBlock.Settings.create().hardness(2.5f));
|
||||
}
|
||||
|
||||
@Override
|
||||
public BlockEntity createBlockEntity(BlockPos pos, BlockState blockState) {
|
||||
return new DrillBlockWestEntity(pos, blockState);
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<ItemStack> getDroppedStacks(BlockState state, Builder builder) {
|
||||
List<ItemStack> list = new ArrayList<>();
|
||||
list.add(new ItemStack(QuickieBlocks.DRILL_WEST.getBlock()));
|
||||
return list;
|
||||
}
|
||||
|
||||
@Override
|
||||
public BlockRenderType getRenderType(BlockState state) {
|
||||
return BlockRenderType.MODEL;
|
||||
}
|
||||
|
||||
@Override
|
||||
public <T extends BlockEntity> BlockEntityTicker<T> getTicker(World world, BlockState state, BlockEntityType<T> type){
|
||||
return (world1, pos, state1, be) -> DrillBlockWestEntity.tick(world1, pos, state1, be);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected MapCodec<? extends FallingBlock> getCodec() {
|
||||
// TODO Auto-generated method stub
|
||||
return null;
|
||||
}
|
||||
}
|
@ -1,30 +0,0 @@
|
||||
package de.jottyfan.quickiemod.blocks;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
import net.minecraft.block.AbstractBlock;
|
||||
import net.minecraft.block.Block;
|
||||
import net.minecraft.block.BlockState;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.loot.context.LootContextParameterSet.Builder;
|
||||
|
||||
|
||||
/**
|
||||
*
|
||||
* @author jotty
|
||||
*
|
||||
*/
|
||||
public class BlockDrillstop extends Block {
|
||||
|
||||
public BlockDrillstop() {
|
||||
super(AbstractBlock.Settings.create().hardness(2.5f));
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<ItemStack> getDroppedStacks(BlockState state, Builder builder) {
|
||||
List<ItemStack> list = new ArrayList<>();
|
||||
list.add(new ItemStack(QuickieBlocks.DRILLSTOP.getBlock()));
|
||||
return list;
|
||||
}
|
||||
}
|
@ -1,38 +0,0 @@
|
||||
package de.jottyfan.quickiemod.blocks;
|
||||
|
||||
import java.util.Arrays;
|
||||
import java.util.List;
|
||||
|
||||
import com.mojang.serialization.MapCodec;
|
||||
|
||||
import net.minecraft.block.AbstractBlock;
|
||||
import net.minecraft.block.BlockState;
|
||||
import net.minecraft.block.FallingBlock;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.item.Items;
|
||||
import net.minecraft.loot.context.LootContextParameterSet.Builder;
|
||||
import net.minecraft.sound.BlockSoundGroup;
|
||||
|
||||
/**
|
||||
*
|
||||
* @author jotty
|
||||
*
|
||||
*/
|
||||
public class BlockKelpstack extends FallingBlock {
|
||||
|
||||
public BlockKelpstack() {
|
||||
super(AbstractBlock.Settings.create().hardness(0.1f).slipperiness(1.0f)
|
||||
.breakInstantly().sounds(BlockSoundGroup.WET_GRASS));
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<ItemStack> getDroppedStacks(BlockState blockState, Builder builder) {
|
||||
return Arrays.asList(new ItemStack[] { new ItemStack(Items.KELP, 9) });
|
||||
}
|
||||
|
||||
@Override
|
||||
protected MapCodec<? extends FallingBlock> getCodec() {
|
||||
// TODO Auto-generated method stub
|
||||
return null;
|
||||
}
|
||||
}
|
@ -1,81 +0,0 @@
|
||||
package de.jottyfan.quickiemod.blocks;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
import de.jottyfan.quickiemod.blockentity.EmptyLavaHoarderBlockEntity;
|
||||
import net.minecraft.block.AbstractBlock;
|
||||
import net.minecraft.block.Block;
|
||||
import net.minecraft.block.BlockEntityProvider;
|
||||
import net.minecraft.block.BlockRenderType;
|
||||
import net.minecraft.block.BlockState;
|
||||
import net.minecraft.block.entity.BlockEntity;
|
||||
import net.minecraft.block.entity.BlockEntityTicker;
|
||||
import net.minecraft.block.entity.BlockEntityType;
|
||||
import net.minecraft.entity.ItemEntity;
|
||||
import net.minecraft.entity.player.PlayerEntity;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.item.Items;
|
||||
import net.minecraft.loot.context.LootContextParameterSet.Builder;
|
||||
import net.minecraft.util.ActionResult;
|
||||
import net.minecraft.util.Hand;
|
||||
import net.minecraft.util.hit.BlockHitResult;
|
||||
import net.minecraft.util.math.BlockPos;
|
||||
import net.minecraft.world.World;
|
||||
|
||||
/**
|
||||
*
|
||||
* @author jotty
|
||||
*
|
||||
*/
|
||||
public class BlockLavahoarder extends Block implements BlockEntityProvider {
|
||||
|
||||
public BlockLavahoarder() {
|
||||
super(AbstractBlock.Settings.create().hardness(2.5f).luminance(state -> 15));
|
||||
}
|
||||
|
||||
@Override
|
||||
public BlockEntity createBlockEntity(BlockPos pos, BlockState blockState) {
|
||||
return new EmptyLavaHoarderBlockEntity(pos, blockState);
|
||||
}
|
||||
|
||||
@Override
|
||||
public BlockRenderType getRenderType(BlockState state) {
|
||||
return BlockRenderType.MODEL;
|
||||
}
|
||||
|
||||
@Override
|
||||
public <T extends BlockEntity> BlockEntityTicker<T> getTicker(World world, BlockState state,
|
||||
BlockEntityType<T> type) {
|
||||
return (world1, pos, state1, be) -> EmptyLavaHoarderBlockEntity.tick(world1, pos, state1, be);
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<ItemStack> getDroppedStacks(BlockState state, Builder builder) {
|
||||
List<ItemStack> list = new ArrayList<>();
|
||||
list.add(new ItemStack(QuickieBlocks.LAVAHOARDER.getBlock()));
|
||||
return list;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected ActionResult onUse(BlockState state, World world, BlockPos pos, PlayerEntity player, BlockHitResult hit) {
|
||||
if (!world.isClient) {
|
||||
Hand hand = player.getActiveHand();
|
||||
ItemStack handStack = player.getStackInHand(hand);
|
||||
if (handStack != null && Items.BUCKET.equals(handStack.getItem())) {
|
||||
Integer amount = handStack.getCount();
|
||||
ItemStack lavaBucketStack = new ItemStack(Items.LAVA_BUCKET, 1);
|
||||
ItemStack emptyBucketStack = new ItemStack(Items.BUCKET, amount - 1);
|
||||
if (emptyBucketStack.getCount() < 1) {
|
||||
player.setStackInHand(hand, lavaBucketStack);
|
||||
} else {
|
||||
player.setStackInHand(hand, emptyBucketStack);
|
||||
world.spawnEntity(new ItemEntity(world, pos.getX(), pos.getY(), pos.getZ(), lavaBucketStack));
|
||||
}
|
||||
EmptyLavaHoarderBlockEntity.spawnRandomItems(world, pos, 2);
|
||||
world.setBlockState(pos, QuickieBlocks.EMPTYLAVAHOARDER.getBlock().getDefaultState());
|
||||
}
|
||||
}
|
||||
return ActionResult.SUCCESS; // forbid to empty the just filled lava bucket
|
||||
}
|
||||
}
|
@ -1,64 +0,0 @@
|
||||
package de.jottyfan.quickiemod.blocks;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
import de.jottyfan.quickiemod.blockentity.MonsterHoarderBlockEntity;
|
||||
import net.minecraft.block.AbstractBlock;
|
||||
import net.minecraft.block.Block;
|
||||
import net.minecraft.block.BlockEntityProvider;
|
||||
import net.minecraft.block.BlockRenderType;
|
||||
import net.minecraft.block.BlockState;
|
||||
import net.minecraft.block.entity.BlockEntity;
|
||||
import net.minecraft.block.entity.BlockEntityTicker;
|
||||
import net.minecraft.block.entity.BlockEntityType;
|
||||
import net.minecraft.entity.LivingEntity;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.loot.context.LootContextParameterSet.Builder;
|
||||
import net.minecraft.sound.SoundCategory;
|
||||
import net.minecraft.sound.SoundEvents;
|
||||
import net.minecraft.util.math.BlockPos;
|
||||
import net.minecraft.world.World;
|
||||
|
||||
/**
|
||||
*
|
||||
* @author jotty
|
||||
*
|
||||
*/
|
||||
public class BlockMonsterhoarder extends Block implements BlockEntityProvider {
|
||||
|
||||
|
||||
public BlockMonsterhoarder() {
|
||||
super(AbstractBlock.Settings.create().hardness(2.5f).luminance(state -> 15));
|
||||
}
|
||||
|
||||
@Override
|
||||
public BlockEntity createBlockEntity(BlockPos pos, BlockState blockState) {
|
||||
return new MonsterHoarderBlockEntity(pos, blockState);
|
||||
}
|
||||
|
||||
@Override
|
||||
public BlockRenderType getRenderType(BlockState state) {
|
||||
return BlockRenderType.MODEL;
|
||||
}
|
||||
|
||||
@Override
|
||||
public <T extends BlockEntity> BlockEntityTicker<T> getTicker(World world, BlockState state, BlockEntityType<T> type){
|
||||
return (world1, pos, state1, be) -> MonsterHoarderBlockEntity.tick(world1, pos, state1, be);
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<ItemStack> getDroppedStacks(BlockState state, Builder builder) {
|
||||
List<ItemStack> list = new ArrayList<>();
|
||||
list.add(new ItemStack(QuickieBlocks.MONSTERHOARDER.getBlock()));
|
||||
return list;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onPlaced(World world, BlockPos pos, BlockState state, LivingEntity placer, ItemStack itemStack) {
|
||||
if (!world.isClient) {
|
||||
world.playSound(null, pos, SoundEvents.UI_TOAST_CHALLENGE_COMPLETE, SoundCategory.PLAYERS, 1f, 1f);
|
||||
}
|
||||
super.onPlaced(world, pos, state, placer, itemStack);
|
||||
}
|
||||
}
|
@ -1,30 +0,0 @@
|
||||
package de.jottyfan.quickiemod.blocks;
|
||||
|
||||
import java.util.Arrays;
|
||||
import java.util.List;
|
||||
|
||||
import de.jottyfan.quickiemod.blocks.help.IntProviderHelper;
|
||||
import de.jottyfan.quickiemod.items.QuickieItems;
|
||||
import net.minecraft.block.BlockState;
|
||||
import net.minecraft.block.ExperienceDroppingBlock;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.loot.context.LootContextParameterSet.Builder;
|
||||
import net.minecraft.sound.BlockSoundGroup;
|
||||
|
||||
|
||||
/**
|
||||
*
|
||||
* @author jotty
|
||||
*
|
||||
*/
|
||||
public class BlockOreDeepslateSulphor extends ExperienceDroppingBlock {
|
||||
|
||||
public BlockOreDeepslateSulphor() {
|
||||
super(IntProviderHelper.of(0, 2), Settings.create().strength(2.5f).hardness(1.9f).sounds(BlockSoundGroup.SOUL_SAND).requiresTool());
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<ItemStack> getDroppedStacks(BlockState state, Builder builder) {
|
||||
return Arrays.asList(new ItemStack[] { new ItemStack(QuickieItems.SULPHOR.getItem(), 4) });
|
||||
}
|
||||
}
|
@ -1,29 +0,0 @@
|
||||
package de.jottyfan.quickiemod.blocks;
|
||||
|
||||
import java.util.Arrays;
|
||||
import java.util.List;
|
||||
|
||||
import de.jottyfan.quickiemod.blocks.help.IntProviderHelper;
|
||||
import de.jottyfan.quickiemod.items.QuickieItems;
|
||||
import net.minecraft.block.BlockState;
|
||||
import net.minecraft.block.ExperienceDroppingBlock;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.loot.context.LootContextParameterSet.Builder;
|
||||
import net.minecraft.sound.BlockSoundGroup;
|
||||
|
||||
/**
|
||||
*
|
||||
* @author jotty
|
||||
*
|
||||
*/
|
||||
public class BlockOreNetherSulphor extends ExperienceDroppingBlock {
|
||||
|
||||
public BlockOreNetherSulphor() {
|
||||
super(IntProviderHelper.of(0, 2), Settings.create().strength(2.5f).hardness(2.1f).sounds(BlockSoundGroup.SOUL_SAND).requiresTool());
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<ItemStack> getDroppedStacks(BlockState state, Builder builder) {
|
||||
return Arrays.asList(new ItemStack[] { new ItemStack(QuickieItems.SULPHOR.getItem()) });
|
||||
}
|
||||
}
|
@ -1,30 +0,0 @@
|
||||
package de.jottyfan.quickiemod.blocks;
|
||||
|
||||
import java.util.Arrays;
|
||||
import java.util.List;
|
||||
|
||||
import de.jottyfan.quickiemod.blocks.help.IntProviderHelper;
|
||||
import de.jottyfan.quickiemod.items.QuickieItems;
|
||||
import net.minecraft.block.BlockState;
|
||||
import net.minecraft.block.ExperienceDroppingBlock;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.loot.context.LootContextParameterSet.Builder;
|
||||
import net.minecraft.sound.BlockSoundGroup;
|
||||
import net.minecraft.util.math.random.Random;
|
||||
|
||||
/**
|
||||
*
|
||||
* @author jotty
|
||||
*
|
||||
*/
|
||||
public class BlockOreSalpeter extends ExperienceDroppingBlock {
|
||||
|
||||
public BlockOreSalpeter() {
|
||||
super(IntProviderHelper.of(0, 2), Settings.create().strength(2.5f).hardness(3.1f).sounds(BlockSoundGroup.SOUL_SAND).requiresTool());
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<ItemStack> getDroppedStacks(BlockState state, Builder builder) {
|
||||
return Arrays.asList(new ItemStack[] { new ItemStack(QuickieItems.SALPETER.getItem(), 2 + Random.create().nextInt(3)) });
|
||||
}
|
||||
}
|
@ -1,30 +0,0 @@
|
||||
package de.jottyfan.quickiemod.blocks;
|
||||
|
||||
import java.util.Arrays;
|
||||
import java.util.List;
|
||||
|
||||
import de.jottyfan.quickiemod.blocks.help.IntProviderHelper;
|
||||
import de.jottyfan.quickiemod.items.QuickieItems;
|
||||
import net.minecraft.block.BlockState;
|
||||
import net.minecraft.block.ExperienceDroppingBlock;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.loot.context.LootContextParameterSet.Builder;
|
||||
import net.minecraft.sound.BlockSoundGroup;
|
||||
|
||||
|
||||
/**
|
||||
*
|
||||
* @author jotty
|
||||
*
|
||||
*/
|
||||
public class BlockOreSulphor extends ExperienceDroppingBlock {
|
||||
|
||||
public BlockOreSulphor() {
|
||||
super(IntProviderHelper.of(0, 2), Settings.create().strength(2.5f).hardness(1.9f).sounds(BlockSoundGroup.SOUL_SAND).requiresTool());
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<ItemStack> getDroppedStacks(BlockState state, Builder builder) {
|
||||
return Arrays.asList(new ItemStack[] { new ItemStack(QuickieItems.SULPHOR.getItem()) });
|
||||
}
|
||||
}
|
@ -1,29 +0,0 @@
|
||||
package de.jottyfan.quickiemod.blocks;
|
||||
|
||||
import java.util.Arrays;
|
||||
import java.util.List;
|
||||
|
||||
import de.jottyfan.quickiemod.blocks.help.IntProviderHelper;
|
||||
import de.jottyfan.quickiemod.items.QuickieItems;
|
||||
import net.minecraft.block.BlockState;
|
||||
import net.minecraft.block.ExperienceDroppingBlock;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.loot.context.LootContextParameterSet.Builder;
|
||||
import net.minecraft.sound.BlockSoundGroup;
|
||||
|
||||
/**
|
||||
*
|
||||
* @author jotty
|
||||
*
|
||||
*/
|
||||
public class BlockSalpeter extends ExperienceDroppingBlock {
|
||||
|
||||
public BlockSalpeter() {
|
||||
super(IntProviderHelper.of(0, 2), Settings.create().strength(2.5f).hardness(0.5f).sounds(BlockSoundGroup.SOUL_SAND).requiresTool());
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<ItemStack> getDroppedStacks(BlockState state, Builder builder) {
|
||||
return Arrays.asList(new ItemStack[] { new ItemStack(QuickieItems.SALPETER.getItem(), 9) });
|
||||
}
|
||||
}
|
@ -1,111 +0,0 @@
|
||||
package de.jottyfan.quickiemod.blocks;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import com.mojang.serialization.MapCodec;
|
||||
|
||||
import de.jottyfan.quickiemod.blockentity.BlockEntityTypes;
|
||||
import de.jottyfan.quickiemod.blockentity.BlockStackerEntity;
|
||||
import de.jottyfan.quickiemod.blocks.help.BlockStacker;
|
||||
import net.minecraft.block.AbstractBlock;
|
||||
import net.minecraft.block.BlockRenderType;
|
||||
import net.minecraft.block.BlockState;
|
||||
import net.minecraft.block.BlockWithEntity;
|
||||
import net.minecraft.block.entity.BlockEntity;
|
||||
import net.minecraft.block.entity.BlockEntityTicker;
|
||||
import net.minecraft.block.entity.BlockEntityType;
|
||||
import net.minecraft.entity.player.PlayerEntity;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.loot.context.LootContextParameterSet.Builder;
|
||||
import net.minecraft.screen.NamedScreenHandlerFactory;
|
||||
import net.minecraft.screen.ScreenHandler;
|
||||
import net.minecraft.util.ActionResult;
|
||||
import net.minecraft.util.ItemScatterer;
|
||||
import net.minecraft.util.hit.BlockHitResult;
|
||||
import net.minecraft.util.math.BlockPos;
|
||||
import net.minecraft.util.math.Direction;
|
||||
import net.minecraft.world.World;
|
||||
|
||||
/**
|
||||
*
|
||||
* @author jotty
|
||||
*
|
||||
*/
|
||||
public class BlockStackerEast extends BlockWithEntity implements BlockStacker {
|
||||
|
||||
public BlockStackerEast() {
|
||||
super(AbstractBlock.Settings.create().hardness(2.5f));
|
||||
}
|
||||
|
||||
@Override
|
||||
public Direction getSourceOffset() {
|
||||
return Direction.WEST;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Direction getDestOffset() {
|
||||
return Direction.EAST;
|
||||
}
|
||||
|
||||
@Override
|
||||
public BlockEntity createBlockEntity(BlockPos pos, BlockState state) {
|
||||
return new BlockStackerEntity(pos, state);
|
||||
}
|
||||
|
||||
@Override
|
||||
public BlockRenderType getRenderType(BlockState state) {
|
||||
return BlockRenderType.MODEL;
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<ItemStack> getDroppedStacks(BlockState state, Builder builder) {
|
||||
return List.of(new ItemStack(QuickieBlocks.BLOCKSTACKEREAST.getBlock()));
|
||||
}
|
||||
|
||||
@Override
|
||||
public <T extends BlockEntity> BlockEntityTicker<T> getTicker(World world, BlockState state,
|
||||
BlockEntityType<T> type) {
|
||||
return validateTicker(type, BlockEntityTypes.BLOCKSTACKER_ENTITY,
|
||||
(world1, pos, state1, be) -> BlockStackerEntity.tick(world1, pos, state1, be));
|
||||
}
|
||||
|
||||
@Override
|
||||
protected ActionResult onUse(BlockState state, World world, BlockPos pos, PlayerEntity player, BlockHitResult hit) {
|
||||
if (!world.isClient) {
|
||||
NamedScreenHandlerFactory screenHandlerFactory = state.createScreenHandlerFactory(world, pos);
|
||||
if (screenHandlerFactory != null) {
|
||||
player.openHandledScreen(screenHandlerFactory);
|
||||
}
|
||||
}
|
||||
return ActionResult.SUCCESS;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onStateReplaced(BlockState state, World world, BlockPos pos, BlockState newState, boolean moved) {
|
||||
if (state.getBlock() != newState.getBlock()) {
|
||||
BlockEntity blockEntity = world.getBlockEntity(pos);
|
||||
if (blockEntity instanceof BlockStackerEntity) {
|
||||
ItemScatterer.spawn(world, pos, (BlockStackerEntity) blockEntity);
|
||||
// update comparators
|
||||
world.updateComparators(pos, this);
|
||||
}
|
||||
super.onStateReplaced(state, world, pos, newState, moved);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean hasComparatorOutput(BlockState state) {
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getComparatorOutput(BlockState state, World world, BlockPos pos) {
|
||||
return ScreenHandler.calculateComparatorOutput(world.getBlockEntity(pos));
|
||||
}
|
||||
|
||||
@Override
|
||||
protected MapCodec<? extends BlockWithEntity> getCodec() {
|
||||
// TODO Auto-generated method stub
|
||||
return null;
|
||||
}
|
||||
}
|
@ -1,111 +0,0 @@
|
||||
package de.jottyfan.quickiemod.blocks;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import com.mojang.serialization.MapCodec;
|
||||
|
||||
import de.jottyfan.quickiemod.blockentity.BlockEntityTypes;
|
||||
import de.jottyfan.quickiemod.blockentity.BlockStackerEntity;
|
||||
import de.jottyfan.quickiemod.blocks.help.BlockStacker;
|
||||
import net.minecraft.block.AbstractBlock;
|
||||
import net.minecraft.block.BlockRenderType;
|
||||
import net.minecraft.block.BlockState;
|
||||
import net.minecraft.block.BlockWithEntity;
|
||||
import net.minecraft.block.entity.BlockEntity;
|
||||
import net.minecraft.block.entity.BlockEntityTicker;
|
||||
import net.minecraft.block.entity.BlockEntityType;
|
||||
import net.minecraft.entity.player.PlayerEntity;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.loot.context.LootContextParameterSet.Builder;
|
||||
import net.minecraft.screen.NamedScreenHandlerFactory;
|
||||
import net.minecraft.screen.ScreenHandler;
|
||||
import net.minecraft.util.ActionResult;
|
||||
import net.minecraft.util.ItemScatterer;
|
||||
import net.minecraft.util.hit.BlockHitResult;
|
||||
import net.minecraft.util.math.BlockPos;
|
||||
import net.minecraft.util.math.Direction;
|
||||
import net.minecraft.world.World;
|
||||
|
||||
/**
|
||||
*
|
||||
* @author jotty
|
||||
*
|
||||
*/
|
||||
public class BlockStackerNorth extends BlockWithEntity implements BlockStacker {
|
||||
|
||||
public BlockStackerNorth() {
|
||||
super(AbstractBlock.Settings.create().hardness(2.5f));
|
||||
}
|
||||
|
||||
@Override
|
||||
public Direction getSourceOffset() {
|
||||
return Direction.SOUTH;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Direction getDestOffset() {
|
||||
return Direction.NORTH;
|
||||
}
|
||||
|
||||
@Override
|
||||
public BlockEntity createBlockEntity(BlockPos pos, BlockState state) {
|
||||
return new BlockStackerEntity(pos, state);
|
||||
}
|
||||
|
||||
@Override
|
||||
public BlockRenderType getRenderType(BlockState state) {
|
||||
return BlockRenderType.MODEL;
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<ItemStack> getDroppedStacks(BlockState state, Builder builder) {
|
||||
return List.of(new ItemStack(QuickieBlocks.BLOCKSTACKERNORTH.getBlock()));
|
||||
}
|
||||
|
||||
@Override
|
||||
public <T extends BlockEntity> BlockEntityTicker<T> getTicker(World world, BlockState state,
|
||||
BlockEntityType<T> type) {
|
||||
return validateTicker(type, BlockEntityTypes.BLOCKSTACKER_ENTITY,
|
||||
(world1, pos, state1, be) -> BlockStackerEntity.tick(world1, pos, state1, be));
|
||||
}
|
||||
|
||||
@Override
|
||||
protected ActionResult onUse(BlockState state, World world, BlockPos pos, PlayerEntity player, BlockHitResult hit) {
|
||||
if (!world.isClient) {
|
||||
NamedScreenHandlerFactory screenHandlerFactory = state.createScreenHandlerFactory(world, pos);
|
||||
if (screenHandlerFactory != null) {
|
||||
player.openHandledScreen(screenHandlerFactory);
|
||||
}
|
||||
}
|
||||
return ActionResult.SUCCESS;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onStateReplaced(BlockState state, World world, BlockPos pos, BlockState newState, boolean moved) {
|
||||
if (state.getBlock() != newState.getBlock()) {
|
||||
BlockEntity blockEntity = world.getBlockEntity(pos);
|
||||
if (blockEntity instanceof BlockStackerEntity) {
|
||||
ItemScatterer.spawn(world, pos, (BlockStackerEntity) blockEntity);
|
||||
// update comparators
|
||||
world.updateComparators(pos, this);
|
||||
}
|
||||
super.onStateReplaced(state, world, pos, newState, moved);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean hasComparatorOutput(BlockState state) {
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getComparatorOutput(BlockState state, World world, BlockPos pos) {
|
||||
return ScreenHandler.calculateComparatorOutput(world.getBlockEntity(pos));
|
||||
}
|
||||
|
||||
@Override
|
||||
protected MapCodec<? extends BlockWithEntity> getCodec() {
|
||||
// TODO Auto-generated method stub
|
||||
return null;
|
||||
}
|
||||
}
|
@ -1,111 +0,0 @@
|
||||
package de.jottyfan.quickiemod.blocks;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import com.mojang.serialization.MapCodec;
|
||||
|
||||
import de.jottyfan.quickiemod.blockentity.BlockEntityTypes;
|
||||
import de.jottyfan.quickiemod.blockentity.BlockStackerEntity;
|
||||
import de.jottyfan.quickiemod.blocks.help.BlockStacker;
|
||||
import net.minecraft.block.AbstractBlock;
|
||||
import net.minecraft.block.BlockRenderType;
|
||||
import net.minecraft.block.BlockState;
|
||||
import net.minecraft.block.BlockWithEntity;
|
||||
import net.minecraft.block.entity.BlockEntity;
|
||||
import net.minecraft.block.entity.BlockEntityTicker;
|
||||
import net.minecraft.block.entity.BlockEntityType;
|
||||
import net.minecraft.entity.player.PlayerEntity;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.loot.context.LootContextParameterSet.Builder;
|
||||
import net.minecraft.screen.NamedScreenHandlerFactory;
|
||||
import net.minecraft.screen.ScreenHandler;
|
||||
import net.minecraft.util.ActionResult;
|
||||
import net.minecraft.util.ItemScatterer;
|
||||
import net.minecraft.util.hit.BlockHitResult;
|
||||
import net.minecraft.util.math.BlockPos;
|
||||
import net.minecraft.util.math.Direction;
|
||||
import net.minecraft.world.World;
|
||||
|
||||
/**
|
||||
*
|
||||
* @author jotty
|
||||
*
|
||||
*/
|
||||
public class BlockStackerSouth extends BlockWithEntity implements BlockStacker {
|
||||
|
||||
public BlockStackerSouth() {
|
||||
super(AbstractBlock.Settings.create().hardness(2.5f));
|
||||
}
|
||||
|
||||
@Override
|
||||
public Direction getSourceOffset() {
|
||||
return Direction.NORTH;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Direction getDestOffset() {
|
||||
return Direction.SOUTH;
|
||||
}
|
||||
|
||||
@Override
|
||||
public BlockEntity createBlockEntity(BlockPos pos, BlockState state) {
|
||||
return new BlockStackerEntity(pos, state);
|
||||
}
|
||||
|
||||
@Override
|
||||
public BlockRenderType getRenderType(BlockState state) {
|
||||
return BlockRenderType.MODEL;
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<ItemStack> getDroppedStacks(BlockState state, Builder builder) {
|
||||
return List.of(new ItemStack(QuickieBlocks.BLOCKSTACKERSOUTH.getBlock()));
|
||||
}
|
||||
|
||||
@Override
|
||||
public <T extends BlockEntity> BlockEntityTicker<T> getTicker(World world, BlockState state,
|
||||
BlockEntityType<T> type) {
|
||||
return validateTicker(type, BlockEntityTypes.BLOCKSTACKER_ENTITY,
|
||||
(world1, pos, state1, be) -> BlockStackerEntity.tick(world1, pos, state1, be));
|
||||
}
|
||||
|
||||
@Override
|
||||
protected ActionResult onUse(BlockState state, World world, BlockPos pos, PlayerEntity player, BlockHitResult hit) {
|
||||
if (!world.isClient) {
|
||||
NamedScreenHandlerFactory screenHandlerFactory = state.createScreenHandlerFactory(world, pos);
|
||||
if (screenHandlerFactory != null) {
|
||||
player.openHandledScreen(screenHandlerFactory);
|
||||
}
|
||||
}
|
||||
return ActionResult.SUCCESS;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onStateReplaced(BlockState state, World world, BlockPos pos, BlockState newState, boolean moved) {
|
||||
if (state.getBlock() != newState.getBlock()) {
|
||||
BlockEntity blockEntity = world.getBlockEntity(pos);
|
||||
if (blockEntity instanceof BlockStackerEntity) {
|
||||
ItemScatterer.spawn(world, pos, (BlockStackerEntity) blockEntity);
|
||||
// update comparators
|
||||
world.updateComparators(pos, this);
|
||||
}
|
||||
super.onStateReplaced(state, world, pos, newState, moved);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean hasComparatorOutput(BlockState state) {
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getComparatorOutput(BlockState state, World world, BlockPos pos) {
|
||||
return ScreenHandler.calculateComparatorOutput(world.getBlockEntity(pos));
|
||||
}
|
||||
|
||||
@Override
|
||||
protected MapCodec<? extends BlockWithEntity> getCodec() {
|
||||
// TODO Auto-generated method stub
|
||||
return null;
|
||||
}
|
||||
}
|
@ -1,111 +0,0 @@
|
||||
package de.jottyfan.quickiemod.blocks;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import com.mojang.serialization.MapCodec;
|
||||
|
||||
import de.jottyfan.quickiemod.blockentity.BlockEntityTypes;
|
||||
import de.jottyfan.quickiemod.blockentity.BlockStackerEntity;
|
||||
import de.jottyfan.quickiemod.blocks.help.BlockStacker;
|
||||
import net.minecraft.block.AbstractBlock;
|
||||
import net.minecraft.block.BlockRenderType;
|
||||
import net.minecraft.block.BlockState;
|
||||
import net.minecraft.block.BlockWithEntity;
|
||||
import net.minecraft.block.entity.BlockEntity;
|
||||
import net.minecraft.block.entity.BlockEntityTicker;
|
||||
import net.minecraft.block.entity.BlockEntityType;
|
||||
import net.minecraft.entity.player.PlayerEntity;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.loot.context.LootContextParameterSet.Builder;
|
||||
import net.minecraft.screen.NamedScreenHandlerFactory;
|
||||
import net.minecraft.screen.ScreenHandler;
|
||||
import net.minecraft.util.ActionResult;
|
||||
import net.minecraft.util.ItemScatterer;
|
||||
import net.minecraft.util.hit.BlockHitResult;
|
||||
import net.minecraft.util.math.BlockPos;
|
||||
import net.minecraft.util.math.Direction;
|
||||
import net.minecraft.world.World;
|
||||
|
||||
/**
|
||||
*
|
||||
* @author jotty
|
||||
*
|
||||
*/
|
||||
public class BlockStackerUp extends BlockWithEntity implements BlockStacker {
|
||||
|
||||
public BlockStackerUp() {
|
||||
super(AbstractBlock.Settings.create().hardness(2.5f));
|
||||
}
|
||||
|
||||
@Override
|
||||
public Direction getSourceOffset() {
|
||||
return Direction.DOWN;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Direction getDestOffset() {
|
||||
return Direction.UP;
|
||||
}
|
||||
|
||||
@Override
|
||||
public BlockEntity createBlockEntity(BlockPos pos, BlockState state) {
|
||||
return new BlockStackerEntity(pos, state);
|
||||
}
|
||||
|
||||
@Override
|
||||
public BlockRenderType getRenderType(BlockState state) {
|
||||
return BlockRenderType.MODEL;
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<ItemStack> getDroppedStacks(BlockState state, Builder builder) {
|
||||
return List.of(new ItemStack(QuickieBlocks.BLOCKSTACKERUP.getBlock()));
|
||||
}
|
||||
|
||||
@Override
|
||||
public <T extends BlockEntity> BlockEntityTicker<T> getTicker(World world, BlockState state,
|
||||
BlockEntityType<T> type) {
|
||||
return validateTicker(type, BlockEntityTypes.BLOCKSTACKER_ENTITY,
|
||||
(world1, pos, state1, be) -> BlockStackerEntity.tick(world1, pos, state1, be));
|
||||
}
|
||||
|
||||
@Override
|
||||
protected ActionResult onUse(BlockState state, World world, BlockPos pos, PlayerEntity player, BlockHitResult hit) {
|
||||
if (!world.isClient) {
|
||||
NamedScreenHandlerFactory screenHandlerFactory = state.createScreenHandlerFactory(world, pos);
|
||||
if (screenHandlerFactory != null) {
|
||||
player.openHandledScreen(screenHandlerFactory);
|
||||
}
|
||||
}
|
||||
return ActionResult.SUCCESS;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onStateReplaced(BlockState state, World world, BlockPos pos, BlockState newState, boolean moved) {
|
||||
if (state.getBlock() != newState.getBlock()) {
|
||||
BlockEntity blockEntity = world.getBlockEntity(pos);
|
||||
if (blockEntity instanceof BlockStackerEntity) {
|
||||
ItemScatterer.spawn(world, pos, (BlockStackerEntity) blockEntity);
|
||||
// update comparators
|
||||
world.updateComparators(pos, this);
|
||||
}
|
||||
super.onStateReplaced(state, world, pos, newState, moved);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean hasComparatorOutput(BlockState state) {
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getComparatorOutput(BlockState state, World world, BlockPos pos) {
|
||||
return ScreenHandler.calculateComparatorOutput(world.getBlockEntity(pos));
|
||||
}
|
||||
|
||||
@Override
|
||||
protected MapCodec<? extends BlockWithEntity> getCodec() {
|
||||
// TODO Auto-generated method stub
|
||||
return null;
|
||||
}
|
||||
}
|
@ -1,111 +0,0 @@
|
||||
package de.jottyfan.quickiemod.blocks;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import com.mojang.serialization.MapCodec;
|
||||
|
||||
import de.jottyfan.quickiemod.blockentity.BlockEntityTypes;
|
||||
import de.jottyfan.quickiemod.blockentity.BlockStackerEntity;
|
||||
import de.jottyfan.quickiemod.blocks.help.BlockStacker;
|
||||
import net.minecraft.block.AbstractBlock;
|
||||
import net.minecraft.block.BlockRenderType;
|
||||
import net.minecraft.block.BlockState;
|
||||
import net.minecraft.block.BlockWithEntity;
|
||||
import net.minecraft.block.entity.BlockEntity;
|
||||
import net.minecraft.block.entity.BlockEntityTicker;
|
||||
import net.minecraft.block.entity.BlockEntityType;
|
||||
import net.minecraft.entity.player.PlayerEntity;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.loot.context.LootContextParameterSet.Builder;
|
||||
import net.minecraft.screen.NamedScreenHandlerFactory;
|
||||
import net.minecraft.screen.ScreenHandler;
|
||||
import net.minecraft.util.ActionResult;
|
||||
import net.minecraft.util.ItemScatterer;
|
||||
import net.minecraft.util.hit.BlockHitResult;
|
||||
import net.minecraft.util.math.BlockPos;
|
||||
import net.minecraft.util.math.Direction;
|
||||
import net.minecraft.world.World;
|
||||
|
||||
/**
|
||||
*
|
||||
* @author jotty
|
||||
*
|
||||
*/
|
||||
public class BlockStackerWest extends BlockWithEntity implements BlockStacker {
|
||||
|
||||
public BlockStackerWest() {
|
||||
super(AbstractBlock.Settings.create().hardness(2.5f));
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<ItemStack> getDroppedStacks(BlockState state, Builder builder) {
|
||||
return List.of(new ItemStack(QuickieBlocks.BLOCKSTACKERWEST.getBlock()));
|
||||
}
|
||||
|
||||
@Override
|
||||
public Direction getSourceOffset() {
|
||||
return Direction.EAST;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Direction getDestOffset() {
|
||||
return Direction.WEST;
|
||||
}
|
||||
|
||||
@Override
|
||||
public BlockEntity createBlockEntity(BlockPos pos, BlockState state) {
|
||||
return new BlockStackerEntity(pos, state);
|
||||
}
|
||||
|
||||
@Override
|
||||
public BlockRenderType getRenderType(BlockState state) {
|
||||
return BlockRenderType.MODEL;
|
||||
}
|
||||
|
||||
@Override
|
||||
public <T extends BlockEntity> BlockEntityTicker<T> getTicker(World world, BlockState state,
|
||||
BlockEntityType<T> type) {
|
||||
return validateTicker(type, BlockEntityTypes.BLOCKSTACKER_ENTITY,
|
||||
(world1, pos, state1, be) -> BlockStackerEntity.tick(world1, pos, state1, be));
|
||||
}
|
||||
|
||||
@Override
|
||||
protected ActionResult onUse(BlockState state, World world, BlockPos pos, PlayerEntity player, BlockHitResult hit) {
|
||||
if (!world.isClient) {
|
||||
NamedScreenHandlerFactory screenHandlerFactory = state.createScreenHandlerFactory(world, pos);
|
||||
if (screenHandlerFactory != null) {
|
||||
player.openHandledScreen(screenHandlerFactory);
|
||||
}
|
||||
}
|
||||
return ActionResult.SUCCESS;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onStateReplaced(BlockState state, World world, BlockPos pos, BlockState newState, boolean moved) {
|
||||
if (state.getBlock() != newState.getBlock()) {
|
||||
BlockEntity blockEntity = world.getBlockEntity(pos);
|
||||
if (blockEntity instanceof BlockStackerEntity) {
|
||||
ItemScatterer.spawn(world, pos, (BlockStackerEntity) blockEntity);
|
||||
// update comparators
|
||||
world.updateComparators(pos, this);
|
||||
}
|
||||
super.onStateReplaced(state, world, pos, newState, moved);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean hasComparatorOutput(BlockState state) {
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getComparatorOutput(BlockState state, World world, BlockPos pos) {
|
||||
return ScreenHandler.calculateComparatorOutput(world.getBlockEntity(pos));
|
||||
}
|
||||
|
||||
@Override
|
||||
protected MapCodec<? extends BlockWithEntity> getCodec() {
|
||||
// TODO Auto-generated method stub
|
||||
return null;
|
||||
}
|
||||
}
|
@ -1,29 +0,0 @@
|
||||
package de.jottyfan.quickiemod.blocks;
|
||||
|
||||
import java.util.Arrays;
|
||||
import java.util.List;
|
||||
|
||||
import de.jottyfan.quickiemod.blocks.help.IntProviderHelper;
|
||||
import de.jottyfan.quickiemod.items.QuickieItems;
|
||||
import net.minecraft.block.BlockState;
|
||||
import net.minecraft.block.ExperienceDroppingBlock;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.loot.context.LootContextParameterSet.Builder;
|
||||
import net.minecraft.sound.BlockSoundGroup;
|
||||
|
||||
/**
|
||||
*
|
||||
* @author jotty
|
||||
*
|
||||
*/
|
||||
public class BlockSulphor extends ExperienceDroppingBlock {
|
||||
|
||||
public BlockSulphor() {
|
||||
super(IntProviderHelper.of(0, 2), Settings.create().strength(2.5f).hardness(0.5f).sounds(BlockSoundGroup.SOUL_SAND).requiresTool());
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<ItemStack> getDroppedStacks(BlockState state, Builder builder) {
|
||||
return Arrays.asList(new ItemStack[] { new ItemStack(QuickieItems.SULPHOR.getItem(), 9) });
|
||||
}
|
||||
}
|
@ -1,69 +0,0 @@
|
||||
package de.jottyfan.quickiemod.blocks;
|
||||
|
||||
import net.minecraft.block.Block;
|
||||
|
||||
/**
|
||||
*
|
||||
* @author jotty
|
||||
*
|
||||
*/
|
||||
public enum QuickieBlocks {
|
||||
// @formatter:off
|
||||
BLOCKSTACKERUP(new BlockStackerUp(), "blockstackerup"),
|
||||
BLOCKSTACKERDOWN(new BlockStackerDown(), "blockstackerdown"),
|
||||
BLOCKSTACKEREAST(new BlockStackerEast(), "blockstackereast"),
|
||||
BLOCKSTACKERWEST(new BlockStackerWest(), "blockstackerwest"),
|
||||
BLOCKSTACKERNORTH(new BlockStackerNorth(), "blockstackernorth"),
|
||||
BLOCKSTACKERSOUTH(new BlockStackerSouth(), "blockstackersouth"),
|
||||
DRILL_DOWN(new BlockDrillDown(), "drill"),
|
||||
DRILL_EAST(new BlockDrillEast(), "drilleast"),
|
||||
DRILL_SOUTH(new BlockDrillSouth(), "drillsouth"),
|
||||
DRILL_WEST(new BlockDrillWest(), "drillwest"),
|
||||
DRILL_NORTH(new BlockDrillNorth(), "drillnorth"),
|
||||
DRILLSTOP(new BlockDrillstop(), "drillstop"),
|
||||
MONSTERHOARDER(new BlockMonsterhoarder(), "monsterhoarder"),
|
||||
ITEMHOARDER(new BlockItemhoarder(), "itemhoarder"),
|
||||
LAVAHOARDER(new BlockLavahoarder(), "lavahoarder", false),
|
||||
EMPTYLAVAHOARDER(new BlockEmptyLavahoarder(), "emptylavahoarder"),
|
||||
KELPSTACK(new BlockKelpstack(), "kelpstack"),
|
||||
COTTONPLANT(new BlockCottonplant(), "cottonplant", false),
|
||||
CANOLAPLANT(new BlockCanolaplant(), "canolaplant", false),
|
||||
DIRTSALPETER(new BlockDirtSalpeter(), "dirtsalpeter"),
|
||||
ORE_NETHER_SULPHOR(new BlockOreNetherSulphor(), "orenethersulphor"),
|
||||
ORE_SALPETER(new BlockOreSalpeter(), "oresalpeter"),
|
||||
ORE_SAND_SALPETER(new BlockSandSalpeter(), "oresandsalpeter"),
|
||||
ORE_SULPHOR(new BlockOreSulphor(), "oresulphor"),
|
||||
ORE_DEEPSLATESULPHOR(new BlockOreDeepslateSulphor(), "oredeepslatesulphor"),
|
||||
SANDSALPETER(new BlockSandSalpeter(), "sandsalpeter"),
|
||||
BLOCKSULPHOR(new BlockSulphor(), "blocksulphor"),
|
||||
BLOCKSALPETER(new BlockSalpeter(), "blocksalpeter"),
|
||||
BLOCKSPEEDPOWDER(new BlockSpeedpowder(), "blockspeedpowder"),
|
||||
BLOCKQUICKIEPOWDER(new BlockQuickiepowder(), "blockquickiepowder");
|
||||
// @formatter:on
|
||||
|
||||
private final Block block;
|
||||
private final String name;
|
||||
private final Boolean add2BlockPanel;
|
||||
|
||||
private QuickieBlocks(Block block, String name) {
|
||||
this(block, name, true);
|
||||
}
|
||||
|
||||
private QuickieBlocks(Block block, String name, Boolean add2BlockPanel) {
|
||||
this.block = block;
|
||||
this.name = name;
|
||||
this.add2BlockPanel = add2BlockPanel;
|
||||
}
|
||||
|
||||
public final Block getBlock() {
|
||||
return block;
|
||||
}
|
||||
|
||||
public final String getName() {
|
||||
return name;
|
||||
}
|
||||
|
||||
public final Boolean getAdd2BlockPanel() {
|
||||
return add2BlockPanel;
|
||||
}
|
||||
}
|
@ -1,25 +0,0 @@
|
||||
package de.jottyfan.quickiemod.blocks.help;
|
||||
|
||||
import net.minecraft.block.BlockEntityProvider;
|
||||
import net.minecraft.util.math.Direction;
|
||||
|
||||
/**
|
||||
*
|
||||
* @author jotty
|
||||
*
|
||||
*/
|
||||
public interface BlockStacker extends BlockEntityProvider {
|
||||
/**
|
||||
* define the source offset
|
||||
*
|
||||
* @return the direction of the source offset (1 block beside)
|
||||
*/
|
||||
public Direction getSourceOffset();
|
||||
|
||||
/**
|
||||
* define the dest offset
|
||||
*
|
||||
* @return the direction of the dest offset (1 block beside)
|
||||
*/
|
||||
public Direction getDestOffset();
|
||||
}
|
@ -1,78 +0,0 @@
|
||||
package de.jottyfan.quickiemod.blocks.help;
|
||||
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
|
||||
import de.jottyfan.quickiemod.items.QuickieItems;
|
||||
import net.minecraft.block.Block;
|
||||
import net.minecraft.block.BlockState;
|
||||
import net.minecraft.block.FallingBlock;
|
||||
import net.minecraft.entity.ItemEntity;
|
||||
import net.minecraft.entity.player.PlayerEntity;
|
||||
import net.minecraft.item.Item;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.item.Items;
|
||||
import net.minecraft.state.property.IntProperty;
|
||||
import net.minecraft.text.Text;
|
||||
import net.minecraft.util.ActionResult;
|
||||
import net.minecraft.util.hit.BlockHitResult;
|
||||
import net.minecraft.util.math.BlockPos;
|
||||
import net.minecraft.world.World;
|
||||
|
||||
/**
|
||||
*
|
||||
* @author jotty
|
||||
*
|
||||
*/
|
||||
public abstract class DrillBlock extends FallingBlock {
|
||||
private static final Integer MAX_FUEL = 255;
|
||||
public static final IntProperty FUEL = IntProperty.of("fuel", 0, MAX_FUEL);
|
||||
|
||||
public DrillBlock(Settings settings) {
|
||||
super(settings);
|
||||
setDefaultState(getDefaultState().with(FUEL, 0));
|
||||
}
|
||||
|
||||
@Override
|
||||
public BlockState onBreak(World world, BlockPos pos, BlockState state, PlayerEntity player) {
|
||||
Integer fuelLeft = state.get(FUEL);
|
||||
world.spawnEntity(new ItemEntity(world, pos.getX(), pos.getY(), pos.getZ(), new ItemStack(QuickieItems.CANOLABOTTLE.getItem(), fuelLeft)));
|
||||
return super.onBreak(world, pos, state, player);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void appendProperties(net.minecraft.state.StateManager.Builder<Block, BlockState> builder) {
|
||||
builder.add(FUEL);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected ActionResult onUse(BlockState state, World world, BlockPos pos, PlayerEntity player, BlockHitResult hit) {
|
||||
Map<Item, Integer> loadings = new HashMap<>();
|
||||
loadings.put(QuickieItems.CANOLABOTTLE.getItem(), 8);
|
||||
loadings.put(QuickieItems.CANOLABOTTLESTACK.getItem(), 72);
|
||||
ItemStack stack = player.getStackInHand(player.getActiveHand());
|
||||
Item item = stack.getItem();
|
||||
if (stack.isEmpty() || !loadings.containsKey(item) ) {
|
||||
if (world.isClient()) {
|
||||
player.sendMessage(Text.translatable("msg.drill.fuelinfo", state.get(FUEL)));
|
||||
}
|
||||
} else {
|
||||
Integer fuelWeight = loadings.get(item);
|
||||
if (fuelWeight != null) {
|
||||
Integer load = MAX_FUEL - state.get(FUEL);
|
||||
if (load < fuelWeight) {
|
||||
// Integer numberOfTooMuchLoad = fuelWeight - load;
|
||||
fuelWeight = load;
|
||||
}
|
||||
world.setBlockState(pos, state.with(FUEL, state.get(FUEL) + fuelWeight));
|
||||
if (item.equals(QuickieItems.CANOLABOTTLE.getItem())) {
|
||||
world.spawnEntity(new ItemEntity(world, pos.getX(), pos.getY(), pos.getZ(), new ItemStack(Items.GLASS_BOTTLE, 1)));
|
||||
} else if (item.equals(QuickieItems.CANOLABOTTLESTACK.getItem())) {
|
||||
world.spawnEntity(new ItemEntity(world, pos.getX(), pos.getY(), pos.getZ(), new ItemStack(Items.GLASS_BOTTLE, 9)));
|
||||
}
|
||||
stack.decrement(1);
|
||||
}
|
||||
}
|
||||
return ActionResult.PASS;
|
||||
}
|
||||
}
|
@ -1,6 +1,6 @@
|
||||
package de.jottyfan.quickiemod.container;
|
||||
|
||||
import de.jottyfan.quickiemod.QuickieMod;
|
||||
import de.jottyfan.quickiemod.Quickiemod;
|
||||
import net.fabricmc.api.EnvType;
|
||||
import net.fabricmc.api.Environment;
|
||||
import net.minecraft.client.gui.DrawContext;
|
||||
@ -18,7 +18,7 @@ import net.minecraft.util.Identifier;
|
||||
@Environment(EnvType.CLIENT)
|
||||
public class BlockStackerScreen extends HandledScreen<BlockStackerScreenHandler>
|
||||
implements ScreenHandlerProvider<BlockStackerScreenHandler> {
|
||||
private final static Identifier TEXTURE = Identifier.of(QuickieMod.MODID, "textures/gui/blockstacker.png");
|
||||
private final static Identifier TEXTURE = Identifier.of(Quickiemod.MOD_ID, "textures/gui/blockstacker.png");
|
||||
private final Integer containerHeight = 222;
|
||||
private final Integer containerWidth = 176;
|
||||
|
||||
@ -39,6 +39,6 @@ public class BlockStackerScreen extends HandledScreen<BlockStackerScreenHandler>
|
||||
int guiX = (this.width - this.containerWidth) / 2;
|
||||
int guiY = (this.height - this.containerHeight) / 2;
|
||||
super.renderInGameBackground(context);
|
||||
context.drawTexture(TEXTURE, guiX, guiY, 0, 0, containerWidth, containerHeight);
|
||||
// context.drawTexture(TEXTURE, guiX, guiY, 0f, 0f, containerWidth, containerHeight, 0, 0);
|
||||
}
|
||||
}
|
||||
|
@ -1,29 +0,0 @@
|
||||
package de.jottyfan.quickiemod.event;
|
||||
|
||||
import net.fabricmc.fabric.api.event.Event;
|
||||
import net.fabricmc.fabric.api.event.EventFactory;
|
||||
import net.minecraft.block.BlockState;
|
||||
import net.minecraft.entity.player.PlayerEntity;
|
||||
import net.minecraft.util.ActionResult;
|
||||
import net.minecraft.util.math.BlockPos;
|
||||
import net.minecraft.world.World;
|
||||
|
||||
/**
|
||||
*
|
||||
* @author jotty
|
||||
*
|
||||
*/
|
||||
public interface BreakBlockCallback {
|
||||
Event<BreakBlockCallback> EVENT = EventFactory.createArrayBacked(BreakBlockCallback.class,
|
||||
(listeners) -> (world, blockPos, blockState, playerEntity) -> {
|
||||
for (BreakBlockCallback listener : listeners) {
|
||||
ActionResult result = listener.injectBlockBreakCallback(world, blockPos, blockState, playerEntity);
|
||||
if (result != ActionResult.PASS) {
|
||||
return result;
|
||||
}
|
||||
}
|
||||
return ActionResult.PASS;
|
||||
});
|
||||
|
||||
ActionResult injectBlockBreakCallback(World world, BlockPos blockPos, BlockState blockState, PlayerEntity playerEntity);
|
||||
}
|
@ -3,13 +3,10 @@ package de.jottyfan.quickiemod.event;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
import org.apache.logging.log4j.LogManager;
|
||||
import org.apache.logging.log4j.Logger;
|
||||
|
||||
import de.jottyfan.quickiemod.QuickieMod;
|
||||
import de.jottyfan.quickiemod.items.HarvestRange;
|
||||
import de.jottyfan.quickiemod.items.QuickieItems;
|
||||
import de.jottyfan.quickiemod.items.ToolRangeable;
|
||||
import de.jottyfan.quickiemod.item.HarvestRange;
|
||||
import de.jottyfan.quickiemod.item.ModItems;
|
||||
import de.jottyfan.quickiemod.item.ToolRangeable;
|
||||
import de.jottyfan.quickiemod.item.ToolSpeedpowderAxe;
|
||||
import net.minecraft.block.Block;
|
||||
import net.minecraft.block.BlockState;
|
||||
import net.minecraft.block.Blocks;
|
||||
@ -27,20 +24,21 @@ import net.minecraft.world.World;
|
||||
*
|
||||
*/
|
||||
public class EventBlockBreak {
|
||||
private static final Logger LOGGER = LogManager.getLogger(QuickieMod.MODID);
|
||||
|
||||
private enum BlockBreakDirection {
|
||||
UPWARDS, ALL;
|
||||
}
|
||||
|
||||
public void doBreakBlock(World world, BlockPos blockPos, BlockState blockState, PlayerEntity playerEntity) {
|
||||
public void doBreakBlock(World world, BlockPos blockPos, BlockState blockState, PlayerEntity playerEntity, Block oldBlock) {
|
||||
ItemStack mainHandItemStack = playerEntity.getEquippedStack(EquipmentSlot.MAINHAND);
|
||||
if (mainHandItemStack != null) {
|
||||
Item item = mainHandItemStack.getItem();
|
||||
if (item instanceof ToolRangeable) {
|
||||
ToolRangeable tool = (ToolRangeable) item;
|
||||
Block block = blockState.getBlock();
|
||||
int handled = handleRangeableTools(tool, mainHandItemStack, world, block, blockPos, playerEntity);
|
||||
if (!world.getBlockState(blockPos).getBlock().equals(oldBlock)) {
|
||||
// recreate old block to make it breakable; otherwise, the recursive algorithm stops directly
|
||||
world.setBlockState(blockPos, oldBlock.getDefaultState());
|
||||
}
|
||||
int handled = handleRangeableTools(tool, mainHandItemStack, world, oldBlock, blockPos, playerEntity);
|
||||
if (handled >= 255) {
|
||||
// reward for using rangeable tool very successful
|
||||
world.spawnEntity(
|
||||
@ -65,32 +63,30 @@ public class EventBlockBreak {
|
||||
BlockPos pos, PlayerEntity player) {
|
||||
List<Block> validBlocks = tool.getBlockList(currentBlock);
|
||||
HarvestRange range = tool.getRange(itemStack);
|
||||
|
||||
LOGGER.debug("current tool: {}", tool);
|
||||
|
||||
if (QuickieItems.SPEEDPOWDERAXE.getItem().equals(tool)) {
|
||||
return breakBlockRecursive(new ArrayList<>(), world, validBlocks, pos, tool, range, BlockBreakDirection.UPWARDS,
|
||||
List<String> visitedBlocks = new ArrayList<>();
|
||||
if (tool instanceof ToolSpeedpowderAxe) {
|
||||
return breakBlockRecursive(visitedBlocks, world, validBlocks, pos, tool, range, BlockBreakDirection.UPWARDS,
|
||||
player, true);
|
||||
} else if (QuickieItems.SPEEDPOWDERPICKAXE.getItem().equals(tool)) {
|
||||
return breakBlockRecursive(new ArrayList<>(), world, validBlocks, pos, tool, range, BlockBreakDirection.ALL,
|
||||
} else if (ModItems.TOOL_SPEEDPOWDERPICKAXE.getName().equals(tool.getName())) {
|
||||
return breakBlockRecursive(visitedBlocks, world, validBlocks, pos, tool, range, BlockBreakDirection.ALL,
|
||||
player, false);
|
||||
} else if (QuickieItems.SPEEDPOWDERSHOVEL.getItem().equals(tool)) {
|
||||
return breakBlockRecursive(new ArrayList<>(), world, validBlocks, pos, tool, range, BlockBreakDirection.ALL,
|
||||
} else if (ModItems.TOOL_SPEEDPOWDERSHOVEL.getName().equals(tool.getName())) {
|
||||
return breakBlockRecursive(visitedBlocks, world, validBlocks, pos, tool, range, BlockBreakDirection.ALL,
|
||||
player, false);
|
||||
} else if (QuickieItems.SPEEDPOWDERHOE.getItem().equals(tool)) {
|
||||
return breakBlockRecursive(new ArrayList<>(), world, validBlocks, pos, tool, range, BlockBreakDirection.ALL,
|
||||
} else if (ModItems.TOOL_SPEEDPOWDERHOE.getName().equals(tool.getName())) {
|
||||
return breakBlockRecursive(visitedBlocks, world, validBlocks, pos, tool, range, BlockBreakDirection.ALL,
|
||||
player, false);
|
||||
} else if (QuickieItems.QUICKIEPOWDERAXE.getItem().equals(tool)) {
|
||||
return breakBlockRecursive(new ArrayList<>(), world, validBlocks, pos, tool, range, BlockBreakDirection.UPWARDS,
|
||||
} else if (ModItems.TOOL_QUICKIEPOWDERAXE.getName().equals(tool.getName())) {
|
||||
return breakBlockRecursive(visitedBlocks, world, validBlocks, pos, tool, range, BlockBreakDirection.UPWARDS,
|
||||
player, true);
|
||||
} else if (QuickieItems.QUICKIEPOWDERPICKAXE.getItem().equals(tool)) {
|
||||
return breakBlockRecursive(new ArrayList<>(), world, validBlocks, pos, tool, range, BlockBreakDirection.ALL,
|
||||
} else if (ModItems.TOOL_QUICKIEPOWDERPICKAXE.getName().equals(tool.getName())) {
|
||||
return breakBlockRecursive(visitedBlocks, world, validBlocks, pos, tool, range, BlockBreakDirection.ALL,
|
||||
player, false);
|
||||
} else if (QuickieItems.QUICKIEPOWDERSHOVEL.getItem().equals(tool)) {
|
||||
return breakBlockRecursive(new ArrayList<>(), world, validBlocks, pos, tool, range, BlockBreakDirection.ALL,
|
||||
} else if (ModItems.TOOL_QUICKIEPOWDERSHOVEL.getName().equals(tool.getName())) {
|
||||
return breakBlockRecursive(visitedBlocks, world, validBlocks, pos, tool, range, BlockBreakDirection.ALL,
|
||||
player, false);
|
||||
} else if (QuickieItems.QUICKIEPOWDERHOE.getItem().equals(tool)) {
|
||||
return breakBlockRecursive(new ArrayList<>(), world, validBlocks, pos, tool, range, BlockBreakDirection.ALL,
|
||||
} else if (ModItems.TOOL_QUICKIEPOWDERHOE.getName().equals(tool.getName())) {
|
||||
return breakBlockRecursive(visitedBlocks, world, validBlocks, pos, tool, range, BlockBreakDirection.ALL,
|
||||
player, false);
|
||||
} else {
|
||||
return 0;
|
||||
@ -113,6 +109,7 @@ public class EventBlockBreak {
|
||||
private int breakBlockRecursive(List<String> visitedBlocks, World world, List<Block> validBlocks, BlockPos pos,
|
||||
ToolRangeable tool, HarvestRange range, BlockBreakDirection blockBreakDirection, PlayerEntity player,
|
||||
boolean breakLeaves) {
|
||||
boolean ignoreSpawn = visitedBlocks.size() < 1; // with this, the already broken block can be omitted to spawn
|
||||
if (visitedBlocks.contains(pos.toString())) {
|
||||
return 0;
|
||||
} else if (validBlocks == null) {
|
||||
@ -125,7 +122,9 @@ public class EventBlockBreak {
|
||||
if (tool.canBreakNeighbors(blockState)) {
|
||||
Block currentBlock = blockState.getBlock();
|
||||
if (validBlocks.contains(currentBlock)) {
|
||||
Block.dropStacks(blockState, world, pos); // includes xorbs
|
||||
if (!ignoreSpawn) {
|
||||
Block.dropStacks(blockState, world, pos); // includes xorbs
|
||||
}
|
||||
affected += 1;
|
||||
world.setBlockState(pos, Blocks.AIR.getDefaultState());
|
||||
if (range == null || range.getxRange() > 1 || range.getyRange() > 1 || range.getzRange() > 1) {
|
||||
|
@ -0,0 +1,66 @@
|
||||
package de.jottyfan.quickiemod.feature;
|
||||
|
||||
import de.jottyfan.quickiemod.Quickiemod;
|
||||
import net.fabricmc.fabric.api.biome.v1.BiomeModifications;
|
||||
import net.fabricmc.fabric.api.biome.v1.BiomeSelectors;
|
||||
import net.fabricmc.fabric.api.biome.v1.ModificationPhase;
|
||||
import net.minecraft.registry.RegistryKey;
|
||||
import net.minecraft.registry.RegistryKeys;
|
||||
import net.minecraft.util.Identifier;
|
||||
import net.minecraft.world.gen.GenerationStep;
|
||||
import net.minecraft.world.gen.feature.ConfiguredFeature;
|
||||
import net.minecraft.world.gen.feature.PlacedFeature;
|
||||
|
||||
/**
|
||||
*
|
||||
* @author jotty
|
||||
*
|
||||
*/
|
||||
public class ModFeatures {
|
||||
|
||||
public static final RegistryKey<ConfiguredFeature<?, ?>> CF_ORESULFUR = genCf("oresulphor");
|
||||
public static final RegistryKey<ConfiguredFeature<?, ?>> CF_OREDEEPSLATESULFUR = genCf("oredepslatesulphor");
|
||||
public static final RegistryKey<ConfiguredFeature<?, ?>> CF_ORESALPETER = genCf("oresalpeter");
|
||||
public static final RegistryKey<ConfiguredFeature<?, ?>> CF_ORENETHERSULPHOR = genCf("orenethersulphore");
|
||||
public static final RegistryKey<ConfiguredFeature<?, ?>> CF_BLOCKSULPHOR = genCf("blocksulphor");
|
||||
public static final RegistryKey<ConfiguredFeature<?, ?>> CF_DIRTSALPETER = genCf("dirtsalpeter");
|
||||
public static final RegistryKey<ConfiguredFeature<?, ?>> CF_SANDSALPETER = genCf("sandsalpeter");
|
||||
public static final RegistryKey<ConfiguredFeature<?, ?>> CF_ORESANDSALPETER = genCf("oresandsalpeter");
|
||||
|
||||
public static final RegistryKey<PlacedFeature> PF_ORESULPHOR = genPf("oresulphor");
|
||||
public static final RegistryKey<PlacedFeature> PF_OREDEEPSLATESULPHOR = genPf("oredeepslatesulphor");
|
||||
public static final RegistryKey<PlacedFeature> PF_ORESALPETER = genPf("oresalpeter");
|
||||
public static final RegistryKey<PlacedFeature> PF_ORENETHERSULPHOR = genPf("orenethersulphor");
|
||||
public static final RegistryKey<PlacedFeature> PF_BLOCKSULPHOR = genPf("blocksulphor");
|
||||
public static final RegistryKey<PlacedFeature> PF_DIRTSALPETER = genPf("dirtsalpeter");
|
||||
public static final RegistryKey<PlacedFeature> PF_SANDSALPETER = genPf("sandsalpeter");
|
||||
public static final RegistryKey<PlacedFeature> PF_ORESANDSALPETER = genPf("oresandsalpeter");
|
||||
|
||||
private static final RegistryKey<ConfiguredFeature<?, ?>> genCf(String name) {
|
||||
return RegistryKey.of(RegistryKeys.CONFIGURED_FEATURE, Identifier.of(Quickiemod.MOD_ID, name));
|
||||
}
|
||||
|
||||
private static final RegistryKey<PlacedFeature> genPf(String name) {
|
||||
return RegistryKey.of(RegistryKeys.PLACED_FEATURE, Identifier.of(Quickiemod.MOD_ID, name));
|
||||
}
|
||||
|
||||
public static final void registerFeatures() {
|
||||
// Overworld features
|
||||
BiomeModifications.create(Identifier.of(Quickiemod.MOD_ID, "features")).add(ModificationPhase.ADDITIONS,
|
||||
BiomeSelectors.foundInOverworld(), (bsc, bmc) -> {
|
||||
bmc.getGenerationSettings().addFeature(GenerationStep.Feature.UNDERGROUND_ORES, PF_ORESULPHOR);
|
||||
bmc.getGenerationSettings().addFeature(GenerationStep.Feature.UNDERGROUND_ORES, PF_ORESALPETER);
|
||||
bmc.getGenerationSettings().addFeature(GenerationStep.Feature.UNDERGROUND_ORES, PF_DIRTSALPETER);
|
||||
bmc.getGenerationSettings().addFeature(GenerationStep.Feature.UNDERGROUND_ORES, PF_SANDSALPETER);
|
||||
bmc.getGenerationSettings().addFeature(GenerationStep.Feature.UNDERGROUND_ORES, PF_ORESANDSALPETER);
|
||||
bmc.getGenerationSettings().addFeature(GenerationStep.Feature.UNDERGROUND_ORES, PF_OREDEEPSLATESULPHOR);
|
||||
});
|
||||
|
||||
// Nether features
|
||||
BiomeModifications.create(Identifier.of(Quickiemod.MOD_ID, "nether_features")).add(ModificationPhase.ADDITIONS,
|
||||
BiomeSelectors.foundInTheNether(), (bsc, bmc) -> {
|
||||
bmc.getGenerationSettings().addFeature(GenerationStep.Feature.UNDERGROUND_ORES, PF_ORENETHERSULPHOR);
|
||||
bmc.getGenerationSettings().addFeature(GenerationStep.Feature.UNDERGROUND_ORES, PF_BLOCKSULPHOR);
|
||||
});
|
||||
}
|
||||
}
|
@ -0,0 +1,77 @@
|
||||
package de.jottyfan.quickiemod.identifier;
|
||||
|
||||
import de.jottyfan.quickiemod.Quickiemod;
|
||||
import net.minecraft.util.Identifier;
|
||||
|
||||
/**
|
||||
*
|
||||
* @author jotty
|
||||
*
|
||||
*/
|
||||
public class ModIdentifiers {
|
||||
public static final Identifier ITEM_STUB = Identifier.of(Quickiemod.MOD_ID, "stub");
|
||||
public static final Identifier ITEM_SPEEDPOWDER = Identifier.of(Quickiemod.MOD_ID, "speedpowder");
|
||||
public static final Identifier ITEM_QUICKIEPOWDER = Identifier.of(Quickiemod.MOD_ID, "quickiepowder");
|
||||
public static final Identifier ITEM_SALPETER = Identifier.of(Quickiemod.MOD_ID, "salpeter");
|
||||
public static final Identifier ITEM_SULFOR = Identifier.of(Quickiemod.MOD_ID, "sulphor");
|
||||
public static final Identifier ITEM_OXIDIZEDCOPPERPOWDER = Identifier.of(Quickiemod.MOD_ID, "oxidizedcopperpowder");
|
||||
public static final Identifier ITEM_SPEEDINGOT = Identifier.of(Quickiemod.MOD_ID, "speedingot");
|
||||
public static final Identifier ITEM_QUICKIEINGOT = Identifier.of(Quickiemod.MOD_ID, "quickieingot");
|
||||
public static final Identifier ITEM_CARROTSTACK = Identifier.of(Quickiemod.MOD_ID, "carrotstack");
|
||||
public static final Identifier ITEM_ROTTENFLESHSTRIPES = Identifier.of(Quickiemod.MOD_ID, "rotten_flesh_stripes");
|
||||
public static final Identifier ITEM_COTTON = Identifier.of(Quickiemod.MOD_ID, "cotton");
|
||||
public static final Identifier ITEM_COTTONPLANT = Identifier.of(Quickiemod.MOD_ID, "cottonplant");
|
||||
public static final Identifier ITEM_COTTONSEED = Identifier.of(Quickiemod.MOD_ID, "cottonseed");
|
||||
public static final Identifier ITEM_CANOLA = Identifier.of(Quickiemod.MOD_ID, "canola");
|
||||
public static final Identifier ITEM_CANOLAPLANT = Identifier.of(Quickiemod.MOD_ID, "canolaplant");
|
||||
public static final Identifier ITEM_CANOLASEED = Identifier.of(Quickiemod.MOD_ID, "canolaseed");
|
||||
public static final Identifier ITEM_CANOLABOTTLE = Identifier.of(Quickiemod.MOD_ID, "canolabottle");
|
||||
public static final Identifier ITEM_CANOLABOTTLESTACK = Identifier.of(Quickiemod.MOD_ID, "canolabottlestack");
|
||||
|
||||
public static final Identifier TOOL_SPEEDPOWDERAXE = Identifier.of(Quickiemod.MOD_ID, "speedpowderaxe");
|
||||
public static final Identifier TOOL_SPEEDPOWDERHOE = Identifier.of(Quickiemod.MOD_ID, "speedpowderhoe");
|
||||
public static final Identifier TOOL_SPEEDPOWDERPICKAXE = Identifier.of(Quickiemod.MOD_ID, "speedpowderpickaxe");
|
||||
public static final Identifier TOOL_SPEEDPOWDERSHEARS = Identifier.of(Quickiemod.MOD_ID, "speedpowdershears");
|
||||
public static final Identifier TOOL_SPEEDPOWDERSHOVEL = Identifier.of(Quickiemod.MOD_ID, "speedpowdershovel");
|
||||
public static final Identifier TOOL_SPEEDPOWDERWATERHOE = Identifier.of(Quickiemod.MOD_ID, "speedpowderwaterhoe");
|
||||
public static final Identifier TOOL_QUICKIEPOWDERAXE = Identifier.of(Quickiemod.MOD_ID, "quickiepowderaxe");
|
||||
public static final Identifier TOOL_QUICKIEPOWDERHOE = Identifier.of(Quickiemod.MOD_ID, "quickiepowderhoe");
|
||||
public static final Identifier TOOL_QUICKIEPOWDERPICKAXE = Identifier.of(Quickiemod.MOD_ID, "quickiepowderpickaxe");
|
||||
public static final Identifier TOOL_QUICKIEPOWDERSHOVEL = Identifier.of(Quickiemod.MOD_ID, "quickiepowdershovel");
|
||||
public static final Identifier TOOL_QUICKIEPOWDERWATERHOE = Identifier.of(Quickiemod.MOD_ID, "quickiepowderwaterhoe");
|
||||
|
||||
public static final Identifier BLOCK_QUICKIEPOWDER = Identifier.of(Quickiemod.MOD_ID, "blockquickiepowder");
|
||||
public static final Identifier BLOCK_SPEEDPOWDER = Identifier.of(Quickiemod.MOD_ID, "blockspeedpowder");
|
||||
public static final Identifier BLOCK_SALPETER = Identifier.of(Quickiemod.MOD_ID, "blocksalpeter");
|
||||
public static final Identifier BLOCK_SULFOR = Identifier.of(Quickiemod.MOD_ID, "blocksulphor");
|
||||
public static final Identifier BLOCK_MONSTERHOARDER = Identifier.of(Quickiemod.MOD_ID, "monsterhoarder");
|
||||
public static final Identifier BLOCK_LAVAHOARDER = Identifier.of(Quickiemod.MOD_ID, "lavahoarder");
|
||||
public static final Identifier BLOCK_EMPTYLAVAHOARDER = Identifier.of(Quickiemod.MOD_ID, "emptylavahoarder");
|
||||
public static final Identifier BLOCK_ITEMHOARDER = Identifier.of(Quickiemod.MOD_ID, "itemhoarder");
|
||||
public static final Identifier BLOCK_DIRTSALPETER = Identifier.of(Quickiemod.MOD_ID, "dirtsalpeter");
|
||||
public static final Identifier BLOCK_OREDEEPSLATESULFOR = Identifier.of(Quickiemod.MOD_ID, "oredeepslatesulphor");
|
||||
public static final Identifier BLOCK_ORENETHERSULFOR = Identifier.of(Quickiemod.MOD_ID, "orenethersulphor");
|
||||
public static final Identifier BLOCK_ORESALPETER = Identifier.of(Quickiemod.MOD_ID, "oresalpeter");
|
||||
public static final Identifier BLOCK_ORESANDSALPETER = Identifier.of(Quickiemod.MOD_ID, "oresandsalpeter");
|
||||
public static final Identifier BLOCK_ORESULFOR = Identifier.of(Quickiemod.MOD_ID, "oresulphor");
|
||||
public static final Identifier BLOCK_SANDSALPETER = Identifier.of(Quickiemod.MOD_ID, "sandsalpeter");
|
||||
public static final Identifier BLOCK_KELPSTACK = Identifier.of(Quickiemod.MOD_ID, "kelpstack");
|
||||
public static final Identifier BLOCK_COTTONPLANT = Identifier.of(Quickiemod.MOD_ID, "blockcottonplant");
|
||||
public static final Identifier BLOCK_CANOLAPLANT = Identifier.of(Quickiemod.MOD_ID, "blockcanolaplant");
|
||||
public static final Identifier BLOCK_DRILLDOWN = Identifier.of(Quickiemod.MOD_ID, "drill");
|
||||
public static final Identifier BLOCK_DRILLEAST = Identifier.of(Quickiemod.MOD_ID, "drilleast");
|
||||
public static final Identifier BLOCK_DRILLSOUTH = Identifier.of(Quickiemod.MOD_ID, "drillsouth");
|
||||
public static final Identifier BLOCK_DRILLWEST = Identifier.of(Quickiemod.MOD_ID, "drillwest");
|
||||
public static final Identifier BLOCK_DRILLNORTH = Identifier.of(Quickiemod.MOD_ID, "drillnorth");
|
||||
public static final Identifier BLOCK_STACKERDOWN = Identifier.of(Quickiemod.MOD_ID, "blockstackerdown");
|
||||
public static final Identifier BLOCK_STACKEREAST = Identifier.of(Quickiemod.MOD_ID, "blockstackereast");
|
||||
public static final Identifier BLOCK_STACKERSOUTH = Identifier.of(Quickiemod.MOD_ID, "blockstackersouth");
|
||||
public static final Identifier BLOCK_STACKERWEST = Identifier.of(Quickiemod.MOD_ID, "blockstackerwest");
|
||||
public static final Identifier BLOCK_STACKERNORTH = Identifier.of(Quickiemod.MOD_ID, "blockstackernorth");
|
||||
public static final Identifier BLOCK_STACKERUP = Identifier.of(Quickiemod.MOD_ID, "blockstackerup");
|
||||
|
||||
public static final Identifier BLOCKENTITY_ITEMHOARDER = Identifier.of(Quickiemod.MOD_ID, "itemhoarderblockentity");
|
||||
public static final Identifier BLOCKENTITY_BLOCKSTACKER = Identifier.of(Quickiemod.MOD_ID, "blockstackerblockentity");
|
||||
public static final Identifier BLOCKENTITY_DRILL = Identifier.of(Quickiemod.MOD_ID, "drillblockentity");
|
||||
public static final Identifier BLOCKSTACKERUP = Identifier.of(Quickiemod.MOD_ID, "blockstackerblockentity");
|
||||
}
|
@ -1,22 +0,0 @@
|
||||
package de.jottyfan.quickiemod.init;
|
||||
|
||||
import de.jottyfan.quickiemod.QuickieMod;
|
||||
import net.minecraft.util.Identifier;
|
||||
|
||||
/**
|
||||
*
|
||||
* @author jotty
|
||||
*
|
||||
*/
|
||||
public class BlockEntityIdentity {
|
||||
public static final Identifier ITEMHOARDER = Identifier.of(QuickieMod.MODID, "itemhoarderblockentity");
|
||||
public static final Identifier BLOCKSPREADER = Identifier.of(QuickieMod.MODID, "blockspreaderblockentity");
|
||||
public static final Identifier BLOCKSTACKERUP = Identifier.of(QuickieMod.MODID, "blockstackerblockentity");
|
||||
public static final Identifier MONSTERHOARDER = Identifier.of(QuickieMod.MODID, "monsterhoarderblockentity");
|
||||
public static final Identifier EMPTYLAVALHOARDER = Identifier.of(QuickieMod.MODID, "emptylavahoarderblockentity");
|
||||
public static final Identifier DRILL_DOWN = Identifier.of(QuickieMod.MODID, "drillblockdownblockentity");
|
||||
public static final Identifier DRILL_EAST = Identifier.of(QuickieMod.MODID, "drillblockeastblockentity");
|
||||
public static final Identifier DRILL_SOUTH = Identifier.of(QuickieMod.MODID, "drillblocksouthblockentity");
|
||||
public static final Identifier DRILL_WEST = Identifier.of(QuickieMod.MODID, "drillblockwestblockentity");
|
||||
public static final Identifier DRILL_NORTH = Identifier.of(QuickieMod.MODID, "drillblocknorthblockentity");
|
||||
}
|
@ -1,66 +0,0 @@
|
||||
package de.jottyfan.quickiemod.init;
|
||||
|
||||
import java.util.function.BiConsumer;
|
||||
|
||||
import de.jottyfan.quickiemod.QuickieMod;
|
||||
import net.fabricmc.fabric.api.biome.v1.BiomeModificationContext;
|
||||
import net.fabricmc.fabric.api.biome.v1.BiomeSelectionContext;
|
||||
import net.minecraft.registry.RegistryKey;
|
||||
import net.minecraft.registry.RegistryKeys;
|
||||
import net.minecraft.util.Identifier;
|
||||
import net.minecraft.world.gen.GenerationStep;
|
||||
import net.minecraft.world.gen.feature.ConfiguredFeature;
|
||||
import net.minecraft.world.gen.feature.PlacedFeature;
|
||||
|
||||
/**
|
||||
*
|
||||
* @author jotty
|
||||
*
|
||||
*/
|
||||
public class FeaturesManager {
|
||||
|
||||
public static final RegistryKey<ConfiguredFeature<?, ?>> CF_ORESULFUR = genCf("oresulphor");
|
||||
public static final RegistryKey<ConfiguredFeature<?, ?>> CF_OREDEEPSLATESULFUR = genCf("oredepslatesulphor");
|
||||
public static final RegistryKey<ConfiguredFeature<?, ?>> CF_ORESALPETER = genCf("oresalpeter");
|
||||
public static final RegistryKey<ConfiguredFeature<?, ?>> CF_ORENETHERSULPHOR = genCf("orenethersulphore");
|
||||
public static final RegistryKey<ConfiguredFeature<?, ?>> CF_BLOCKSULPHOR = genCf("blocksulphor");
|
||||
public static final RegistryKey<ConfiguredFeature<?, ?>> CF_DIRTSALPETER = genCf("dirtsalpeter");
|
||||
public static final RegistryKey<ConfiguredFeature<?, ?>> CF_SANDSALPETER = genCf("sandsalpeter");
|
||||
public static final RegistryKey<ConfiguredFeature<?, ?>> CF_ORESANDSALPETER = genCf("oresandsalpeter");
|
||||
|
||||
public static final RegistryKey<PlacedFeature> PF_ORESULPHOR = genPf("oresulphor");
|
||||
public static final RegistryKey<PlacedFeature> PF_OREDEEPSLATESULPHOR = genPf("oredeepslatesulphor");
|
||||
public static final RegistryKey<PlacedFeature> PF_ORESALPETER = genPf("oresalpeter");
|
||||
public static final RegistryKey<PlacedFeature> PF_ORENETHERSULPHOR = genPf("orenethersulphor");
|
||||
public static final RegistryKey<PlacedFeature> PF_BLOCKSULPHOR = genPf("blocksulphor");
|
||||
public static final RegistryKey<PlacedFeature> PF_DIRTSALPETER = genPf("dirtsalpeter");
|
||||
public static final RegistryKey<PlacedFeature> PF_SANDSALPETER = genPf("sandsalpeter");
|
||||
public static final RegistryKey<PlacedFeature> PF_ORESANDSALPETER = genPf("oresandsalpeter");
|
||||
|
||||
private static final RegistryKey<ConfiguredFeature<?, ?>> genCf(String name) {
|
||||
return RegistryKey.of(RegistryKeys.CONFIGURED_FEATURE, Identifier.of(QuickieMod.MODID, name));
|
||||
}
|
||||
|
||||
private static final RegistryKey<PlacedFeature> genPf(String name) {
|
||||
return RegistryKey.of(RegistryKeys.PLACED_FEATURE, Identifier.of(QuickieMod.MODID, name));
|
||||
}
|
||||
|
||||
protected static final BiConsumer<BiomeSelectionContext, BiomeModificationContext> overworldOres() {
|
||||
return (bsc, bmc) -> {
|
||||
bmc.getGenerationSettings().addFeature(GenerationStep.Feature.UNDERGROUND_ORES, PF_ORESULPHOR);
|
||||
bmc.getGenerationSettings().addFeature(GenerationStep.Feature.UNDERGROUND_ORES, PF_ORESALPETER);
|
||||
bmc.getGenerationSettings().addFeature(GenerationStep.Feature.UNDERGROUND_ORES, PF_DIRTSALPETER);
|
||||
bmc.getGenerationSettings().addFeature(GenerationStep.Feature.UNDERGROUND_ORES, PF_SANDSALPETER);
|
||||
bmc.getGenerationSettings().addFeature(GenerationStep.Feature.UNDERGROUND_ORES, PF_ORESANDSALPETER);
|
||||
bmc.getGenerationSettings().addFeature(GenerationStep.Feature.UNDERGROUND_ORES, PF_OREDEEPSLATESULPHOR);
|
||||
};
|
||||
}
|
||||
|
||||
protected static final BiConsumer<BiomeSelectionContext, BiomeModificationContext> netherOres() {
|
||||
return (bsc, bmc) -> {
|
||||
bmc.getGenerationSettings().addFeature(GenerationStep.Feature.UNDERGROUND_ORES, PF_ORENETHERSULPHOR);
|
||||
bmc.getGenerationSettings().addFeature(GenerationStep.Feature.UNDERGROUND_ORES, PF_BLOCKSULPHOR);
|
||||
};
|
||||
}
|
||||
|
||||
}
|
@ -1,102 +0,0 @@
|
||||
package de.jottyfan.quickiemod.init;
|
||||
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
|
||||
import de.jottyfan.quickiemod.QuickieMod;
|
||||
import de.jottyfan.quickiemod.blockentity.BlockEntityTypes;
|
||||
import de.jottyfan.quickiemod.blocks.QuickieBlocks;
|
||||
import de.jottyfan.quickiemod.event.BreakBlockCallback;
|
||||
import de.jottyfan.quickiemod.event.EventBlockBreak;
|
||||
import de.jottyfan.quickiemod.items.QuickieItems;
|
||||
import net.fabricmc.fabric.api.biome.v1.BiomeModifications;
|
||||
import net.fabricmc.fabric.api.biome.v1.BiomeSelectors;
|
||||
import net.fabricmc.fabric.api.biome.v1.ModificationPhase;
|
||||
import net.fabricmc.fabric.api.itemgroup.v1.FabricItemGroup;
|
||||
import net.fabricmc.fabric.api.registry.FuelRegistry;
|
||||
import net.minecraft.block.ComposterBlock;
|
||||
import net.minecraft.item.BlockItem;
|
||||
import net.minecraft.item.Item.Settings;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.registry.Registries;
|
||||
import net.minecraft.registry.Registry;
|
||||
import net.minecraft.registry.RegistryKey;
|
||||
import net.minecraft.registry.RegistryKeys;
|
||||
import net.minecraft.text.Text;
|
||||
import net.minecraft.util.ActionResult;
|
||||
import net.minecraft.util.Identifier;
|
||||
|
||||
/**
|
||||
*
|
||||
* @author jotty
|
||||
*
|
||||
*/
|
||||
public class RegistryManager {
|
||||
private static final Logger LOGGER = LoggerFactory.getLogger(QuickieMod.MODID);
|
||||
|
||||
public static final void registerItemGroup() {
|
||||
Registry.register(Registries.ITEM_GROUP, RegistryKey.of(RegistryKeys.ITEM_GROUP, Identifier.of(QuickieMod.MODID, "itemgroups")),
|
||||
FabricItemGroup.builder().icon(() -> new ItemStack(QuickieItems.ROTTEN_FLESH_STRIPES.getItem())).displayName(Text.literal(QuickieMod.MODID))
|
||||
.entries((enabledFeatures, stacks) -> {
|
||||
for (QuickieItems i : QuickieItems.values()) {
|
||||
stacks.add(new ItemStack(i.getItem()));
|
||||
}
|
||||
for (QuickieBlocks b : QuickieBlocks.values()) {
|
||||
if (b.getAdd2BlockPanel()) {
|
||||
stacks.add(new ItemStack(b.getBlock()));
|
||||
}
|
||||
}
|
||||
}).build());
|
||||
}
|
||||
|
||||
public static final void registerItems() {
|
||||
LOGGER.info("registering items");
|
||||
for (QuickieItems i : QuickieItems.values()) {
|
||||
Registry.register(Registries.ITEM, Identifier.of(QuickieMod.MODID, i.getName()), i.getItem());
|
||||
}
|
||||
ComposterBlock.ITEM_TO_LEVEL_INCREASE_CHANCE.put(QuickieItems.COTTONSEED.getItem(), 0.5f);
|
||||
ComposterBlock.ITEM_TO_LEVEL_INCREASE_CHANCE.put(QuickieItems.COTTON.getItem(), 0.75f);
|
||||
ComposterBlock.ITEM_TO_LEVEL_INCREASE_CHANCE.put(QuickieItems.CANOLASEED.getItem(), 0.5f);
|
||||
ComposterBlock.ITEM_TO_LEVEL_INCREASE_CHANCE.put(QuickieItems.CANOLA.getItem(), 0.75f);
|
||||
FuelRegistry.INSTANCE.add(QuickieItems.SULPHOR.getItem(), 200);
|
||||
FuelRegistry.INSTANCE.add(QuickieBlocks.BLOCKSULPHOR.getBlock(), 2000);
|
||||
}
|
||||
|
||||
public static final void registerBlocks() {
|
||||
LOGGER.info("registering blocks");
|
||||
for (QuickieBlocks b : QuickieBlocks.values()) {
|
||||
Registry.register(Registries.BLOCK, Identifier.of(QuickieMod.MODID, b.getName()), b.getBlock());
|
||||
Registry.register(Registries.ITEM, Identifier.of(QuickieMod.MODID, b.getName()), new BlockItem(b.getBlock(), new Settings()));
|
||||
}
|
||||
}
|
||||
|
||||
public static final void registerFeatures() {
|
||||
// Overworld features
|
||||
BiomeModifications.create(Identifier.of(QuickieMod.MODID, "features")).add(ModificationPhase.ADDITIONS, BiomeSelectors.foundInOverworld(),
|
||||
FeaturesManager.overworldOres());
|
||||
|
||||
// Nether features
|
||||
BiomeModifications.create(Identifier.of(QuickieMod.MODID, "nether_features")).add(ModificationPhase.ADDITIONS, BiomeSelectors.foundInTheNether(),
|
||||
FeaturesManager.netherOres());
|
||||
}
|
||||
|
||||
public static final void registerEvents() {
|
||||
LOGGER.info("registering events");
|
||||
BreakBlockCallback.EVENT.register((world, blockPos, blockState, playerEntity) -> {
|
||||
new EventBlockBreak().doBreakBlock(world, blockPos, blockState, playerEntity);
|
||||
return ActionResult.SUCCESS;
|
||||
});
|
||||
}
|
||||
|
||||
public static final void registerBlockEntityTypes() {
|
||||
try {
|
||||
Class.forName(BlockEntityTypes.class.getName());
|
||||
LOGGER.info("registering block entity types");
|
||||
} catch (ClassNotFoundException e) {
|
||||
LOGGER.error("class BlockEntityType not loaded", e);
|
||||
}
|
||||
}
|
||||
|
||||
public static final void registerScreenHandlerTypes() {
|
||||
}
|
||||
}
|
@ -0,0 +1,20 @@
|
||||
package de.jottyfan.quickiemod.item;
|
||||
|
||||
import net.minecraft.item.Item;
|
||||
import net.minecraft.registry.RegistryKey;
|
||||
import net.minecraft.registry.RegistryKeys;
|
||||
import net.minecraft.util.Identifier;
|
||||
|
||||
/**
|
||||
*
|
||||
* @author jotty
|
||||
*
|
||||
*/
|
||||
public abstract class AbstractIdentifiedItem extends Item {
|
||||
|
||||
public AbstractIdentifiedItem(Identifier identifier, Integer maxCount) {
|
||||
super(new Item.Settings().maxCount(maxCount).useItemPrefixedTranslationKey()
|
||||
.registryKey(RegistryKey.of(RegistryKeys.ITEM, identifier)));
|
||||
}
|
||||
|
||||
}
|
@ -1,4 +1,4 @@
|
||||
package de.jottyfan.quickiemod.items;
|
||||
package de.jottyfan.quickiemod.item;
|
||||
|
||||
import java.io.Serializable;
|
||||
|
||||
@ -34,6 +34,15 @@ public class HarvestRange implements Serializable {
|
||||
this.zRange = zRange;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
StringBuilder buf = new StringBuilder();
|
||||
buf.append(xRange).append(":");
|
||||
buf.append(yRange).append(":");
|
||||
buf.append(zRange).append(":");
|
||||
return buf.toString();
|
||||
}
|
||||
|
||||
/**
|
||||
* add i to x, y and z and return the resulting class as a new one
|
||||
*
|
16
src/main/java/de/jottyfan/quickiemod/item/Item64Stack.java
Normal file
16
src/main/java/de/jottyfan/quickiemod/item/Item64Stack.java
Normal file
@ -0,0 +1,16 @@
|
||||
package de.jottyfan.quickiemod.item;
|
||||
|
||||
import net.minecraft.util.Identifier;
|
||||
|
||||
/**
|
||||
*
|
||||
* @author jotty
|
||||
*
|
||||
*/
|
||||
public class Item64Stack extends AbstractIdentifiedItem {
|
||||
|
||||
public Item64Stack(Identifier identifier) {
|
||||
super(identifier, 64);
|
||||
}
|
||||
|
||||
}
|
45
src/main/java/de/jottyfan/quickiemod/item/ItemSeed.java
Normal file
45
src/main/java/de/jottyfan/quickiemod/item/ItemSeed.java
Normal file
@ -0,0 +1,45 @@
|
||||
package de.jottyfan.quickiemod.item;
|
||||
|
||||
import de.jottyfan.quickiemod.Quickiemod;
|
||||
import net.minecraft.block.BlockState;
|
||||
import net.minecraft.block.Blocks;
|
||||
import net.minecraft.item.ItemUsageContext;
|
||||
import net.minecraft.registry.Registries;
|
||||
import net.minecraft.util.ActionResult;
|
||||
import net.minecraft.util.Identifier;
|
||||
import net.minecraft.util.math.BlockPos;
|
||||
import net.minecraft.world.World;
|
||||
|
||||
/**
|
||||
*
|
||||
* @author jotty
|
||||
*
|
||||
*/
|
||||
public class ItemSeed extends Item64Stack {
|
||||
|
||||
private Identifier plant;
|
||||
|
||||
public ItemSeed(Identifier identifier, Identifier plant) {
|
||||
super(identifier);
|
||||
this.plant = plant;
|
||||
}
|
||||
|
||||
@Override
|
||||
public ActionResult useOnBlock(ItemUsageContext context) {
|
||||
BlockPos pos = context.getBlockPos();
|
||||
World world = context.getWorld();
|
||||
if (this.asItem().equals(context.getStack().getItem())) {
|
||||
BlockState state = world.getBlockState(pos);
|
||||
if (Registries.BLOCK.containsId(plant)) {
|
||||
if (Blocks.FARMLAND.equals(state.getBlock()) && world.getBlockState(pos.up()).isAir()) {
|
||||
world.setBlockState(pos.up(), Registries.BLOCK.get(plant).getDefaultState());
|
||||
context.getStack().decrement(1);
|
||||
} else {
|
||||
Quickiemod.LOGGER.error("could not find block {} in Registries...", plant.toShortTranslationKey());
|
||||
}
|
||||
}
|
||||
}
|
||||
return super.useOnBlock(context);
|
||||
}
|
||||
|
||||
}
|
117
src/main/java/de/jottyfan/quickiemod/item/ModItems.java
Normal file
117
src/main/java/de/jottyfan/quickiemod/item/ModItems.java
Normal file
@ -0,0 +1,117 @@
|
||||
package de.jottyfan.quickiemod.item;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
import de.jottyfan.quickiemod.Quickiemod;
|
||||
import de.jottyfan.quickiemod.identifier.ModIdentifiers;
|
||||
import net.minecraft.item.Item;
|
||||
import net.minecraft.registry.Registries;
|
||||
import net.minecraft.registry.Registry;
|
||||
import net.minecraft.util.Identifier;
|
||||
|
||||
/**
|
||||
*
|
||||
* @author jotty
|
||||
*
|
||||
*/
|
||||
public class ModItems {
|
||||
public static final Item ITEM_STUB = registerItem(ModIdentifiers.ITEM_STUB,
|
||||
new Item64Stack(ModIdentifiers.ITEM_STUB));
|
||||
public static final Item ITEM_SPEEDPOWDER = registerItem(ModIdentifiers.ITEM_SPEEDPOWDER,
|
||||
new Item64Stack(ModIdentifiers.ITEM_SPEEDPOWDER));
|
||||
public static final Item ITEM_QUICKIEPOWDER = registerItem(ModIdentifiers.ITEM_QUICKIEPOWDER,
|
||||
new Item64Stack(ModIdentifiers.ITEM_QUICKIEPOWDER));
|
||||
public static final Item ITEM_SALPETER = registerItem(ModIdentifiers.ITEM_SALPETER,
|
||||
new Item64Stack(ModIdentifiers.ITEM_SALPETER));
|
||||
public static final Item ITEM_SULFOR = registerItem(ModIdentifiers.ITEM_SULFOR,
|
||||
new Item64Stack(ModIdentifiers.ITEM_SULFOR));
|
||||
public static final Item ITEM_OXIDIZEDCOPPERPOWDER = registerItem(ModIdentifiers.ITEM_OXIDIZEDCOPPERPOWDER,
|
||||
new Item64Stack(ModIdentifiers.ITEM_OXIDIZEDCOPPERPOWDER));
|
||||
public static final Item ITEM_SPEEDINGOT = registerItem(ModIdentifiers.ITEM_SPEEDINGOT,
|
||||
new Item64Stack(ModIdentifiers.ITEM_SPEEDINGOT));
|
||||
public static final Item ITEM_QUICKIEINGOT = registerItem(ModIdentifiers.ITEM_QUICKIEINGOT,
|
||||
new Item64Stack(ModIdentifiers.ITEM_QUICKIEINGOT));
|
||||
public static final Item ITEM_CARROTSTACK = registerItem(ModIdentifiers.ITEM_CARROTSTACK,
|
||||
new Item64Stack(ModIdentifiers.ITEM_CARROTSTACK));
|
||||
public static final Item ITEM_ROTTENFLESHSTRIPES = registerItem(ModIdentifiers.ITEM_ROTTENFLESHSTRIPES,
|
||||
new Item64Stack(ModIdentifiers.ITEM_ROTTENFLESHSTRIPES));
|
||||
public static final Item ITEM_COTTON = registerItem(ModIdentifiers.ITEM_COTTON,
|
||||
new Item64Stack(ModIdentifiers.ITEM_COTTON));
|
||||
public static final Item ITEM_COTTONPLANT = registerItem(ModIdentifiers.ITEM_COTTONPLANT,
|
||||
new Item64Stack(ModIdentifiers.BLOCK_COTTONPLANT));
|
||||
public static final Item ITEM_COTTONSEED = registerItem(ModIdentifiers.ITEM_COTTONSEED,
|
||||
new ItemSeed(ModIdentifiers.ITEM_COTTONSEED, ModIdentifiers.BLOCK_COTTONPLANT));
|
||||
public static final Item ITEM_CANOLA = registerItem(ModIdentifiers.ITEM_CANOLA,
|
||||
new Item64Stack(ModIdentifiers.ITEM_CANOLA));
|
||||
public static final Item ITEM_CANOLAPLANT = registerItem(ModIdentifiers.ITEM_CANOLAPLANT,
|
||||
new Item64Stack(ModIdentifiers.BLOCK_CANOLAPLANT));
|
||||
public static final Item ITEM_CANOLASEED = registerItem(ModIdentifiers.ITEM_CANOLASEED,
|
||||
new ItemSeed(ModIdentifiers.ITEM_CANOLASEED, ModIdentifiers.BLOCK_CANOLAPLANT));
|
||||
public static final Item ITEM_CANOLABOTTLE = registerItem(ModIdentifiers.ITEM_CANOLABOTTLE,
|
||||
new Item64Stack(ModIdentifiers.ITEM_CANOLABOTTLE));
|
||||
public static final Item ITEM_CANOLABOTTLESTACK = registerItem(ModIdentifiers.ITEM_CANOLABOTTLESTACK,
|
||||
new Item64Stack(ModIdentifiers.ITEM_CANOLABOTTLESTACK));
|
||||
|
||||
public static final Item TOOL_SPEEDPOWDERAXE = registerItem(ModIdentifiers.TOOL_SPEEDPOWDERAXE,
|
||||
new ToolSpeedpowderAxe(ModIdentifiers.TOOL_SPEEDPOWDERAXE));
|
||||
public static final Item TOOL_SPEEDPOWDERHOE = registerItem(ModIdentifiers.TOOL_SPEEDPOWDERHOE,
|
||||
new ToolSpeedpowderHoe(ModIdentifiers.TOOL_SPEEDPOWDERHOE));
|
||||
public static final Item TOOL_SPEEDPOWDERPICKAXE = registerItem(ModIdentifiers.TOOL_SPEEDPOWDERPICKAXE,
|
||||
new ToolSpeedpowderPickaxe(ModIdentifiers.TOOL_SPEEDPOWDERPICKAXE));
|
||||
public static final Item TOOL_SPEEDPOWDERSHEARS = registerItem(ModIdentifiers.TOOL_SPEEDPOWDERSHEARS,
|
||||
new ToolSpeedpowderShears(ModIdentifiers.TOOL_SPEEDPOWDERSHEARS));
|
||||
public static final Item TOOL_SPEEDPOWDERSHOVEL = registerItem(ModIdentifiers.TOOL_SPEEDPOWDERSHOVEL,
|
||||
new ToolSpeedpowderShovel(ModIdentifiers.TOOL_SPEEDPOWDERSHOVEL));
|
||||
public static final Item TOOL_SPEEDPOWDERWATERHOE = registerItem(ModIdentifiers.TOOL_SPEEDPOWDERWATERHOE,
|
||||
new ToolSpeedpowderWaterHoe(ModIdentifiers.TOOL_SPEEDPOWDERWATERHOE));
|
||||
public static final Item TOOL_QUICKIEPOWDERAXE = registerItem(ModIdentifiers.TOOL_QUICKIEPOWDERAXE,
|
||||
new ToolQuickiepowderAxe(ModIdentifiers.TOOL_QUICKIEPOWDERAXE));
|
||||
public static final Item TOOL_QUICKIEPOWDERHOE = registerItem(ModIdentifiers.TOOL_QUICKIEPOWDERHOE,
|
||||
new ToolQuickiepowderHoe(ModIdentifiers.TOOL_QUICKIEPOWDERHOE));
|
||||
public static final Item TOOL_QUICKIEPOWDERPICKAXE = registerItem(ModIdentifiers.TOOL_QUICKIEPOWDERPICKAXE,
|
||||
new ToolQuickiepowderPickaxe(ModIdentifiers.TOOL_QUICKIEPOWDERPICKAXE));
|
||||
public static final Item TOOL_QUICKIEPOWDERSHOVEL = registerItem(ModIdentifiers.TOOL_QUICKIEPOWDERSHOVEL,
|
||||
new ToolQuickiepowderShovel(ModIdentifiers.TOOL_QUICKIEPOWDERSHOVEL));
|
||||
public static final Item TOOL_QUICKIEPOWDERWATERHOE = registerItem(ModIdentifiers.TOOL_QUICKIEPOWDERWATERHOE,
|
||||
new ToolQuickiepowderWaterHoe(ModIdentifiers.TOOL_QUICKIEPOWDERWATERHOE));
|
||||
|
||||
private static final Item registerItem(Identifier identifier, Item item) {
|
||||
return Registry.register(Registries.ITEM, identifier, item);
|
||||
}
|
||||
|
||||
public static final List<Item> registerModItems() {
|
||||
Quickiemod.LOGGER.debug(String.format("registering item %s", Quickiemod.MOD_ID));
|
||||
|
||||
List<Item> items = new ArrayList<>();
|
||||
items.add(ITEM_STUB);
|
||||
items.add(ITEM_SPEEDPOWDER);
|
||||
items.add(ITEM_QUICKIEPOWDER);
|
||||
items.add(ITEM_SALPETER);
|
||||
items.add(ITEM_SULFOR);
|
||||
items.add(ITEM_OXIDIZEDCOPPERPOWDER);
|
||||
items.add(ITEM_SPEEDINGOT);
|
||||
items.add(ITEM_QUICKIEINGOT);
|
||||
items.add(ITEM_CARROTSTACK);
|
||||
items.add(ITEM_ROTTENFLESHSTRIPES);
|
||||
items.add(ITEM_COTTON);
|
||||
items.add(ITEM_COTTONSEED);
|
||||
items.add(ITEM_CANOLA);
|
||||
items.add(ITEM_CANOLASEED);
|
||||
items.add(ITEM_CANOLABOTTLE);
|
||||
items.add(ITEM_CANOLABOTTLESTACK);
|
||||
|
||||
items.add(TOOL_SPEEDPOWDERPICKAXE);
|
||||
items.add(TOOL_SPEEDPOWDERAXE);
|
||||
items.add(TOOL_SPEEDPOWDERSHOVEL);
|
||||
items.add(TOOL_SPEEDPOWDERHOE);
|
||||
items.add(TOOL_SPEEDPOWDERWATERHOE);
|
||||
items.add(TOOL_SPEEDPOWDERSHEARS);
|
||||
items.add(TOOL_QUICKIEPOWDERPICKAXE);
|
||||
items.add(TOOL_QUICKIEPOWDERAXE);
|
||||
items.add(TOOL_QUICKIEPOWDERSHOVEL);
|
||||
items.add(TOOL_QUICKIEPOWDERHOE);
|
||||
items.add(TOOL_QUICKIEPOWDERWATERHOE);
|
||||
return items;
|
||||
}
|
||||
}
|
@ -1,21 +0,0 @@
|
||||
package de.jottyfan.quickiemod.item;
|
||||
|
||||
import net.minecraft.entity.player.PlayerEntity;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.item.ItemUsageContext;
|
||||
import net.minecraft.util.Hand;
|
||||
import net.minecraft.util.hit.BlockHitResult;
|
||||
import net.minecraft.world.World;
|
||||
|
||||
/**
|
||||
*
|
||||
* @author jotty
|
||||
*
|
||||
*/
|
||||
public class ModdedItemUsageContext extends ItemUsageContext {
|
||||
|
||||
public ModdedItemUsageContext(World world, PlayerEntity player, Hand hand, ItemStack stack, BlockHitResult hit) {
|
||||
super(world, player, hand, stack, hit);
|
||||
}
|
||||
|
||||
}
|
@ -0,0 +1,30 @@
|
||||
package de.jottyfan.quickiemod.item;
|
||||
|
||||
import net.minecraft.item.Item;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.item.ToolMaterial;
|
||||
import net.minecraft.registry.RegistryKey;
|
||||
import net.minecraft.registry.RegistryKeys;
|
||||
import net.minecraft.registry.tag.BlockTags;
|
||||
import net.minecraft.registry.tag.ItemTags;
|
||||
import net.minecraft.util.Identifier;
|
||||
|
||||
/**
|
||||
*
|
||||
* @author jotty
|
||||
*
|
||||
*/
|
||||
public class ToolQuickiepowderAxe extends ToolRangeableAxe {
|
||||
|
||||
private final static ToolMaterial MATERIAL = new ToolMaterial(BlockTags.INCORRECT_FOR_DIAMOND_TOOL, 2400, 7f, 1f, 15, ItemTags.DIAMOND_TOOL_MATERIALS);
|
||||
|
||||
public ToolQuickiepowderAxe(Identifier identifier) {
|
||||
super(MATERIAL, 7F, -3.1F, new Item.Settings().useItemPrefixedTranslationKey().registryKey(RegistryKey.of(RegistryKeys.ITEM, identifier)));
|
||||
}
|
||||
|
||||
@Override
|
||||
public HarvestRange getRange(ItemStack stack) {
|
||||
// TODO: get the range from the stack
|
||||
return new HarvestRange(64, 128, 64); // trees bigger than that are too heavy for one small axe...
|
||||
}
|
||||
}
|
@ -0,0 +1,24 @@
|
||||
package de.jottyfan.quickiemod.item;
|
||||
|
||||
import net.minecraft.item.Item;
|
||||
import net.minecraft.item.ToolMaterial;
|
||||
import net.minecraft.registry.RegistryKey;
|
||||
import net.minecraft.registry.RegistryKeys;
|
||||
import net.minecraft.registry.tag.BlockTags;
|
||||
import net.minecraft.registry.tag.ItemTags;
|
||||
import net.minecraft.util.Identifier;
|
||||
|
||||
/**
|
||||
*
|
||||
* @author jotty
|
||||
*
|
||||
*/
|
||||
public class ToolQuickiepowderHoe extends ToolRangeableHoe {
|
||||
|
||||
public static final Integer DEFAULT_PLOW_RANGE = 4;
|
||||
private final static ToolMaterial MATERIAL = new ToolMaterial(BlockTags.INCORRECT_FOR_DIAMOND_TOOL, 2400, 7f, 1f, 15, ItemTags.DIAMOND_TOOL_MATERIALS);
|
||||
|
||||
public ToolQuickiepowderHoe(Identifier identifier) {
|
||||
super(MATERIAL, 7F, -3.1f, new Item.Settings().useItemPrefixedTranslationKey().registryKey(RegistryKey.of(RegistryKeys.ITEM, identifier)), new HarvestRange(DEFAULT_PLOW_RANGE));
|
||||
}
|
||||
}
|
@ -1,15 +1,20 @@
|
||||
package de.jottyfan.quickiemod.items;
|
||||
package de.jottyfan.quickiemod.item;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import com.google.common.collect.Lists;
|
||||
|
||||
import de.jottyfan.quickiemod.items.mat.QuickieToolMaterial;
|
||||
import net.minecraft.block.Block;
|
||||
import net.minecraft.block.BlockState;
|
||||
import net.minecraft.item.Item;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.item.PickaxeItem;
|
||||
import net.minecraft.item.ToolMaterial;
|
||||
import net.minecraft.registry.RegistryKey;
|
||||
import net.minecraft.registry.RegistryKeys;
|
||||
import net.minecraft.registry.tag.BlockTags;
|
||||
import net.minecraft.registry.tag.ItemTags;
|
||||
import net.minecraft.util.Identifier;
|
||||
|
||||
/**
|
||||
*
|
||||
@ -19,10 +24,15 @@ import net.minecraft.item.PickaxeItem;
|
||||
public class ToolQuickiepowderPickaxe extends PickaxeItem implements ToolRangeable {
|
||||
|
||||
public static final int[] DEFAULT_HARVEST_RANGE = new int[] { 6, 6, 6 };
|
||||
private final static QuickieToolMaterial MATERIAL = QuickieToolMaterial.of(7f, 2400, 15, 1f, QuickieItems.SPEEDINGOT.getItem());
|
||||
private final static ToolMaterial MATERIAL = new ToolMaterial(BlockTags.INCORRECT_FOR_DIAMOND_TOOL, 2400, 7f, 1f, 15, ItemTags.DIAMOND_TOOL_MATERIALS);
|
||||
|
||||
public ToolQuickiepowderPickaxe() {
|
||||
super(MATERIAL, new Item.Settings().attributeModifiers(PickaxeItem.createAttributeModifiers(MATERIAL, 7F, -3.1F)));
|
||||
public ToolQuickiepowderPickaxe(Identifier identifier) {
|
||||
super(MATERIAL, 7F, -3.1F, new Item.Settings().useItemPrefixedTranslationKey().registryKey(RegistryKey.of(RegistryKeys.ITEM, identifier)));
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isCorrectForDrops(ItemStack stack, BlockState state) {
|
||||
return super.isCorrectForDrops(stack, state);
|
||||
}
|
||||
|
||||
@Override
|
@ -1,17 +1,22 @@
|
||||
package de.jottyfan.quickiemod.items;
|
||||
package de.jottyfan.quickiemod.item;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import com.google.common.collect.Lists;
|
||||
|
||||
import de.jottyfan.quickiemod.items.mat.QuickieToolMaterial;
|
||||
import net.minecraft.block.Block;
|
||||
import net.minecraft.block.BlockState;
|
||||
import net.minecraft.item.Item;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.item.ItemUsageContext;
|
||||
import net.minecraft.item.ShovelItem;
|
||||
import net.minecraft.item.ToolMaterial;
|
||||
import net.minecraft.registry.RegistryKey;
|
||||
import net.minecraft.registry.RegistryKeys;
|
||||
import net.minecraft.registry.tag.BlockTags;
|
||||
import net.minecraft.registry.tag.ItemTags;
|
||||
import net.minecraft.util.ActionResult;
|
||||
import net.minecraft.util.Identifier;
|
||||
import net.minecraft.util.math.BlockPos;
|
||||
import net.minecraft.util.math.Direction;
|
||||
import net.minecraft.world.World;
|
||||
@ -23,11 +28,11 @@ import net.minecraft.world.World;
|
||||
*/
|
||||
public class ToolQuickiepowderShovel extends ShovelItem implements ToolRangeable {
|
||||
public static final Integer DEFAULT_HARVEST_RANGE = 6;
|
||||
private final static QuickieToolMaterial MATERIAL = QuickieToolMaterial.of(7f, 2400, 15, 1f, QuickieItems.SPEEDINGOT.getItem());
|
||||
private final static ToolMaterial MATERIAL = new ToolMaterial(BlockTags.INCORRECT_FOR_DIAMOND_TOOL, 2400, 7f, 1f, 15, ItemTags.DIAMOND_TOOL_MATERIALS);
|
||||
public HarvestRange range;
|
||||
|
||||
public ToolQuickiepowderShovel() {
|
||||
super(MATERIAL, new Item.Settings().attributeModifiers(ShovelItem.createAttributeModifiers(MATERIAL, 7F, -3.1F)));
|
||||
public ToolQuickiepowderShovel(Identifier identifier) {
|
||||
super(MATERIAL, 7F, -3.1F, new Item.Settings().useItemPrefixedTranslationKey().registryKey(RegistryKey.of(RegistryKeys.ITEM, identifier)));
|
||||
this.range = new HarvestRange(DEFAULT_HARVEST_RANGE);
|
||||
}
|
||||
|
@ -1,4 +1,4 @@
|
||||
package de.jottyfan.quickiemod.items;
|
||||
package de.jottyfan.quickiemod.item;
|
||||
|
||||
import net.minecraft.block.BlockState;
|
||||
import net.minecraft.block.Blocks;
|
||||
@ -8,6 +8,7 @@ import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.item.ItemUsageContext;
|
||||
import net.minecraft.util.ActionResult;
|
||||
import net.minecraft.util.Hand;
|
||||
import net.minecraft.util.Identifier;
|
||||
import net.minecraft.util.math.BlockPos;
|
||||
import net.minecraft.world.World;
|
||||
|
||||
@ -17,6 +18,10 @@ import net.minecraft.world.World;
|
||||
*
|
||||
*/
|
||||
public class ToolQuickiepowderWaterHoe extends ToolQuickiepowderHoe {
|
||||
public ToolQuickiepowderWaterHoe(Identifier identifier) {
|
||||
super(identifier);
|
||||
}
|
||||
|
||||
@Override
|
||||
public ActionResult useOnBlock(ItemUsageContext context) {
|
||||
ActionResult res = super.useOnBlock(context);
|
||||
@ -28,7 +33,7 @@ public class ToolQuickiepowderWaterHoe extends ToolQuickiepowderHoe {
|
||||
Hand hand = context.getHand();
|
||||
PlayerEntity player = context.getPlayer();
|
||||
ItemStack oldTool = player.getStackInHand(hand);
|
||||
ItemStack newTool = new ItemStack(QuickieItems.QUICKIEPOWDERHOE.getItem());
|
||||
ItemStack newTool = new ItemStack(ModItems.TOOL_QUICKIEPOWDERHOE);
|
||||
newTool.setDamage(oldTool.getDamage());
|
||||
world.spawnEntity(new ItemEntity(world, pos.getX(), pos.getY(), pos.getZ(), new ItemStack(oldBlockState.getBlock())));
|
||||
player.setStackInHand(hand, newTool);
|
@ -1,10 +1,11 @@
|
||||
package de.jottyfan.quickiemod.items;
|
||||
package de.jottyfan.quickiemod.item;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import net.minecraft.block.Block;
|
||||
import net.minecraft.block.BlockState;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.text.Text;
|
||||
|
||||
/**
|
||||
*
|
||||
@ -13,6 +14,13 @@ import net.minecraft.item.ItemStack;
|
||||
*/
|
||||
public interface ToolRangeable {
|
||||
|
||||
/**
|
||||
* dummy to have a getName method that comes with the item
|
||||
*
|
||||
* @return the name
|
||||
*/
|
||||
public Text getName();
|
||||
|
||||
/**
|
||||
* @param stack the item stack that keeps the range
|
||||
* @return range of blocks to be harvested
|
@ -1,4 +1,4 @@
|
||||
package de.jottyfan.quickiemod.items;
|
||||
package de.jottyfan.quickiemod.item;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
@ -20,8 +20,8 @@ import net.minecraft.registry.tag.BlockTags;
|
||||
*/
|
||||
public abstract class ToolRangeableAxe extends AxeItem implements ToolRangeable {
|
||||
|
||||
protected ToolRangeableAxe(ToolMaterial material, Item.Settings settings) {
|
||||
super(material, settings);
|
||||
protected ToolRangeableAxe(ToolMaterial material, float attackDamage, float attackSpeed, Item.Settings settings) {
|
||||
super(material, attackDamage, attackSpeed, settings);
|
||||
}
|
||||
|
||||
@Override
|
||||
@ -53,7 +53,7 @@ public abstract class ToolRangeableAxe extends AxeItem implements ToolRangeable
|
||||
|
||||
@Override
|
||||
public boolean canBreakNeighbors(BlockState blockIn) {
|
||||
return new ItemStack(this).isSuitableFor(blockIn) || isLeavesBlock(blockIn) || blockIn.isIn(BlockTags.LOGS);
|
||||
return new ItemStack(this).isSuitableFor(blockIn) || isLeavesBlock(blockIn) || blockIn.isIn(BlockTags.LOGS);
|
||||
}
|
||||
|
||||
@Override
|
@ -1,4 +1,4 @@
|
||||
package de.jottyfan.quickiemod.items;
|
||||
package de.jottyfan.quickiemod.item;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
@ -28,8 +28,8 @@ public abstract class ToolRangeableHoe extends HoeItem implements ToolRangeable
|
||||
|
||||
public HarvestRange range;
|
||||
|
||||
public ToolRangeableHoe(ToolMaterial material, Settings settings, HarvestRange range) {
|
||||
super(material, settings);
|
||||
public ToolRangeableHoe(ToolMaterial material, float attackDamage, float attackSpeed, Settings settings, HarvestRange range) {
|
||||
super(material, attackDamage, attackSpeed, settings);
|
||||
this.range = range;
|
||||
}
|
||||
|
@ -0,0 +1,30 @@
|
||||
package de.jottyfan.quickiemod.item;
|
||||
|
||||
import net.minecraft.item.Item;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.item.ToolMaterial;
|
||||
import net.minecraft.registry.RegistryKey;
|
||||
import net.minecraft.registry.RegistryKeys;
|
||||
import net.minecraft.registry.tag.BlockTags;
|
||||
import net.minecraft.registry.tag.ItemTags;
|
||||
import net.minecraft.util.Identifier;
|
||||
|
||||
/**
|
||||
*
|
||||
* @author jotty
|
||||
*
|
||||
*/
|
||||
public class ToolSpeedpowderAxe extends ToolRangeableAxe {
|
||||
|
||||
private final static ToolMaterial MATERIAL = new ToolMaterial(BlockTags.INCORRECT_FOR_DIAMOND_TOOL, 800, 7f, 1f, 15, ItemTags.DIAMOND_TOOL_MATERIALS);
|
||||
|
||||
public ToolSpeedpowderAxe(Identifier identifier) {
|
||||
super(MATERIAL, 7f, -3.1f, new Item.Settings().useItemPrefixedTranslationKey().registryKey(RegistryKey.of(RegistryKeys.ITEM, identifier)));
|
||||
}
|
||||
|
||||
@Override
|
||||
public HarvestRange getRange(ItemStack stack) {
|
||||
// TODO: get the range from the stack
|
||||
return new HarvestRange(32, 64, 32);
|
||||
}
|
||||
}
|
@ -0,0 +1,24 @@
|
||||
package de.jottyfan.quickiemod.item;
|
||||
|
||||
import net.minecraft.item.Item;
|
||||
import net.minecraft.item.ToolMaterial;
|
||||
import net.minecraft.registry.RegistryKey;
|
||||
import net.minecraft.registry.RegistryKeys;
|
||||
import net.minecraft.registry.tag.BlockTags;
|
||||
import net.minecraft.registry.tag.ItemTags;
|
||||
import net.minecraft.util.Identifier;
|
||||
|
||||
/**
|
||||
*
|
||||
* @author jotty
|
||||
*
|
||||
*/
|
||||
public class ToolSpeedpowderHoe extends ToolRangeableHoe {
|
||||
|
||||
public static final Integer DEFAULT_PLOW_RANGE = 2;
|
||||
private final static ToolMaterial MATERIAL = new ToolMaterial(BlockTags.INCORRECT_FOR_DIAMOND_TOOL, 800, 7f, 1f, 15, ItemTags.DIAMOND_TOOL_MATERIALS);
|
||||
|
||||
public ToolSpeedpowderHoe(Identifier identifier) {
|
||||
super(MATERIAL, 7F, -3.1F, new Item.Settings().useItemPrefixedTranslationKey().registryKey(RegistryKey.of(RegistryKeys.ITEM, identifier)), new HarvestRange(DEFAULT_PLOW_RANGE));
|
||||
}
|
||||
}
|
@ -1,16 +1,20 @@
|
||||
package de.jottyfan.quickiemod.items;
|
||||
package de.jottyfan.quickiemod.item;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import com.google.common.collect.Lists;
|
||||
|
||||
import de.jottyfan.quickiemod.items.mat.QuickieToolMaterial;
|
||||
import net.minecraft.block.Block;
|
||||
import net.minecraft.block.BlockState;
|
||||
import net.minecraft.item.AxeItem;
|
||||
import net.minecraft.item.Item;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.item.PickaxeItem;
|
||||
import net.minecraft.item.ToolMaterial;
|
||||
import net.minecraft.registry.RegistryKey;
|
||||
import net.minecraft.registry.RegistryKeys;
|
||||
import net.minecraft.registry.tag.BlockTags;
|
||||
import net.minecraft.registry.tag.ItemTags;
|
||||
import net.minecraft.util.Identifier;
|
||||
|
||||
/**
|
||||
*
|
||||
@ -20,10 +24,10 @@ import net.minecraft.item.PickaxeItem;
|
||||
public class ToolSpeedpowderPickaxe extends PickaxeItem implements ToolRangeable {
|
||||
|
||||
public static final int[] DEFAULT_HARVEST_RANGE = new int[] { 3, 3, 3 };
|
||||
private final static QuickieToolMaterial MATERIAL = QuickieToolMaterial.of(7f, 800, 15, 1f, QuickieItems.SPEEDINGOT.getItem());
|
||||
private final static ToolMaterial MATERIAL = new ToolMaterial(BlockTags.INCORRECT_FOR_DIAMOND_TOOL, 800, 7.0F, 1.0F, 15, ItemTags.DIAMOND_TOOL_MATERIALS);
|
||||
|
||||
public ToolSpeedpowderPickaxe() {
|
||||
super(MATERIAL, new Item.Settings().attributeModifiers(AxeItem.createAttributeModifiers(MATERIAL, 7F, -3.1F)));
|
||||
public ToolSpeedpowderPickaxe(Identifier identifier) {
|
||||
super(MATERIAL, 7F, -3.1F, new Item.Settings().useItemPrefixedTranslationKey().registryKey(RegistryKey.of(RegistryKeys.ITEM, identifier)));
|
||||
}
|
||||
|
||||
@Override
|
@ -1,4 +1,4 @@
|
||||
package de.jottyfan.quickiemod.items;
|
||||
package de.jottyfan.quickiemod.item;
|
||||
|
||||
import java.util.Random;
|
||||
|
||||
@ -14,9 +14,12 @@ import net.minecraft.item.Item;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.item.Items;
|
||||
import net.minecraft.item.ShearsItem;
|
||||
import net.minecraft.registry.RegistryKey;
|
||||
import net.minecraft.registry.RegistryKeys;
|
||||
import net.minecraft.util.ActionResult;
|
||||
import net.minecraft.util.DyeColor;
|
||||
import net.minecraft.util.Hand;
|
||||
import net.minecraft.util.Identifier;
|
||||
import net.minecraft.util.math.Vec3d;
|
||||
|
||||
/**
|
||||
@ -26,8 +29,8 @@ import net.minecraft.util.math.Vec3d;
|
||||
*/
|
||||
public class ToolSpeedpowderShears extends ShearsItem {
|
||||
|
||||
public ToolSpeedpowderShears() {
|
||||
super(new Item.Settings().component(DataComponentTypes.TOOL, ShearsItem.createToolComponent()));
|
||||
public ToolSpeedpowderShears(Identifier identifier) {
|
||||
super(new Item.Settings().component(DataComponentTypes.TOOL, ShearsItem.createToolComponent()).useItemPrefixedTranslationKey().registryKey(RegistryKey.of(RegistryKeys.ITEM, identifier)));
|
||||
}
|
||||
|
||||
@Override
|
@ -1,17 +1,22 @@
|
||||
package de.jottyfan.quickiemod.items;
|
||||
package de.jottyfan.quickiemod.item;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import com.google.common.collect.Lists;
|
||||
|
||||
import de.jottyfan.quickiemod.items.mat.QuickieToolMaterial;
|
||||
import net.minecraft.block.Block;
|
||||
import net.minecraft.block.BlockState;
|
||||
import net.minecraft.item.Item;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.item.ItemUsageContext;
|
||||
import net.minecraft.item.ShovelItem;
|
||||
import net.minecraft.item.ToolMaterial;
|
||||
import net.minecraft.registry.RegistryKey;
|
||||
import net.minecraft.registry.RegistryKeys;
|
||||
import net.minecraft.registry.tag.BlockTags;
|
||||
import net.minecraft.registry.tag.ItemTags;
|
||||
import net.minecraft.util.ActionResult;
|
||||
import net.minecraft.util.Identifier;
|
||||
import net.minecraft.util.math.BlockPos;
|
||||
import net.minecraft.util.math.Direction;
|
||||
import net.minecraft.world.World;
|
||||
@ -23,11 +28,11 @@ import net.minecraft.world.World;
|
||||
*/
|
||||
public class ToolSpeedpowderShovel extends ShovelItem implements ToolRangeable {
|
||||
public static final Integer DEFAULT_HARVEST_RANGE = 3;
|
||||
private final static QuickieToolMaterial MATERIAL = QuickieToolMaterial.of(7f, 800, 15, 1f, QuickieItems.SPEEDINGOT.getItem());
|
||||
private final static ToolMaterial MATERIAL = new ToolMaterial(BlockTags.INCORRECT_FOR_DIAMOND_TOOL, 800, 7f, 1f, 15, ItemTags.DIAMOND_TOOL_MATERIALS);
|
||||
public HarvestRange range;
|
||||
|
||||
public ToolSpeedpowderShovel() {
|
||||
super(MATERIAL, new Item.Settings().attributeModifiers(ShovelItem.createAttributeModifiers(MATERIAL, 7F, -3.1F)));
|
||||
public ToolSpeedpowderShovel(Identifier identifier) {
|
||||
super(MATERIAL, 7F, -3.1F, new Item.Settings().useItemPrefixedTranslationKey().registryKey(RegistryKey.of(RegistryKeys.ITEM, identifier)));
|
||||
this.range = new HarvestRange(DEFAULT_HARVEST_RANGE);
|
||||
}
|
||||
|
@ -1,4 +1,4 @@
|
||||
package de.jottyfan.quickiemod.items;
|
||||
package de.jottyfan.quickiemod.item;
|
||||
|
||||
import net.minecraft.block.BlockState;
|
||||
import net.minecraft.block.Blocks;
|
||||
@ -8,6 +8,7 @@ import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.item.ItemUsageContext;
|
||||
import net.minecraft.util.ActionResult;
|
||||
import net.minecraft.util.Hand;
|
||||
import net.minecraft.util.Identifier;
|
||||
import net.minecraft.util.math.BlockPos;
|
||||
import net.minecraft.world.World;
|
||||
|
||||
@ -17,6 +18,10 @@ import net.minecraft.world.World;
|
||||
*
|
||||
*/
|
||||
public class ToolSpeedpowderWaterHoe extends ToolSpeedpowderHoe {
|
||||
public ToolSpeedpowderWaterHoe(Identifier identifier) {
|
||||
super(identifier);
|
||||
}
|
||||
|
||||
@Override
|
||||
public ActionResult useOnBlock(ItemUsageContext context) {
|
||||
ActionResult res = super.useOnBlock(context);
|
||||
@ -28,7 +33,7 @@ public class ToolSpeedpowderWaterHoe extends ToolSpeedpowderHoe {
|
||||
Hand hand = context.getHand();
|
||||
PlayerEntity player = context.getPlayer();
|
||||
ItemStack oldTool = player.getStackInHand(hand);
|
||||
ItemStack newTool = new ItemStack(QuickieItems.SPEEDPOWDERHOE.getItem());
|
||||
ItemStack newTool = new ItemStack(ModItems.TOOL_SPEEDPOWDERHOE);
|
||||
newTool.setDamage(oldTool.getDamage());
|
||||
world.spawnEntity(new ItemEntity(world, pos.getX(), pos.getY(), pos.getZ(), new ItemStack(oldBlockState.getBlock())));
|
||||
player.setStackInHand(hand, newTool);
|
@ -0,0 +1,38 @@
|
||||
package de.jottyfan.quickiemod.itemgroup;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import de.jottyfan.quickiemod.Quickiemod;
|
||||
import de.jottyfan.quickiemod.item.ModItems;
|
||||
import net.fabricmc.fabric.api.itemgroup.v1.FabricItemGroup;
|
||||
import net.minecraft.block.Block;
|
||||
import net.minecraft.item.Item;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.registry.Registries;
|
||||
import net.minecraft.registry.Registry;
|
||||
import net.minecraft.registry.RegistryKey;
|
||||
import net.minecraft.registry.RegistryKeys;
|
||||
import net.minecraft.text.Text;
|
||||
import net.minecraft.util.Identifier;
|
||||
|
||||
/**
|
||||
*
|
||||
* @author jotty
|
||||
*
|
||||
*/
|
||||
public class ModItemGroup {
|
||||
|
||||
public static final void registerItemGroup(List<Item> items, List<Block> blocks) {
|
||||
Registry.register(Registries.ITEM_GROUP,
|
||||
RegistryKey.of(RegistryKeys.ITEM_GROUP, Identifier.of(Quickiemod.MOD_ID, "itemgroup")),
|
||||
FabricItemGroup.builder().icon(() -> new ItemStack(ModItems.ITEM_SPEEDPOWDER))
|
||||
.displayName(Text.literal(Quickiemod.MOD_ID)).entries((enabledFeatures, stacks) -> {
|
||||
for (Item item : items) {
|
||||
stacks.add(new ItemStack(item));
|
||||
}
|
||||
for (Block block : blocks) {
|
||||
stacks.add(new ItemStack(block));
|
||||
}
|
||||
}).build());
|
||||
}
|
||||
}
|
@ -1,15 +0,0 @@
|
||||
package de.jottyfan.quickiemod.items;
|
||||
|
||||
import net.minecraft.item.Item;
|
||||
|
||||
/**
|
||||
*
|
||||
* @author jotty
|
||||
*
|
||||
*/
|
||||
public class ItemCanola extends Item {
|
||||
|
||||
public ItemCanola() {
|
||||
super(new Item.Settings().maxCount(64));
|
||||
}
|
||||
}
|
Some files were not shown because too many files have changed in this diff Show More
Loading…
x
Reference in New Issue
Block a user