-
Notifications
You must be signed in to change notification settings - Fork 15
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* fix: useItemOn
- Loading branch information
Showing
5 changed files
with
535 additions
and
1 deletion.
There are no files selected for viewing
36 changes: 36 additions & 0 deletions
36
.../java/org/allaymc/server/item/component/spawnegg/ItemEvokerSpawnEggBaseComponentImpl.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
package org.allaymc.server.item.component.spawnegg; | ||
|
||
import lombok.extern.slf4j.Slf4j; | ||
import org.allaymc.api.block.component.common.PlayerInteractInfo; | ||
import org.allaymc.api.entity.init.SimpleEntityInitInfo; | ||
import org.allaymc.api.entity.type.EntityTypes; | ||
import org.allaymc.api.item.init.ItemStackInitInfo; | ||
import org.allaymc.api.item.interfaces.egg.ItemEvokerSpawnEggStack; | ||
import org.allaymc.api.world.Dimension; | ||
import org.allaymc.server.item.component.common.ItemBaseComponentImpl; | ||
import org.joml.Vector3ic; | ||
|
||
/** | ||
* Allay Project 27/06/2024 | ||
* | ||
* @author IWareQ | ||
*/ | ||
@Slf4j | ||
public class ItemEvokerSpawnEggBaseComponentImpl extends ItemBaseComponentImpl<ItemEvokerSpawnEggStack> { | ||
public ItemEvokerSpawnEggBaseComponentImpl(ItemStackInitInfo<ItemEvokerSpawnEggStack> initInfo) { | ||
super(initInfo); | ||
} | ||
|
||
@Override | ||
public boolean useItemOn(Dimension dimension, Vector3ic placeBlockPos, PlayerInteractInfo interactInfo) { | ||
if (interactInfo == null) return false; | ||
var entity = EntityTypes.EVOCATION_ILLAGER_TYPE.createEntity( | ||
SimpleEntityInitInfo.builder() | ||
.dimension(dimension) | ||
.pos(placeBlockPos.x(), placeBlockPos.y(), placeBlockPos.z()) | ||
.build() | ||
); | ||
dimension.getEntityService().addEntity(entity); | ||
return true; | ||
} | ||
} |
41 changes: 41 additions & 0 deletions
41
...c/main/java/org/allaymc/server/item/component/spawnegg/ItemSpawnEggBaseComponentImpl.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,41 @@ | ||
package org.allaymc.server.item.component.spawnegg; | ||
|
||
import lombok.extern.slf4j.Slf4j; | ||
import org.allaymc.api.block.component.common.PlayerInteractInfo; | ||
import org.allaymc.api.entity.init.SimpleEntityInitInfo; | ||
import org.allaymc.api.entity.registry.EntityTypeRegistry; | ||
import org.allaymc.api.item.ItemStack; | ||
import org.allaymc.api.item.init.ItemStackInitInfo; | ||
import org.allaymc.api.utils.Identifier; | ||
import org.allaymc.api.world.Dimension; | ||
import org.allaymc.server.item.component.common.ItemBaseComponentImpl; | ||
import org.joml.Vector3ic; | ||
|
||
/** | ||
* Allay Project 27/06/2024 | ||
* | ||
* @author IWareQ | ||
*/ | ||
@Slf4j | ||
public class ItemSpawnEggBaseComponentImpl<T extends ItemStack> extends ItemBaseComponentImpl<T> { | ||
public ItemSpawnEggBaseComponentImpl(ItemStackInitInfo<T> initInfo) { | ||
super(initInfo); | ||
} | ||
|
||
@Override | ||
public boolean useItemOn(Dimension dimension, Vector3ic placeBlockPos, PlayerInteractInfo interactInfo) { | ||
if (interactInfo == null) return false; | ||
var identifier = thisItemStack.getItemType().getIdentifier(); | ||
identifier = new Identifier(identifier.toString().replace("_spawn_egg", "")); | ||
|
||
var entityType = EntityTypeRegistry.getRegistry().get(identifier); | ||
var entity = entityType.createEntity( | ||
SimpleEntityInitInfo.builder() | ||
.dimension(dimension) | ||
.pos(placeBlockPos.x(), placeBlockPos.y(), placeBlockPos.z()) | ||
.build() | ||
); | ||
dimension.getEntityService().addEntity(entity); | ||
return true; | ||
} | ||
} |
36 changes: 36 additions & 0 deletions
36
...org/allaymc/server/item/component/spawnegg/ItemTropicalFishSpawnEggBaseComponentImpl.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
package org.allaymc.server.item.component.spawnegg; | ||
|
||
import lombok.extern.slf4j.Slf4j; | ||
import org.allaymc.api.block.component.common.PlayerInteractInfo; | ||
import org.allaymc.api.entity.init.SimpleEntityInitInfo; | ||
import org.allaymc.api.entity.type.EntityTypes; | ||
import org.allaymc.api.item.init.ItemStackInitInfo; | ||
import org.allaymc.api.item.interfaces.egg.ItemTropicalFishSpawnEggStack; | ||
import org.allaymc.api.world.Dimension; | ||
import org.allaymc.server.item.component.common.ItemBaseComponentImpl; | ||
import org.joml.Vector3ic; | ||
|
||
/** | ||
* Allay Project 27/06/2024 | ||
* | ||
* @author IWareQ | ||
*/ | ||
@Slf4j | ||
public class ItemTropicalFishSpawnEggBaseComponentImpl extends ItemBaseComponentImpl<ItemTropicalFishSpawnEggStack> { | ||
public ItemTropicalFishSpawnEggBaseComponentImpl(ItemStackInitInfo<ItemTropicalFishSpawnEggStack> initInfo) { | ||
super(initInfo); | ||
} | ||
|
||
@Override | ||
public boolean useItemOn(Dimension dimension, Vector3ic placeBlockPos, PlayerInteractInfo interactInfo) { | ||
if (interactInfo == null) return false; | ||
var entity = EntityTypes.TROPICALFISH_TYPE.createEntity( | ||
SimpleEntityInitInfo.builder() | ||
.dimension(dimension) | ||
.pos(placeBlockPos.x(), placeBlockPos.y(), placeBlockPos.z()) | ||
.build() | ||
); | ||
dimension.getEntityService().addEntity(entity); | ||
return true; | ||
} | ||
} |
Oops, something went wrong.